| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_PROPERTY_H_ | 5 #ifndef V8_PROPERTY_H_ |
| 6 #define V8_PROPERTY_H_ | 6 #define V8_PROPERTY_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 | 113 |
| 114 class LookupResult FINAL BASE_EMBEDDED { | 114 class LookupResult FINAL BASE_EMBEDDED { |
| 115 public: | 115 public: |
| 116 explicit LookupResult(Isolate* isolate) | 116 explicit LookupResult(Isolate* isolate) |
| 117 : isolate_(isolate), | 117 : isolate_(isolate), |
| 118 next_(isolate->top_lookup_result()), | 118 next_(isolate->top_lookup_result()), |
| 119 lookup_type_(NOT_FOUND), | 119 lookup_type_(NOT_FOUND), |
| 120 holder_(NULL), | 120 holder_(NULL), |
| 121 transition_(NULL), | 121 transition_(NULL), |
| 122 details_(NONE, NORMAL, Representation::None()) { | 122 details_(NONE, FIELD, Representation::None()) { |
| 123 isolate->set_top_lookup_result(this); | 123 isolate->set_top_lookup_result(this); |
| 124 } | 124 } |
| 125 | 125 |
| 126 ~LookupResult() { | 126 ~LookupResult() { |
| 127 DCHECK(isolate()->top_lookup_result() == this); | 127 DCHECK(isolate()->top_lookup_result() == this); |
| 128 isolate()->set_top_lookup_result(next_); | 128 isolate()->set_top_lookup_result(next_); |
| 129 } | 129 } |
| 130 | 130 |
| 131 Isolate* isolate() const { return isolate_; } | 131 Isolate* isolate() const { return isolate_; } |
| 132 | 132 |
| 133 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 133 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
| 134 lookup_type_ = DESCRIPTOR_TYPE; | 134 lookup_type_ = DESCRIPTOR_TYPE; |
| 135 holder_ = holder; | 135 holder_ = holder; |
| 136 transition_ = NULL; | 136 transition_ = NULL; |
| 137 details_ = details; | 137 details_ = details; |
| 138 number_ = number; | 138 number_ = number; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void TransitionResult(JSObject* holder, Map* target) { | 141 void TransitionResult(JSObject* holder, Map* target) { |
| 142 lookup_type_ = TRANSITION_TYPE; | 142 lookup_type_ = TRANSITION_TYPE; |
| 143 number_ = target->LastAdded(); | 143 number_ = target->LastAdded(); |
| 144 details_ = target->instance_descriptors()->GetDetails(number_); | 144 details_ = target->instance_descriptors()->GetDetails(number_); |
| 145 holder_ = holder; | 145 holder_ = holder; |
| 146 transition_ = target; | 146 transition_ = target; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void NotFound() { | 149 void NotFound() { |
| 150 lookup_type_ = NOT_FOUND; | 150 lookup_type_ = NOT_FOUND; |
| 151 details_ = PropertyDetails(NONE, NORMAL, Representation::None()); | 151 details_ = PropertyDetails(NONE, FIELD, 0); |
| 152 holder_ = NULL; | 152 holder_ = NULL; |
| 153 transition_ = NULL; | 153 transition_ = NULL; |
| 154 } | 154 } |
| 155 | 155 |
| 156 Representation representation() const { | 156 Representation representation() const { |
| 157 DCHECK(IsFound()); | 157 DCHECK(IsFound()); |
| 158 return details_.representation(); | 158 return details_.representation(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Property callbacks does not include transitions to callbacks. | 161 // Property callbacks does not include transitions to callbacks. |
| 162 bool IsPropertyCallbacks() const { | 162 bool IsPropertyCallbacks() const { |
| 163 DCHECK(!(details_.type() == CALLBACKS && !IsFound())); | |
| 164 return !IsTransition() && details_.type() == CALLBACKS; | 163 return !IsTransition() && details_.type() == CALLBACKS; |
| 165 } | 164 } |
| 166 | 165 |
| 167 bool IsReadOnly() const { | 166 bool IsReadOnly() const { |
| 168 DCHECK(IsFound()); | 167 DCHECK(IsFound()); |
| 169 return details_.IsReadOnly(); | 168 return details_.IsReadOnly(); |
| 170 } | 169 } |
| 171 | 170 |
| 172 bool IsField() const { | 171 bool IsField() const { |
| 173 DCHECK(!(details_.type() == FIELD && !IsFound())); | |
| 174 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == FIELD; | 172 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == FIELD; |
| 175 } | 173 } |
| 176 | 174 |
| 177 bool IsConstant() const { | 175 bool IsConstant() const { |
| 178 DCHECK(!(details_.type() == CONSTANT && !IsFound())); | |
| 179 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == CONSTANT; | 176 return lookup_type_ == DESCRIPTOR_TYPE && details_.type() == CONSTANT; |
| 180 } | 177 } |
| 181 | 178 |
| 182 bool IsConfigurable() const { return details_.IsConfigurable(); } | 179 bool IsConfigurable() const { return details_.IsConfigurable(); } |
| 183 bool IsFound() const { return lookup_type_ != NOT_FOUND; } | 180 bool IsFound() const { return lookup_type_ != NOT_FOUND; } |
| 184 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; } | 181 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; } |
| 185 | 182 |
| 186 // Is the result is a property excluding transitions and the null descriptor? | 183 // Is the result is a property excluding transitions and the null descriptor? |
| 187 bool IsProperty() const { | 184 bool IsProperty() const { |
| 188 return IsFound() && !IsTransition(); | 185 return IsFound() && !IsTransition(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 Map* transition_; | 243 Map* transition_; |
| 247 int number_; | 244 int number_; |
| 248 PropertyDetails details_; | 245 PropertyDetails details_; |
| 249 }; | 246 }; |
| 250 | 247 |
| 251 | 248 |
| 252 std::ostream& operator<<(std::ostream& os, const LookupResult& r); | 249 std::ostream& operator<<(std::ostream& os, const LookupResult& r); |
| 253 } } // namespace v8::internal | 250 } } // namespace v8::internal |
| 254 | 251 |
| 255 #endif // V8_PROPERTY_H_ | 252 #endif // V8_PROPERTY_H_ |
| OLD | NEW |