| 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 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 | 606 |
| 607 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, | 607 static Handle<Object> GetImpl(Handle<JSObject> obj, uint32_t key, |
| 608 Handle<FixedArrayBase> backing_store) { | 608 Handle<FixedArrayBase> backing_store) { |
| 609 if (key < ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) { | 609 if (key < ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)) { |
| 610 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); | 610 return BackingStore::get(Handle<BackingStore>::cast(backing_store), key); |
| 611 } else { | 611 } else { |
| 612 return backing_store->GetIsolate()->factory()->the_hole_value(); | 612 return backing_store->GetIsolate()->factory()->the_hole_value(); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 | 615 |
| 616 virtual Handle<Object> Set(Handle<JSObject> holder, uint32_t key, | 616 virtual void Set(Handle<JSObject> holder, uint32_t key, |
| 617 Handle<FixedArrayBase> backing_store, | 617 Handle<FixedArrayBase> backing_store, |
| 618 Handle<Object> value) final { | 618 Handle<Object> value) final { |
| 619 return ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value); | 619 ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value); |
| 620 } | 620 } |
| 621 | 621 |
| 622 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, | 622 static void SetImpl(Handle<JSObject> obj, uint32_t key, |
| 623 Handle<FixedArrayBase> backing_store, | 623 Handle<FixedArrayBase> backing_store, |
| 624 Handle<Object> value) { | 624 Handle<Object> value) { |
| 625 CHECK(key < | 625 CHECK(key < |
| 626 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); | 626 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store)); |
| 627 return BackingStore::SetValue( | 627 BackingStore::SetValue(obj, Handle<BackingStore>::cast(backing_store), key, |
| 628 obj, Handle<BackingStore>::cast(backing_store), key, value); | 628 value); |
| 629 } | 629 } |
| 630 | 630 |
| 631 virtual MaybeHandle<AccessorPair> GetAccessorPair( | 631 virtual MaybeHandle<AccessorPair> GetAccessorPair( |
| 632 Handle<JSObject> holder, uint32_t key, | 632 Handle<JSObject> holder, uint32_t key, |
| 633 Handle<FixedArrayBase> backing_store) final { | 633 Handle<FixedArrayBase> backing_store) final { |
| 634 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, | 634 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, |
| 635 backing_store); | 635 backing_store); |
| 636 } | 636 } |
| 637 | 637 |
| 638 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 638 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 Handle<SeededNumberDictionary> backing_store = | 1440 Handle<SeededNumberDictionary> backing_store = |
| 1441 Handle<SeededNumberDictionary>::cast(store); | 1441 Handle<SeededNumberDictionary>::cast(store); |
| 1442 Isolate* isolate = backing_store->GetIsolate(); | 1442 Isolate* isolate = backing_store->GetIsolate(); |
| 1443 int entry = backing_store->FindEntry(key); | 1443 int entry = backing_store->FindEntry(key); |
| 1444 if (entry != SeededNumberDictionary::kNotFound) { | 1444 if (entry != SeededNumberDictionary::kNotFound) { |
| 1445 return handle(backing_store->ValueAt(entry), isolate); | 1445 return handle(backing_store->ValueAt(entry), isolate); |
| 1446 } | 1446 } |
| 1447 return isolate->factory()->the_hole_value(); | 1447 return isolate->factory()->the_hole_value(); |
| 1448 } | 1448 } |
| 1449 | 1449 |
| 1450 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, | 1450 static void SetImpl(Handle<JSObject> obj, uint32_t key, |
| 1451 Handle<FixedArrayBase> store, | 1451 Handle<FixedArrayBase> store, Handle<Object> value) { |
| 1452 Handle<Object> value) { | |
| 1453 Handle<SeededNumberDictionary> backing_store = | 1452 Handle<SeededNumberDictionary> backing_store = |
| 1454 Handle<SeededNumberDictionary>::cast(store); | 1453 Handle<SeededNumberDictionary>::cast(store); |
| 1455 int entry = backing_store->FindEntry(key); | 1454 int entry = backing_store->FindEntry(key); |
| 1456 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); | 1455 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); |
| 1457 backing_store->ValueAtPut(entry, *value); | 1456 backing_store->ValueAtPut(entry, *value); |
| 1458 return value; | |
| 1459 } | 1457 } |
| 1460 | 1458 |
| 1461 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1459 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
| 1462 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { | 1460 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { |
| 1463 Handle<SeededNumberDictionary> backing_store = | 1461 Handle<SeededNumberDictionary> backing_store = |
| 1464 Handle<SeededNumberDictionary>::cast(store); | 1462 Handle<SeededNumberDictionary>::cast(store); |
| 1465 int entry = backing_store->FindEntry(key); | 1463 int entry = backing_store->FindEntry(key); |
| 1466 if (entry != SeededNumberDictionary::kNotFound && | 1464 if (entry != SeededNumberDictionary::kNotFound && |
| 1467 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && | 1465 backing_store->DetailsAt(entry).type() == ACCESSOR_CONSTANT && |
| 1468 backing_store->ValueAt(entry)->IsAccessorPair()) { | 1466 backing_store->ValueAt(entry)->IsAccessorPair()) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 Context* context = Context::cast(parameter_map->get(0)); | 1537 Context* context = Context::cast(parameter_map->get(0)); |
| 1540 int context_index = entry->aliased_context_slot(); | 1538 int context_index = entry->aliased_context_slot(); |
| 1541 DCHECK(!context->get(context_index)->IsTheHole()); | 1539 DCHECK(!context->get(context_index)->IsTheHole()); |
| 1542 return handle(context->get(context_index), isolate); | 1540 return handle(context->get(context_index), isolate); |
| 1543 } else { | 1541 } else { |
| 1544 return result; | 1542 return result; |
| 1545 } | 1543 } |
| 1546 } | 1544 } |
| 1547 } | 1545 } |
| 1548 | 1546 |
| 1549 static Handle<Object> SetImpl(Handle<JSObject> obj, uint32_t key, | 1547 static void SetImpl(Handle<JSObject> obj, uint32_t key, |
| 1550 Handle<FixedArrayBase> store, | 1548 Handle<FixedArrayBase> store, Handle<Object> value) { |
| 1551 Handle<Object> value) { | |
| 1552 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); | 1549 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); |
| 1553 Object* probe = GetParameterMapArg(*parameter_map, key); | 1550 Object* probe = GetParameterMapArg(*parameter_map, key); |
| 1554 if (!probe->IsTheHole()) { | 1551 if (!probe->IsTheHole()) { |
| 1555 Context* context = Context::cast(parameter_map->get(0)); | 1552 Context* context = Context::cast(parameter_map->get(0)); |
| 1556 int context_index = Smi::cast(probe)->value(); | 1553 int context_index = Smi::cast(probe)->value(); |
| 1557 DCHECK(!context->get(context_index)->IsTheHole()); | 1554 DCHECK(!context->get(context_index)->IsTheHole()); |
| 1558 context->set(context_index, *value); | 1555 context->set(context_index, *value); |
| 1559 return value; | 1556 } else { |
| 1557 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); |
| 1558 ElementsAccessor::ForArray(arguments)->Set(obj, key, arguments, value); |
| 1560 } | 1559 } |
| 1561 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); | |
| 1562 return ElementsAccessor::ForArray(arguments) | |
| 1563 ->Set(obj, key, arguments, value); | |
| 1564 } | 1560 } |
| 1565 | 1561 |
| 1566 static MaybeHandle<AccessorPair> GetAccessorPairImpl( | 1562 static MaybeHandle<AccessorPair> GetAccessorPairImpl( |
| 1567 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { | 1563 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { |
| 1568 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); | 1564 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); |
| 1569 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), | 1565 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), |
| 1570 obj->GetIsolate()); | 1566 obj->GetIsolate()); |
| 1571 if (!probe->IsTheHole()) { | 1567 if (!probe->IsTheHole()) { |
| 1572 return MaybeHandle<AccessorPair>(); | 1568 return MaybeHandle<AccessorPair>(); |
| 1573 } else { | 1569 } else { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 break; | 1867 break; |
| 1872 } | 1868 } |
| 1873 | 1869 |
| 1874 array->set_elements(*elms); | 1870 array->set_elements(*elms); |
| 1875 array->set_length(Smi::FromInt(number_of_elements)); | 1871 array->set_length(Smi::FromInt(number_of_elements)); |
| 1876 return array; | 1872 return array; |
| 1877 } | 1873 } |
| 1878 | 1874 |
| 1879 } // namespace internal | 1875 } // namespace internal |
| 1880 } // namespace v8 | 1876 } // namespace v8 |
| OLD | NEW |