Commit b6c555bd authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

Add ApiNatives::InstantiateFunction that explicitly takes native context

This CL changes {CreateApiFunction} to take an explicit native context
to set on the newly created JSFunction. The CL also adds a new variant
of {ApiNatives::InstatiateFunction}, that takes a native context and passes
it through to {CreateApiFunction}.

This is a refactoring in preparation for a bugfix.
AccessorPairs can be instantiated lazily. At the time of
lazy instantiation, the current context does not necessarily match
the creation context of the holder of an AccessorPair.

Bug: chromium:986063, chromium:989909
Change-Id: Idea4b5052f2baff5c3d916f5ab8ed5017b60699b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1735308
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63063}
parent e0b3fbee
This diff is collapsed.
...@@ -24,6 +24,11 @@ class ApiNatives { ...@@ -24,6 +24,11 @@ class ApiNatives {
public: public:
static const int kInitialFunctionCacheSize = 256; static const int kInitialFunctionCacheSize = 256;
V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
Isolate* isolate, Handle<NativeContext> native_context,
Handle<FunctionTemplateInfo> data,
MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction( V8_WARN_UNUSED_RESULT static MaybeHandle<JSFunction> InstantiateFunction(
Handle<FunctionTemplateInfo> data, Handle<FunctionTemplateInfo> data,
MaybeHandle<Name> maybe_name = MaybeHandle<Name>()); MaybeHandle<Name> maybe_name = MaybeHandle<Name>());
...@@ -36,9 +41,9 @@ class ApiNatives { ...@@ -36,9 +41,9 @@ class ApiNatives {
Handle<ObjectTemplateInfo> data); Handle<ObjectTemplateInfo> data);
static Handle<JSFunction> CreateApiFunction( static Handle<JSFunction> CreateApiFunction(
Isolate* isolate, Handle<FunctionTemplateInfo> obj, Isolate* isolate, Handle<NativeContext> native_context,
Handle<Object> prototype, InstanceType type, Handle<FunctionTemplateInfo> obj, Handle<Object> prototype,
MaybeHandle<Name> name = MaybeHandle<Name>()); InstanceType type, MaybeHandle<Name> name = MaybeHandle<Name>());
static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info, static void AddDataProperty(Isolate* isolate, Handle<TemplateInfo> info,
Handle<Name> name, Handle<Object> value, Handle<Name> name, Handle<Object> value,
......
...@@ -1222,8 +1222,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals( ...@@ -1222,8 +1222,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals(
FunctionTemplateInfo::cast(js_global_object_template->constructor()), FunctionTemplateInfo::cast(js_global_object_template->constructor()),
isolate()); isolate());
js_global_object_function = ApiNatives::CreateApiFunction( js_global_object_function = ApiNatives::CreateApiFunction(
isolate(), js_global_object_constructor, factory()->the_hole_value(), isolate(), isolate()->native_context(), js_global_object_constructor,
JS_GLOBAL_OBJECT_TYPE); factory()->the_hole_value(), JS_GLOBAL_OBJECT_TYPE);
} }
js_global_object_function->initial_map().set_is_prototype_map(true); js_global_object_function->initial_map().set_is_prototype_map(true);
...@@ -1248,8 +1248,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals( ...@@ -1248,8 +1248,8 @@ Handle<JSGlobalObject> Genesis::CreateNewGlobals(
Handle<FunctionTemplateInfo> global_constructor( Handle<FunctionTemplateInfo> global_constructor(
FunctionTemplateInfo::cast(data->constructor()), isolate()); FunctionTemplateInfo::cast(data->constructor()), isolate());
global_proxy_function = ApiNatives::CreateApiFunction( global_proxy_function = ApiNatives::CreateApiFunction(
isolate(), global_constructor, factory()->the_hole_value(), isolate(), isolate()->native_context(), global_constructor,
JS_GLOBAL_PROXY_TYPE); factory()->the_hole_value(), JS_GLOBAL_PROXY_TYPE);
} }
global_proxy_function->initial_map().set_is_access_check_needed(true); global_proxy_function->initial_map().set_is_access_check_needed(true);
global_proxy_function->initial_map().set_may_have_interesting_symbols(true); global_proxy_function->initial_map().set_may_have_interesting_symbols(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment