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

Unified Diff: src/api.cc

Issue 1702353002: Attempt to speed up v8::Object::SetPrivate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index b7dcd446c154e9d232ada47575fe5c227775e07a..56eb11af5fcdc20f1698bf644eb9a13f3cd7f45e 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3600,8 +3600,27 @@ bool v8::Object::ForceSet(v8::Local<Value> key, v8::Local<Value> value,
Maybe<bool> v8::Object::SetPrivate(Local<Context> context, Local<Private> key,
Local<Value> value) {
- return DefineOwnProperty(context, Local<Name>(reinterpret_cast<Name*>(*key)),
- value, DontEnum);
+ PREPARE_FOR_EXECUTION_PRIMITIVE(context, "v8::Object::SetPrivate()", bool);
+ auto self = Utils::OpenHandle(this);
+ auto key_obj = Utils::OpenHandle(reinterpret_cast<Name*>(*key));
+ auto value_obj = Utils::OpenHandle(*value);
+ if (self->IsJSProxy()) {
+ i::PropertyDescriptor desc;
+ desc.set_writable(true);
+ desc.set_enumerable(false);
+ desc.set_configurable(true);
+ desc.set_value(value_obj);
+ return i::JSProxy::SetPrivateProperty(
+ isolate, i::Handle<i::JSProxy>::cast(self),
+ i::Handle<i::Symbol>::cast(key_obj), &desc, i::Object::DONT_THROW);
+ }
+ auto js_object = i::Handle<i::JSObject>::cast(self);
+ i::LookupIterator it(js_object, key_obj);
+ has_pending_exception = i::JSObject::DefineOwnPropertyIgnoreAttributes(
+ &it, value_obj, i::DONT_ENUM)
+ .is_null();
+ RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
+ return Just(true);
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698