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

Side by Side Diff: src/api.cc

Issue 1224523002: Avoid converting key to string for deleting of elements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | src/array.js » ('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 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after
3600 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3600 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3601 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3601 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3602 has_pending_exception = 3602 has_pending_exception =
3603 DefineObjectProperty(self, key_obj, value_obj, 3603 DefineObjectProperty(self, key_obj, value_obj,
3604 static_cast<PropertyAttributes>(attribs)).is_null(); 3604 static_cast<PropertyAttributes>(attribs)).is_null();
3605 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false); 3605 EXCEPTION_BAILOUT_CHECK_SCOPED(isolate, false);
3606 return true; 3606 return true;
3607 } 3607 }
3608 3608
3609 3609
3610 MUST_USE_RESULT
3611 static i::MaybeHandle<i::Object> DeleteObjectProperty(
3612 i::Isolate* isolate, i::Handle<i::JSReceiver> receiver,
3613 i::Handle<i::Object> key, i::LanguageMode language_mode) {
3614 // Check if the given key is an array index.
3615 uint32_t index = 0;
3616 if (key->ToArrayIndex(&index)) {
3617 return i::JSReceiver::DeleteElement(receiver, index, language_mode);
3618 }
3619
3620 i::Handle<i::Name> name;
3621 ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, name,
3622 i::Runtime::ToName(isolate, key),
3623 i::MaybeHandle<i::Object>());
3624
3625 return i::JSReceiver::DeletePropertyOrElement(receiver, name, language_mode);
3626 }
3627
3628
3629 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context, 3610 MaybeLocal<Value> v8::Object::Get(Local<v8::Context> context,
3630 Local<Value> key) { 3611 Local<Value> key) {
3631 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value); 3612 PREPARE_FOR_EXECUTION(context, "v8::Object::Get()", Value);
3632 auto self = Utils::OpenHandle(this); 3613 auto self = Utils::OpenHandle(this);
3633 auto key_obj = Utils::OpenHandle(*key); 3614 auto key_obj = Utils::OpenHandle(*key);
3634 i::Handle<i::Object> result; 3615 i::Handle<i::Object> result;
3635 has_pending_exception = 3616 has_pending_exception =
3636 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result); 3617 !i::Runtime::GetObjectProperty(isolate, self, key_obj).ToHandle(&result);
3637 RETURN_ON_FAILED_EXECUTION(Value); 3618 RETURN_ON_FAILED_EXECUTION(Value);
3638 RETURN_ESCAPED(Utils::ToLocal(result)); 3619 RETURN_ESCAPED(Utils::ToLocal(result));
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3876 return Utils::ToLocal(name); 3857 return Utils::ToLocal(name);
3877 } 3858 }
3878 3859
3879 3860
3880 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) { 3861 Maybe<bool> v8::Object::Delete(Local<Context> context, Local<Value> key) {
3881 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool); 3862 PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::Delete()", bool);
3882 auto self = Utils::OpenHandle(this); 3863 auto self = Utils::OpenHandle(this);
3883 auto key_obj = Utils::OpenHandle(*key); 3864 auto key_obj = Utils::OpenHandle(*key);
3884 i::Handle<i::Object> obj; 3865 i::Handle<i::Object> obj;
3885 has_pending_exception = 3866 has_pending_exception =
3886 !DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY).ToHandle(&obj); 3867 !i::Runtime::DeleteObjectProperty(isolate, self, key_obj, i::SLOPPY)
3868 .ToHandle(&obj);
3887 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool); 3869 RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
3888 return Just(obj->IsTrue()); 3870 return Just(obj->IsTrue());
3889 } 3871 }
3890 3872
3891 3873
3892 bool v8::Object::Delete(v8::Handle<Value> key) { 3874 bool v8::Object::Delete(v8::Handle<Value> key) {
3893 auto context = ContextFromHeapObject(Utils::OpenHandle(this)); 3875 auto context = ContextFromHeapObject(Utils::OpenHandle(this));
3894 return Delete(context, key).FromMaybe(false); 3876 return Delete(context, key).FromMaybe(false);
3895 } 3877 }
3896 3878
(...skipping 4558 matching lines...) Expand 10 before | Expand all | Expand 10 after
8455 Address callback_address = 8437 Address callback_address =
8456 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8438 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8457 VMState<EXTERNAL> state(isolate); 8439 VMState<EXTERNAL> state(isolate);
8458 ExternalCallbackScope call_scope(isolate, callback_address); 8440 ExternalCallbackScope call_scope(isolate, callback_address);
8459 callback(info); 8441 callback(info);
8460 } 8442 }
8461 8443
8462 8444
8463 } // namespace internal 8445 } // namespace internal
8464 } // namespace v8 8446 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698