OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 } | 1392 } |
1393 | 1393 |
1394 | 1394 |
1395 MaybeObject* JSObject::AddProperty(String* name, | 1395 MaybeObject* JSObject::AddProperty(String* name, |
1396 Object* value, | 1396 Object* value, |
1397 PropertyAttributes attributes) { | 1397 PropertyAttributes attributes) { |
1398 ASSERT(!IsJSGlobalProxy()); | 1398 ASSERT(!IsJSGlobalProxy()); |
1399 if (!map()->is_extensible()) { | 1399 if (!map()->is_extensible()) { |
1400 Handle<Object> args[1] = {Handle<String>(name)}; | 1400 Handle<Object> args[1] = {Handle<String>(name)}; |
1401 return Top::Throw(*Factory::NewTypeError("object_not_extensible", | 1401 return Top::Throw(*Factory::NewTypeError("object_not_extensible", |
1402 HandleVector(args, 1))); | 1402 HandleVector(args, 1))); |
1403 } | 1403 } |
1404 if (HasFastProperties()) { | 1404 if (HasFastProperties()) { |
1405 // Ensure the descriptor array does not get too big. | 1405 // Ensure the descriptor array does not get too big. |
1406 if (map()->instance_descriptors()->number_of_descriptors() < | 1406 if (map()->instance_descriptors()->number_of_descriptors() < |
1407 DescriptorArray::kMaxNumberOfDescriptors) { | 1407 DescriptorArray::kMaxNumberOfDescriptors) { |
1408 if (value->IsJSFunction() && !Heap::InNewSpace(value)) { | 1408 if (value->IsJSFunction() && !Heap::InNewSpace(value)) { |
1409 return AddConstantFunctionProperty(name, | 1409 return AddConstantFunctionProperty(name, |
1410 JSFunction::cast(value), | 1410 JSFunction::cast(value), |
1411 attributes); | 1411 attributes); |
1412 } else { | 1412 } else { |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2613 case EXTERNAL_INT_ELEMENTS: | 2613 case EXTERNAL_INT_ELEMENTS: |
2614 case EXTERNAL_UNSIGNED_INT_ELEMENTS: | 2614 case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
2615 case EXTERNAL_FLOAT_ELEMENTS: | 2615 case EXTERNAL_FLOAT_ELEMENTS: |
2616 // Pixel and external array elements cannot be deleted. Just | 2616 // Pixel and external array elements cannot be deleted. Just |
2617 // silently ignore here. | 2617 // silently ignore here. |
2618 break; | 2618 break; |
2619 case DICTIONARY_ELEMENTS: { | 2619 case DICTIONARY_ELEMENTS: { |
2620 NumberDictionary* dictionary = element_dictionary(); | 2620 NumberDictionary* dictionary = element_dictionary(); |
2621 int entry = dictionary->FindEntry(index); | 2621 int entry = dictionary->FindEntry(index); |
2622 if (entry != NumberDictionary::kNotFound) { | 2622 if (entry != NumberDictionary::kNotFound) { |
2623 return dictionary->DeleteProperty(entry, mode); | 2623 Object* result = dictionary->DeleteProperty(entry, mode); |
Martin Maly
2011/02/14 05:15:22
DeleteProperty is a wrong place to report the erro
Mads Ager (chromium)
2011/02/14 10:27:24
I think that makes sense. Could you add a comment
Martin Maly
2011/02/14 21:46:51
Done.
| |
2624 if (mode == STRICT_DELETION && result == Heap::false_value()) { | |
2625 HandleScope scope; | |
2626 Handle<Object> i = Factory::NewNumberFromUint(index); | |
2627 Handle<Object> args[2] = { i, Handle<Object>(this) }; | |
2628 return Top::Throw(*Factory::NewTypeError("strict_delete_property", | |
2629 HandleVector(args, 2))); | |
2630 } | |
2624 } | 2631 } |
2625 break; | 2632 break; |
2626 } | 2633 } |
2627 default: | 2634 default: |
2628 UNREACHABLE(); | 2635 UNREACHABLE(); |
2629 break; | 2636 break; |
2630 } | 2637 } |
2631 return Heap::true_value(); | 2638 return Heap::true_value(); |
2632 } | 2639 } |
2633 | 2640 |
(...skipping 18 matching lines...) Expand all Loading... | |
2652 | 2659 |
2653 uint32_t index = 0; | 2660 uint32_t index = 0; |
2654 if (name->AsArrayIndex(&index)) { | 2661 if (name->AsArrayIndex(&index)) { |
2655 return DeleteElement(index, mode); | 2662 return DeleteElement(index, mode); |
2656 } else { | 2663 } else { |
2657 LookupResult result; | 2664 LookupResult result; |
2658 LocalLookup(name, &result); | 2665 LocalLookup(name, &result); |
2659 if (!result.IsProperty()) return Heap::true_value(); | 2666 if (!result.IsProperty()) return Heap::true_value(); |
2660 // Ignore attributes if forcing a deletion. | 2667 // Ignore attributes if forcing a deletion. |
2661 if (result.IsDontDelete() && mode != FORCE_DELETION) { | 2668 if (result.IsDontDelete() && mode != FORCE_DELETION) { |
2669 if (mode == STRICT_DELETION) { | |
2670 HandleScope scope; | |
2671 Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) }; | |
2672 return Top::Throw(*Factory::NewTypeError("strict_delete_property", | |
2673 HandleVector(args, 2))); | |
2674 } | |
2662 return Heap::false_value(); | 2675 return Heap::false_value(); |
2663 } | 2676 } |
2664 // Check for interceptor. | 2677 // Check for interceptor. |
2665 if (result.type() == INTERCEPTOR) { | 2678 if (result.type() == INTERCEPTOR) { |
2666 // Skip interceptor if forcing a deletion. | 2679 // Skip interceptor if forcing a deletion. |
2667 if (mode == FORCE_DELETION) { | 2680 if (mode == FORCE_DELETION) { |
2668 return DeletePropertyPostInterceptor(name, mode); | 2681 return DeletePropertyPostInterceptor(name, mode); |
2669 } | 2682 } |
2670 return DeletePropertyWithInterceptor(name); | 2683 return DeletePropertyWithInterceptor(name); |
2671 } | 2684 } |
(...skipping 6666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9338 // Update the number of elements. | 9351 // Update the number of elements. |
9339 ElementsRemoved(removed_entries); | 9352 ElementsRemoved(removed_entries); |
9340 } | 9353 } |
9341 | 9354 |
9342 | 9355 |
9343 template<typename Shape, typename Key> | 9356 template<typename Shape, typename Key> |
9344 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, | 9357 Object* Dictionary<Shape, Key>::DeleteProperty(int entry, |
9345 JSObject::DeleteMode mode) { | 9358 JSObject::DeleteMode mode) { |
9346 PropertyDetails details = DetailsAt(entry); | 9359 PropertyDetails details = DetailsAt(entry); |
9347 // Ignore attributes if forcing a deletion. | 9360 // Ignore attributes if forcing a deletion. |
9348 if (details.IsDontDelete() && mode == JSObject::NORMAL_DELETION) { | 9361 if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) { |
9349 return Heap::false_value(); | 9362 return Heap::false_value(); |
9350 } | 9363 } |
9351 SetEntry(entry, Heap::null_value(), Heap::null_value(), Smi::FromInt(0)); | 9364 SetEntry(entry, Heap::null_value(), Heap::null_value(), Smi::FromInt(0)); |
9352 HashTable<Shape, Key>::ElementRemoved(); | 9365 HashTable<Shape, Key>::ElementRemoved(); |
9353 return Heap::true_value(); | 9366 return Heap::true_value(); |
9354 } | 9367 } |
9355 | 9368 |
9356 | 9369 |
9357 template<typename Shape, typename Key> | 9370 template<typename Shape, typename Key> |
9358 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) { | 9371 MaybeObject* Dictionary<Shape, Key>::AtPut(Key key, Object* value) { |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9953 if (break_point_objects()->IsUndefined()) return 0; | 9966 if (break_point_objects()->IsUndefined()) return 0; |
9954 // Single beak point. | 9967 // Single beak point. |
9955 if (!break_point_objects()->IsFixedArray()) return 1; | 9968 if (!break_point_objects()->IsFixedArray()) return 1; |
9956 // Multiple break points. | 9969 // Multiple break points. |
9957 return FixedArray::cast(break_point_objects())->length(); | 9970 return FixedArray::cast(break_point_objects())->length(); |
9958 } | 9971 } |
9959 #endif | 9972 #endif |
9960 | 9973 |
9961 | 9974 |
9962 } } // namespace v8::internal | 9975 } } // namespace v8::internal |
OLD | NEW |