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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 880 |
881 static MaybeObject* Runtime_PreventExtensions(Arguments args) { | 881 static MaybeObject* Runtime_PreventExtensions(Arguments args) { |
882 ASSERT(args.length() == 1); | 882 ASSERT(args.length() == 1); |
883 CONVERT_CHECKED(JSObject, obj, args[0]); | 883 CONVERT_CHECKED(JSObject, obj, args[0]); |
884 return obj->PreventExtensions(); | 884 return obj->PreventExtensions(); |
885 } | 885 } |
886 | 886 |
887 static MaybeObject* Runtime_IsExtensible(Arguments args) { | 887 static MaybeObject* Runtime_IsExtensible(Arguments args) { |
888 ASSERT(args.length() == 1); | 888 ASSERT(args.length() == 1); |
889 CONVERT_CHECKED(JSObject, obj, args[0]); | 889 CONVERT_CHECKED(JSObject, obj, args[0]); |
890 return obj->map()->is_extensible() ? Heap::true_value() | 890 return obj->map()->is_extensible() ? Heap::true_value() |
891 : Heap::false_value(); | 891 : Heap::false_value(); |
892 } | 892 } |
893 | 893 |
894 | 894 |
895 static MaybeObject* Runtime_RegExpCompile(Arguments args) { | 895 static MaybeObject* Runtime_RegExpCompile(Arguments args) { |
896 HandleScope scope; | 896 HandleScope scope; |
897 ASSERT(args.length() == 3); | 897 ASSERT(args.length() == 3); |
898 CONVERT_ARG_CHECKED(JSRegExp, re, 0); | 898 CONVERT_ARG_CHECKED(JSRegExp, re, 0); |
899 CONVERT_ARG_CHECKED(String, pattern, 1); | 899 CONVERT_ARG_CHECKED(String, pattern, 1); |
900 CONVERT_ARG_CHECKED(String, flags, 2); | 900 CONVERT_ARG_CHECKED(String, flags, 2); |
(...skipping 2760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3661 // Check if this is an element. | 3661 // Check if this is an element. |
3662 uint32_t index; | 3662 uint32_t index; |
3663 bool is_element = name->AsArrayIndex(&index); | 3663 bool is_element = name->AsArrayIndex(&index); |
3664 | 3664 |
3665 // Special case for elements if any of the flags are true. | 3665 // Special case for elements if any of the flags are true. |
3666 // If elements are in fast case we always implicitly assume that: | 3666 // If elements are in fast case we always implicitly assume that: |
3667 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. | 3667 // DONT_DELETE: false, DONT_ENUM: false, READ_ONLY: false. |
3668 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && | 3668 if (((unchecked & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) && |
3669 is_element) { | 3669 is_element) { |
3670 // Normalize the elements to enable attributes on the property. | 3670 // Normalize the elements to enable attributes on the property. |
3671 if (!js_object->IsJSGlobalProxy()) { | 3671 if (js_object->IsJSGlobalProxy()) { |
3672 NormalizeElements(js_object); | 3672 Handle<Object> proto(js_object->GetPrototype()); |
| 3673 // If proxy is detached, ignore the assignment. Alternatively, |
| 3674 // we could throw an exception. |
| 3675 if (proto->IsNull()) return *obj_value; |
| 3676 js_object = Handle<JSObject>::cast(proto); |
3673 } | 3677 } |
| 3678 NormalizeElements(js_object); |
3674 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); | 3679 Handle<NumberDictionary> dictionary(js_object->element_dictionary()); |
3675 // Make sure that we never go back to fast case. | 3680 // Make sure that we never go back to fast case. |
3676 dictionary->set_requires_slow_elements(); | 3681 dictionary->set_requires_slow_elements(); |
3677 PropertyDetails details = PropertyDetails(attr, NORMAL); | 3682 PropertyDetails details = PropertyDetails(attr, NORMAL); |
3678 NumberDictionarySet(dictionary, index, obj_value, details); | 3683 NumberDictionarySet(dictionary, index, obj_value, details); |
| 3684 return *obj_value; |
3679 } | 3685 } |
3680 | 3686 |
3681 LookupResult result; | 3687 LookupResult result; |
3682 js_object->LookupRealNamedProperty(*name, &result); | 3688 js_object->LookupRealNamedProperty(*name, &result); |
3683 | 3689 |
3684 // Take special care when attributes are different and there is already | 3690 // Take special care when attributes are different and there is already |
3685 // a property. For simplicity we normalize the property which enables us | 3691 // a property. For simplicity we normalize the property which enables us |
3686 // to not worry about changing the instance_descriptor and creating a new | 3692 // to not worry about changing the instance_descriptor and creating a new |
3687 // map. The current version of SetObjectProperty does not handle attributes | 3693 // map. The current version of SetObjectProperty does not handle attributes |
3688 // correctly in the case where a property is a field and is reset with | 3694 // correctly in the case where a property is a field and is reset with |
3689 // new attributes. | 3695 // new attributes. |
3690 if (result.IsProperty() && | 3696 if (result.IsProperty() && |
3691 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { | 3697 (attr != result.GetAttributes() || result.type() == CALLBACKS)) { |
3692 // New attributes - normalize to avoid writing to instance descriptor | 3698 // New attributes - normalize to avoid writing to instance descriptor |
3693 if (!js_object->IsJSGlobalProxy()) { | 3699 if (js_object->IsJSGlobalProxy()) { |
3694 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); | 3700 // Since the result is a property, the prototype will exist so |
| 3701 // we don't have to check for null. |
| 3702 js_object = Handle<JSObject>(JSObject::cast(js_object->GetPrototype())); |
3695 } | 3703 } |
| 3704 NormalizeProperties(js_object, CLEAR_INOBJECT_PROPERTIES, 0); |
3696 // Use IgnoreAttributes version since a readonly property may be | 3705 // Use IgnoreAttributes version since a readonly property may be |
3697 // overridden and SetProperty does not allow this. | 3706 // overridden and SetProperty does not allow this. |
3698 return js_object->SetLocalPropertyIgnoreAttributes(*name, | 3707 return js_object->SetLocalPropertyIgnoreAttributes(*name, |
3699 *obj_value, | 3708 *obj_value, |
3700 attr); | 3709 attr); |
3701 } | 3710 } |
3702 | 3711 |
3703 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); | 3712 return Runtime::SetObjectProperty(js_object, name, obj_value, attr); |
3704 } | 3713 } |
3705 | 3714 |
(...skipping 7361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11067 } else { | 11076 } else { |
11068 // Handle last resort GC and make sure to allow future allocations | 11077 // Handle last resort GC and make sure to allow future allocations |
11069 // to grow the heap without causing GCs (if possible). | 11078 // to grow the heap without causing GCs (if possible). |
11070 Counters::gc_last_resort_from_js.Increment(); | 11079 Counters::gc_last_resort_from_js.Increment(); |
11071 Heap::CollectAllGarbage(false); | 11080 Heap::CollectAllGarbage(false); |
11072 } | 11081 } |
11073 } | 11082 } |
11074 | 11083 |
11075 | 11084 |
11076 } } // namespace v8::internal | 11085 } } // namespace v8::internal |
OLD | NEW |