| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 class LookupResult BASE_EMBEDDED { | 180 class LookupResult BASE_EMBEDDED { |
| 181 public: | 181 public: |
| 182 explicit LookupResult(Isolate* isolate) | 182 explicit LookupResult(Isolate* isolate) |
| 183 : isolate_(isolate), | 183 : isolate_(isolate), |
| 184 next_(isolate->top_lookup_result()), | 184 next_(isolate->top_lookup_result()), |
| 185 lookup_type_(NOT_FOUND), | 185 lookup_type_(NOT_FOUND), |
| 186 holder_(NULL), | 186 holder_(NULL), |
| 187 transition_(NULL), | 187 transition_(NULL), |
| 188 cacheable_(true), | 188 cacheable_(true), |
| 189 details_(NONE, NONEXISTENT, Representation::None()) { | 189 details_(NONE, NONEXISTENT, Representation::None()) { |
| 190 isolate->set_top_lookup_result(this); | 190 isolate->SetTopLookupResult(this); |
| 191 } | 191 } |
| 192 | 192 |
| 193 ~LookupResult() { | 193 ~LookupResult() { |
| 194 ASSERT(isolate()->top_lookup_result() == this); | 194 ASSERT(isolate()->top_lookup_result() == this); |
| 195 isolate()->set_top_lookup_result(next_); | 195 isolate()->SetTopLookupResult(next_); |
| 196 } | 196 } |
| 197 | 197 |
| 198 Isolate* isolate() const { return isolate_; } | 198 Isolate* isolate() const { return isolate_; } |
| 199 | 199 |
| 200 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { | 200 void DescriptorResult(JSObject* holder, PropertyDetails details, int number) { |
| 201 lookup_type_ = DESCRIPTOR_TYPE; | 201 lookup_type_ = DESCRIPTOR_TYPE; |
| 202 holder_ = holder; | 202 holder_ = holder; |
| 203 transition_ = NULL; | |
| 204 details_ = details; | 203 details_ = details; |
| 205 number_ = number; | 204 number_ = number; |
| 205 transition_ = NULL; |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool CanHoldValue(Handle<Object> value) { | 208 bool CanHoldValue(Handle<Object> value) { |
| 209 if (IsNormal()) return true; | 209 if (IsNormal()) return true; |
| 210 ASSERT(!IsTransition()); | 210 ASSERT(!IsTransition()); |
| 211 return value->FitsRepresentation(details_.representation()); | 211 return value->FitsRepresentation(details_.representation()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void TransitionResult(JSObject* holder, Map* target) { | 214 void TransitionResult(JSObject* holder, Map* target) { |
| 215 lookup_type_ = TRANSITION_TYPE; | 215 lookup_type_ = TRANSITION_TYPE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 239 lookup_type_ = INTERCEPTOR_TYPE; | 239 lookup_type_ = INTERCEPTOR_TYPE; |
| 240 holder_ = holder; | 240 holder_ = holder; |
| 241 transition_ = NULL; | 241 transition_ = NULL; |
| 242 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); | 242 details_ = PropertyDetails(NONE, INTERCEPTOR, Representation::Tagged()); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void NotFound() { | 245 void NotFound() { |
| 246 lookup_type_ = NOT_FOUND; | 246 lookup_type_ = NOT_FOUND; |
| 247 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); | 247 details_ = PropertyDetails(NONE, NONEXISTENT, Representation::None()); |
| 248 holder_ = NULL; | 248 holder_ = NULL; |
| 249 transition_ = NULL; | |
| 250 } | 249 } |
| 251 | 250 |
| 252 JSObject* holder() const { | 251 JSObject* holder() { |
| 253 ASSERT(IsFound()); | 252 ASSERT(IsFound()); |
| 254 return JSObject::cast(holder_); | 253 return JSObject::cast(holder_); |
| 255 } | 254 } |
| 256 | 255 |
| 257 JSProxy* proxy() const { | 256 JSProxy* proxy() { |
| 258 ASSERT(IsHandler()); | 257 ASSERT(IsHandler()); |
| 259 return JSProxy::cast(holder_); | 258 return JSProxy::cast(holder_); |
| 260 } | 259 } |
| 261 | 260 |
| 262 PropertyType type() const { | 261 PropertyType type() { |
| 263 ASSERT(IsFound()); | 262 ASSERT(IsFound()); |
| 264 return details_.type(); | 263 return details_.type(); |
| 265 } | 264 } |
| 266 | 265 |
| 267 Representation representation() const { | 266 Representation representation() { |
| 268 ASSERT(IsFound()); | 267 ASSERT(IsFound()); |
| 269 ASSERT(!IsTransition()); | 268 ASSERT(!IsTransition()); |
| 270 ASSERT(details_.type() != NONEXISTENT); | 269 ASSERT(details_.type() != NONEXISTENT); |
| 271 return details_.representation(); | 270 return details_.representation(); |
| 272 } | 271 } |
| 273 | 272 |
| 274 PropertyAttributes GetAttributes() const { | 273 PropertyAttributes GetAttributes() { |
| 275 ASSERT(!IsTransition()); | 274 ASSERT(!IsTransition()); |
| 276 ASSERT(IsFound()); | 275 ASSERT(IsFound()); |
| 277 ASSERT(details_.type() != NONEXISTENT); | 276 ASSERT(details_.type() != NONEXISTENT); |
| 278 return details_.attributes(); | 277 return details_.attributes(); |
| 279 } | 278 } |
| 280 | 279 |
| 281 PropertyDetails GetPropertyDetails() const { | 280 PropertyDetails GetPropertyDetails() { |
| 282 ASSERT(!IsTransition()); | 281 ASSERT(!IsTransition()); |
| 283 return details_; | 282 return details_; |
| 284 } | 283 } |
| 285 | 284 |
| 286 bool IsFastPropertyType() const { | 285 bool IsFastPropertyType() { |
| 287 ASSERT(IsFound()); | 286 ASSERT(IsFound()); |
| 288 return IsTransition() || type() != NORMAL; | 287 return IsTransition() || type() != NORMAL; |
| 289 } | 288 } |
| 290 | 289 |
| 291 // Property callbacks does not include transitions to callbacks. | 290 // Property callbacks does not include transitions to callbacks. |
| 292 bool IsPropertyCallbacks() const { | 291 bool IsPropertyCallbacks() { |
| 293 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); | 292 ASSERT(!(details_.type() == CALLBACKS && !IsFound())); |
| 294 return details_.type() == CALLBACKS; | 293 return details_.type() == CALLBACKS; |
| 295 } | 294 } |
| 296 | 295 |
| 297 bool IsReadOnly() const { | 296 bool IsReadOnly() { |
| 298 ASSERT(IsFound()); | 297 ASSERT(IsFound()); |
| 299 ASSERT(!IsTransition()); | 298 ASSERT(!IsTransition()); |
| 300 ASSERT(details_.type() != NONEXISTENT); | 299 ASSERT(details_.type() != NONEXISTENT); |
| 301 return details_.IsReadOnly(); | 300 return details_.IsReadOnly(); |
| 302 } | 301 } |
| 303 | 302 |
| 304 bool IsField() const { | 303 bool IsField() { |
| 305 ASSERT(!(details_.type() == FIELD && !IsFound())); | 304 ASSERT(!(details_.type() == FIELD && !IsFound())); |
| 306 return details_.type() == FIELD; | 305 return details_.type() == FIELD; |
| 307 } | 306 } |
| 308 | 307 |
| 309 bool IsNormal() const { | 308 bool IsNormal() { |
| 310 ASSERT(!(details_.type() == NORMAL && !IsFound())); | 309 ASSERT(!(details_.type() == NORMAL && !IsFound())); |
| 311 return details_.type() == NORMAL; | 310 return details_.type() == NORMAL; |
| 312 } | 311 } |
| 313 | 312 |
| 314 bool IsConstant() const { | 313 bool IsConstant() { |
| 315 ASSERT(!(details_.type() == CONSTANT && !IsFound())); | 314 ASSERT(!(details_.type() == CONSTANT && !IsFound())); |
| 316 return details_.type() == CONSTANT; | 315 return details_.type() == CONSTANT; |
| 317 } | 316 } |
| 318 | 317 |
| 319 bool IsConstantFunction() const { | 318 bool IsConstantFunction() { |
| 320 return IsConstant() && GetValue()->IsJSFunction(); | 319 return IsConstant() && GetValue()->IsJSFunction(); |
| 321 } | 320 } |
| 322 | 321 |
| 323 bool IsDontDelete() const { return details_.IsDontDelete(); } | 322 bool IsDontDelete() { return details_.IsDontDelete(); } |
| 324 bool IsDontEnum() const { return details_.IsDontEnum(); } | 323 bool IsDontEnum() { return details_.IsDontEnum(); } |
| 325 bool IsFound() const { return lookup_type_ != NOT_FOUND; } | 324 bool IsFound() { return lookup_type_ != NOT_FOUND; } |
| 326 bool IsTransition() const { return lookup_type_ == TRANSITION_TYPE; } | 325 bool IsTransition() { return lookup_type_ == TRANSITION_TYPE; } |
| 327 bool IsHandler() const { return lookup_type_ == HANDLER_TYPE; } | 326 bool IsHandler() { return lookup_type_ == HANDLER_TYPE; } |
| 328 bool IsInterceptor() const { return lookup_type_ == INTERCEPTOR_TYPE; } | 327 bool IsInterceptor() { return lookup_type_ == INTERCEPTOR_TYPE; } |
| 329 | 328 |
| 330 // Is the result is a property excluding transitions and the null descriptor? | 329 // Is the result is a property excluding transitions and the null descriptor? |
| 331 bool IsProperty() const { | 330 bool IsProperty() { |
| 332 return IsFound() && !IsTransition(); | 331 return IsFound() && !IsTransition(); |
| 333 } | 332 } |
| 334 | 333 |
| 335 bool IsDataProperty() const { | 334 bool IsDataProperty() { |
| 336 switch (type()) { | 335 switch (type()) { |
| 337 case FIELD: | 336 case FIELD: |
| 338 case NORMAL: | 337 case NORMAL: |
| 339 case CONSTANT: | 338 case CONSTANT: |
| 340 return true; | 339 return true; |
| 341 case CALLBACKS: { | 340 case CALLBACKS: { |
| 342 Object* callback = GetCallbackObject(); | 341 Object* callback = GetCallbackObject(); |
| 343 return callback->IsAccessorInfo() || callback->IsForeign(); | 342 return callback->IsAccessorInfo() || callback->IsForeign(); |
| 344 } | 343 } |
| 345 case HANDLER: | 344 case HANDLER: |
| 346 case INTERCEPTOR: | 345 case INTERCEPTOR: |
| 347 case TRANSITION: | 346 case TRANSITION: |
| 348 case NONEXISTENT: | 347 case NONEXISTENT: |
| 349 return false; | 348 return false; |
| 350 } | 349 } |
| 351 UNREACHABLE(); | 350 UNREACHABLE(); |
| 352 return false; | 351 return false; |
| 353 } | 352 } |
| 354 | 353 |
| 355 bool IsCacheable() const { return cacheable_; } | 354 bool IsCacheable() { return cacheable_; } |
| 356 void DisallowCaching() { cacheable_ = false; } | 355 void DisallowCaching() { cacheable_ = false; } |
| 357 | 356 |
| 358 Object* GetLazyValue() const { | 357 Object* GetLazyValue() { |
| 359 switch (type()) { | 358 switch (type()) { |
| 360 case FIELD: | 359 case FIELD: |
| 361 return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); | 360 return holder()->RawFastPropertyAt(GetFieldIndex().field_index()); |
| 362 case NORMAL: { | 361 case NORMAL: { |
| 363 Object* value; | 362 Object* value; |
| 364 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); | 363 value = holder()->property_dictionary()->ValueAt(GetDictionaryEntry()); |
| 365 if (holder()->IsGlobalObject()) { | 364 if (holder()->IsGlobalObject()) { |
| 366 value = PropertyCell::cast(value)->value(); | 365 value = PropertyCell::cast(value)->value(); |
| 367 } | 366 } |
| 368 return value; | 367 return value; |
| 369 } | 368 } |
| 370 case CONSTANT: | 369 case CONSTANT: |
| 371 return GetConstant(); | 370 return GetConstant(); |
| 372 case CALLBACKS: | 371 case CALLBACKS: |
| 373 case HANDLER: | 372 case HANDLER: |
| 374 case INTERCEPTOR: | 373 case INTERCEPTOR: |
| 375 case TRANSITION: | 374 case TRANSITION: |
| 376 case NONEXISTENT: | 375 case NONEXISTENT: |
| 377 return isolate()->heap()->the_hole_value(); | 376 return isolate()->heap()->the_hole_value(); |
| 378 } | 377 } |
| 379 UNREACHABLE(); | 378 UNREACHABLE(); |
| 380 return NULL; | 379 return NULL; |
| 381 } | 380 } |
| 382 | 381 |
| 383 Map* GetTransitionTarget() const { | 382 Map* GetTransitionTarget() { |
| 384 return transition_; | 383 return transition_; |
| 385 } | 384 } |
| 386 | 385 |
| 387 PropertyDetails GetTransitionDetails() const { | 386 PropertyDetails GetTransitionDetails() { |
| 388 ASSERT(IsTransition()); | |
| 389 return transition_->GetLastDescriptorDetails(); | 387 return transition_->GetLastDescriptorDetails(); |
| 390 } | 388 } |
| 391 | 389 |
| 392 bool IsTransitionToField() const { | 390 bool IsTransitionToField() { |
| 393 return IsTransition() && GetTransitionDetails().type() == FIELD; | 391 return IsTransition() && GetTransitionDetails().type() == FIELD; |
| 394 } | 392 } |
| 395 | 393 |
| 396 bool IsTransitionToConstant() const { | 394 bool IsTransitionToConstant() { |
| 397 return IsTransition() && GetTransitionDetails().type() == CONSTANT; | 395 return IsTransition() && GetTransitionDetails().type() == CONSTANT; |
| 398 } | 396 } |
| 399 | 397 |
| 400 int GetDescriptorIndex() const { | 398 int GetTransitionIndex() { |
| 399 ASSERT(IsTransition()); |
| 400 return number_; |
| 401 } |
| 402 |
| 403 int GetDescriptorIndex() { |
| 401 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 404 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 402 return number_; | 405 return number_; |
| 403 } | 406 } |
| 404 | 407 |
| 405 PropertyIndex GetFieldIndex() const { | 408 PropertyIndex GetFieldIndex() { |
| 406 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 409 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| 407 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); | 410 return PropertyIndex::NewFieldIndex(GetFieldIndexFromMap(holder()->map())); |
| 408 } | 411 } |
| 409 | 412 |
| 410 int GetLocalFieldIndexFromMap(Map* map) const { | 413 int GetLocalFieldIndexFromMap(Map* map) { |
| 411 return GetFieldIndexFromMap(map) - map->inobject_properties(); | 414 return GetFieldIndexFromMap(map) - map->inobject_properties(); |
| 412 } | 415 } |
| 413 | 416 |
| 414 int GetDictionaryEntry() const { | 417 int GetDictionaryEntry() { |
| 415 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 418 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 416 return number_; | 419 return number_; |
| 417 } | 420 } |
| 418 | 421 |
| 419 JSFunction* GetConstantFunction() const { | 422 JSFunction* GetConstantFunction() { |
| 420 ASSERT(type() == CONSTANT); | 423 ASSERT(type() == CONSTANT); |
| 421 return JSFunction::cast(GetValue()); | 424 return JSFunction::cast(GetValue()); |
| 422 } | 425 } |
| 423 | 426 |
| 424 Object* GetConstantFromMap(Map* map) const { | 427 Object* GetConstantFromMap(Map* map) { |
| 425 ASSERT(type() == CONSTANT); | 428 ASSERT(type() == CONSTANT); |
| 426 return GetValueFromMap(map); | 429 return GetValueFromMap(map); |
| 427 } | 430 } |
| 428 | 431 |
| 429 JSFunction* GetConstantFunctionFromMap(Map* map) const { | 432 JSFunction* GetConstantFunctionFromMap(Map* map) { |
| 430 return JSFunction::cast(GetConstantFromMap(map)); | 433 return JSFunction::cast(GetConstantFromMap(map)); |
| 431 } | 434 } |
| 432 | 435 |
| 433 Object* GetConstant() const { | 436 Object* GetConstant() { |
| 434 ASSERT(type() == CONSTANT); | 437 ASSERT(type() == CONSTANT); |
| 435 return GetValue(); | 438 return GetValue(); |
| 436 } | 439 } |
| 437 | 440 |
| 438 Object* GetCallbackObject() const { | 441 Object* GetCallbackObject() { |
| 439 ASSERT(type() == CALLBACKS && !IsTransition()); | 442 ASSERT(type() == CALLBACKS && !IsTransition()); |
| 440 return GetValue(); | 443 return GetValue(); |
| 441 } | 444 } |
| 442 | 445 |
| 443 #ifdef OBJECT_PRINT | 446 #ifdef OBJECT_PRINT |
| 444 void Print(FILE* out); | 447 void Print(FILE* out); |
| 445 #endif | 448 #endif |
| 446 | 449 |
| 447 Object* GetValue() const { | 450 Object* GetValue() { |
| 448 if (lookup_type_ == DESCRIPTOR_TYPE) { | 451 if (lookup_type_ == DESCRIPTOR_TYPE) { |
| 449 return GetValueFromMap(holder()->map()); | 452 return GetValueFromMap(holder()->map()); |
| 450 } | 453 } |
| 451 // In the dictionary case, the data is held in the value field. | 454 // In the dictionary case, the data is held in the value field. |
| 452 ASSERT(lookup_type_ == DICTIONARY_TYPE); | 455 ASSERT(lookup_type_ == DICTIONARY_TYPE); |
| 453 return holder()->GetNormalizedProperty(this); | 456 return holder()->GetNormalizedProperty(this); |
| 454 } | 457 } |
| 455 | 458 |
| 456 Object* GetValueFromMap(Map* map) const { | 459 Object* GetValueFromMap(Map* map) const { |
| 457 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); | 460 ASSERT(lookup_type_ == DESCRIPTOR_TYPE); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 485 Map* transition_; | 488 Map* transition_; |
| 486 int number_; | 489 int number_; |
| 487 bool cacheable_; | 490 bool cacheable_; |
| 488 PropertyDetails details_; | 491 PropertyDetails details_; |
| 489 }; | 492 }; |
| 490 | 493 |
| 491 | 494 |
| 492 } } // namespace v8::internal | 495 } } // namespace v8::internal |
| 493 | 496 |
| 494 #endif // V8_PROPERTY_H_ | 497 #endif // V8_PROPERTY_H_ |
| OLD | NEW |