| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 7770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7781 } | 7781 } |
| 7782 ASSERT(Map::cast(new_map)->prototype() == value); | 7782 ASSERT(Map::cast(new_map)->prototype() == value); |
| 7783 real_receiver->set_map(Map::cast(new_map)); | 7783 real_receiver->set_map(Map::cast(new_map)); |
| 7784 | 7784 |
| 7785 heap->ClearInstanceofCache(); | 7785 heap->ClearInstanceofCache(); |
| 7786 ASSERT(size == Size()); | 7786 ASSERT(size == Size()); |
| 7787 return value; | 7787 return value; |
| 7788 } | 7788 } |
| 7789 | 7789 |
| 7790 | 7790 |
| 7791 bool JSObject::HasElementPostInterceptor(JSReceiver* receiver, uint32_t index) { | |
| 7792 switch (GetElementsKind()) { | |
| 7793 case FAST_ELEMENTS: { | |
| 7794 uint32_t length = IsJSArray() ? | |
| 7795 static_cast<uint32_t> | |
| 7796 (Smi::cast(JSArray::cast(this)->length())->value()) : | |
| 7797 static_cast<uint32_t>(FixedArray::cast(elements())->length()); | |
| 7798 if ((index < length) && | |
| 7799 !FixedArray::cast(elements())->get(index)->IsTheHole()) { | |
| 7800 return true; | |
| 7801 } | |
| 7802 break; | |
| 7803 } | |
| 7804 case FAST_DOUBLE_ELEMENTS: { | |
| 7805 uint32_t length = IsJSArray() ? | |
| 7806 static_cast<uint32_t> | |
| 7807 (Smi::cast(JSArray::cast(this)->length())->value()) : | |
| 7808 static_cast<uint32_t>(FixedDoubleArray::cast(elements())->length()); | |
| 7809 if ((index < length) && | |
| 7810 !FixedDoubleArray::cast(elements())->is_the_hole(index)) { | |
| 7811 return true; | |
| 7812 } | |
| 7813 break; | |
| 7814 } | |
| 7815 case EXTERNAL_PIXEL_ELEMENTS: { | |
| 7816 ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); | |
| 7817 if (index < static_cast<uint32_t>(pixels->length())) { | |
| 7818 return true; | |
| 7819 } | |
| 7820 break; | |
| 7821 } | |
| 7822 case EXTERNAL_BYTE_ELEMENTS: | |
| 7823 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: | |
| 7824 case EXTERNAL_SHORT_ELEMENTS: | |
| 7825 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: | |
| 7826 case EXTERNAL_INT_ELEMENTS: | |
| 7827 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | |
| 7828 case EXTERNAL_FLOAT_ELEMENTS: | |
| 7829 case EXTERNAL_DOUBLE_ELEMENTS: { | |
| 7830 ExternalArray* array = ExternalArray::cast(elements()); | |
| 7831 if (index < static_cast<uint32_t>(array->length())) { | |
| 7832 return true; | |
| 7833 } | |
| 7834 break; | |
| 7835 } | |
| 7836 case DICTIONARY_ELEMENTS: { | |
| 7837 if (element_dictionary()->FindEntry(index) | |
| 7838 != NumberDictionary::kNotFound) { | |
| 7839 return true; | |
| 7840 } | |
| 7841 break; | |
| 7842 } | |
| 7843 case NON_STRICT_ARGUMENTS_ELEMENTS: | |
| 7844 UNREACHABLE(); | |
| 7845 break; | |
| 7846 } | |
| 7847 | |
| 7848 // Handle [] on String objects. | |
| 7849 if (this->IsStringObjectWithCharacterAt(index)) return true; | |
| 7850 | |
| 7851 Object* pt = GetPrototype(); | |
| 7852 if (pt->IsNull()) return false; | |
| 7853 return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); | |
| 7854 } | |
| 7855 | |
| 7856 | |
| 7857 bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { | 7791 bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { |
| 7858 Isolate* isolate = GetIsolate(); | 7792 Isolate* isolate = GetIsolate(); |
| 7859 // Make sure that the top context does not change when doing | 7793 // Make sure that the top context does not change when doing |
| 7860 // callbacks or interceptor calls. | 7794 // callbacks or interceptor calls. |
| 7861 AssertNoContextChange ncc; | 7795 AssertNoContextChange ncc; |
| 7862 HandleScope scope(isolate); | 7796 HandleScope scope(isolate); |
| 7863 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); | 7797 Handle<InterceptorInfo> interceptor(GetIndexedInterceptor()); |
| 7864 Handle<JSReceiver> receiver_handle(receiver); | 7798 Handle<JSReceiver> receiver_handle(receiver); |
| 7865 Handle<JSObject> holder_handle(this); | 7799 Handle<JSObject> holder_handle(this); |
| 7866 CustomArguments args(isolate, interceptor->data(), receiver, this); | 7800 CustomArguments args(isolate, interceptor->data(), receiver, this); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 7886 LOG(isolate, | 7820 LOG(isolate, |
| 7887 ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index)); | 7821 ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index)); |
| 7888 v8::Handle<v8::Value> result; | 7822 v8::Handle<v8::Value> result; |
| 7889 { | 7823 { |
| 7890 // Leaving JavaScript. | 7824 // Leaving JavaScript. |
| 7891 VMState state(isolate, EXTERNAL); | 7825 VMState state(isolate, EXTERNAL); |
| 7892 result = getter(index, info); | 7826 result = getter(index, info); |
| 7893 } | 7827 } |
| 7894 if (!result.IsEmpty()) return true; | 7828 if (!result.IsEmpty()) return true; |
| 7895 } | 7829 } |
| 7896 return holder_handle->HasElementPostInterceptor(*receiver_handle, index); | 7830 |
| 7831 if (holder_handle->GetElementsAccessor()->HasElementAtKey( |
| 7832 holder_handle->elements(), index, *holder_handle, *receiver_handle)) { |
| 7833 return true; |
| 7834 } |
| 7835 |
| 7836 if (holder_handle->IsStringObjectWithCharacterAt(index)) return true; |
| 7837 |
| 7838 Object* pt = holder_handle->GetPrototype(); |
| 7839 if (pt->IsNull()) return false; |
| 7840 return JSObject::cast(pt)->HasElementWithReceiver(*receiver_handle, index); |
| 7897 } | 7841 } |
| 7898 | 7842 |
| 7899 | 7843 |
| 7900 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { | 7844 JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { |
| 7901 // Check access rights if needed. | 7845 // Check access rights if needed. |
| 7902 if (IsAccessCheckNeeded()) { | 7846 if (IsAccessCheckNeeded()) { |
| 7903 Heap* heap = GetHeap(); | 7847 Heap* heap = GetHeap(); |
| 7904 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { | 7848 if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) { |
| 7905 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); | 7849 heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS); |
| 7906 return UNDEFINED_ELEMENT; | 7850 return UNDEFINED_ELEMENT; |
| (...skipping 3684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11591 if (break_point_objects()->IsUndefined()) return 0; | 11535 if (break_point_objects()->IsUndefined()) return 0; |
| 11592 // Single break point. | 11536 // Single break point. |
| 11593 if (!break_point_objects()->IsFixedArray()) return 1; | 11537 if (!break_point_objects()->IsFixedArray()) return 1; |
| 11594 // Multiple break points. | 11538 // Multiple break points. |
| 11595 return FixedArray::cast(break_point_objects())->length(); | 11539 return FixedArray::cast(break_point_objects())->length(); |
| 11596 } | 11540 } |
| 11597 #endif | 11541 #endif |
| 11598 | 11542 |
| 11599 | 11543 |
| 11600 } } // namespace v8::internal | 11544 } } // namespace v8::internal |
| OLD | NEW |