| 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 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 Object** argv[] = { value_handle.location() }; | 1653 Object** argv[] = { value_handle.location() }; |
| 1654 Execution::Call(fun, self, 1, argv, &has_pending_exception); | 1654 Execution::Call(fun, self, 1, argv, &has_pending_exception); |
| 1655 // Check for pending exception and return the result. | 1655 // Check for pending exception and return the result. |
| 1656 if (has_pending_exception) return Failure::Exception(); | 1656 if (has_pending_exception) return Failure::Exception(); |
| 1657 return *value_handle; | 1657 return *value_handle; |
| 1658 } | 1658 } |
| 1659 | 1659 |
| 1660 | 1660 |
| 1661 void JSObject::LookupCallbackSetterInPrototypes(String* name, | 1661 void JSObject::LookupCallbackSetterInPrototypes(String* name, |
| 1662 LookupResult* result) { | 1662 LookupResult* result) { |
| 1663 Heap* heap = HEAP; |
| 1663 for (Object* pt = GetPrototype(); | 1664 for (Object* pt = GetPrototype(); |
| 1664 pt != HEAP->null_value(); | 1665 pt != heap->null_value(); |
| 1665 pt = pt->GetPrototype()) { | 1666 pt = pt->GetPrototype()) { |
| 1666 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); | 1667 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); |
| 1667 if (result->IsProperty()) { | 1668 if (result->IsProperty()) { |
| 1668 if (result->IsReadOnly()) { | 1669 if (result->IsReadOnly()) { |
| 1669 result->NotFound(); | 1670 result->NotFound(); |
| 1670 return; | 1671 return; |
| 1671 } | 1672 } |
| 1672 if (result->type() == CALLBACKS) { | 1673 if (result->type() == CALLBACKS) { |
| 1673 return; | 1674 return; |
| 1674 } | 1675 } |
| 1675 } | 1676 } |
| 1676 } | 1677 } |
| 1677 result->NotFound(); | 1678 result->NotFound(); |
| 1678 } | 1679 } |
| 1679 | 1680 |
| 1680 | 1681 |
| 1681 bool JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index, | 1682 bool JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index, |
| 1682 Object* value) { | 1683 Object* value) { |
| 1684 Heap* heap = HEAP; |
| 1683 for (Object* pt = GetPrototype(); | 1685 for (Object* pt = GetPrototype(); |
| 1684 pt != HEAP->null_value(); | 1686 pt != heap->null_value(); |
| 1685 pt = pt->GetPrototype()) { | 1687 pt = pt->GetPrototype()) { |
| 1686 if (!JSObject::cast(pt)->HasDictionaryElements()) { | 1688 if (!JSObject::cast(pt)->HasDictionaryElements()) { |
| 1687 continue; | 1689 continue; |
| 1688 } | 1690 } |
| 1689 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); | 1691 NumberDictionary* dictionary = JSObject::cast(pt)->element_dictionary(); |
| 1690 int entry = dictionary->FindEntry(index); | 1692 int entry = dictionary->FindEntry(index); |
| 1691 if (entry != NumberDictionary::kNotFound) { | 1693 if (entry != NumberDictionary::kNotFound) { |
| 1692 Object* element = dictionary->ValueAt(entry); | 1694 Object* element = dictionary->ValueAt(entry); |
| 1693 PropertyDetails details = dictionary->DetailsAt(entry); | 1695 PropertyDetails details = dictionary->DetailsAt(entry); |
| 1694 if (details.type() == CALLBACKS) { | 1696 if (details.type() == CALLBACKS) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 void JSObject::LookupRealNamedProperty(String* name, LookupResult* result) { | 1772 void JSObject::LookupRealNamedProperty(String* name, LookupResult* result) { |
| 1771 LocalLookupRealNamedProperty(name, result); | 1773 LocalLookupRealNamedProperty(name, result); |
| 1772 if (result->IsProperty()) return; | 1774 if (result->IsProperty()) return; |
| 1773 | 1775 |
| 1774 LookupRealNamedPropertyInPrototypes(name, result); | 1776 LookupRealNamedPropertyInPrototypes(name, result); |
| 1775 } | 1777 } |
| 1776 | 1778 |
| 1777 | 1779 |
| 1778 void JSObject::LookupRealNamedPropertyInPrototypes(String* name, | 1780 void JSObject::LookupRealNamedPropertyInPrototypes(String* name, |
| 1779 LookupResult* result) { | 1781 LookupResult* result) { |
| 1782 Heap* heap = HEAP; |
| 1780 for (Object* pt = GetPrototype(); | 1783 for (Object* pt = GetPrototype(); |
| 1781 pt != HEAP->null_value(); | 1784 pt != heap->null_value(); |
| 1782 pt = JSObject::cast(pt)->GetPrototype()) { | 1785 pt = JSObject::cast(pt)->GetPrototype()) { |
| 1783 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); | 1786 JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result); |
| 1784 if (result->IsProperty() && (result->type() != INTERCEPTOR)) return; | 1787 if (result->IsProperty() && (result->type() != INTERCEPTOR)) return; |
| 1785 } | 1788 } |
| 1786 result->NotFound(); | 1789 result->NotFound(); |
| 1787 } | 1790 } |
| 1788 | 1791 |
| 1789 | 1792 |
| 1790 // We only need to deal with CALLBACKS and INTERCEPTORS | 1793 // We only need to deal with CALLBACKS and INTERCEPTORS |
| 1791 Object* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result, | 1794 Object* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2003 String* name, | 2006 String* name, |
| 2004 bool continue_search) { | 2007 bool continue_search) { |
| 2005 // Check local property, ignore interceptor. | 2008 // Check local property, ignore interceptor. |
| 2006 LookupResult result; | 2009 LookupResult result; |
| 2007 LocalLookupRealNamedProperty(name, &result); | 2010 LocalLookupRealNamedProperty(name, &result); |
| 2008 if (result.IsProperty()) return result.GetAttributes(); | 2011 if (result.IsProperty()) return result.GetAttributes(); |
| 2009 | 2012 |
| 2010 if (continue_search) { | 2013 if (continue_search) { |
| 2011 // Continue searching via the prototype chain. | 2014 // Continue searching via the prototype chain. |
| 2012 Object* pt = GetPrototype(); | 2015 Object* pt = GetPrototype(); |
| 2013 if (pt != HEAP->null_value()) { | 2016 if (!pt->IsNull()) { |
| 2014 return JSObject::cast(pt)-> | 2017 return JSObject::cast(pt)-> |
| 2015 GetPropertyAttributeWithReceiver(receiver, name); | 2018 GetPropertyAttributeWithReceiver(receiver, name); |
| 2016 } | 2019 } |
| 2017 } | 2020 } |
| 2018 return ABSENT; | 2021 return ABSENT; |
| 2019 } | 2022 } |
| 2020 | 2023 |
| 2021 | 2024 |
| 2022 PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( | 2025 PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor( |
| 2023 JSObject* receiver, | 2026 JSObject* receiver, |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 return true; | 2505 return true; |
| 2503 } | 2506 } |
| 2504 | 2507 |
| 2505 // Is the object the prototype for this object? | 2508 // Is the object the prototype for this object? |
| 2506 if (map()->prototype() == obj) { | 2509 if (map()->prototype() == obj) { |
| 2507 return true; | 2510 return true; |
| 2508 } | 2511 } |
| 2509 | 2512 |
| 2510 // Check if the object is among the named properties. | 2513 // Check if the object is among the named properties. |
| 2511 Object* key = SlowReverseLookup(obj); | 2514 Object* key = SlowReverseLookup(obj); |
| 2512 if (key != HEAP->undefined_value()) { | 2515 if (!key->IsUndefined()) { |
| 2513 return true; | 2516 return true; |
| 2514 } | 2517 } |
| 2515 | 2518 |
| 2516 // Check if the object is among the indexed properties. | 2519 // Check if the object is among the indexed properties. |
| 2517 switch (GetElementsKind()) { | 2520 switch (GetElementsKind()) { |
| 2518 case PIXEL_ELEMENTS: | 2521 case PIXEL_ELEMENTS: |
| 2519 case EXTERNAL_BYTE_ELEMENTS: | 2522 case EXTERNAL_BYTE_ELEMENTS: |
| 2520 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | 2523 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| 2521 case EXTERNAL_SHORT_ELEMENTS: | 2524 case EXTERNAL_SHORT_ELEMENTS: |
| 2522 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | 2525 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2533 for (int i = 0; i < length; i++) { | 2536 for (int i = 0; i < length; i++) { |
| 2534 Object* element = FixedArray::cast(elements())->get(i); | 2537 Object* element = FixedArray::cast(elements())->get(i); |
| 2535 if (!element->IsTheHole() && element == obj) { | 2538 if (!element->IsTheHole() && element == obj) { |
| 2536 return true; | 2539 return true; |
| 2537 } | 2540 } |
| 2538 } | 2541 } |
| 2539 break; | 2542 break; |
| 2540 } | 2543 } |
| 2541 case DICTIONARY_ELEMENTS: { | 2544 case DICTIONARY_ELEMENTS: { |
| 2542 key = element_dictionary()->SlowReverseLookup(obj); | 2545 key = element_dictionary()->SlowReverseLookup(obj); |
| 2543 if (key != HEAP->undefined_value()) { | 2546 if (!key->IsUndefined()) { |
| 2544 return true; | 2547 return true; |
| 2545 } | 2548 } |
| 2546 break; | 2549 break; |
| 2547 } | 2550 } |
| 2548 default: | 2551 default: |
| 2549 UNREACHABLE(); | 2552 UNREACHABLE(); |
| 2550 break; | 2553 break; |
| 2551 } | 2554 } |
| 2552 | 2555 |
| 2553 // For functions check the context. | 2556 // For functions check the context. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2611 return new_map; | 2614 return new_map; |
| 2612 } | 2615 } |
| 2613 | 2616 |
| 2614 | 2617 |
| 2615 // Tests for the fast common case for property enumeration: | 2618 // Tests for the fast common case for property enumeration: |
| 2616 // - This object and all prototypes has an enum cache (which means that it has | 2619 // - This object and all prototypes has an enum cache (which means that it has |
| 2617 // no interceptors and needs no access checks). | 2620 // no interceptors and needs no access checks). |
| 2618 // - This object has no elements. | 2621 // - This object has no elements. |
| 2619 // - No prototype has enumerable properties/elements. | 2622 // - No prototype has enumerable properties/elements. |
| 2620 bool JSObject::IsSimpleEnum() { | 2623 bool JSObject::IsSimpleEnum() { |
| 2624 Heap* heap = HEAP; |
| 2621 for (Object* o = this; | 2625 for (Object* o = this; |
| 2622 o != HEAP->null_value(); | 2626 o != heap->null_value(); |
| 2623 o = JSObject::cast(o)->GetPrototype()) { | 2627 o = JSObject::cast(o)->GetPrototype()) { |
| 2624 JSObject* curr = JSObject::cast(o); | 2628 JSObject* curr = JSObject::cast(o); |
| 2625 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false; | 2629 if (!curr->map()->instance_descriptors()->HasEnumCache()) return false; |
| 2626 ASSERT(!curr->HasNamedInterceptor()); | 2630 ASSERT(!curr->HasNamedInterceptor()); |
| 2627 ASSERT(!curr->HasIndexedInterceptor()); | 2631 ASSERT(!curr->HasIndexedInterceptor()); |
| 2628 ASSERT(!curr->IsAccessCheckNeeded()); | 2632 ASSERT(!curr->IsAccessCheckNeeded()); |
| 2629 if (curr->NumberOfEnumElements() > 0) return false; | 2633 if (curr->NumberOfEnumElements() > 0) return false; |
| 2630 if (curr != this) { | 2634 if (curr != this) { |
| 2631 FixedArray* curr_fixed_array = | 2635 FixedArray* curr_fixed_array = |
| 2632 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache()); | 2636 FixedArray::cast(curr->map()->instance_descriptors()->GetEnumCache()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2712 result->InterceptorResult(this); | 2716 result->InterceptorResult(this); |
| 2713 return; | 2717 return; |
| 2714 } | 2718 } |
| 2715 | 2719 |
| 2716 LocalLookupRealNamedProperty(name, result); | 2720 LocalLookupRealNamedProperty(name, result); |
| 2717 } | 2721 } |
| 2718 | 2722 |
| 2719 | 2723 |
| 2720 void JSObject::Lookup(String* name, LookupResult* result) { | 2724 void JSObject::Lookup(String* name, LookupResult* result) { |
| 2721 // Ecma-262 3rd 8.6.2.4 | 2725 // Ecma-262 3rd 8.6.2.4 |
| 2726 Heap* heap = HEAP; |
| 2722 for (Object* current = this; | 2727 for (Object* current = this; |
| 2723 current != HEAP->null_value(); | 2728 current != heap->null_value(); |
| 2724 current = JSObject::cast(current)->GetPrototype()) { | 2729 current = JSObject::cast(current)->GetPrototype()) { |
| 2725 JSObject::cast(current)->LocalLookup(name, result); | 2730 JSObject::cast(current)->LocalLookup(name, result); |
| 2726 if (result->IsProperty()) return; | 2731 if (result->IsProperty()) return; |
| 2727 } | 2732 } |
| 2728 result->NotFound(); | 2733 result->NotFound(); |
| 2729 } | 2734 } |
| 2730 | 2735 |
| 2731 | 2736 |
| 2732 // Search object and it's prototype chain for callback properties. | 2737 // Search object and it's prototype chain for callback properties. |
| 2733 void JSObject::LookupCallback(String* name, LookupResult* result) { | 2738 void JSObject::LookupCallback(String* name, LookupResult* result) { |
| 2739 Heap* heap = HEAP; |
| 2734 for (Object* current = this; | 2740 for (Object* current = this; |
| 2735 current != HEAP->null_value(); | 2741 current != heap->null_value(); |
| 2736 current = JSObject::cast(current)->GetPrototype()) { | 2742 current = JSObject::cast(current)->GetPrototype()) { |
| 2737 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); | 2743 JSObject::cast(current)->LocalLookupRealNamedProperty(name, result); |
| 2738 if (result->IsProperty() && result->type() == CALLBACKS) return; | 2744 if (result->IsProperty() && result->type() == CALLBACKS) return; |
| 2739 } | 2745 } |
| 2740 result->NotFound(); | 2746 result->NotFound(); |
| 2741 } | 2747 } |
| 2742 | 2748 |
| 2743 | 2749 |
| 2744 Object* JSObject::DefineGetterSetter(String* name, | 2750 Object* JSObject::DefineGetterSetter(String* name, |
| 2745 PropertyAttributes attributes) { | 2751 PropertyAttributes attributes) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3006 // Check access rights if needed. | 3012 // Check access rights if needed. |
| 3007 if (IsAccessCheckNeeded() && | 3013 if (IsAccessCheckNeeded() && |
| 3008 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { | 3014 !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_HAS)) { |
| 3009 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 3015 Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 3010 return HEAP->undefined_value(); | 3016 return HEAP->undefined_value(); |
| 3011 } | 3017 } |
| 3012 | 3018 |
| 3013 // Make the lookup and include prototypes. | 3019 // Make the lookup and include prototypes. |
| 3014 int accessor_index = is_getter ? kGetterIndex : kSetterIndex; | 3020 int accessor_index = is_getter ? kGetterIndex : kSetterIndex; |
| 3015 uint32_t index = 0; | 3021 uint32_t index = 0; |
| 3022 Heap* heap = HEAP; |
| 3016 if (name->AsArrayIndex(&index)) { | 3023 if (name->AsArrayIndex(&index)) { |
| 3017 for (Object* obj = this; | 3024 for (Object* obj = this; |
| 3018 obj != HEAP->null_value(); | 3025 obj != heap->null_value(); |
| 3019 obj = JSObject::cast(obj)->GetPrototype()) { | 3026 obj = JSObject::cast(obj)->GetPrototype()) { |
| 3020 JSObject* js_object = JSObject::cast(obj); | 3027 JSObject* js_object = JSObject::cast(obj); |
| 3021 if (js_object->HasDictionaryElements()) { | 3028 if (js_object->HasDictionaryElements()) { |
| 3022 NumberDictionary* dictionary = js_object->element_dictionary(); | 3029 NumberDictionary* dictionary = js_object->element_dictionary(); |
| 3023 int entry = dictionary->FindEntry(index); | 3030 int entry = dictionary->FindEntry(index); |
| 3024 if (entry != NumberDictionary::kNotFound) { | 3031 if (entry != NumberDictionary::kNotFound) { |
| 3025 Object* element = dictionary->ValueAt(entry); | 3032 Object* element = dictionary->ValueAt(entry); |
| 3026 PropertyDetails details = dictionary->DetailsAt(entry); | 3033 PropertyDetails details = dictionary->DetailsAt(entry); |
| 3027 if (details.type() == CALLBACKS) { | 3034 if (details.type() == CALLBACKS) { |
| 3028 if (element->IsFixedArray()) { | 3035 if (element->IsFixedArray()) { |
| 3029 return FixedArray::cast(element)->get(accessor_index); | 3036 return FixedArray::cast(element)->get(accessor_index); |
| 3030 } | 3037 } |
| 3031 } | 3038 } |
| 3032 } | 3039 } |
| 3033 } | 3040 } |
| 3034 } | 3041 } |
| 3035 } else { | 3042 } else { |
| 3036 for (Object* obj = this; | 3043 for (Object* obj = this; |
| 3037 obj != HEAP->null_value(); | 3044 obj != heap->null_value(); |
| 3038 obj = JSObject::cast(obj)->GetPrototype()) { | 3045 obj = JSObject::cast(obj)->GetPrototype()) { |
| 3039 LookupResult result; | 3046 LookupResult result; |
| 3040 JSObject::cast(obj)->LocalLookup(name, &result); | 3047 JSObject::cast(obj)->LocalLookup(name, &result); |
| 3041 if (result.IsProperty()) { | 3048 if (result.IsProperty()) { |
| 3042 if (result.IsReadOnly()) return HEAP->undefined_value(); | 3049 if (result.IsReadOnly()) return HEAP->undefined_value(); |
| 3043 if (result.type() == CALLBACKS) { | 3050 if (result.type() == CALLBACKS) { |
| 3044 Object* obj = result.GetCallbackObject(); | 3051 Object* obj = result.GetCallbackObject(); |
| 3045 if (obj->IsFixedArray()) { | 3052 if (obj->IsFixedArray()) { |
| 3046 return FixedArray::cast(obj)->get(accessor_index); | 3053 return FixedArray::cast(obj)->get(accessor_index); |
| 3047 } | 3054 } |
| (...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5120 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); | 5127 return Context::cast(literals->get(JSFunction::kLiteralGlobalContextIndex)); |
| 5121 } | 5128 } |
| 5122 | 5129 |
| 5123 | 5130 |
| 5124 void Oddball::OddballIterateBody(ObjectVisitor* v) { | 5131 void Oddball::OddballIterateBody(ObjectVisitor* v) { |
| 5125 // Assumes all Object* members are contiguously allocated! | 5132 // Assumes all Object* members are contiguously allocated! |
| 5126 IteratePointers(v, kToStringOffset, kToNumberOffset + kPointerSize); | 5133 IteratePointers(v, kToStringOffset, kToNumberOffset + kPointerSize); |
| 5127 } | 5134 } |
| 5128 | 5135 |
| 5129 | 5136 |
| 5130 Object* Oddball::Initialize(const char* to_string, Object* to_number) { | 5137 Object* Oddball::Initialize(const char* to_string, |
| 5138 Object* to_number, |
| 5139 byte kind) { |
| 5131 Object* symbol = HEAP->LookupAsciiSymbol(to_string); | 5140 Object* symbol = HEAP->LookupAsciiSymbol(to_string); |
| 5132 if (symbol->IsFailure()) return symbol; | 5141 if (symbol->IsFailure()) return symbol; |
| 5133 set_to_string(String::cast(symbol)); | 5142 set_to_string(String::cast(symbol)); |
| 5134 set_to_number(to_number); | 5143 set_to_number(to_number); |
| 5144 set_kind(kind); |
| 5135 return this; | 5145 return this; |
| 5136 } | 5146 } |
| 5137 | 5147 |
| 5138 | 5148 |
| 5139 bool SharedFunctionInfo::HasSourceCode() { | 5149 bool SharedFunctionInfo::HasSourceCode() { |
| 5140 return !script()->IsUndefined() && | 5150 return !script()->IsUndefined() && |
| 5141 !Script::cast(script())->source()->IsUndefined(); | 5151 !Script::cast(script())->source()->IsUndefined(); |
| 5142 } | 5152 } |
| 5143 | 5153 |
| 5144 | 5154 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5177 } | 5187 } |
| 5178 | 5188 |
| 5179 // If the prototype is null inline constructors cause no problems. | 5189 // If the prototype is null inline constructors cause no problems. |
| 5180 if (!prototype->IsJSObject()) { | 5190 if (!prototype->IsJSObject()) { |
| 5181 ASSERT(prototype->IsNull()); | 5191 ASSERT(prototype->IsNull()); |
| 5182 return true; | 5192 return true; |
| 5183 } | 5193 } |
| 5184 | 5194 |
| 5185 // Traverse the proposed prototype chain looking for setters for properties of | 5195 // Traverse the proposed prototype chain looking for setters for properties of |
| 5186 // the same names as are set by the inline constructor. | 5196 // the same names as are set by the inline constructor. |
| 5197 Heap* heap = HEAP; |
| 5187 for (Object* obj = prototype; | 5198 for (Object* obj = prototype; |
| 5188 obj != HEAP->null_value(); | 5199 obj != heap->null_value(); |
| 5189 obj = obj->GetPrototype()) { | 5200 obj = obj->GetPrototype()) { |
| 5190 JSObject* js_object = JSObject::cast(obj); | 5201 JSObject* js_object = JSObject::cast(obj); |
| 5191 for (int i = 0; i < this_property_assignments_count(); i++) { | 5202 for (int i = 0; i < this_property_assignments_count(); i++) { |
| 5192 LookupResult result; | 5203 LookupResult result; |
| 5193 String* name = GetThisPropertyAssignmentName(i); | 5204 String* name = GetThisPropertyAssignmentName(i); |
| 5194 js_object->LocalLookupRealNamedProperty(name, &result); | 5205 js_object->LocalLookupRealNamedProperty(name, &result); |
| 5195 if (result.IsProperty() && result.type() == CALLBACKS) { | 5206 if (result.IsProperty() && result.type() == CALLBACKS) { |
| 5196 return false; | 5207 return false; |
| 5197 } | 5208 } |
| 5198 } | 5209 } |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5733 Object* JSObject::SetPrototype(Object* value, | 5744 Object* JSObject::SetPrototype(Object* value, |
| 5734 bool skip_hidden_prototypes) { | 5745 bool skip_hidden_prototypes) { |
| 5735 // Silently ignore the change if value is not a JSObject or null. | 5746 // Silently ignore the change if value is not a JSObject or null. |
| 5736 // SpiderMonkey behaves this way. | 5747 // SpiderMonkey behaves this way. |
| 5737 if (!value->IsJSObject() && !value->IsNull()) return value; | 5748 if (!value->IsJSObject() && !value->IsNull()) return value; |
| 5738 | 5749 |
| 5739 // Before we can set the prototype we need to be sure | 5750 // Before we can set the prototype we need to be sure |
| 5740 // prototype cycles are prevented. | 5751 // prototype cycles are prevented. |
| 5741 // It is sufficient to validate that the receiver is not in the new prototype | 5752 // It is sufficient to validate that the receiver is not in the new prototype |
| 5742 // chain. | 5753 // chain. |
| 5743 for (Object* pt = value; pt != HEAP->null_value(); pt = pt->GetPrototype()) { | 5754 Heap* heap = HEAP; |
| 5755 for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) { |
| 5744 if (JSObject::cast(pt) == this) { | 5756 if (JSObject::cast(pt) == this) { |
| 5745 // Cycle detected. | 5757 // Cycle detected. |
| 5746 HandleScope scope; | 5758 HandleScope scope; |
| 5747 return Isolate::Current()->Throw( | 5759 return Isolate::Current()->Throw( |
| 5748 *Factory::NewError("cyclic_proto", HandleVector<Object>(NULL, 0))); | 5760 *Factory::NewError("cyclic_proto", HandleVector<Object>(NULL, 0))); |
| 5749 } | 5761 } |
| 5750 } | 5762 } |
| 5751 | 5763 |
| 5752 JSObject* real_receiver = this; | 5764 JSObject* real_receiver = this; |
| 5753 | 5765 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5818 } | 5830 } |
| 5819 default: | 5831 default: |
| 5820 UNREACHABLE(); | 5832 UNREACHABLE(); |
| 5821 break; | 5833 break; |
| 5822 } | 5834 } |
| 5823 | 5835 |
| 5824 // Handle [] on String objects. | 5836 // Handle [] on String objects. |
| 5825 if (this->IsStringObjectWithCharacterAt(index)) return true; | 5837 if (this->IsStringObjectWithCharacterAt(index)) return true; |
| 5826 | 5838 |
| 5827 Object* pt = GetPrototype(); | 5839 Object* pt = GetPrototype(); |
| 5828 if (pt == HEAP->null_value()) return false; | 5840 if (pt->IsNull()) return false; |
| 5829 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); | 5841 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); |
| 5830 } | 5842 } |
| 5831 | 5843 |
| 5832 | 5844 |
| 5833 bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) { | 5845 bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) { |
| 5834 // Make sure that the top context does not change when doing | 5846 // Make sure that the top context does not change when doing |
| 5835 // callbacks or interceptor calls. | 5847 // callbacks or interceptor calls. |
| 5836 AssertNoContextChange ncc; | 5848 AssertNoContextChange ncc; |
| 5837 HandleScope scope; | 5849 HandleScope scope; |
| 5838 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 5850 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5971 } | 5983 } |
| 5972 default: | 5984 default: |
| 5973 UNREACHABLE(); | 5985 UNREACHABLE(); |
| 5974 break; | 5986 break; |
| 5975 } | 5987 } |
| 5976 | 5988 |
| 5977 // Handle [] on String objects. | 5989 // Handle [] on String objects. |
| 5978 if (this->IsStringObjectWithCharacterAt(index)) return true; | 5990 if (this->IsStringObjectWithCharacterAt(index)) return true; |
| 5979 | 5991 |
| 5980 Object* pt = GetPrototype(); | 5992 Object* pt = GetPrototype(); |
| 5981 if (pt == HEAP->null_value()) return false; | 5993 if (pt->IsNull()) return false; |
| 5982 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); | 5994 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); |
| 5983 } | 5995 } |
| 5984 | 5996 |
| 5985 | 5997 |
| 5986 Object* JSObject::SetElementWithInterceptor(uint32_t index, Object* value) { | 5998 Object* JSObject::SetElementWithInterceptor(uint32_t index, Object* value) { |
| 5987 // Make sure that the top context does not change when doing | 5999 // Make sure that the top context does not change when doing |
| 5988 // callbacks or interceptor calls. | 6000 // callbacks or interceptor calls. |
| 5989 AssertNoContextChange ncc; | 6001 AssertNoContextChange ncc; |
| 5990 HandleScope scope; | 6002 HandleScope scope; |
| 5991 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 6003 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6368 } | 6380 } |
| 6369 break; | 6381 break; |
| 6370 } | 6382 } |
| 6371 default: | 6383 default: |
| 6372 UNREACHABLE(); | 6384 UNREACHABLE(); |
| 6373 break; | 6385 break; |
| 6374 } | 6386 } |
| 6375 | 6387 |
| 6376 // Continue searching via the prototype chain. | 6388 // Continue searching via the prototype chain. |
| 6377 Object* pt = GetPrototype(); | 6389 Object* pt = GetPrototype(); |
| 6378 if (pt == HEAP->null_value()) return HEAP->undefined_value(); | 6390 if (pt->IsNull()) return HEAP->undefined_value(); |
| 6379 return pt->GetElementWithReceiver(receiver, index); | 6391 return pt->GetElementWithReceiver(receiver, index); |
| 6380 } | 6392 } |
| 6381 | 6393 |
| 6382 | 6394 |
| 6383 Object* JSObject::GetElementWithInterceptor(JSObject* receiver, | 6395 Object* JSObject::GetElementWithInterceptor(JSObject* receiver, |
| 6384 uint32_t index) { | 6396 uint32_t index) { |
| 6385 // Make sure that the top context does not change when doing | 6397 // Make sure that the top context does not change when doing |
| 6386 // callbacks or interceptor calls. | 6398 // callbacks or interceptor calls. |
| 6387 AssertNoContextChange ncc; | 6399 AssertNoContextChange ncc; |
| 6388 HandleScope scope; | 6400 HandleScope scope; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6515 index, | 6527 index, |
| 6516 this); | 6528 this); |
| 6517 } | 6529 } |
| 6518 return element; | 6530 return element; |
| 6519 } | 6531 } |
| 6520 break; | 6532 break; |
| 6521 } | 6533 } |
| 6522 } | 6534 } |
| 6523 | 6535 |
| 6524 Object* pt = GetPrototype(); | 6536 Object* pt = GetPrototype(); |
| 6525 if (pt == HEAP->null_value()) return HEAP->undefined_value(); | 6537 if (pt->IsNull()) return HEAP->undefined_value(); |
| 6526 return pt->GetElementWithReceiver(receiver, index); | 6538 return pt->GetElementWithReceiver(receiver, index); |
| 6527 } | 6539 } |
| 6528 | 6540 |
| 6529 | 6541 |
| 6530 bool JSObject::HasDenseElements() { | 6542 bool JSObject::HasDenseElements() { |
| 6531 int capacity = 0; | 6543 int capacity = 0; |
| 6532 int number_of_elements = 0; | 6544 int number_of_elements = 0; |
| 6533 | 6545 |
| 6534 switch (GetElementsKind()) { | 6546 switch (GetElementsKind()) { |
| 6535 case FAST_ELEMENTS: { | 6547 case FAST_ELEMENTS: { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6669 PropertyAttributes* attributes) { | 6681 PropertyAttributes* attributes) { |
| 6670 // Check local property in holder, ignore interceptor. | 6682 // Check local property in holder, ignore interceptor. |
| 6671 LookupResult result; | 6683 LookupResult result; |
| 6672 LocalLookupRealNamedProperty(name, &result); | 6684 LocalLookupRealNamedProperty(name, &result); |
| 6673 if (result.IsProperty()) { | 6685 if (result.IsProperty()) { |
| 6674 return GetProperty(receiver, &result, name, attributes); | 6686 return GetProperty(receiver, &result, name, attributes); |
| 6675 } | 6687 } |
| 6676 // Continue searching via the prototype chain. | 6688 // Continue searching via the prototype chain. |
| 6677 Object* pt = GetPrototype(); | 6689 Object* pt = GetPrototype(); |
| 6678 *attributes = ABSENT; | 6690 *attributes = ABSENT; |
| 6679 if (pt == HEAP->null_value()) return HEAP->undefined_value(); | 6691 if (pt->IsNull()) return HEAP->undefined_value(); |
| 6680 return pt->GetPropertyWithReceiver(receiver, name, attributes); | 6692 return pt->GetPropertyWithReceiver(receiver, name, attributes); |
| 6681 } | 6693 } |
| 6682 | 6694 |
| 6683 | 6695 |
| 6684 Object* JSObject::GetLocalPropertyPostInterceptor( | 6696 Object* JSObject::GetLocalPropertyPostInterceptor( |
| 6685 JSObject* receiver, | 6697 JSObject* receiver, |
| 6686 String* name, | 6698 String* name, |
| 6687 PropertyAttributes* attributes) { | 6699 PropertyAttributes* attributes) { |
| 6688 // Check local property in holder, ignore interceptor. | 6700 // Check local property in holder, ignore interceptor. |
| 6689 LookupResult result; | 6701 LookupResult result; |
| (...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8791 if (break_point_objects()->IsUndefined()) return 0; | 8803 if (break_point_objects()->IsUndefined()) return 0; |
| 8792 // Single beak point. | 8804 // Single beak point. |
| 8793 if (!break_point_objects()->IsFixedArray()) return 1; | 8805 if (!break_point_objects()->IsFixedArray()) return 1; |
| 8794 // Multiple break points. | 8806 // Multiple break points. |
| 8795 return FixedArray::cast(break_point_objects())->length(); | 8807 return FixedArray::cast(break_point_objects())->length(); |
| 8796 } | 8808 } |
| 8797 #endif | 8809 #endif |
| 8798 | 8810 |
| 8799 | 8811 |
| 8800 } } // namespace v8::internal | 8812 } } // namespace v8::internal |
| OLD | NEW |