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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 | 918 |
919 // Check whether the backing store should be expanded. | 919 // Check whether the backing store should be expanded. |
920 uint32_t min = JSObject::NewElementsCapacity(old_capacity); | 920 uint32_t min = JSObject::NewElementsCapacity(old_capacity); |
921 uint32_t new_capacity = length > min ? length : min; | 921 uint32_t new_capacity = length > min ? length : min; |
922 FastElementsAccessorSubclass::SetFastElementsCapacityAndLength( | 922 FastElementsAccessorSubclass::SetFastElementsCapacityAndLength( |
923 array, new_capacity, length); | 923 array, new_capacity, length); |
924 JSObject::ValidateElements(array); | 924 JSObject::ValidateElements(array); |
925 return length_object; | 925 return length_object; |
926 } | 926 } |
927 | 927 |
928 static Handle<Object> DeleteCommon(Handle<JSObject> obj, uint32_t key, | 928 static MaybeHandle<Object> DeleteCommon(Handle<JSObject> obj, uint32_t key, |
929 LanguageMode language_mode) { | 929 LanguageMode language_mode) { |
930 DCHECK(obj->HasFastSmiOrObjectElements() || | 930 DCHECK(obj->HasFastSmiOrObjectElements() || |
931 obj->HasFastDoubleElements() || | 931 obj->HasFastDoubleElements() || |
932 obj->HasFastArgumentsElements()); | 932 obj->HasFastArgumentsElements()); |
933 Isolate* isolate = obj->GetIsolate(); | 933 Isolate* isolate = obj->GetIsolate(); |
934 Heap* heap = obj->GetHeap(); | 934 Heap* heap = obj->GetHeap(); |
935 Handle<FixedArrayBase> elements(obj->elements()); | 935 Handle<FixedArrayBase> elements(obj->elements()); |
936 if (*elements == heap->empty_fixed_array()) { | 936 if (*elements == heap->empty_fixed_array()) { |
937 return isolate->factory()->true_value(); | 937 return isolate->factory()->true_value(); |
938 } | 938 } |
939 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements); | 939 Handle<BackingStore> backing_store = Handle<BackingStore>::cast(elements); |
940 if (obj->map()->is_strong() && !backing_store->is_the_hole(key)) { | |
arv (Not doing code reviews)
2015/05/28 15:46:17
When do we holes in the backing store of a strong
conradw
2015/05/28 16:36:44
The elements backing store can become some flavour
| |
941 if (is_strict(language_mode)) { | |
942 Handle<Object> name = isolate->factory()->NewNumberFromUint(key); | |
943 THROW_NEW_ERROR( | |
944 isolate, | |
945 NewTypeError(MessageTemplate::kStrongDeleteProperty, obj, name), | |
946 Object); | |
947 } | |
948 return isolate->factory()->false_value(); | |
949 } | |
940 bool is_sloppy_arguments_elements_map = | 950 bool is_sloppy_arguments_elements_map = |
941 backing_store->map() == heap->sloppy_arguments_elements_map(); | 951 backing_store->map() == heap->sloppy_arguments_elements_map(); |
942 if (is_sloppy_arguments_elements_map) { | 952 if (is_sloppy_arguments_elements_map) { |
943 backing_store = handle( | 953 backing_store = handle( |
944 BackingStore::cast(Handle<FixedArray>::cast(backing_store)->get(1)), | 954 BackingStore::cast(Handle<FixedArray>::cast(backing_store)->get(1)), |
945 isolate); | 955 isolate); |
946 } | 956 } |
947 uint32_t length = static_cast<uint32_t>( | 957 uint32_t length = static_cast<uint32_t>( |
948 obj->IsJSArray() | 958 obj->IsJSArray() |
949 ? Smi::cast(Handle<JSArray>::cast(obj)->length())->value() | 959 ? Smi::cast(Handle<JSArray>::cast(obj)->length())->value() |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1413 isolate); | 1423 isolate); |
1414 bool is_arguments = | 1424 bool is_arguments = |
1415 (obj->GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS); | 1425 (obj->GetElementsKind() == SLOPPY_ARGUMENTS_ELEMENTS); |
1416 if (is_arguments) { | 1426 if (is_arguments) { |
1417 backing_store = handle(FixedArray::cast(backing_store->get(1)), isolate); | 1427 backing_store = handle(FixedArray::cast(backing_store->get(1)), isolate); |
1418 } | 1428 } |
1419 Handle<SeededNumberDictionary> dictionary = | 1429 Handle<SeededNumberDictionary> dictionary = |
1420 Handle<SeededNumberDictionary>::cast(backing_store); | 1430 Handle<SeededNumberDictionary>::cast(backing_store); |
1421 int entry = dictionary->FindEntry(key); | 1431 int entry = dictionary->FindEntry(key); |
1422 if (entry != SeededNumberDictionary::kNotFound) { | 1432 if (entry != SeededNumberDictionary::kNotFound) { |
1423 Handle<Object> result = | 1433 Handle<Object> result; |
1424 SeededNumberDictionary::DeleteProperty(dictionary, entry); | 1434 bool strong = obj->map()->is_strong(); |
1425 if (*result == *isolate->factory()->false_value()) { | 1435 if (!strong) { |
1436 result = SeededNumberDictionary::DeleteProperty(dictionary, entry); | |
1437 } | |
1438 if (strong || *result == *isolate->factory()->false_value()) { | |
1439 // Fail if the property is not configurable, or on a strong object. | |
1426 if (is_strict(language_mode)) { | 1440 if (is_strict(language_mode)) { |
1427 // Deleting a non-configurable property in strict mode. | |
1428 Handle<Object> name = isolate->factory()->NewNumberFromUint(key); | 1441 Handle<Object> name = isolate->factory()->NewNumberFromUint(key); |
1442 if (strong) { | |
1443 THROW_NEW_ERROR( | |
1444 isolate, | |
1445 NewTypeError(MessageTemplate::kStrongDeleteProperty, obj, name), | |
1446 Object); | |
1447 } | |
1429 THROW_NEW_ERROR( | 1448 THROW_NEW_ERROR( |
1430 isolate, | 1449 isolate, |
1431 NewTypeError(MessageTemplate::kStrictDeleteProperty, name, obj), | 1450 NewTypeError(MessageTemplate::kStrictDeleteProperty, name, obj), |
1432 Object); | 1451 Object); |
1433 } | 1452 } |
1434 return isolate->factory()->false_value(); | 1453 return isolate->factory()->false_value(); |
1435 } | 1454 } |
1436 Handle<FixedArray> new_elements = | 1455 Handle<FixedArray> new_elements = |
1437 SeededNumberDictionary::Shrink(dictionary, key); | 1456 SeededNumberDictionary::Shrink(dictionary, key); |
1438 | 1457 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1894 UNREACHABLE(); | 1913 UNREACHABLE(); |
1895 break; | 1914 break; |
1896 } | 1915 } |
1897 | 1916 |
1898 array->set_elements(*elms); | 1917 array->set_elements(*elms); |
1899 array->set_length(Smi::FromInt(number_of_elements)); | 1918 array->set_length(Smi::FromInt(number_of_elements)); |
1900 return array; | 1919 return array; |
1901 } | 1920 } |
1902 | 1921 |
1903 } } // namespace v8::internal | 1922 } } // namespace v8::internal |
OLD | NEW |