OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5063 // In Firefox/SpiderMonkey, Safari and Opera you can access the | 5063 // In Firefox/SpiderMonkey, Safari and Opera you can access the |
5064 // characters of a string using [] notation. In the case of a | 5064 // characters of a string using [] notation. In the case of a |
5065 // String object we just need to redirect the deletion to the | 5065 // String object we just need to redirect the deletion to the |
5066 // underlying string if the index is in range. Since the | 5066 // underlying string if the index is in range. Since the |
5067 // underlying string does nothing with the deletion, we can ignore | 5067 // underlying string does nothing with the deletion, we can ignore |
5068 // such deletions. | 5068 // such deletions. |
5069 if (receiver->IsStringObjectWithCharacterAt(index)) { | 5069 if (receiver->IsStringObjectWithCharacterAt(index)) { |
5070 return isolate->heap()->true_value(); | 5070 return isolate->heap()->true_value(); |
5071 } | 5071 } |
5072 | 5072 |
5073 return receiver->DeleteElement(index, mode); | 5073 Handle<Object> result = JSReceiver::DeleteElement(receiver, index, mode); |
| 5074 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 5075 return *result; |
5074 } | 5076 } |
5075 | 5077 |
5076 Handle<Name> name; | 5078 Handle<Name> name; |
5077 if (key->IsName()) { | 5079 if (key->IsName()) { |
5078 name = Handle<Name>::cast(key); | 5080 name = Handle<Name>::cast(key); |
5079 } else { | 5081 } else { |
5080 // Call-back into JavaScript to convert the key to a string. | 5082 // Call-back into JavaScript to convert the key to a string. |
5081 bool has_pending_exception = false; | 5083 bool has_pending_exception = false; |
5082 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); | 5084 Handle<Object> converted = Execution::ToString(key, &has_pending_exception); |
5083 if (has_pending_exception) return Failure::Exception(); | 5085 if (has_pending_exception) return Failure::Exception(); |
5084 name = Handle<String>::cast(converted); | 5086 name = Handle<String>::cast(converted); |
5085 } | 5087 } |
5086 | 5088 |
5087 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); | 5089 if (name->IsString()) Handle<String>::cast(name)->TryFlatten(); |
5088 return receiver->DeleteProperty(*name, mode); | 5090 Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode); |
| 5091 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 5092 return *result; |
5089 } | 5093 } |
5090 | 5094 |
5091 | 5095 |
5092 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 5096 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { |
5093 SealHandleScope shs(isolate); | 5097 SealHandleScope shs(isolate); |
5094 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 5098 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
5095 | 5099 |
5096 Handle<Object> object = args.at<Object>(0); | 5100 Handle<Object> object = args.at<Object>(0); |
5097 Handle<Object> key = args.at<Object>(1); | 5101 Handle<Object> key = args.at<Object>(1); |
5098 Handle<Object> value = args.at<Object>(2); | 5102 Handle<Object> value = args.at<Object>(2); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5284 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5288 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5285 attributes = static_cast<PropertyAttributes>(unchecked_value); | 5289 attributes = static_cast<PropertyAttributes>(unchecked_value); |
5286 } | 5290 } |
5287 | 5291 |
5288 return object-> | 5292 return object-> |
5289 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); | 5293 SetLocalPropertyIgnoreAttributes(name, args[2], attributes); |
5290 } | 5294 } |
5291 | 5295 |
5292 | 5296 |
5293 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 5297 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { |
5294 SealHandleScope shs(isolate); | 5298 HandleScope scope(isolate); |
5295 ASSERT(args.length() == 3); | 5299 ASSERT(args.length() == 3); |
5296 | 5300 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
5297 CONVERT_ARG_CHECKED(JSReceiver, object, 0); | 5301 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5298 CONVERT_ARG_CHECKED(Name, key, 1); | |
5299 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5302 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
5300 return object->DeleteProperty(key, (strict_mode == kStrictMode) | 5303 JSReceiver::DeleteMode delete_mode = (strict_mode == kStrictMode) |
5301 ? JSReceiver::STRICT_DELETION | 5304 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; |
5302 : JSReceiver::NORMAL_DELETION); | 5305 Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode); |
| 5306 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 5307 return *result; |
5303 } | 5308 } |
5304 | 5309 |
5305 | 5310 |
5306 static Object* HasLocalPropertyImplementation(Isolate* isolate, | 5311 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
5307 Handle<JSObject> object, | 5312 Handle<JSObject> object, |
5308 Handle<Name> key) { | 5313 Handle<Name> key) { |
5309 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); | 5314 if (object->HasLocalProperty(*key)) return isolate->heap()->true_value(); |
5310 // Handle hidden prototypes. If there's a hidden prototype above this thing | 5315 // Handle hidden prototypes. If there's a hidden prototype above this thing |
5311 // then we have to check it for properties, because they are supposed to | 5316 // then we have to check it for properties, because they are supposed to |
5312 // look like they are on this object. | 5317 // look like they are on this object. |
(...skipping 3514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8827 | 8832 |
8828 // If the slot was found in a context, it should be DONT_DELETE. | 8833 // If the slot was found in a context, it should be DONT_DELETE. |
8829 if (holder->IsContext()) { | 8834 if (holder->IsContext()) { |
8830 return isolate->heap()->false_value(); | 8835 return isolate->heap()->false_value(); |
8831 } | 8836 } |
8832 | 8837 |
8833 // The slot was found in a JSObject, either a context extension object, | 8838 // The slot was found in a JSObject, either a context extension object, |
8834 // the global object, or the subject of a with. Try to delete it | 8839 // the global object, or the subject of a with. Try to delete it |
8835 // (respecting DONT_DELETE). | 8840 // (respecting DONT_DELETE). |
8836 Handle<JSObject> object = Handle<JSObject>::cast(holder); | 8841 Handle<JSObject> object = Handle<JSObject>::cast(holder); |
8837 return object->DeleteProperty(*name, JSReceiver::NORMAL_DELETION); | 8842 Handle<Object> result = JSReceiver::DeleteProperty(object, name); |
| 8843 RETURN_IF_EMPTY_HANDLE(isolate, result); |
| 8844 return *result; |
8838 } | 8845 } |
8839 | 8846 |
8840 | 8847 |
8841 // A mechanism to return a pair of Object pointers in registers (if possible). | 8848 // A mechanism to return a pair of Object pointers in registers (if possible). |
8842 // How this is achieved is calling convention-dependent. | 8849 // How this is achieved is calling convention-dependent. |
8843 // All currently supported x86 compiles uses calling conventions that are cdecl | 8850 // All currently supported x86 compiles uses calling conventions that are cdecl |
8844 // variants where a 64-bit value is returned in two 32-bit registers | 8851 // variants where a 64-bit value is returned in two 32-bit registers |
8845 // (edx:eax on ia32, r1:r0 on ARM). | 8852 // (edx:eax on ia32, r1:r0 on ARM). |
8846 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. | 8853 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. |
8847 // In Win64 calling convention, a struct of two pointers is returned in memory, | 8854 // In Win64 calling convention, a struct of two pointers is returned in memory, |
(...skipping 5099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13947 // Handle last resort GC and make sure to allow future allocations | 13954 // Handle last resort GC and make sure to allow future allocations |
13948 // to grow the heap without causing GCs (if possible). | 13955 // to grow the heap without causing GCs (if possible). |
13949 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13956 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13950 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13957 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13951 "Runtime::PerformGC"); | 13958 "Runtime::PerformGC"); |
13952 } | 13959 } |
13953 } | 13960 } |
13954 | 13961 |
13955 | 13962 |
13956 } } // namespace v8::internal | 13963 } } // namespace v8::internal |
OLD | NEW |