| 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 "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
| 10 #include "src/field-index-inl.h" | 10 #include "src/field-index-inl.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 class LookupResult V8_FINAL BASE_EMBEDDED { | 114 class LookupResult V8_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 cacheable_(true), | 122 cacheable_(true), |
| 123 details_(NONE, NONEXISTENT, Representation::None()) { | 123 details_(NONE, NORMAL, Representation::None()) { |
| 124 isolate->set_top_lookup_result(this); | 124 isolate->set_top_lookup_result(this); |
| 125 } | 125 } |
| 126 | 126 |
| 127 ~LookupResult() { | 127 ~LookupResult() { |
| 128 DCHECK(isolate()->top_lookup_result() == this); | 128 DCHECK(isolate()->top_lookup_result() == this); |
| 129 isolate()->set_top_lookup_result(next_); | 129 isolate()->set_top_lookup_result(next_); |
| 130 } | 130 } |
| 131 | 131 |
| 132 Isolate* isolate() const { return isolate_; } | 132 Isolate* isolate() const { return isolate_; } |
| 133 | 133 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 151 lookup_type_ == DESCRIPTOR_TYPE ? holder_->map() : transition_; | 151 lookup_type_ == DESCRIPTOR_TYPE ? holder_->map() : transition_; |
| 152 Object* constant = GetConstantFromMap(map); | 152 Object* constant = GetConstantFromMap(map); |
| 153 DCHECK(constant != *value || | 153 DCHECK(constant != *value || |
| 154 value->FitsRepresentation(representation())); | 154 value->FitsRepresentation(representation())); |
| 155 return constant == *value; | 155 return constant == *value; |
| 156 } | 156 } |
| 157 case CALLBACKS: | 157 case CALLBACKS: |
| 158 case HANDLER: | 158 case HANDLER: |
| 159 case INTERCEPTOR: | 159 case INTERCEPTOR: |
| 160 return true; | 160 return true; |
| 161 case NONEXISTENT: | |
| 162 UNREACHABLE(); | |
| 163 } | 161 } |
| 164 UNREACHABLE(); | 162 UNREACHABLE(); |
| 165 return true; | 163 return true; |
| 166 } | 164 } |
| 167 | 165 |
| 168 void TransitionResult(JSObject* holder, Map* target) { | 166 void TransitionResult(JSObject* holder, Map* target) { |
| 169 lookup_type_ = TRANSITION_TYPE; | 167 lookup_type_ = TRANSITION_TYPE; |
| 170 number_ = target->LastAdded(); | 168 number_ = target->LastAdded(); |
| 171 details_ = target->instance_descriptors()->GetDetails(number_); | 169 details_ = target->instance_descriptors()->GetDetails(number_); |
| 172 holder_ = holder; | 170 holder_ = holder; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 191 | 189 |
| 192 void InterceptorResult(JSObject* holder) { | 190 void InterceptorResult(JSObject* holder) { |
| 193 lookup_type_ = INTERCEPTOR_TYPE; | 191 lookup_type_ = INTERCEPTOR_TYPE; |
| 194 holder_ = holder; | 192 holder_ = holder; |
| 195 transition_ = NULL; | 193 transition_ = NULL; |
| 196 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); | 194 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); |
| 197 } | 195 } |
| 198 | 196 |
| 199 void NotFound() { | 197 void NotFound() { |
| 200 lookup_type_ = NOT_FOUND; | 198 lookup_type_ = NOT_FOUND; |
| 201 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); | 199 details_ = PropertyDetails(NONE, NORMAL, Representation::None()); |
| 202 holder_ = NULL; | 200 holder_ = NULL; |
| 203 transition_ = NULL; | 201 transition_ = NULL; |
| 204 } | 202 } |
| 205 | 203 |
| 206 JSObject* holder() const { | 204 JSObject* holder() const { |
| 207 DCHECK(IsFound()); | 205 DCHECK(IsFound()); |
| 208 return JSObject::cast(holder_); | 206 return JSObject::cast(holder_); |
| 209 } | 207 } |
| 210 | 208 |
| 211 JSProxy* proxy() const { | 209 JSProxy* proxy() const { |
| 212 DCHECK(IsHandler()); | 210 DCHECK(IsHandler()); |
| 213 return JSProxy::cast(holder_); | 211 return JSProxy::cast(holder_); |
| 214 } | 212 } |
| 215 | 213 |
| 216 PropertyType type() const { | 214 PropertyType type() const { |
| 217 DCHECK(IsFound()); | 215 DCHECK(IsFound()); |
| 218 return details_.type(); | 216 return details_.type(); |
| 219 } | 217 } |
| 220 | 218 |
| 221 Representation representation() const { | 219 Representation representation() const { |
| 222 DCHECK(IsFound()); | 220 DCHECK(IsFound()); |
| 223 DCHECK(details_.type() != NONEXISTENT); | |
| 224 return details_.representation(); | 221 return details_.representation(); |
| 225 } | 222 } |
| 226 | 223 |
| 227 PropertyAttributes GetAttributes() const { | 224 PropertyAttributes GetAttributes() const { |
| 228 DCHECK(IsFound()); | 225 DCHECK(IsFound()); |
| 229 DCHECK(details_.type() != NONEXISTENT); | |
| 230 return details_.attributes(); | 226 return details_.attributes(); |
| 231 } | 227 } |
| 232 | 228 |
| 233 PropertyDetails GetPropertyDetails() const { | 229 PropertyDetails GetPropertyDetails() const { |
| 234 return details_; | 230 return details_; |
| 235 } | 231 } |
| 236 | 232 |
| 237 bool IsFastPropertyType() const { | 233 bool IsFastPropertyType() const { |
| 238 DCHECK(IsFound()); | 234 DCHECK(IsFound()); |
| 239 return IsTransition() || type() != NORMAL; | 235 return IsTransition() || type() != NORMAL; |
| 240 } | 236 } |
| 241 | 237 |
| 242 // Property callbacks does not include transitions to callbacks. | 238 // Property callbacks does not include transitions to callbacks. |
| 243 bool IsPropertyCallbacks() const { | 239 bool IsPropertyCallbacks() const { |
| 244 DCHECK(!(details_.type() == CALLBACKS && !IsFound())); | 240 DCHECK(!(details_.type() == CALLBACKS && !IsFound())); |
| 245 return !IsTransition() && details_.type() == CALLBACKS; | 241 return !IsTransition() && details_.type() == CALLBACKS; |
| 246 } | 242 } |
| 247 | 243 |
| 248 bool IsReadOnly() const { | 244 bool IsReadOnly() const { |
| 249 DCHECK(IsFound()); | 245 DCHECK(IsFound()); |
| 250 DCHECK(details_.type() != NONEXISTENT); | |
| 251 return details_.IsReadOnly(); | 246 return details_.IsReadOnly(); |
| 252 } | 247 } |
| 253 | 248 |
| 254 bool IsField() const { | 249 bool IsField() const { |
| 255 DCHECK(!(details_.type() == FIELD && !IsFound())); | 250 DCHECK(!(details_.type() == FIELD && !IsFound())); |
| 256 return IsDescriptorOrDictionary() && type() == FIELD; | 251 return IsDescriptorOrDictionary() && type() == FIELD; |
| 257 } | 252 } |
| 258 | 253 |
| 259 bool IsNormal() const { | 254 bool IsNormal() const { |
| 260 DCHECK(!(details_.type() == NORMAL && !IsFound())); | 255 return IsFound() && IsDescriptorOrDictionary() && type() == NORMAL; |
| 261 return IsDescriptorOrDictionary() && type() == NORMAL; | |
| 262 } | 256 } |
| 263 | 257 |
| 264 bool IsConstant() const { | 258 bool IsConstant() const { |
| 265 DCHECK(!(details_.type() == CONSTANT && !IsFound())); | 259 DCHECK(!(details_.type() == CONSTANT && !IsFound())); |
| 266 return IsDescriptorOrDictionary() && type() == CONSTANT; | 260 return IsDescriptorOrDictionary() && type() == CONSTANT; |
| 267 } | 261 } |
| 268 | 262 |
| 269 bool IsDontDelete() const { return details_.IsDontDelete(); } | 263 bool IsDontDelete() const { return details_.IsDontDelete(); } |
| 270 bool IsDontEnum() const { return details_.IsDontEnum(); } | 264 bool IsDontEnum() const { return details_.IsDontEnum(); } |
| 271 bool IsFound() const { return lookup_type_ != NOT_FOUND; } | 265 bool IsFound() const { return lookup_type_ != NOT_FOUND; } |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 int number_; | 384 int number_; |
| 391 bool cacheable_; | 385 bool cacheable_; |
| 392 PropertyDetails details_; | 386 PropertyDetails details_; |
| 393 }; | 387 }; |
| 394 | 388 |
| 395 | 389 |
| 396 OStream& operator<<(OStream& os, const LookupResult& r); | 390 OStream& operator<<(OStream& os, const LookupResult& r); |
| 397 } } // namespace v8::internal | 391 } } // namespace v8::internal |
| 398 | 392 |
| 399 #endif // V8_PROPERTY_H_ | 393 #endif // V8_PROPERTY_H_ |
| OLD | NEW |