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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 SeededNumberDictionary::cast(obj->elements())); | 923 SeededNumberDictionary::cast(obj->elements())); |
924 uint32_t index = GetIndexForEntryImpl(*dict, entry); | 924 uint32_t index = GetIndexForEntryImpl(*dict, entry); |
925 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); | 925 Handle<Object> result = SeededNumberDictionary::DeleteProperty(dict, entry); |
926 USE(result); | 926 USE(result); |
927 DCHECK(result->IsTrue()); | 927 DCHECK(result->IsTrue()); |
928 Handle<FixedArray> new_elements = | 928 Handle<FixedArray> new_elements = |
929 SeededNumberDictionary::Shrink(dict, index); | 929 SeededNumberDictionary::Shrink(dict, index); |
930 obj->set_elements(*new_elements); | 930 obj->set_elements(*new_elements); |
931 } | 931 } |
932 | 932 |
| 933 static Object* GetRaw(FixedArrayBase* store, uint32_t entry) { |
| 934 SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); |
| 935 return backing_store->ValueAt(entry); |
| 936 } |
| 937 |
933 static Handle<Object> GetImpl(Handle<FixedArrayBase> store, uint32_t entry) { | 938 static Handle<Object> GetImpl(Handle<FixedArrayBase> store, uint32_t entry) { |
934 Handle<SeededNumberDictionary> backing_store = | 939 Isolate* isolate = store->GetIsolate(); |
935 Handle<SeededNumberDictionary>::cast(store); | 940 return handle(GetRaw(*store, entry), isolate); |
936 Isolate* isolate = backing_store->GetIsolate(); | |
937 return handle(backing_store->ValueAt(entry), isolate); | |
938 } | 941 } |
939 | 942 |
940 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) { | 943 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) { |
941 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(store); | 944 SeededNumberDictionary* dictionary = SeededNumberDictionary::cast(store); |
942 dictionary->ValueAtPut(entry, value); | 945 dictionary->ValueAtPut(entry, value); |
943 } | 946 } |
944 | 947 |
945 static void ReconfigureImpl(Handle<JSObject> object, | 948 static void ReconfigureImpl(Handle<JSObject> object, |
946 Handle<FixedArrayBase> store, uint32_t entry, | 949 Handle<FixedArrayBase> store, uint32_t entry, |
947 Handle<Object> value, | 950 Handle<Object> value, |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 | 1171 |
1169 template<typename FastElementsAccessorSubclass, | 1172 template<typename FastElementsAccessorSubclass, |
1170 typename KindTraits> | 1173 typename KindTraits> |
1171 class FastSmiOrObjectElementsAccessor | 1174 class FastSmiOrObjectElementsAccessor |
1172 : public FastElementsAccessor<FastElementsAccessorSubclass, KindTraits> { | 1175 : public FastElementsAccessor<FastElementsAccessorSubclass, KindTraits> { |
1173 public: | 1176 public: |
1174 explicit FastSmiOrObjectElementsAccessor(const char* name) | 1177 explicit FastSmiOrObjectElementsAccessor(const char* name) |
1175 : FastElementsAccessor<FastElementsAccessorSubclass, | 1178 : FastElementsAccessor<FastElementsAccessorSubclass, |
1176 KindTraits>(name) {} | 1179 KindTraits>(name) {} |
1177 | 1180 |
| 1181 static Object* GetRaw(FixedArray* backing_store, uint32_t entry) { |
| 1182 uint32_t index = FastElementsAccessorSubclass::GetIndexForEntryImpl( |
| 1183 backing_store, entry); |
| 1184 return backing_store->get(index); |
| 1185 } |
| 1186 |
1178 // NOTE: this method violates the handlified function signature convention: | 1187 // NOTE: this method violates the handlified function signature convention: |
1179 // raw pointer parameters in the function that allocates. | 1188 // raw pointer parameters in the function that allocates. |
1180 // See ElementsAccessor::CopyElements() for details. | 1189 // See ElementsAccessor::CopyElements() for details. |
1181 // This method could actually allocate if copying from double elements to | 1190 // This method could actually allocate if copying from double elements to |
1182 // object elements. | 1191 // object elements. |
1183 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, | 1192 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, |
1184 FixedArrayBase* to, ElementsKind from_kind, | 1193 FixedArrayBase* to, ElementsKind from_kind, |
1185 uint32_t to_start, int packed_size, | 1194 uint32_t to_start, int packed_size, |
1186 int copy_size) { | 1195 int copy_size) { |
1187 DisallowHeapAllocation no_gc; | 1196 DisallowHeapAllocation no_gc; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 return handle(context->get(context_entry), isolate); | 1447 return handle(context->get(context_entry), isolate); |
1439 } else { | 1448 } else { |
1440 // Object is not mapped, defer to the arguments. | 1449 // Object is not mapped, defer to the arguments. |
1441 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)), | 1450 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)), |
1442 isolate); | 1451 isolate); |
1443 Handle<Object> result = | 1452 Handle<Object> result = |
1444 ArgumentsAccessor::GetImpl(arguments, entry - length); | 1453 ArgumentsAccessor::GetImpl(arguments, entry - length); |
1445 // Elements of the arguments object in slow mode might be slow aliases. | 1454 // Elements of the arguments object in slow mode might be slow aliases. |
1446 if (result->IsAliasedArgumentsEntry()) { | 1455 if (result->IsAliasedArgumentsEntry()) { |
1447 DisallowHeapAllocation no_gc; | 1456 DisallowHeapAllocation no_gc; |
1448 AliasedArgumentsEntry* entry = AliasedArgumentsEntry::cast(*result); | 1457 AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(*result); |
1449 Context* context = Context::cast(parameter_map->get(0)); | 1458 Context* context = Context::cast(parameter_map->get(0)); |
1450 int context_entry = entry->aliased_context_slot(); | 1459 int context_entry = alias->aliased_context_slot(); |
1451 DCHECK(!context->get(context_entry)->IsTheHole()); | 1460 DCHECK(!context->get(context_entry)->IsTheHole()); |
1452 return handle(context->get(context_entry), isolate); | 1461 return handle(context->get(context_entry), isolate); |
1453 } | 1462 } |
1454 return result; | 1463 return result; |
1455 } | 1464 } |
1456 } | 1465 } |
1457 | 1466 |
1458 static void GrowCapacityAndConvertImpl(Handle<JSObject> object, | 1467 static void GrowCapacityAndConvertImpl(Handle<JSObject> object, |
1459 uint32_t capacity) { | 1468 uint32_t capacity) { |
1460 UNREACHABLE(); | 1469 UNREACHABLE(); |
1461 } | 1470 } |
1462 | 1471 |
1463 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) { | 1472 static void SetImpl(FixedArrayBase* store, uint32_t entry, Object* value) { |
1464 FixedArray* parameter_map = FixedArray::cast(store); | 1473 FixedArray* parameter_map = FixedArray::cast(store); |
1465 uint32_t length = parameter_map->length() - 2; | 1474 uint32_t length = parameter_map->length() - 2; |
1466 if (entry < length) { | 1475 if (entry < length) { |
1467 Object* probe = parameter_map->get(entry + 2); | 1476 Object* probe = parameter_map->get(entry + 2); |
1468 Context* context = Context::cast(parameter_map->get(0)); | 1477 Context* context = Context::cast(parameter_map->get(0)); |
1469 int context_entry = Smi::cast(probe)->value(); | 1478 int context_entry = Smi::cast(probe)->value(); |
1470 DCHECK(!context->get(context_entry)->IsTheHole()); | 1479 DCHECK(!context->get(context_entry)->IsTheHole()); |
1471 context->set(context_entry, value); | 1480 context->set(context_entry, value); |
1472 } else { | 1481 } else { |
1473 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); | 1482 FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
1474 ArgumentsAccessor::SetImpl(arguments, entry - length, value); | 1483 Object* current = ArgumentsAccessor::GetRaw(arguments, entry - length); |
| 1484 if (current->IsAliasedArgumentsEntry()) { |
| 1485 AliasedArgumentsEntry* alias = AliasedArgumentsEntry::cast(current); |
| 1486 Context* context = Context::cast(parameter_map->get(0)); |
| 1487 int context_entry = alias->aliased_context_slot(); |
| 1488 DCHECK(!context->get(context_entry)->IsTheHole()); |
| 1489 context->set(context_entry, value); |
| 1490 } else { |
| 1491 ArgumentsAccessor::SetImpl(arguments, entry - length, value); |
| 1492 } |
1475 } | 1493 } |
1476 } | 1494 } |
1477 | 1495 |
1478 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, | 1496 static void SetLengthImpl(Handle<JSArray> array, uint32_t length, |
1479 Handle<FixedArrayBase> parameter_map) { | 1497 Handle<FixedArrayBase> parameter_map) { |
1480 // Sloppy arguments objects are not arrays. | 1498 // Sloppy arguments objects are not arrays. |
1481 UNREACHABLE(); | 1499 UNREACHABLE(); |
1482 } | 1500 } |
1483 | 1501 |
1484 static uint32_t GetCapacityImpl(JSObject* holder, | 1502 static uint32_t GetCapacityImpl(JSObject* holder, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1919 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; | 1937 #define ACCESSOR_DELETE(Class, Kind, Store) delete elements_accessors_[Kind]; |
1920 ELEMENTS_LIST(ACCESSOR_DELETE) | 1938 ELEMENTS_LIST(ACCESSOR_DELETE) |
1921 #undef ACCESSOR_DELETE | 1939 #undef ACCESSOR_DELETE |
1922 elements_accessors_ = NULL; | 1940 elements_accessors_ = NULL; |
1923 } | 1941 } |
1924 | 1942 |
1925 | 1943 |
1926 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; | 1944 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; |
1927 } // namespace internal | 1945 } // namespace internal |
1928 } // namespace v8 | 1946 } // namespace v8 |
OLD | NEW |