OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/elements.h" | 9 #include "src/elements.h" |
10 #include "src/messages.h" | 10 #include "src/messages.h" |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 ElementsAccessorSubclass::AddImpl(object, index, value, attributes, | 643 ElementsAccessorSubclass::AddImpl(object, index, value, attributes, |
644 new_capacity); | 644 new_capacity); |
645 } | 645 } |
646 | 646 |
647 static void AddImpl(Handle<JSObject> object, uint32_t index, | 647 static void AddImpl(Handle<JSObject> object, uint32_t index, |
648 Handle<Object> value, PropertyAttributes attributes, | 648 Handle<Object> value, PropertyAttributes attributes, |
649 uint32_t new_capacity) { | 649 uint32_t new_capacity) { |
650 UNREACHABLE(); | 650 UNREACHABLE(); |
651 } | 651 } |
652 | 652 |
653 virtual MaybeHandle<AccessorPair> GetAccessorPair( | |
654 Handle<JSObject> holder, uint32_t key, | |
655 Handle<FixedArrayBase> backing_store) final { | |
656 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, | |
657 backing_store); | |
658 } | |
659 | |
660 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | |
661 Handle<JSObject> obj, uint32_t key, | |
662 Handle<FixedArrayBase> backing_store) { | |
663 return MaybeHandle<AccessorPair>(); | |
664 } | |
665 | |
666 virtual void SetLength(Handle<JSArray> array, uint32_t length) final { | 653 virtual void SetLength(Handle<JSArray> array, uint32_t length) final { |
667 ElementsAccessorSubclass::SetLengthImpl(array, length, | 654 ElementsAccessorSubclass::SetLengthImpl(array, length, |
668 handle(array->elements())); | 655 handle(array->elements())); |
669 } | 656 } |
670 | 657 |
671 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, | 658 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, |
672 Handle<FixedArrayBase> backing_store); | 659 Handle<FixedArrayBase> backing_store); |
673 | 660 |
674 static Handle<FixedArrayBase> ConvertElementsWithCapacity( | 661 static Handle<FixedArrayBase> ConvertElementsWithCapacity( |
675 Handle<JSObject> object, Handle<FixedArrayBase> old_elements, | 662 Handle<JSObject> object, Handle<FixedArrayBase> old_elements, |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 ? JSObject::NormalizeElements(object) | 1039 ? JSObject::NormalizeElements(object) |
1053 : handle(SeededNumberDictionary::cast(object->elements())); | 1040 : handle(SeededNumberDictionary::cast(object->elements())); |
1054 Handle<SeededNumberDictionary> new_dictionary = | 1041 Handle<SeededNumberDictionary> new_dictionary = |
1055 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, | 1042 SeededNumberDictionary::AddNumberEntry(dictionary, index, value, |
1056 details); | 1043 details); |
1057 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); | 1044 if (attributes != NONE) new_dictionary->set_requires_slow_elements(); |
1058 if (dictionary.is_identical_to(new_dictionary)) return; | 1045 if (dictionary.is_identical_to(new_dictionary)) return; |
1059 object->set_elements(*new_dictionary); | 1046 object->set_elements(*new_dictionary); |
1060 } | 1047 } |
1061 | 1048 |
1062 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | |
1063 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { | |
1064 Handle<SeededNumberDictionary> backing_store = | |
1065 Handle<SeededNumberDictionary>::cast(store); | |
1066 int entry = backing_store->FindEntry(key); | |
1067 if (entry != SeededNumberDictionary::kNotFound && | |
1068 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && | |
1069 backing_store->ValueAt(entry)->IsAccessorPair()) { | |
1070 return handle(AccessorPair::cast(backing_store->ValueAt(entry))); | |
1071 } | |
1072 return MaybeHandle<AccessorPair>(); | |
1073 } | |
1074 | |
1075 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { | 1049 static bool HasIndexImpl(FixedArrayBase* store, uint32_t index) { |
1076 DisallowHeapAllocation no_gc; | 1050 DisallowHeapAllocation no_gc; |
1077 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1051 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
1078 Object* key = dict->KeyAt(index); | 1052 Object* key = dict->KeyAt(index); |
1079 return !key->IsTheHole(); | 1053 return !key->IsTheHole(); |
1080 } | 1054 } |
1081 | 1055 |
1082 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { | 1056 static uint32_t GetKeyForIndexImpl(FixedArrayBase* store, uint32_t index) { |
1083 DisallowHeapAllocation no_gc; | 1057 DisallowHeapAllocation no_gc; |
1084 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); | 1058 SeededNumberDictionary* dict = SeededNumberDictionary::cast(store); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 Context* context = Context::cast(parameter_map->get(0)); | 1514 Context* context = Context::cast(parameter_map->get(0)); |
1541 int context_index = Smi::cast(probe)->value(); | 1515 int context_index = Smi::cast(probe)->value(); |
1542 DCHECK(!context->get(context_index)->IsTheHole()); | 1516 DCHECK(!context->get(context_index)->IsTheHole()); |
1543 context->set(context_index, value); | 1517 context->set(context_index, value); |
1544 } else { | 1518 } else { |
1545 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1519 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1546 ArgumentsAccessor::SetImpl(arguments, key, value); | 1520 ArgumentsAccessor::SetImpl(arguments, key, value); |
1547 } | 1521 } |
1548 } | 1522 } |
1549 | 1523 |
1550 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | |
1551 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { | |
1552 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); | |
1553 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), | |
1554 obj->GetIsolate()); | |
1555 if (!probe->IsTheHole()) { | |
1556 return MaybeHandle<AccessorPair>(); | |
1557 } else { | |
1558 // If not aliased, check the arguments. | |
1559 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | |
1560 return ArgumentsAccessor::GetAccessorPairImpl(obj, key, arguments); | |
1561 } | |
1562 } | |
1563 | |
1564 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, | 1524 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, |
1565 Handle<FixedArrayBase> parameter_map) { | 1525 Handle<FixedArrayBase> parameter_map) { |
1566 // Sloppy arguments objects are not arrays. | 1526 // Sloppy arguments objects are not arrays. |
1567 UNREACHABLE(); | 1527 UNREACHABLE(); |
1568 } | 1528 } |
1569 | 1529 |
1570 static uint32_t GetCapacityImpl(JSObject* holder, | 1530 static uint32_t GetCapacityImpl(JSObject* holder, |
1571 FixedArrayBase* backing_store) { | 1531 FixedArrayBase* backing_store) { |
1572 FixedArray* parameter_map = FixedArray::cast(backing_store); | 1532 FixedArray* parameter_map = FixedArray::cast(backing_store); |
1573 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); | 1533 FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 break; | 1886 break; |
1927 } | 1887 } |
1928 | 1888 |
1929 array->set_elements(*elms); | 1889 array->set_elements(*elms); |
1930 array->set_length(Smi::FromInt(number_of_elements)); | 1890 array->set_length(Smi::FromInt(number_of_elements)); |
1931 return array; | 1891 return array; |
1932 } | 1892 } |
1933 | 1893 |
1934 } // namespace internal | 1894 } // namespace internal |
1935 } // namespace v8 | 1895 } // namespace v8 |
OLD | NEW |