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

Side by Side Diff: src/api.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 | « include/v8.h ('k') | src/elements.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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 3019 matching lines...) Expand 10 before | Expand all | Expand 10 after
3030 3030
3031 3031
3032 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { 3032 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) {
3033 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), 3033 return ForceSet(v8::Handle<Value>(reinterpret_cast<Value*>(*key)),
3034 value, DontEnum); 3034 value, DontEnum);
3035 } 3035 }
3036 3036
3037 3037
3038 i::MaybeHandle<i::Object> DeleteObjectProperty( 3038 i::MaybeHandle<i::Object> DeleteObjectProperty(
3039 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver, 3039 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
3040 i::Handle<i::Object> key, i::JSReceiver::DeleteMode mode) { 3040 i::Handle<i::Object> key, i::StrictMode strict_mode) {
3041 // Check if the given key is an array index. 3041 // Check if the given key is an array index.
3042 uint32_t index; 3042 uint32_t index;
3043 if (key->ToArrayIndex(&index)) { 3043 if (key->ToArrayIndex(&index)) {
3044 // In Firefox/SpiderMonkey, Safari and Opera you can access the 3044 // In Firefox/SpiderMonkey, Safari and Opera you can access the
3045 // characters of a string using [] notation. In the case of a 3045 // characters of a string using [] notation. In the case of a
3046 // String object we just need to redirect the deletion to the 3046 // String object we just need to redirect the deletion to the
3047 // underlying string if the index is in range. Since the 3047 // underlying string if the index is in range. Since the
3048 // underlying string does nothing with the deletion, we can ignore 3048 // underlying string does nothing with the deletion, we can ignore
3049 // such deletions. 3049 // such deletions.
3050 if (receiver->IsStringObjectWithCharacterAt(index)) { 3050 if (receiver->IsStringObjectWithCharacterAt(index)) {
3051 return isolate->factory()->true_value(); 3051 return isolate->factory()->true_value();
3052 } 3052 }
3053 3053
3054 return i::JSReceiver::DeleteElement(receiver, index, mode); 3054 return i::JSReceiver::DeleteElement(receiver, index, strict_mode);
3055 } 3055 }
3056 3056
3057 i::Handle<i::Name> name; 3057 i::Handle<i::Name> name;
3058 if (key->IsName()) { 3058 if (key->IsName()) {
3059 name = i::Handle<i::Name>::cast(key); 3059 name = i::Handle<i::Name>::cast(key);
3060 } else { 3060 } else {
3061 // Call-back into JavaScript to convert the key to a string. 3061 // Call-back into JavaScript to convert the key to a string.
3062 i::Handle<i::Object> converted; 3062 i::Handle<i::Object> converted;
3063 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) { 3063 if (!i::Execution::ToString(isolate, key).ToHandle(&converted)) {
3064 return i::MaybeHandle<i::Object>(); 3064 return i::MaybeHandle<i::Object>();
3065 } 3065 }
3066 name = i::Handle<i::String>::cast(converted); 3066 name = i::Handle<i::String>::cast(converted);
3067 } 3067 }
3068 3068
3069 if (name->IsString()) { 3069 if (name->IsString()) {
3070 name = i::String::Flatten(i::Handle<i::String>::cast(name)); 3070 name = i::String::Flatten(i::Handle<i::String>::cast(name));
3071 } 3071 }
3072 return i::JSReceiver::DeleteProperty(receiver, name, mode); 3072 return i::JSReceiver::DeleteProperty(receiver, name, strict_mode);
3073 } 3073 }
3074 3074
3075 3075
3076 bool v8::Object::ForceDelete(v8::Handle<Value> key) {
3077 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3078 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false);
3079 ENTER_V8(isolate);
3080 i::HandleScope scope(isolate);
3081 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3082 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3083
3084 EXCEPTION_PREAMBLE(isolate);
3085 i::Handle<i::Object> obj;
3086 has_pending_exception =
3087 !DeleteObjectProperty(isolate, self, key_obj,
3088 i::JSReceiver::FORCE_DELETION).ToHandle(&obj);
3089 EXCEPTION_BAILOUT_CHECK(isolate, false);
3090 return obj->IsTrue();
3091 }
3092
3093
3094 Local<Value> v8::Object::Get(v8::Handle<Value> key) { 3076 Local<Value> v8::Object::Get(v8::Handle<Value> key) {
3095 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3077 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3096 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>()); 3078 ON_BAILOUT(isolate, "v8::Object::Get()", return Local<v8::Value>());
3097 ENTER_V8(isolate); 3079 ENTER_V8(isolate);
3098 i::Handle<i::Object> self = Utils::OpenHandle(this); 3080 i::Handle<i::Object> self = Utils::OpenHandle(this);
3099 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3081 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3100 EXCEPTION_PREAMBLE(isolate); 3082 EXCEPTION_PREAMBLE(isolate);
3101 i::Handle<i::Object> result; 3083 i::Handle<i::Object> result;
3102 has_pending_exception = 3084 has_pending_exception =
3103 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); 3085 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 bool v8::Object::Delete(v8::Handle<Value> key) { 3366 bool v8::Object::Delete(v8::Handle<Value> key) {
3385 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3367 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3386 ON_BAILOUT(isolate, "v8::Object::Delete()", return false); 3368 ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
3387 ENTER_V8(isolate); 3369 ENTER_V8(isolate);
3388 i::HandleScope scope(isolate); 3370 i::HandleScope scope(isolate);
3389 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3371 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3390 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3372 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3391 EXCEPTION_PREAMBLE(isolate); 3373 EXCEPTION_PREAMBLE(isolate);
3392 i::Handle<i::Object> obj; 3374 i::Handle<i::Object> obj;
3393 has_pending_exception = 3375 has_pending_exception =
3394 !DeleteObjectProperty(isolate, self, key_obj, 3376 !DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY).ToHandle(&obj);
3395 i::JSReceiver::NORMAL_DELETION).ToHandle(&obj);
3396 EXCEPTION_BAILOUT_CHECK(isolate, false); 3377 EXCEPTION_BAILOUT_CHECK(isolate, false);
3397 return obj->IsTrue(); 3378 return obj->IsTrue();
3398 } 3379 }
3399 3380
3400 3381
3401 bool v8::Object::DeletePrivate(v8::Handle<Private> key) { 3382 bool v8::Object::DeletePrivate(v8::Handle<Private> key) {
3402 return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); 3383 return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key)));
3403 } 3384 }
3404 3385
3405 3386
(...skipping 4233 matching lines...) Expand 10 before | Expand all | Expand 10 after
7639 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7620 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7640 Address callback_address = 7621 Address callback_address =
7641 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7622 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7642 VMState<EXTERNAL> state(isolate); 7623 VMState<EXTERNAL> state(isolate);
7643 ExternalCallbackScope call_scope(isolate, callback_address); 7624 ExternalCallbackScope call_scope(isolate, callback_address);
7644 callback(info); 7625 callback(info);
7645 } 7626 }
7646 7627
7647 7628
7648 } } // namespace v8::internal 7629 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/elements.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698