Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: src/elements.cc

Issue 1180753005: Cleanup typed array setters, the property is guaranteed to be there. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/elements.h ('k') | src/lookup.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 void Set(Handle<JSObject> holder, uint32_t key, 616 virtual void Set(Handle<FixedArrayBase> backing_store, uint32_t key,
617 Handle<FixedArrayBase> backing_store,
618 Handle<Object> value) final { 617 Handle<Object> value) final {
619 ElementsAccessorSubclass::SetImpl(holder, key, backing_store, value); 618 ElementsAccessorSubclass::SetImpl(backing_store, key, value);
620 } 619 }
621 620
622 static void SetImpl(Handle<JSObject> obj, uint32_t key, 621 static void SetImpl(Handle<FixedArrayBase> backing_store, uint32_t key,
623 Handle<FixedArrayBase> backing_store,
624 Handle<Object> value) { 622 Handle<Object> value) {
625 CHECK(key < 623 BackingStore::SetValue(Handle<BackingStore>::cast(backing_store), key,
626 ElementsAccessorSubclass::GetCapacityImpl(*obj, *backing_store));
627 BackingStore::SetValue(obj, Handle<BackingStore>::cast(backing_store), key,
628 value); 624 value);
629 } 625 }
630 626
631 virtual MaybeHandle<AccessorPair> GetAccessorPair( 627 virtual MaybeHandle<AccessorPair> GetAccessorPair(
632 Handle<JSObject> holder, uint32_t key, 628 Handle<JSObject> holder, uint32_t key,
633 Handle<FixedArrayBase> backing_store) final { 629 Handle<FixedArrayBase> backing_store) final {
634 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key, 630 return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key,
635 backing_store); 631 backing_store);
636 } 632 }
637 633
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 Handle<SeededNumberDictionary> backing_store = 1436 Handle<SeededNumberDictionary> backing_store =
1441 Handle<SeededNumberDictionary>::cast(store); 1437 Handle<SeededNumberDictionary>::cast(store);
1442 Isolate* isolate = backing_store->GetIsolate(); 1438 Isolate* isolate = backing_store->GetIsolate();
1443 int entry = backing_store->FindEntry(key); 1439 int entry = backing_store->FindEntry(key);
1444 if (entry != SeededNumberDictionary::kNotFound) { 1440 if (entry != SeededNumberDictionary::kNotFound) {
1445 return handle(backing_store->ValueAt(entry), isolate); 1441 return handle(backing_store->ValueAt(entry), isolate);
1446 } 1442 }
1447 return isolate->factory()->the_hole_value(); 1443 return isolate->factory()->the_hole_value();
1448 } 1444 }
1449 1445
1450 static void SetImpl(Handle<JSObject> obj, uint32_t key, 1446 static void SetImpl(Handle<FixedArrayBase> store, uint32_t key,
1451 Handle<FixedArrayBase> store, Handle<Object> value) { 1447 Handle<Object> value) {
1452 Handle<SeededNumberDictionary> backing_store = 1448 Handle<SeededNumberDictionary> backing_store =
1453 Handle<SeededNumberDictionary>::cast(store); 1449 Handle<SeededNumberDictionary>::cast(store);
1454 int entry = backing_store->FindEntry(key); 1450 int entry = backing_store->FindEntry(key);
1455 DCHECK_NE(SeededNumberDictionary::kNotFound, entry); 1451 DCHECK_NE(SeededNumberDictionary::kNotFound, entry);
1456 backing_store->ValueAtPut(entry, *value); 1452 backing_store->ValueAtPut(entry, *value);
1457 } 1453 }
1458 1454
1459 static MaybeHandle<AccessorPair> GetAccessorPairImpl( 1455 static MaybeHandle<AccessorPair> GetAccessorPairImpl(
1460 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) { 1456 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> store) {
1461 Handle<SeededNumberDictionary> backing_store = 1457 Handle<SeededNumberDictionary> backing_store =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 Context* context = Context::cast(parameter_map->get(0)); 1533 Context* context = Context::cast(parameter_map->get(0));
1538 int context_index = entry->aliased_context_slot(); 1534 int context_index = entry->aliased_context_slot();
1539 DCHECK(!context->get(context_index)->IsTheHole()); 1535 DCHECK(!context->get(context_index)->IsTheHole());
1540 return handle(context->get(context_index), isolate); 1536 return handle(context->get(context_index), isolate);
1541 } else { 1537 } else {
1542 return result; 1538 return result;
1543 } 1539 }
1544 } 1540 }
1545 } 1541 }
1546 1542
1547 static void SetImpl(Handle<JSObject> obj, uint32_t key, 1543 static void SetImpl(Handle<FixedArrayBase> store, uint32_t key,
1548 Handle<FixedArrayBase> store, Handle<Object> value) { 1544 Handle<Object> value) {
1549 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store); 1545 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(store);
1550 Object* probe = GetParameterMapArg(*parameter_map, key); 1546 Object* probe = GetParameterMapArg(*parameter_map, key);
1551 if (!probe->IsTheHole()) { 1547 if (!probe->IsTheHole()) {
1552 Context* context = Context::cast(parameter_map->get(0)); 1548 Context* context = Context::cast(parameter_map->get(0));
1553 int context_index = Smi::cast(probe)->value(); 1549 int context_index = Smi::cast(probe)->value();
1554 DCHECK(!context->get(context_index)->IsTheHole()); 1550 DCHECK(!context->get(context_index)->IsTheHole());
1555 context->set(context_index, *value); 1551 context->set(context_index, *value);
1556 } else { 1552 } else {
1557 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); 1553 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
1558 ElementsAccessor::ForArray(arguments)->Set(obj, key, arguments, value); 1554 ElementsAccessor::ForArray(arguments)->Set(arguments, key, value);
1559 } 1555 }
1560 } 1556 }
1561 1557
1562 static MaybeHandle<AccessorPair> GetAccessorPairImpl( 1558 static MaybeHandle<AccessorPair> GetAccessorPairImpl(
1563 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) { 1559 Handle<JSObject> obj, uint32_t key, Handle<FixedArrayBase> parameters) {
1564 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters); 1560 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters);
1565 Handle<Object> probe(GetParameterMapArg(*parameter_map, key), 1561 Handle<Object> probe(GetParameterMapArg(*parameter_map, key),
1566 obj->GetIsolate()); 1562 obj->GetIsolate());
1567 if (!probe->IsTheHole()) { 1563 if (!probe->IsTheHole()) {
1568 return MaybeHandle<AccessorPair>(); 1564 return MaybeHandle<AccessorPair>();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 break; 1863 break;
1868 } 1864 }
1869 1865
1870 array->set_elements(*elms); 1866 array->set_elements(*elms);
1871 array->set_length(Smi::FromInt(number_of_elements)); 1867 array->set_length(Smi::FromInt(number_of_elements));
1872 return array; 1868 return array;
1873 } 1869 }
1874 1870
1875 } // namespace internal 1871 } // namespace internal
1876 } // namespace v8 1872 } // namespace v8
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/lookup.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698