Commit d0225c83 authored by yangguo's avatar yangguo Committed by Commit bot

Native context: install JS builtins via container object.

Instead of installing them on the JS builtins object and later
grab them from there.

R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/1296163003

Cr-Commit-Position: refs/heads/master@{#30248}
parent 4adb8dca
......@@ -242,7 +242,6 @@ class Genesis BASE_EMBEDDED {
v8::RegisteredExtension* current,
ExtensionStates* extension_states);
static bool InstallSpecialObjects(Handle<Context> native_context);
bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
bool ConfigureApiObject(Handle<JSObject> object,
Handle<ObjectTemplateInfo> object_template);
bool ConfigureGlobalObjects(
......@@ -1869,6 +1868,24 @@ void Bootstrapper::ImportExperimentalNatives(Isolate* isolate,
#undef INSTALL_NATIVE
bool Bootstrapper::InstallJSBuiltins(Isolate* isolate,
Handle<JSObject> container) {
HandleScope scope(isolate);
Handle<JSBuiltinsObject> builtins = isolate->js_builtins_object();
for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
Handle<Object> function_object =
Object::GetProperty(isolate, container, Builtins::GetName(id))
.ToHandleChecked();
DCHECK(function_object->IsJSFunction());
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
builtins->set_javascript_builtin(id, *function);
}
return true;
}
#define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \
void Genesis::InitializeGlobal_##id() {}
......@@ -2098,7 +2115,6 @@ bool Genesis::InstallNatives(ContextType context_type) {
if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
DCHECK_EQ(builtin_index, Natives::GetIndex("runtime"));
if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false;
if (!InstallJSBuiltins(builtins)) return false;
// A thin context is ready at this point.
if (context_type == THIN_CONTEXT) return true;
......@@ -2908,19 +2924,6 @@ bool Genesis::InstallExtension(Isolate* isolate,
}
bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
HandleScope scope(isolate());
for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
Handle<Object> function_object = Object::GetProperty(
isolate(), builtins, Builtins::GetName(id)).ToHandleChecked();
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
builtins->set_javascript_builtin(id, *function);
}
return true;
}
bool Genesis::ConfigureGlobalObjects(
v8::Local<v8::ObjectTemplate> global_proxy_template) {
Handle<JSObject> global_proxy(
......
......@@ -121,6 +121,7 @@ class Bootstrapper final {
static void ImportNatives(Isolate* isolate, Handle<JSObject> container);
static void ImportExperimentalNatives(Isolate* isolate,
Handle<JSObject> container);
static bool InstallJSBuiltins(Isolate* isolate, Handle<JSObject> container);
private:
Isolate* isolate_;
......
This diff is collapsed.
......@@ -44,6 +44,16 @@ RUNTIME_FUNCTION(Runtime_ImportExperimentalToRuntime) {
}
RUNTIME_FUNCTION(Runtime_InstallJSBuiltins) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, container, 0);
RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
Bootstrapper::InstallJSBuiltins(isolate, container);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_Throw) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
......
......@@ -303,6 +303,7 @@ namespace internal {
F(CheckIsBootstrapping, 0, 1) \
F(ImportToRuntime, 1, 1) \
F(ImportExperimentalToRuntime, 1, 1) \
F(InstallJSBuiltins, 1, 1) \
F(Throw, 1, 1) \
F(ReThrow, 1, 1) \
F(UnwindAndFindExceptionHandler, 0, 1) \
......
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