Commit b78511bd authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[runtime] Cleanup JSFunction creation in bootstrapper.

This is a preliminary step before we stop swapping maps in the bootstrapper
(strict/sloppy map with writable prototype <-> readonly prototype).

Bug: v8:6459
Change-Id: I120550c10e98a234e283d79a8d408096601c92af
Reviewed-on: https://chromium-review.googlesource.com/558879Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46403}
parent f447e678
This diff is collapsed.
...@@ -303,7 +303,6 @@ enum ContextLookupFlags { ...@@ -303,7 +303,6 @@ enum ContextLookupFlags {
V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map) \ V(PROXY_CALLABLE_MAP_INDEX, Map, proxy_callable_map) \
V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map) \ V(PROXY_CONSTRUCTOR_MAP_INDEX, Map, proxy_constructor_map) \
V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function) \ V(PROXY_FUNCTION_INDEX, JSFunction, proxy_function) \
V(PROXY_FUNCTION_MAP_INDEX, Map, proxy_function_map) \
V(PROXY_MAP_INDEX, Map, proxy_map) \ V(PROXY_MAP_INDEX, Map, proxy_map) \
V(PROMISE_GET_CAPABILITIES_EXECUTOR_SHARED_FUN, SharedFunctionInfo, \ V(PROMISE_GET_CAPABILITIES_EXECUTOR_SHARED_FUN, SharedFunctionInfo, \
promise_get_capabilities_executor_shared_fun) \ promise_get_capabilities_executor_shared_fun) \
...@@ -354,6 +353,8 @@ enum ContextLookupFlags { ...@@ -354,6 +353,8 @@ enum ContextLookupFlags {
V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \ V(STRICT_FUNCTION_MAP_INDEX, Map, strict_function_map) \
V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \ V(STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX, Map, \
strict_function_without_prototype_map) \ strict_function_without_prototype_map) \
V(STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX, Map, \
strict_function_with_readonly_prototype_map) \
V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \ V(GENERATOR_FUNCTION_MAP_INDEX, Map, generator_function_map) \
V(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map) \ V(ASYNC_GENERATOR_FUNCTION_MAP_INDEX, Map, async_generator_function_map) \
V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map) \ V(CLASS_FUNCTION_MAP_INDEX, Map, class_function_map) \
......
...@@ -1456,27 +1456,41 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map, ...@@ -1456,27 +1456,41 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
return function; return function;
} }
Handle<JSFunction> Factory::NewFunction(Handle<Map> map, Handle<String> name,
Handle<JSFunction> Factory::NewFunction(Handle<Map> map, MaybeHandle<Code> maybe_code) {
Handle<String> name,
MaybeHandle<Code> code) {
Handle<Context> context(isolate()->native_context()); Handle<Context> context(isolate()->native_context());
Handle<SharedFunctionInfo> info = Handle<SharedFunctionInfo> info =
NewSharedFunctionInfo(name, code, map->is_constructor()); NewSharedFunctionInfo(name, maybe_code, map->is_constructor());
// Proper language mode in shared function info will be set outside. // Proper language mode in shared function info will be set outside.
DCHECK(is_sloppy(info->language_mode())); DCHECK(is_sloppy(info->language_mode()));
DCHECK(!map->IsUndefined(isolate())); DCHECK(!map->IsUndefined(isolate()));
DCHECK( #ifdef DEBUG
map.is_identical_to(isolate()->sloppy_function_map()) || if (isolate()->bootstrapper()->IsActive()) {
map.is_identical_to(isolate()->sloppy_function_without_prototype_map()) || Handle<Code> code;
map.is_identical_to( bool has_code = maybe_code.ToHandle(&code);
isolate()->sloppy_function_with_readonly_prototype_map()) || DCHECK(
map.is_identical_to(isolate()->strict_function_map()) || // During bootstrapping some of these maps could be not created yet.
map.is_identical_to(isolate()->strict_function_without_prototype_map()) || (*map == context->get(Context::STRICT_FUNCTION_MAP_INDEX)) ||
// TODO(titzer): wasm_function_map() could be undefined here. ugly. (*map ==
(*map == context->get(Context::WASM_FUNCTION_MAP_INDEX)) || context->get(Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX)) ||
(*map == context->get(Context::NATIVE_FUNCTION_MAP_INDEX)) || (*map ==
map.is_identical_to(isolate()->proxy_function_map())); context->get(
Context::STRICT_FUNCTION_WITH_READONLY_PROTOTYPE_MAP_INDEX)) ||
// Check if it's a creation of an empty or Proxy function during
// bootstrapping.
(has_code && (code->builtin_index() == Builtins::kEmptyFunction ||
code->builtin_index() == Builtins::kProxyConstructor)));
} else {
DCHECK(
(*map == *isolate()->sloppy_function_map()) ||
(*map == *isolate()->sloppy_function_without_prototype_map()) ||
(*map == *isolate()->sloppy_function_with_readonly_prototype_map()) ||
(*map == *isolate()->strict_function_map()) ||
(*map == *isolate()->strict_function_without_prototype_map()) ||
(*map == *isolate()->wasm_function_map()) ||
(*map == *isolate()->native_function_map()));
}
#endif
return NewFunction(map, info, context); return NewFunction(map, info, context);
} }
...@@ -1528,10 +1542,7 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code, ...@@ -1528,10 +1542,7 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, Handle<Code> code,
prototype = NewFunctionPrototype(function); prototype = NewFunctionPrototype(function);
} }
} }
JSFunction::SetInitialMap(function, initial_map, prototype);
JSFunction::SetInitialMap(function, initial_map,
Handle<JSReceiver>::cast(prototype));
return function; return function;
} }
...@@ -1540,7 +1551,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name, ...@@ -1540,7 +1551,8 @@ Handle<JSFunction> Factory::NewFunction(Handle<String> name,
Handle<Code> code, Handle<Code> code,
InstanceType type, InstanceType type,
int instance_size) { int instance_size) {
return NewFunction(name, code, the_hole_value(), type, instance_size); DCHECK(isolate()->bootstrapper()->IsActive());
return NewFunction(name, code, the_hole_value(), type, instance_size, STRICT);
} }
......
...@@ -913,7 +913,8 @@ void WasmJs::Install(Isolate* isolate) { ...@@ -913,7 +913,8 @@ void WasmJs::Install(Isolate* isolate) {
// Setup WebAssembly // Setup WebAssembly
Handle<String> name = v8_str(isolate, "WebAssembly"); Handle<String> name = v8_str(isolate, "WebAssembly");
Handle<JSFunction> cons = factory->NewFunction(name); Handle<JSFunction> cons = factory->NewFunction(isolate->strict_function_map(),
name, MaybeHandle<Code>());
JSFunction::SetPrototype(cons, isolate->initial_object_prototype()); JSFunction::SetPrototype(cons, isolate->initial_object_prototype());
cons->shared()->set_instance_class_name(*name); cons->shared()->set_instance_class_name(*name);
Handle<JSObject> webassembly = factory->NewJSObject(cons, TENURED); Handle<JSObject> webassembly = factory->NewJSObject(cons, TENURED);
......
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