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

Side by Side Diff: src/elements.cc

Issue 854493004: Remove ForceDelete (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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/objects.h » ('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/objects.h" 10 #include "src/objects.h"
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 } 684 }
685 685
686 static void SetFastElementsCapacityAndLength( 686 static void SetFastElementsCapacityAndLength(
687 Handle<JSObject> obj, 687 Handle<JSObject> obj,
688 int capacity, 688 int capacity,
689 int length) { 689 int length) {
690 UNIMPLEMENTED(); 690 UNIMPLEMENTED();
691 } 691 }
692 692
693 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 693 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
694 Handle<JSObject> obj, 694 Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) OVERRIDE = 0;
695 uint32_t key,
696 JSReceiver::DeleteMode mode) OVERRIDE = 0;
697 695
698 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, 696 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
699 FixedArrayBase* to, ElementsKind from_kind, 697 FixedArrayBase* to, ElementsKind from_kind,
700 uint32_t to_start, int packed_size, 698 uint32_t to_start, int packed_size,
701 int copy_size) { 699 int copy_size) {
702 UNREACHABLE(); 700 UNREACHABLE();
703 } 701 }
704 702
705 virtual void CopyElements(Handle<FixedArrayBase> from, uint32_t from_start, 703 virtual void CopyElements(Handle<FixedArrayBase> from, uint32_t from_start,
706 ElementsKind from_kind, Handle<FixedArrayBase> to, 704 ElementsKind from_kind, Handle<FixedArrayBase> to,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 906
909 // Check whether the backing store should be expanded. 907 // Check whether the backing store should be expanded.
910 uint32_t min = JSObject::NewElementsCapacity(old_capacity); 908 uint32_t min = JSObject::NewElementsCapacity(old_capacity);
911 uint32_t new_capacity = length > min ? length : min; 909 uint32_t new_capacity = length > min ? length : min;
912 FastElementsAccessorSubclass::SetFastElementsCapacityAndLength( 910 FastElementsAccessorSubclass::SetFastElementsCapacityAndLength(
913 array, new_capacity, length); 911 array, new_capacity, length);
914 JSObject::ValidateElements(array); 912 JSObject::ValidateElements(array);
915 return length_object; 913 return length_object;
916 } 914 }
917 915
918 static Handle<Object> DeleteCommon(Handle<JSObject> obj, 916 static Handle<Object> DeleteCommon(Handle<JSObject> obj, uint32_t key,
919 uint32_t key, 917 StrictMode strict_mode) {
920 JSReceiver::DeleteMode mode) {
921 DCHECK(obj->HasFastSmiOrObjectElements() || 918 DCHECK(obj->HasFastSmiOrObjectElements() ||
922 obj->HasFastDoubleElements() || 919 obj->HasFastDoubleElements() ||
923 obj->HasFastArgumentsElements()); 920 obj->HasFastArgumentsElements());
924 Isolate* isolate = obj->GetIsolate(); 921 Isolate* isolate = obj->GetIsolate();
925 Heap* heap = obj->GetHeap(); 922 Heap* heap = obj->GetHeap();
926 Handle<FixedArrayBase> elements(obj->elements()); 923 Handle<FixedArrayBase> elements(obj->elements());
927 if (*elements == heap->empty_fixed_array()) { 924 if (*elements == heap->empty_fixed_array()) {
928 return isolate->factory()->true_value(); 925 return isolate->factory()->true_value();
929 } 926 }
930 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements); 927 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 } 965 }
969 if (4 * num_used <= backing_store->length()) { 966 if (4 * num_used <= backing_store->length()) {
970 JSObject::NormalizeElements(obj); 967 JSObject::NormalizeElements(obj);
971 } 968 }
972 } 969 }
973 } 970 }
974 return isolate->factory()->true_value(); 971 return isolate->factory()->true_value();
975 } 972 }
976 973
977 virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key, 974 virtual MaybeHandle<Object> Delete(Handle<JSObject> obj, uint32_t key,
978 JSReceiver::DeleteMode mode) FINAL { 975 StrictMode strict_mode) FINAL {
979 return DeleteCommon(obj, key, mode); 976 return DeleteCommon(obj, key, strict_mode);
980 } 977 }
981 978
982 static bool HasElementImpl( 979 static bool HasElementImpl(
983 Handle<Object> receiver, 980 Handle<Object> receiver,
984 Handle<JSObject> holder, 981 Handle<JSObject> holder,
985 uint32_t key, 982 uint32_t key,
986 Handle<FixedArrayBase> backing_store) { 983 Handle<FixedArrayBase> backing_store) {
987 if (key >= static_cast<uint32_t>(backing_store->length())) { 984 if (key >= static_cast<uint32_t>(backing_store->length())) {
988 return false; 985 return false;
989 } 986 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl( 1288 MUST_USE_RESULT static MaybeHandle<Object> SetLengthImpl(
1292 Handle<JSObject> obj, 1289 Handle<JSObject> obj,
1293 Handle<Object> length, 1290 Handle<Object> length,
1294 Handle<FixedArrayBase> backing_store) { 1291 Handle<FixedArrayBase> backing_store) {
1295 // External arrays do not support changing their length. 1292 // External arrays do not support changing their length.
1296 UNREACHABLE(); 1293 UNREACHABLE();
1297 return obj; 1294 return obj;
1298 } 1295 }
1299 1296
1300 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1297 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
1301 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { 1298 Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
1302 // External arrays always ignore deletes. 1299 // External arrays always ignore deletes.
1303 return obj->GetIsolate()->factory()->true_value(); 1300 return obj->GetIsolate()->factory()->true_value();
1304 } 1301 }
1305 1302
1306 static bool HasElementImpl(Handle<Object> receiver, 1303 static bool HasElementImpl(Handle<Object> receiver,
1307 Handle<JSObject> holder, 1304 Handle<JSObject> holder,
1308 uint32_t key, 1305 uint32_t key,
1309 Handle<FixedArrayBase> backing_store) { 1306 Handle<FixedArrayBase> backing_store) {
1310 uint32_t capacity = 1307 uint32_t capacity =
1311 AccessorClass::GetCapacityImpl(backing_store); 1308 AccessorClass::GetCapacityImpl(backing_store);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1390 } 1387 }
1391 } 1388 }
1392 1389
1393 // Update the number of elements. 1390 // Update the number of elements.
1394 dict->ElementsRemoved(removed_entries); 1391 dict->ElementsRemoved(removed_entries);
1395 } 1392 }
1396 return length_object; 1393 return length_object;
1397 } 1394 }
1398 1395
1399 MUST_USE_RESULT static MaybeHandle<Object> DeleteCommon( 1396 MUST_USE_RESULT static MaybeHandle<Object> DeleteCommon(
1400 Handle<JSObject> obj, 1397 Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) {
1401 uint32_t key,
1402 JSReceiver::DeleteMode mode) {
1403 Isolate* isolate = obj->GetIsolate(); 1398 Isolate* isolate = obj->GetIsolate();
1404 Handle<FixedArray> backing_store(FixedArray::cast(obj->elements()), 1399 Handle<FixedArray> backing_store(FixedArray::cast(obj->elements()),
1405 isolate); 1400 isolate);
1406 bool is_arguments = 1401 bool is_arguments =
1407 (obj->GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS); 1402 (obj->GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS);
1408 if (is_arguments) { 1403 if (is_arguments) {
1409 backing_store = handle(FixedArray::cast(backing_store->get(1)), isolate); 1404 backing_store = handle(FixedArray::cast(backing_store->get(1)), isolate);
1410 } 1405 }
1411 Handle<SeededNumberDictionary> dictionary = 1406 Handle<SeededNumberDictionary> dictionary =
1412 Handle<SeededNumberDictionary>::cast(backing_store); 1407 Handle<SeededNumberDictionary>::cast(backing_store);
1413 int entry = dictionary->FindEntry(key); 1408 int entry = dictionary->FindEntry(key);
1414 if (entry != SeededNumberDictionary::kNotFound) { 1409 if (entry != SeededNumberDictionary::kNotFound) {
1415 Handle<Object> result = 1410 Handle<Object> result =
1416 SeededNumberDictionary::DeleteProperty(dictionary, entry, mode); 1411 SeededNumberDictionary::DeleteProperty(dictionary, entry);
1417 if (*result == *isolate->factory()->false_value()) { 1412 if (*result == *isolate->factory()->false_value()) {
1418 if (mode == JSObject::STRICT_DELETION) { 1413 if (strict_mode == STRICT) {
1419 // Deleting a non-configurable property in strict mode. 1414 // Deleting a non-configurable property in strict mode.
1420 Handle<Object> name = isolate->factory()->NewNumberFromUint(key); 1415 Handle<Object> name = isolate->factory()->NewNumberFromUint(key);
1421 Handle<Object> args[2] = { name, obj }; 1416 Handle<Object> args[2] = { name, obj };
1422 THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property", 1417 THROW_NEW_ERROR(isolate, NewTypeError("strict_delete_property",
1423 HandleVector(args, 2)), 1418 HandleVector(args, 2)),
1424 Object); 1419 Object);
1425 } 1420 }
1426 return isolate->factory()->false_value(); 1421 return isolate->factory()->false_value();
1427 } 1422 }
1428 Handle<FixedArray> new_elements = 1423 Handle<FixedArray> new_elements =
(...skipping 14 matching lines...) Expand all
1443 int copy_size) { 1438 int copy_size) {
1444 UNREACHABLE(); 1439 UNREACHABLE();
1445 } 1440 }
1446 1441
1447 1442
1448 protected: 1443 protected:
1449 friend class ElementsAccessorBase<DictionaryElementsAccessor, 1444 friend class ElementsAccessorBase<DictionaryElementsAccessor,
1450 ElementsKindTraits<DICTIONARY_ELEMENTS> >; 1445 ElementsKindTraits<DICTIONARY_ELEMENTS> >;
1451 1446
1452 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1447 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
1453 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { 1448 Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
1454 return DeleteCommon(obj, key, mode); 1449 return DeleteCommon(obj, key, strict_mode);
1455 } 1450 }
1456 1451
1457 MUST_USE_RESULT static MaybeHandle<Object> GetImpl( 1452 MUST_USE_RESULT static MaybeHandle<Object> GetImpl(
1458 Handle<Object> receiver, 1453 Handle<Object> receiver,
1459 Handle<JSObject> obj, 1454 Handle<JSObject> obj,
1460 uint32_t key, 1455 uint32_t key,
1461 Handle<FixedArrayBase> store) { 1456 Handle<FixedArrayBase> store) {
1462 Handle<SeededNumberDictionary> backing_store = 1457 Handle<SeededNumberDictionary> backing_store =
1463 Handle<SeededNumberDictionary>::cast(store); 1458 Handle<SeededNumberDictionary>::cast(store);
1464 Isolate* isolate = backing_store->GetIsolate(); 1459 Isolate* isolate = backing_store->GetIsolate();
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 Handle<JSObject> obj, 1610 Handle<JSObject> obj,
1616 Handle<Object> length, 1611 Handle<Object> length,
1617 Handle<FixedArrayBase> parameter_map) { 1612 Handle<FixedArrayBase> parameter_map) {
1618 // TODO(mstarzinger): This was never implemented but will be used once we 1613 // TODO(mstarzinger): This was never implemented but will be used once we
1619 // correctly implement [[DefineOwnProperty]] on arrays. 1614 // correctly implement [[DefineOwnProperty]] on arrays.
1620 UNIMPLEMENTED(); 1615 UNIMPLEMENTED();
1621 return obj; 1616 return obj;
1622 } 1617 }
1623 1618
1624 MUST_USE_RESULT virtual MaybeHandle<Object> Delete( 1619 MUST_USE_RESULT virtual MaybeHandle<Object> Delete(
1625 Handle<JSObject> obj, uint32_t key, JSReceiver::DeleteMode mode) FINAL { 1620 Handle<JSObject> obj, uint32_t key, StrictMode strict_mode) FINAL {
1626 Isolate* isolate = obj->GetIsolate(); 1621 Isolate* isolate = obj->GetIsolate();
1627 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements())); 1622 Handle<FixedArray> parameter_map(FixedArray::cast(obj->elements()));
1628 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key); 1623 Handle<Object> probe = GetParameterMapArg(obj, parameter_map, key);
1629 if (!probe->IsTheHole()) { 1624 if (!probe->IsTheHole()) {
1630 // TODO(kmillikin): We could check if this was the last aliased 1625 // TODO(kmillikin): We could check if this was the last aliased
1631 // parameter, and revert to normal elements in that case. That 1626 // parameter, and revert to normal elements in that case. That
1632 // would enable GC of the context. 1627 // would enable GC of the context.
1633 parameter_map->set_the_hole(key + 2); 1628 parameter_map->set_the_hole(key + 2);
1634 } else { 1629 } else {
1635 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1))); 1630 Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
1636 if (arguments->IsDictionary()) { 1631 if (arguments->IsDictionary()) {
1637 return DictionaryElementsAccessor::DeleteCommon(obj, key, mode); 1632 return DictionaryElementsAccessor::DeleteCommon(obj, key, strict_mode);
1638 } else { 1633 } else {
1639 // It's difficult to access the version of DeleteCommon that is declared 1634 // It's difficult to access the version of DeleteCommon that is declared
1640 // in the templatized super class, call the concrete implementation in 1635 // in the templatized super class, call the concrete implementation in
1641 // the class for the most generalized ElementsKind subclass. 1636 // the class for the most generalized ElementsKind subclass.
1642 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key, mode); 1637 return FastHoleyObjectElementsAccessor::DeleteCommon(obj, key,
1638 strict_mode);
1643 } 1639 }
1644 } 1640 }
1645 return isolate->factory()->true_value(); 1641 return isolate->factory()->true_value();
1646 } 1642 }
1647 1643
1648 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start, 1644 static void CopyElementsImpl(FixedArrayBase* from, uint32_t from_start,
1649 FixedArrayBase* to, ElementsKind from_kind, 1645 FixedArrayBase* to, ElementsKind from_kind,
1650 uint32_t to_start, int packed_size, 1646 uint32_t to_start, int packed_size,
1651 int copy_size) { 1647 int copy_size) {
1652 UNREACHABLE(); 1648 UNREACHABLE();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1885 UNREACHABLE(); 1881 UNREACHABLE();
1886 break; 1882 break;
1887 } 1883 }
1888 1884
1889 array->set_elements(*elms); 1885 array->set_elements(*elms);
1890 array->set_length(Smi::FromInt(number_of_elements)); 1886 array->set_length(Smi::FromInt(number_of_elements));
1891 return array; 1887 return array;
1892 } 1888 }
1893 1889
1894 } } // namespace v8::internal 1890 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/elements.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698