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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 explicit ElementsAccessorBase(const char* name) | 584 explicit ElementsAccessorBase(const char* name) |
585 : ElementsAccessor(name) { } | 585 : ElementsAccessor(name) { } |
586 | 586 |
587 typedef ElementsTraitsParam ElementsTraits; | 587 typedef ElementsTraitsParam ElementsTraits; |
588 typedef typename ElementsTraitsParam::BackingStore BackingStore; | 588 typedef typename ElementsTraitsParam::BackingStore BackingStore; |
589 | 589 |
590 virtual ElementsKind kind() const V8_FINAL V8_OVERRIDE { | 590 virtual ElementsKind kind() const V8_FINAL V8_OVERRIDE { |
591 return ElementsTraits::Kind; | 591 return ElementsTraits::Kind; |
592 } | 592 } |
593 | 593 |
594 static void ValidateContents(JSObject* holder, int length) { | 594 static void ValidateContents(Handle<JSObject> holder, int length) { |
595 } | 595 } |
596 | 596 |
597 static void ValidateImpl(JSObject* holder) { | 597 static void ValidateImpl(Handle<JSObject> holder) { |
598 FixedArrayBase* fixed_array_base = holder->elements(); | 598 Handle<FixedArrayBase> fixed_array_base(holder->elements()); |
599 // When objects are first allocated, its elements are Failures. | 599 // When objects are first allocated, its elements are Failures. |
600 if (fixed_array_base->IsFailure()) return; | 600 if (fixed_array_base->IsFailure()) return; |
601 if (!fixed_array_base->IsHeapObject()) return; | 601 if (!fixed_array_base->IsHeapObject()) return; |
602 // Arrays that have been shifted in place can't be verified. | 602 // Arrays that have been shifted in place can't be verified. |
603 if (fixed_array_base->IsFiller()) return; | 603 if (fixed_array_base->IsFiller()) return; |
604 int length = 0; | 604 int length = 0; |
605 if (holder->IsJSArray()) { | 605 if (holder->IsJSArray()) { |
606 Object* length_obj = JSArray::cast(holder)->length(); | 606 Object* length_obj = Handle<JSArray>::cast(holder)->length(); |
607 if (length_obj->IsSmi()) { | 607 if (length_obj->IsSmi()) { |
608 length = Smi::cast(length_obj)->value(); | 608 length = Smi::cast(length_obj)->value(); |
609 } | 609 } |
610 } else { | 610 } else { |
611 length = fixed_array_base->length(); | 611 length = fixed_array_base->length(); |
612 } | 612 } |
613 ElementsAccessorSubclass::ValidateContents(holder, length); | 613 ElementsAccessorSubclass::ValidateContents(holder, length); |
614 } | 614 } |
615 | 615 |
616 virtual void Validate(Handle<JSObject> holder) V8_FINAL V8_OVERRIDE { | 616 virtual void Validate(Handle<JSObject> holder) V8_FINAL V8_OVERRIDE { |
617 DisallowHeapAllocation no_gc; | 617 DisallowHeapAllocation no_gc; |
618 ElementsAccessorSubclass::ValidateImpl(*holder); | 618 ElementsAccessorSubclass::ValidateImpl(holder); |
619 } | 619 } |
620 | 620 |
621 static bool HasElementImpl(Handle<Object> receiver, | 621 static bool HasElementImpl(Handle<Object> receiver, |
622 Handle<JSObject> holder, | 622 Handle<JSObject> holder, |
623 uint32_t key, | 623 uint32_t key, |
624 Handle<FixedArrayBase> backing_store) { | 624 Handle<FixedArrayBase> backing_store) { |
625 return ElementsAccessorSubclass::GetAttributesImpl( | 625 return ElementsAccessorSubclass::GetAttributesImpl( |
626 receiver, holder, key, backing_store) != ABSENT; | 626 receiver, holder, key, backing_store) != ABSENT; |
627 } | 627 } |
628 | 628 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 Handle<Object> receiver, | 1056 Handle<Object> receiver, |
1057 Handle<JSObject> holder, | 1057 Handle<JSObject> holder, |
1058 uint32_t key, | 1058 uint32_t key, |
1059 Handle<FixedArrayBase> backing_store) { | 1059 Handle<FixedArrayBase> backing_store) { |
1060 if (key >= static_cast<uint32_t>(backing_store->length())) { | 1060 if (key >= static_cast<uint32_t>(backing_store->length())) { |
1061 return false; | 1061 return false; |
1062 } | 1062 } |
1063 return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key); | 1063 return !Handle<BackingStore>::cast(backing_store)->is_the_hole(key); |
1064 } | 1064 } |
1065 | 1065 |
1066 static void ValidateContents(JSObject* holder, int length) { | 1066 static void ValidateContents(Handle<JSObject> holder, int length) { |
1067 #if DEBUG | 1067 #if DEBUG |
1068 FixedArrayBase* elements = holder->elements(); | 1068 Isolate* isolate = holder->GetIsolate(); |
1069 Heap* heap = elements->GetHeap(); | 1069 HandleScope scope(isolate); |
| 1070 Handle<FixedArrayBase> elements(holder->elements(), isolate); |
1070 Map* map = elements->map(); | 1071 Map* map = elements->map(); |
1071 ASSERT((IsFastSmiOrObjectElementsKind(KindTraits::Kind) && | 1072 ASSERT((IsFastSmiOrObjectElementsKind(KindTraits::Kind) && |
1072 (map == heap->fixed_array_map() || | 1073 (map == isolate->heap()->fixed_array_map() || |
1073 map == heap->fixed_cow_array_map())) || | 1074 map == isolate->heap()->fixed_cow_array_map())) || |
1074 (IsFastDoubleElementsKind(KindTraits::Kind) == | 1075 (IsFastDoubleElementsKind(KindTraits::Kind) == |
1075 ((map == heap->fixed_array_map() && length == 0) || | 1076 ((map == isolate->heap()->fixed_array_map() && length == 0) || |
1076 map == heap->fixed_double_array_map()))); | 1077 map == isolate->heap()->fixed_double_array_map()))); |
| 1078 DisallowHeapAllocation no_gc; |
1077 for (int i = 0; i < length; i++) { | 1079 for (int i = 0; i < length; i++) { |
1078 BackingStore* backing_store = BackingStore::cast(elements); | 1080 HandleScope scope(isolate); |
| 1081 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements); |
1079 ASSERT((!IsFastSmiElementsKind(KindTraits::Kind) || | 1082 ASSERT((!IsFastSmiElementsKind(KindTraits::Kind) || |
1080 static_cast<Object*>(backing_store->get(i))->IsSmi()) || | 1083 BackingStore::get(backing_store, i)->IsSmi()) || |
1081 (IsFastHoleyElementsKind(KindTraits::Kind) == | 1084 (IsFastHoleyElementsKind(KindTraits::Kind) == |
1082 backing_store->is_the_hole(i))); | 1085 backing_store->is_the_hole(i))); |
1083 } | 1086 } |
1084 #endif | 1087 #endif |
1085 } | 1088 } |
1086 }; | 1089 }; |
1087 | 1090 |
1088 | 1091 |
1089 static inline ElementsKind ElementsKindForArray(Handle<FixedArrayBase> array) { | 1092 static inline ElementsKind ElementsKindForArray(Handle<FixedArrayBase> array) { |
1090 switch (array->map()->instance_type()) { | 1093 switch (array->map()->instance_type()) { |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 UNREACHABLE(); | 2016 UNREACHABLE(); |
2014 break; | 2017 break; |
2015 } | 2018 } |
2016 | 2019 |
2017 array->set_elements(*elms); | 2020 array->set_elements(*elms); |
2018 array->set_length(Smi::FromInt(number_of_elements)); | 2021 array->set_length(Smi::FromInt(number_of_elements)); |
2019 return array; | 2022 return array; |
2020 } | 2023 } |
2021 | 2024 |
2022 } } // namespace v8::internal | 2025 } } // namespace v8::internal |
OLD | NEW |