| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 break; | 332 break; |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 | 336 |
| 337 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 337 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 338 return ABSENT; | 338 return ABSENT; |
| 339 } | 339 } |
| 340 | 340 |
| 341 | 341 |
| 342 Object* JSObject::GetLazyProperty(Object* receiver, | |
| 343 LookupResult* result, | |
| 344 String* name, | |
| 345 PropertyAttributes* attributes) { | |
| 346 HandleScope scope; | |
| 347 Handle<Object> this_handle(this); | |
| 348 Handle<Object> receiver_handle(receiver); | |
| 349 Handle<String> name_handle(name); | |
| 350 bool pending_exception; | |
| 351 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 352 &pending_exception); | |
| 353 if (pending_exception) return Failure::Exception(); | |
| 354 return this_handle->GetPropertyWithReceiver(*receiver_handle, | |
| 355 *name_handle, | |
| 356 attributes); | |
| 357 } | |
| 358 | |
| 359 | |
| 360 Object* JSObject::SetLazyProperty(LookupResult* result, | |
| 361 String* name, | |
| 362 Object* value, | |
| 363 PropertyAttributes attributes) { | |
| 364 ASSERT(!IsJSGlobalProxy()); | |
| 365 HandleScope scope; | |
| 366 Handle<JSObject> this_handle(this); | |
| 367 Handle<String> name_handle(name); | |
| 368 Handle<Object> value_handle(value); | |
| 369 bool pending_exception; | |
| 370 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 371 &pending_exception); | |
| 372 if (pending_exception) return Failure::Exception(); | |
| 373 return this_handle->SetProperty(*name_handle, *value_handle, attributes); | |
| 374 } | |
| 375 | |
| 376 | |
| 377 Object* JSObject::DeleteLazyProperty(LookupResult* result, | |
| 378 String* name, | |
| 379 DeleteMode mode) { | |
| 380 HandleScope scope; | |
| 381 Handle<JSObject> this_handle(this); | |
| 382 Handle<String> name_handle(name); | |
| 383 bool pending_exception; | |
| 384 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 385 &pending_exception); | |
| 386 if (pending_exception) return Failure::Exception(); | |
| 387 return this_handle->DeleteProperty(*name_handle, mode); | |
| 388 } | |
| 389 | |
| 390 | |
| 391 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 342 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
| 392 ASSERT(!HasFastProperties()); | 343 ASSERT(!HasFastProperties()); |
| 393 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 344 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 394 if (IsGlobalObject()) { | 345 if (IsGlobalObject()) { |
| 395 value = JSGlobalPropertyCell::cast(value)->value(); | 346 value = JSGlobalPropertyCell::cast(value)->value(); |
| 396 } | 347 } |
| 397 ASSERT(!value->IsJSGlobalPropertyCell()); | 348 ASSERT(!value->IsJSGlobalPropertyCell()); |
| 398 return value; | 349 return value; |
| 399 } | 350 } |
| 400 | 351 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // chain; either the holder of the result or null in case of an | 475 // chain; either the holder of the result or null in case of an |
| 525 // absent property. | 476 // absent property. |
| 526 if (current == last) break; | 477 if (current == last) break; |
| 527 } | 478 } |
| 528 | 479 |
| 529 if (!result->IsProperty()) { | 480 if (!result->IsProperty()) { |
| 530 *attributes = ABSENT; | 481 *attributes = ABSENT; |
| 531 return Heap::undefined_value(); | 482 return Heap::undefined_value(); |
| 532 } | 483 } |
| 533 *attributes = result->GetAttributes(); | 484 *attributes = result->GetAttributes(); |
| 534 if (!result->IsLoaded()) { | |
| 535 return JSObject::cast(this)->GetLazyProperty(receiver, | |
| 536 result, | |
| 537 name, | |
| 538 attributes); | |
| 539 } | |
| 540 Object* value; | 485 Object* value; |
| 541 JSObject* holder = result->holder(); | 486 JSObject* holder = result->holder(); |
| 542 switch (result->type()) { | 487 switch (result->type()) { |
| 543 case NORMAL: | 488 case NORMAL: |
| 544 value = holder->GetNormalizedProperty(result); | 489 value = holder->GetNormalizedProperty(result); |
| 545 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 490 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
| 546 return value->IsTheHole() ? Heap::undefined_value() : value; | 491 return value->IsTheHole() ? Heap::undefined_value() : value; |
| 547 case FIELD: | 492 case FIELD: |
| 548 value = holder->FastPropertyAt(result->GetFieldIndex()); | 493 value = holder->FastPropertyAt(result->GetFieldIndex()); |
| 549 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 494 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 int entry = property_dictionary()->FindEntry(name); | 1717 int entry = property_dictionary()->FindEntry(name); |
| 1773 if (entry != StringDictionary::kNotFound) { | 1718 if (entry != StringDictionary::kNotFound) { |
| 1774 Object* value = property_dictionary()->ValueAt(entry); | 1719 Object* value = property_dictionary()->ValueAt(entry); |
| 1775 if (IsGlobalObject()) { | 1720 if (IsGlobalObject()) { |
| 1776 PropertyDetails d = property_dictionary()->DetailsAt(entry); | 1721 PropertyDetails d = property_dictionary()->DetailsAt(entry); |
| 1777 if (d.IsDeleted()) { | 1722 if (d.IsDeleted()) { |
| 1778 result->NotFound(); | 1723 result->NotFound(); |
| 1779 return; | 1724 return; |
| 1780 } | 1725 } |
| 1781 value = JSGlobalPropertyCell::cast(value)->value(); | 1726 value = JSGlobalPropertyCell::cast(value)->value(); |
| 1782 ASSERT(result->IsLoaded()); | |
| 1783 } | 1727 } |
| 1784 // Make sure to disallow caching for uninitialized constants | 1728 // Make sure to disallow caching for uninitialized constants |
| 1785 // found in the dictionary-mode objects. | 1729 // found in the dictionary-mode objects. |
| 1786 if (value->IsTheHole()) result->DisallowCaching(); | 1730 if (value->IsTheHole()) result->DisallowCaching(); |
| 1787 result->DictionaryResult(this, entry); | 1731 result->DictionaryResult(this, entry); |
| 1788 return; | 1732 return; |
| 1789 } | 1733 } |
| 1790 // Slow case object skipped during lookup. Do not use inline caching. | 1734 // Slow case object skipped during lookup. Do not use inline caching. |
| 1791 if (!IsGlobalObject()) result->DisallowCaching(); | 1735 if (!IsGlobalObject()) result->DisallowCaching(); |
| 1792 } | 1736 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 if (accessor_result.IsValid()) { | 1850 if (accessor_result.IsValid()) { |
| 1907 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 1851 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| 1908 name, | 1852 name, |
| 1909 value, | 1853 value, |
| 1910 accessor_result.holder()); | 1854 accessor_result.holder()); |
| 1911 } | 1855 } |
| 1912 } | 1856 } |
| 1913 if (result->IsNotFound()) { | 1857 if (result->IsNotFound()) { |
| 1914 return AddProperty(name, value, attributes); | 1858 return AddProperty(name, value, attributes); |
| 1915 } | 1859 } |
| 1916 if (!result->IsLoaded()) { | |
| 1917 return SetLazyProperty(result, name, value, attributes); | |
| 1918 } | |
| 1919 if (result->IsReadOnly() && result->IsProperty()) return value; | 1860 if (result->IsReadOnly() && result->IsProperty()) return value; |
| 1920 // This is a real property that is not read-only, or it is a | 1861 // This is a real property that is not read-only, or it is a |
| 1921 // transition or null descriptor and there are no setters in the prototypes. | 1862 // transition or null descriptor and there are no setters in the prototypes. |
| 1922 switch (result->type()) { | 1863 switch (result->type()) { |
| 1923 case NORMAL: | 1864 case NORMAL: |
| 1924 return SetNormalizedProperty(result, value); | 1865 return SetNormalizedProperty(result, value); |
| 1925 case FIELD: | 1866 case FIELD: |
| 1926 return FastPropertyAtPut(result->GetFieldIndex(), value); | 1867 return FastPropertyAtPut(result->GetFieldIndex(), value); |
| 1927 case MAP_TRANSITION: | 1868 case MAP_TRANSITION: |
| 1928 if (attributes == result->GetAttributes()) { | 1869 if (attributes == result->GetAttributes()) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 return JSObject::cast(proto)->IgnoreAttributesAndSetLocalProperty( | 1931 return JSObject::cast(proto)->IgnoreAttributesAndSetLocalProperty( |
| 1991 name, | 1932 name, |
| 1992 value, | 1933 value, |
| 1993 attributes); | 1934 attributes); |
| 1994 } | 1935 } |
| 1995 | 1936 |
| 1996 // Check for accessor in prototype chain removed here in clone. | 1937 // Check for accessor in prototype chain removed here in clone. |
| 1997 if (result->IsNotFound()) { | 1938 if (result->IsNotFound()) { |
| 1998 return AddProperty(name, value, attributes); | 1939 return AddProperty(name, value, attributes); |
| 1999 } | 1940 } |
| 2000 if (!result->IsLoaded()) { | |
| 2001 return SetLazyProperty(result, name, value, attributes); | |
| 2002 } | |
| 2003 // Check of IsReadOnly removed from here in clone. | 1941 // Check of IsReadOnly removed from here in clone. |
| 2004 switch (result->type()) { | 1942 switch (result->type()) { |
| 2005 case NORMAL: | 1943 case NORMAL: |
| 2006 return SetNormalizedProperty(result, value); | 1944 return SetNormalizedProperty(result, value); |
| 2007 case FIELD: | 1945 case FIELD: |
| 2008 return FastPropertyAtPut(result->GetFieldIndex(), value); | 1946 return FastPropertyAtPut(result->GetFieldIndex(), value); |
| 2009 case MAP_TRANSITION: | 1947 case MAP_TRANSITION: |
| 2010 if (attributes == result->GetAttributes()) { | 1948 if (attributes == result->GetAttributes()) { |
| 2011 // Only use map transition if the attributes match. | 1949 // Only use map transition if the attributes match. |
| 2012 return AddFastPropertyUsingMap(result->GetTransitionMap(), | 1950 return AddFastPropertyUsingMap(result->GetTransitionMap(), |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2513 return Heap::false_value(); | 2451 return Heap::false_value(); |
| 2514 } | 2452 } |
| 2515 // Check for interceptor. | 2453 // Check for interceptor. |
| 2516 if (result.type() == INTERCEPTOR) { | 2454 if (result.type() == INTERCEPTOR) { |
| 2517 // Skip interceptor if forcing a deletion. | 2455 // Skip interceptor if forcing a deletion. |
| 2518 if (mode == FORCE_DELETION) { | 2456 if (mode == FORCE_DELETION) { |
| 2519 return DeletePropertyPostInterceptor(name, mode); | 2457 return DeletePropertyPostInterceptor(name, mode); |
| 2520 } | 2458 } |
| 2521 return DeletePropertyWithInterceptor(name); | 2459 return DeletePropertyWithInterceptor(name); |
| 2522 } | 2460 } |
| 2523 if (!result.IsLoaded()) { | |
| 2524 return JSObject::cast(this)->DeleteLazyProperty(&result, | |
| 2525 name, | |
| 2526 mode); | |
| 2527 } | |
| 2528 // Normalize object if needed. | 2461 // Normalize object if needed. |
| 2529 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 2462 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
| 2530 if (obj->IsFailure()) return obj; | 2463 if (obj->IsFailure()) return obj; |
| 2531 // Make sure the properties are normalized before removing the entry. | 2464 // Make sure the properties are normalized before removing the entry. |
| 2532 return DeleteNormalizedProperty(name, mode); | 2465 return DeleteNormalizedProperty(name, mode); |
| 2533 } | 2466 } |
| 2534 } | 2467 } |
| 2535 | 2468 |
| 2536 | 2469 |
| 2537 // Check whether this object references another object. | 2470 // Check whether this object references another object. |
| (...skipping 5762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8300 if (break_point_objects()->IsUndefined()) return 0; | 8233 if (break_point_objects()->IsUndefined()) return 0; |
| 8301 // Single beak point. | 8234 // Single beak point. |
| 8302 if (!break_point_objects()->IsFixedArray()) return 1; | 8235 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8303 // Multiple break points. | 8236 // Multiple break points. |
| 8304 return FixedArray::cast(break_point_objects())->length(); | 8237 return FixedArray::cast(break_point_objects())->length(); |
| 8305 } | 8238 } |
| 8306 #endif | 8239 #endif |
| 8307 | 8240 |
| 8308 | 8241 |
| 8309 } } // namespace v8::internal | 8242 } } // namespace v8::internal |
| OLD | NEW |