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

Unified Diff: src/builtins.cc

Issue 1642223003: [api] Make ObjectTemplate::SetNativeDataProperty() work even if the ObjectTemplate does not have a … (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed asserts preventing JSReceiver properties in ObjectTemplate 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 | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index de5817188d95db5b9c63cb773f8592b0e08ad5ab..0a1262ffa062ce602c026262c300c97d998e9074 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -3523,22 +3523,33 @@ MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
Isolate* isolate, BuiltinArguments<BuiltinExtraArguments::kTarget> args) {
HandleScope scope(isolate);
Handle<JSFunction> function = args.target();
- DCHECK(args.receiver()->IsJSReceiver());
+ Handle<JSReceiver> receiver;
// TODO(ishell): turn this back to a DCHECK.
CHECK(function->shared()->IsApiFunction());
Handle<FunctionTemplateInfo> fun_data(
function->shared()->get_api_func_data(), isolate);
if (is_construct) {
- ASSIGN_RETURN_ON_EXCEPTION(
- isolate, fun_data,
- ApiNatives::ConfigureInstance(isolate, fun_data,
- Handle<JSObject>::cast(args.receiver())),
- Object);
+ DCHECK(args.receiver()->IsTheHole());
+ if (fun_data->instance_template()->IsUndefined()) {
+ v8::Local<ObjectTemplate> templ =
+ ObjectTemplate::New(reinterpret_cast<v8::Isolate*>(isolate),
+ ToApiHandle<v8::FunctionTemplate>(fun_data));
+ fun_data->set_instance_template(*Utils::OpenHandle(*templ));
+ }
+ Handle<ObjectTemplateInfo> instance_template(
+ ObjectTemplateInfo::cast(fun_data->instance_template()), isolate);
+ ASSIGN_RETURN_ON_EXCEPTION(isolate, receiver,
+ ApiNatives::InstantiateObject(instance_template),
+ Object);
+ args[0] = *receiver;
+ DCHECK_EQ(*receiver, *args.receiver());
+ } else {
+ DCHECK(args.receiver()->IsJSReceiver());
+ receiver = args.at<JSReceiver>(0);
}
if (!is_construct && !fun_data->accept_any_receiver()) {
- Handle<JSReceiver> receiver = args.at<JSReceiver>(0);
if (receiver->IsJSObject() && receiver->IsAccessCheckNeeded()) {
Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver);
if (!isolate->MayAccess(handle(isolate->context()), js_receiver)) {
@@ -3548,7 +3559,7 @@ MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
}
}
- Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, args[0]);
+ Object* raw_holder = fun_data->GetCompatibleReceiver(isolate, *receiver);
if (raw_holder->IsNull()) {
// This function cannot be called with the given receiver. Abort!
@@ -3592,7 +3603,7 @@ MUST_USE_RESULT MaybeHandle<Object> HandleApiCallHelper(
}
}
- return scope.CloseAndEscape(args.receiver());
+ return scope.CloseAndEscape(receiver);
}
} // namespace
« no previous file with comments | « src/bootstrapper.cc ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698