| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 default: | 331 default: |
| 332 UNREACHABLE(); | 332 UNREACHABLE(); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 336 Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 337 return ABSENT; | 337 return ABSENT; |
| 338 } | 338 } |
| 339 | 339 |
| 340 | 340 |
| 341 Object* JSObject::GetLazyProperty(Object* receiver, | |
| 342 LookupResult* result, | |
| 343 String* name, | |
| 344 PropertyAttributes* attributes) { | |
| 345 HandleScope scope; | |
| 346 Handle<Object> this_handle(this); | |
| 347 Handle<Object> receiver_handle(receiver); | |
| 348 Handle<String> name_handle(name); | |
| 349 bool pending_exception; | |
| 350 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 351 &pending_exception); | |
| 352 if (pending_exception) return Failure::Exception(); | |
| 353 return this_handle->GetPropertyWithReceiver(*receiver_handle, | |
| 354 *name_handle, | |
| 355 attributes); | |
| 356 } | |
| 357 | |
| 358 | |
| 359 Object* JSObject::SetLazyProperty(LookupResult* result, | |
| 360 String* name, | |
| 361 Object* value, | |
| 362 PropertyAttributes attributes) { | |
| 363 ASSERT(!IsJSGlobalProxy()); | |
| 364 HandleScope scope; | |
| 365 Handle<JSObject> this_handle(this); | |
| 366 Handle<String> name_handle(name); | |
| 367 Handle<Object> value_handle(value); | |
| 368 bool pending_exception; | |
| 369 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 370 &pending_exception); | |
| 371 if (pending_exception) return Failure::Exception(); | |
| 372 return this_handle->SetProperty(*name_handle, *value_handle, attributes); | |
| 373 } | |
| 374 | |
| 375 | |
| 376 Object* JSObject::DeleteLazyProperty(LookupResult* result, | |
| 377 String* name, | |
| 378 DeleteMode mode) { | |
| 379 HandleScope scope; | |
| 380 Handle<JSObject> this_handle(this); | |
| 381 Handle<String> name_handle(name); | |
| 382 bool pending_exception; | |
| 383 LoadLazy(Handle<JSObject>(JSObject::cast(result->GetLazyValue())), | |
| 384 &pending_exception); | |
| 385 if (pending_exception) return Failure::Exception(); | |
| 386 return this_handle->DeleteProperty(*name_handle, mode); | |
| 387 } | |
| 388 | |
| 389 | |
| 390 Object* JSObject::GetNormalizedProperty(LookupResult* result) { | 341 Object* JSObject::GetNormalizedProperty(LookupResult* result) { |
| 391 ASSERT(!HasFastProperties()); | 342 ASSERT(!HasFastProperties()); |
| 392 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); | 343 Object* value = property_dictionary()->ValueAt(result->GetDictionaryEntry()); |
| 393 if (IsGlobalObject()) { | 344 if (IsGlobalObject()) { |
| 394 value = JSGlobalPropertyCell::cast(value)->value(); | 345 value = JSGlobalPropertyCell::cast(value)->value(); |
| 395 } | 346 } |
| 396 ASSERT(!value->IsJSGlobalPropertyCell()); | 347 ASSERT(!value->IsJSGlobalPropertyCell()); |
| 397 return value; | 348 return value; |
| 398 } | 349 } |
| 399 | 350 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 // chain; either the holder of the result or null in case of an | 474 // chain; either the holder of the result or null in case of an |
| 524 // absent property. | 475 // absent property. |
| 525 if (current == last) break; | 476 if (current == last) break; |
| 526 } | 477 } |
| 527 | 478 |
| 528 if (!result->IsProperty()) { | 479 if (!result->IsProperty()) { |
| 529 *attributes = ABSENT; | 480 *attributes = ABSENT; |
| 530 return Heap::undefined_value(); | 481 return Heap::undefined_value(); |
| 531 } | 482 } |
| 532 *attributes = result->GetAttributes(); | 483 *attributes = result->GetAttributes(); |
| 533 if (!result->IsLoaded()) { | |
| 534 return JSObject::cast(this)->GetLazyProperty(receiver, | |
| 535 result, | |
| 536 name, | |
| 537 attributes); | |
| 538 } | |
| 539 Object* value; | 484 Object* value; |
| 540 JSObject* holder = result->holder(); | 485 JSObject* holder = result->holder(); |
| 541 switch (result->type()) { | 486 switch (result->type()) { |
| 542 case NORMAL: | 487 case NORMAL: |
| 543 value = holder->GetNormalizedProperty(result); | 488 value = holder->GetNormalizedProperty(result); |
| 544 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 489 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
| 545 return value->IsTheHole() ? Heap::undefined_value() : value; | 490 return value->IsTheHole() ? Heap::undefined_value() : value; |
| 546 case FIELD: | 491 case FIELD: |
| 547 value = holder->FastPropertyAt(result->GetFieldIndex()); | 492 value = holder->FastPropertyAt(result->GetFieldIndex()); |
| 548 ASSERT(!value->IsTheHole() || result->IsReadOnly()); | 493 ASSERT(!value->IsTheHole() || result->IsReadOnly()); |
| (...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 int entry = property_dictionary()->FindEntry(name); | 1724 int entry = property_dictionary()->FindEntry(name); |
| 1780 if (entry != StringDictionary::kNotFound) { | 1725 if (entry != StringDictionary::kNotFound) { |
| 1781 Object* value = property_dictionary()->ValueAt(entry); | 1726 Object* value = property_dictionary()->ValueAt(entry); |
| 1782 if (IsGlobalObject()) { | 1727 if (IsGlobalObject()) { |
| 1783 PropertyDetails d = property_dictionary()->DetailsAt(entry); | 1728 PropertyDetails d = property_dictionary()->DetailsAt(entry); |
| 1784 if (d.IsDeleted()) { | 1729 if (d.IsDeleted()) { |
| 1785 result->NotFound(); | 1730 result->NotFound(); |
| 1786 return; | 1731 return; |
| 1787 } | 1732 } |
| 1788 value = JSGlobalPropertyCell::cast(value)->value(); | 1733 value = JSGlobalPropertyCell::cast(value)->value(); |
| 1789 ASSERT(result->IsLoaded()); | |
| 1790 } | 1734 } |
| 1791 // Make sure to disallow caching for uninitialized constants | 1735 // Make sure to disallow caching for uninitialized constants |
| 1792 // found in the dictionary-mode objects. | 1736 // found in the dictionary-mode objects. |
| 1793 if (value->IsTheHole()) result->DisallowCaching(); | 1737 if (value->IsTheHole()) result->DisallowCaching(); |
| 1794 result->DictionaryResult(this, entry); | 1738 result->DictionaryResult(this, entry); |
| 1795 return; | 1739 return; |
| 1796 } | 1740 } |
| 1797 // Slow case object skipped during lookup. Do not use inline caching. | 1741 // Slow case object skipped during lookup. Do not use inline caching. |
| 1798 if (!IsGlobalObject()) result->DisallowCaching(); | 1742 if (!IsGlobalObject()) result->DisallowCaching(); |
| 1799 } | 1743 } |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1905 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), | 1849 return SetPropertyWithCallback(accessor_result.GetCallbackObject(), |
| 1906 name, | 1850 name, |
| 1907 value, | 1851 value, |
| 1908 accessor_result.holder()); | 1852 accessor_result.holder()); |
| 1909 } | 1853 } |
| 1910 } | 1854 } |
| 1911 if (!result->IsFound()) { | 1855 if (!result->IsFound()) { |
| 1912 // Neither properties nor transitions found. | 1856 // Neither properties nor transitions found. |
| 1913 return AddProperty(name, value, attributes); | 1857 return AddProperty(name, value, attributes); |
| 1914 } | 1858 } |
| 1915 if (!result->IsLoaded()) { | |
| 1916 return SetLazyProperty(result, name, value, attributes); | |
| 1917 } | |
| 1918 if (result->IsReadOnly() && result->IsProperty()) return value; | 1859 if (result->IsReadOnly() && result->IsProperty()) return value; |
| 1919 // This is a real property that is not read-only, or it is a | 1860 // This is a real property that is not read-only, or it is a |
| 1920 // transition or null descriptor and there are no setters in the prototypes. | 1861 // transition or null descriptor and there are no setters in the prototypes. |
| 1921 switch (result->type()) { | 1862 switch (result->type()) { |
| 1922 case NORMAL: | 1863 case NORMAL: |
| 1923 return SetNormalizedProperty(result, value); | 1864 return SetNormalizedProperty(result, value); |
| 1924 case FIELD: | 1865 case FIELD: |
| 1925 return FastPropertyAtPut(result->GetFieldIndex(), value); | 1866 return FastPropertyAtPut(result->GetFieldIndex(), value); |
| 1926 case MAP_TRANSITION: | 1867 case MAP_TRANSITION: |
| 1927 if (attributes == result->GetAttributes()) { | 1868 if (attributes == result->GetAttributes()) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 name, | 1928 name, |
| 1988 value, | 1929 value, |
| 1989 attributes); | 1930 attributes); |
| 1990 } | 1931 } |
| 1991 | 1932 |
| 1992 // Check for accessor in prototype chain removed here in clone. | 1933 // Check for accessor in prototype chain removed here in clone. |
| 1993 if (!result.IsFound()) { | 1934 if (!result.IsFound()) { |
| 1994 // Neither properties nor transitions found. | 1935 // Neither properties nor transitions found. |
| 1995 return AddProperty(name, value, attributes); | 1936 return AddProperty(name, value, attributes); |
| 1996 } | 1937 } |
| 1997 if (!result.IsLoaded()) { | 1938 |
| 1998 return SetLazyProperty(&result, name, value, attributes); | |
| 1999 } | |
| 2000 PropertyDetails details = PropertyDetails(attributes, NORMAL); | 1939 PropertyDetails details = PropertyDetails(attributes, NORMAL); |
| 2001 | 1940 |
| 2002 // Check of IsReadOnly removed from here in clone. | 1941 // Check of IsReadOnly removed from here in clone. |
| 2003 switch (result.type()) { | 1942 switch (result.type()) { |
| 2004 case NORMAL: | 1943 case NORMAL: |
| 2005 return SetNormalizedProperty(name, value, details); | 1944 return SetNormalizedProperty(name, value, details); |
| 2006 case FIELD: | 1945 case FIELD: |
| 2007 return FastPropertyAtPut(result.GetFieldIndex(), value); | 1946 return FastPropertyAtPut(result.GetFieldIndex(), value); |
| 2008 case MAP_TRANSITION: | 1947 case MAP_TRANSITION: |
| 2009 if (attributes == result.GetAttributes()) { | 1948 if (attributes == result.GetAttributes()) { |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 return Heap::false_value(); | 2446 return Heap::false_value(); |
| 2508 } | 2447 } |
| 2509 // Check for interceptor. | 2448 // Check for interceptor. |
| 2510 if (result.type() == INTERCEPTOR) { | 2449 if (result.type() == INTERCEPTOR) { |
| 2511 // Skip interceptor if forcing a deletion. | 2450 // Skip interceptor if forcing a deletion. |
| 2512 if (mode == FORCE_DELETION) { | 2451 if (mode == FORCE_DELETION) { |
| 2513 return DeletePropertyPostInterceptor(name, mode); | 2452 return DeletePropertyPostInterceptor(name, mode); |
| 2514 } | 2453 } |
| 2515 return DeletePropertyWithInterceptor(name); | 2454 return DeletePropertyWithInterceptor(name); |
| 2516 } | 2455 } |
| 2517 if (!result.IsLoaded()) { | |
| 2518 return JSObject::cast(this)->DeleteLazyProperty(&result, | |
| 2519 name, | |
| 2520 mode); | |
| 2521 } | |
| 2522 // Normalize object if needed. | 2456 // Normalize object if needed. |
| 2523 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); | 2457 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0); |
| 2524 if (obj->IsFailure()) return obj; | 2458 if (obj->IsFailure()) return obj; |
| 2525 // Make sure the properties are normalized before removing the entry. | 2459 // Make sure the properties are normalized before removing the entry. |
| 2526 return DeleteNormalizedProperty(name, mode); | 2460 return DeleteNormalizedProperty(name, mode); |
| 2527 } | 2461 } |
| 2528 } | 2462 } |
| 2529 | 2463 |
| 2530 | 2464 |
| 2531 // Check whether this object references another object. | 2465 // Check whether this object references another object. |
| (...skipping 6047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8579 if (break_point_objects()->IsUndefined()) return 0; | 8513 if (break_point_objects()->IsUndefined()) return 0; |
| 8580 // Single beak point. | 8514 // Single beak point. |
| 8581 if (!break_point_objects()->IsFixedArray()) return 1; | 8515 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8582 // Multiple break points. | 8516 // Multiple break points. |
| 8583 return FixedArray::cast(break_point_objects())->length(); | 8517 return FixedArray::cast(break_point_objects())->length(); |
| 8584 } | 8518 } |
| 8585 #endif | 8519 #endif |
| 8586 | 8520 |
| 8587 | 8521 |
| 8588 } } // namespace v8::internal | 8522 } } // namespace v8::internal |
| OLD | NEW |