1 | /* |
2 | * Copyright (C) 2015 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "ObjectPropertyCondition.h" |
28 | |
29 | #include "JSCInlines.h" |
30 | #include "TrackedReferences.h" |
31 | |
32 | namespace JSC { |
33 | |
34 | void ObjectPropertyCondition::dumpInContext(PrintStream& out, DumpContext* context) const |
35 | { |
36 | if (!*this) { |
37 | out.print("<invalid>" ); |
38 | return; |
39 | } |
40 | |
41 | out.print("<" , inContext(JSValue(m_object), context), ": " , inContext(m_condition, context), ">" ); |
42 | } |
43 | |
44 | void ObjectPropertyCondition::dump(PrintStream& out) const |
45 | { |
46 | dumpInContext(out, nullptr); |
47 | } |
48 | |
49 | bool ObjectPropertyCondition::structureEnsuresValidityAssumingImpurePropertyWatchpoint( |
50 | Structure* structure) const |
51 | { |
52 | return m_condition.isStillValidAssumingImpurePropertyWatchpoint(structure); |
53 | } |
54 | |
55 | bool ObjectPropertyCondition::structureEnsuresValidityAssumingImpurePropertyWatchpoint() const |
56 | { |
57 | if (!*this) |
58 | return false; |
59 | |
60 | return structureEnsuresValidityAssumingImpurePropertyWatchpoint(m_object->structure()); |
61 | } |
62 | |
63 | bool ObjectPropertyCondition::validityRequiresImpurePropertyWatchpoint(Structure* structure) const |
64 | { |
65 | return m_condition.validityRequiresImpurePropertyWatchpoint(structure); |
66 | } |
67 | |
68 | bool ObjectPropertyCondition::validityRequiresImpurePropertyWatchpoint() const |
69 | { |
70 | if (!*this) |
71 | return false; |
72 | |
73 | return validityRequiresImpurePropertyWatchpoint(m_object->structure()); |
74 | } |
75 | |
76 | bool ObjectPropertyCondition::isStillValidAssumingImpurePropertyWatchpoint(Structure* structure) const |
77 | { |
78 | return m_condition.isStillValidAssumingImpurePropertyWatchpoint(structure, m_object); |
79 | } |
80 | |
81 | bool ObjectPropertyCondition::isStillValidAssumingImpurePropertyWatchpoint() const |
82 | { |
83 | if (!*this) |
84 | return false; |
85 | |
86 | return isStillValidAssumingImpurePropertyWatchpoint(m_object->structure()); |
87 | } |
88 | |
89 | |
90 | bool ObjectPropertyCondition::isStillValid(Structure* structure) const |
91 | { |
92 | return m_condition.isStillValid(structure, m_object); |
93 | } |
94 | |
95 | bool ObjectPropertyCondition::isStillValid() const |
96 | { |
97 | if (!*this) |
98 | return false; |
99 | |
100 | return isStillValid(m_object->structure()); |
101 | } |
102 | |
103 | bool ObjectPropertyCondition::structureEnsuresValidity(Structure* structure) const |
104 | { |
105 | return m_condition.isStillValid(structure); |
106 | } |
107 | |
108 | bool ObjectPropertyCondition::structureEnsuresValidity() const |
109 | { |
110 | if (!*this) |
111 | return false; |
112 | |
113 | return structureEnsuresValidity(m_object->structure()); |
114 | } |
115 | |
116 | bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint( |
117 | Structure* structure, PropertyCondition::WatchabilityEffort effort) const |
118 | { |
119 | return m_condition.isWatchableAssumingImpurePropertyWatchpoint(structure, m_object, effort); |
120 | } |
121 | |
122 | bool ObjectPropertyCondition::isWatchableAssumingImpurePropertyWatchpoint( |
123 | PropertyCondition::WatchabilityEffort effort) const |
124 | { |
125 | if (!*this) |
126 | return false; |
127 | |
128 | return isWatchableAssumingImpurePropertyWatchpoint(m_object->structure(), effort); |
129 | } |
130 | |
131 | bool ObjectPropertyCondition::isWatchable( |
132 | Structure* structure, PropertyCondition::WatchabilityEffort effort) const |
133 | { |
134 | return m_condition.isWatchable(structure, m_object, effort); |
135 | } |
136 | |
137 | bool ObjectPropertyCondition::isWatchable(PropertyCondition::WatchabilityEffort effort) const |
138 | { |
139 | if (!*this) |
140 | return false; |
141 | |
142 | return isWatchable(m_object->structure(), effort); |
143 | } |
144 | |
145 | bool ObjectPropertyCondition::isStillLive(VM& vm) const |
146 | { |
147 | if (!*this) |
148 | return false; |
149 | |
150 | if (!vm.heap.isMarked(m_object)) |
151 | return false; |
152 | |
153 | return m_condition.isStillLive(vm); |
154 | } |
155 | |
156 | void ObjectPropertyCondition::validateReferences(const TrackedReferences& tracked) const |
157 | { |
158 | if (!*this) |
159 | return; |
160 | |
161 | tracked.check(m_object); |
162 | m_condition.validateReferences(tracked); |
163 | } |
164 | |
165 | ObjectPropertyCondition ObjectPropertyCondition::attemptToMakeEquivalenceWithoutBarrier(VM& vm) const |
166 | { |
167 | PropertyCondition result = condition().attemptToMakeEquivalenceWithoutBarrier(vm, object()); |
168 | if (!result) |
169 | return ObjectPropertyCondition(); |
170 | return ObjectPropertyCondition(object(), result); |
171 | } |
172 | |
173 | } // namespace JSC |
174 | |
175 | |