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

Unified Diff: src/bootstrapper.cc

Issue 1144163002: Revert of Use shared container to manage imports/exports. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/arraybuffer.js ('k') | src/collection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 08627e82768815093ecf02078678dcc22c72e26c..d93c465b47dd20b7e290bf8865b747d4dcb88469 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -307,14 +307,13 @@
FunctionMode function_mode);
void SetStrongFunctionInstanceDescriptor(Handle<Map> map);
- static bool CompileBuiltin(Isolate* isolate, int index);
+ static bool CompileBuiltin(Isolate* isolate, int index,
+ Handle<JSObject> shared);
static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
static bool CompileExtraBuiltin(Isolate* isolate, int index);
static bool CompileNative(Isolate* isolate, Vector<const char> name,
Handle<String> source, int argc,
Handle<Object> argv[]);
-
- static bool CallUtilsFunction(Isolate* isolate, const char* name);
static bool CompileExtension(Isolate* isolate, v8::Extension* extension);
@@ -1443,13 +1442,14 @@
}
-bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
+bool Genesis::CompileBuiltin(Isolate* isolate, int index,
+ Handle<JSObject> shared) {
Vector<const char> name = Natives::GetScriptName(index);
Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<Natives>(index);
Handle<Object> global = isolate->global_object();
- Handle<Object> utils = isolate->natives_utils_object();
- Handle<Object> args[] = {global, utils};
+ Handle<Object> exports = isolate->builtin_exports_object();
+ Handle<Object> args[] = {global, shared, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
}
@@ -1460,8 +1460,8 @@
Handle<String> source_code =
isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index);
Handle<Object> global = isolate->global_object();
- Handle<Object> utils = isolate->natives_utils_object();
- Handle<Object> args[] = {global, utils};
+ Handle<Object> exports = isolate->builtin_exports_object();
+ Handle<Object> args[] = {global, exports};
return CompileNative(isolate, name, source_code, arraysize(args), args);
}
@@ -1514,17 +1514,6 @@
// Then run the function wrapper.
return !Execution::Call(isolate, Handle<JSFunction>::cast(wrapper), receiver,
argc, argv).is_null();
-}
-
-
-bool Genesis::CallUtilsFunction(Isolate* isolate, const char* name) {
- Handle<JSObject> utils =
- Handle<JSObject>::cast(isolate->natives_utils_object());
- Handle<String> name_string =
- isolate->factory()->NewStringFromAsciiChecked(name);
- Handle<Object> fun = JSObject::GetDataProperty(utils, name_string);
- Handle<Object> receiver = isolate->factory()->undefined_value();
- return !Execution::Call(isolate, fun, receiver, 0, NULL).is_null();
}
@@ -1929,11 +1918,19 @@
native_context()->set_runtime_context(*context);
- // Set up the utils object as shared container between native scripts.
- Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function());
- JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16,
- "utils container for native scripts");
- native_context()->set_natives_utils_object(*utils);
+ // Set up shared object to set up cross references between native scripts.
+ // "shared" is used for cross references between native scripts that are part
+ // of the snapshot. "builtin_exports" is used for experimental natives.
+ Handle<JSObject> shared =
+ factory()->NewJSObject(isolate()->object_function());
+ JSObject::NormalizeProperties(shared, CLEAR_INOBJECT_PROPERTIES, 16,
+ "container to share between native scripts");
+
+ Handle<JSObject> builtin_exports =
+ factory()->NewJSObject(isolate()->object_function());
+ JSObject::NormalizeProperties(builtin_exports, CLEAR_INOBJECT_PROPERTIES, 16,
+ "container to export to experimental natives");
+ native_context()->set_builtin_exports_object(*builtin_exports);
Handle<JSObject> extras_exports =
factory()->NewJSObject(isolate()->object_function());
@@ -1942,8 +1939,8 @@
native_context()->set_extras_exports_object(*extras_exports);
if (FLAG_expose_natives_as != NULL) {
- Handle<String> utils_key = factory()->NewStringFromAsciiChecked("utils");
- JSObject::AddProperty(builtins, utils_key, utils, NONE);
+ Handle<String> shared_key = factory()->NewStringFromAsciiChecked("shared");
+ JSObject::AddProperty(builtins, shared_key, shared, NONE);
}
{ // -- S c r i p t
@@ -2119,12 +2116,12 @@
// transition easy to trap. Moreover, they rarely are smi-only.
{
HandleScope scope(isolate());
- Handle<JSObject> utils =
- Handle<JSObject>::cast(isolate()->natives_utils_object());
- Handle<JSFunction> array_function =
- InstallInternalArray(utils, "InternalArray", FAST_HOLEY_ELEMENTS);
+ Handle<JSObject> builtin_exports =
+ Handle<JSObject>::cast(isolate()->builtin_exports_object());
+ Handle<JSFunction> array_function = InstallInternalArray(
+ builtin_exports, "InternalArray", FAST_HOLEY_ELEMENTS);
native_context()->set_internal_array_function(*array_function);
- InstallInternalArray(utils, "InternalPackedArray", FAST_ELEMENTS);
+ InstallInternalArray(builtin_exports, "InternalPackedArray", FAST_ELEMENTS);
}
{ // -- S e t I t e r a t o r
@@ -2224,15 +2221,16 @@
#undef INSTALL_PUBLIC_SYMBOL
}
+ // Install natives. Everything exported to experimental natives is also
+ // shared to regular natives.
+ TransferNamedProperties(builtin_exports, shared);
int i = Natives::GetDebuggerCount();
- if (!CompileBuiltin(isolate(), i)) return false;
+ if (!CompileBuiltin(isolate(), i, shared)) return false;
if (!InstallJSBuiltins(builtins)) return false;
for (++i; i < Natives::GetBuiltinsCount(); ++i) {
- if (!CompileBuiltin(isolate(), i)) return false;
- }
-
- if (!CallUtilsFunction(isolate(), "PostNatives")) return false;
+ if (!CompileBuiltin(isolate(), i, shared)) return false;
+ }
InstallNativeFunctions();
@@ -2546,8 +2544,9 @@
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
JSObject::AddProperty(Error, name, stack_trace_limit, NONE);
- // By now the utils object is useless and can be removed.
- native_context->set_natives_utils_object(*factory->undefined_value());
+ Handle<Object> builtin_exports(native_context->builtin_exports_object(),
+ isolate);
+ native_context->set_builtin_exports_object(Smi::FromInt(0));
// Expose the natives in global if a name for it is specified.
if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
@@ -2557,6 +2556,9 @@
if (natives_key->AsArrayIndex(&dummy_index)) return true;
Handle<JSBuiltinsObject> natives(global->builtins());
JSObject::AddProperty(global, natives_key, natives, DONT_ENUM);
+ Handle<String> builtin_exports_key =
+ factory->NewStringFromAsciiChecked("builtin_exports");
+ JSObject::AddProperty(natives, builtin_exports_key, builtin_exports, NONE);
}
// Expose the stack trace symbol to native JS.
« no previous file with comments | « src/arraybuffer.js ('k') | src/collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698