Reviewers: Yang,
Message:
Depends on previous CL https://codereview.chromium.org/1289603002
Description:
Add experimental, non-snapshotted V8 extras
Embedders would use these for features which must be able to be turned
off at runtime, despite being compiled into V8. They can be turned on
and off by the embedder using the --experimental_extras flag, e.g. via
v8::SetFlagsFromString.
[email protected]
BUG=https://code.google.com/p/chromium/issues/detail?id=507137
LOG=Y
Please review this at https://codereview.chromium.org/1284413002/
Base URL:
https://chromium.googlesource.com/v8/v8.git@non-experimental-extras
Affected files (+90, -1 lines):
M src/bootstrapper.h
M src/bootstrapper.cc
M src/flag-definitions.h
M src/heap/heap.h
M src/heap/heap.cc
M src/snapshot/natives.h
M tools/gyp/v8.gyp
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
c3e9d24e11ad0bbee5c6ea81df61bd6c1955ca5c..47dd6130668d634c3e79720951dfa0a3fbb4717b
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -43,6 +43,12 @@ FixedArray* GetCache<ExperimentalNatives>(Heap* heap) {
template <>
+FixedArray* GetCache<ExperimentalExtraNatives>(Heap* heap) {
+ return heap->experimental_extra_natives_source_cache();
+}
+
+
+template <>
FixedArray* GetCache<ExtraNatives>(Heap* heap) {
return heap->extra_natives_source_cache();
}
@@ -79,6 +85,8 @@ Handle<String> Bootstrapper::SourceLookup(int index) {
template Handle<String> Bootstrapper::SourceLookup<Natives>(int index);
template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>(
int index);
+template Handle<String>
Bootstrapper::SourceLookup<ExperimentalExtraNatives>(
+ int index);
template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int
index);
template Handle<String> Bootstrapper::SourceLookup<CodeStubNatives>(int
index);
@@ -149,6 +157,8 @@ void Bootstrapper::TearDown() {
DeleteNativeSources(isolate_->heap()->natives_source_cache());
DeleteNativeSources(isolate_->heap()->experimental_natives_source_cache());
DeleteNativeSources(isolate_->heap()->extra_natives_source_cache());
+ DeleteNativeSources(
+ isolate_->heap()->experimental_extra_natives_source_cache());
DeleteNativeSources(isolate_->heap()->code_stub_natives_source_cache());
extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical
}
@@ -239,6 +249,7 @@ class Genesis BASE_EMBEDDED {
Handle<JSFunction>* fun);
bool InstallExperimentalNatives();
bool InstallExtraNatives(ContextType context_type);
+ bool InstallExperimentalExtraNatives();
bool InstallDebuggerNatives();
void InstallBuiltinFunctionIds();
void InstallExperimentalBuiltinFunctionIds();
@@ -1559,6 +1570,21 @@ bool Bootstrapper::CompileExtraBuiltin(Isolate*
isolate, int index) {
}
+bool Bootstrapper::CompileExperimentalExtraBuiltin(Isolate* isolate,
+ int index) {
+ HandleScope scope(isolate);
+ Vector<const char> name = ExperimentalExtraNatives::GetScriptName(index);
+ Handle<String> source_code =
+
isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index);
+ Handle<Object> global = isolate->global_object();
+ Handle<Object> binding = isolate->extras_binding_object();
+ Handle<Object> args[] = {global, binding};
+ return Bootstrapper::CompileNative(
+ isolate, name,
Handle<JSObject>(isolate->native_context()->builtins()),
+ source_code, arraysize(args), args);
+}
+
+
bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) {
HandleScope scope(isolate);
Vector<const char> name = CodeStubNatives::GetScriptName(index);
@@ -2629,6 +2655,17 @@ bool Genesis::InstallExtraNatives(ContextType
context_type) {
}
+bool Genesis::InstallExperimentalExtraNatives() {
+ for (int i = ExperimentalExtraNatives::GetDebuggerCount();
+ i < ExperimentalExtraNatives::GetBuiltinsCount(); i++) {
+ if (!Bootstrapper::CompileExperimentalExtraBuiltin(isolate(), i))
+ return false;
+ }
+
+ return true;
+}
+
+
bool Genesis::InstallDebuggerNatives() {
for (int i = 0; i < Natives::GetDebuggerCount(); ++i) {
if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false;
@@ -3241,6 +3278,11 @@ Genesis::Genesis(Isolate* isolate,
if (!isolate->serializer_enabled()) {
InitializeExperimentalGlobal();
if (!InstallExperimentalNatives()) return;
+
+ if (FLAG_experimental_extras) {
+ if (!InstallExperimentalExtraNatives()) return;
+ }
+
// By now the utils object is useless and can be removed.
native_context()->set_natives_utils_object(
isolate->heap()->undefined_value());
Index: src/bootstrapper.h
diff --git a/src/bootstrapper.h b/src/bootstrapper.h
index
39d9e2dfc4724d9b12c3bf1ac367139f733c9718..1edae1c09f9c6cb87a943e10454b8b2f358c9d3f
100644
--- a/src/bootstrapper.h
+++ b/src/bootstrapper.h
@@ -115,6 +115,7 @@ class Bootstrapper final {
static bool CompileBuiltin(Isolate* isolate, int index);
static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
static bool CompileExtraBuiltin(Isolate* isolate, int index);
+ static bool CompileExperimentalExtraBuiltin(Isolate* isolate, int index);
static bool CompileCodeStubBuiltin(Isolate* isolate, int index);
static bool InstallCodeStubNatives(Isolate* isolate);
Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index
aebf72cf5c959d6d3a6ca7cc06db5f5630c19c41..65056638d4ddd72773197c82b597365db18b377a
100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -167,6 +167,9 @@ struct MaybeBoolFlag {
//
#define FLAG FLAG_FULL
+DEFINE_BOOL(experimental_extras, false,
+ "enable code compiled in via
v8_experimental_extra_library_files")
+
// Flags for language modes and experimental language features.
DEFINE_BOOL(use_strict, false, "enforce strict mode")
DEFINE_BOOL(use_strong, false, "enforce strong mode")
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
5597553b733e4524bf2329c53487c190cbf53ca6..cb498e5711e595bce3ed1f79e90b1f6787b2da93
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -3323,6 +3323,9 @@ void Heap::CreateInitialObjects() {
set_extra_natives_source_cache(
*factory->NewFixedArray(ExtraNatives::GetBuiltinsCount()));
+ set_experimental_extra_natives_source_cache(
+
*factory->NewFixedArray(ExperimentalExtraNatives::GetBuiltinsCount()));
+
set_code_stub_natives_source_cache(
*factory->NewFixedArray(CodeStubNatives::GetBuiltinsCount()));
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
162849414bb449d08f63ea44f3f1fb2f3ec94604..46ec9f725551598b33ed69e4155e26c19a5ca4de
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -162,6 +162,8 @@ namespace internal {
V(FixedArray,
experimental_natives_source_cache, \
ExperimentalNativesSourceCache) \
V(FixedArray, extra_natives_source_cache,
ExtraNativesSourceCache) \
+ V(FixedArray,
experimental_extra_natives_source_cache, \
+
ExperimentalExtraNativesSourceCache) \
V(FixedArray, code_stub_natives_source_cache,
CodeStubNativesSourceCache) \
V(Script, empty_script,
EmptyScript) \
V(NameDictionary, intrinsic_function_names,
IntrinsicFunctionNames) \
Index: src/snapshot/natives.h
diff --git a/src/snapshot/natives.h b/src/snapshot/natives.h
index
08bc40cf86464a0d51c3cafc31dcac299b5981bc..2a9369aa6246d5525142f31b672395be2f7431db
100644
--- a/src/snapshot/natives.h
+++ b/src/snapshot/natives.h
@@ -12,7 +12,15 @@ namespace v8 { class StartupData; } // Forward
declaration.
namespace v8 {
namespace internal {
-enum NativeType { CORE, CODE_STUB, EXPERIMENTAL, EXTRAS, D8, TEST };
+enum NativeType {
+ CORE,
+ CODE_STUB,
+ EXPERIMENTAL,
+ EXTRAS,
+ EXPERIMENTAL_EXTRAS,
+ D8,
+ TEST
+};
template <NativeType type>
class NativesCollection {
@@ -36,6 +44,7 @@ typedef NativesCollection<CORE> Natives;
typedef NativesCollection<CODE_STUB> CodeStubNatives;
typedef NativesCollection<EXPERIMENTAL> ExperimentalNatives;
typedef NativesCollection<EXTRAS> ExtraNatives;
+typedef NativesCollection<EXPERIMENTAL_EXTRAS> ExperimentalExtraNatives;
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
// Used for reading the natives at runtime. Implementation in
natives-empty.cc
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index
8ebc727dbebb066512227d845ed84d5e216d53fa..5357a7259f067121239557986eb66babb1a4fcce
100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -32,6 +32,7 @@
'v8_random_seed%': 314159265,
'embed_script%': "",
'v8_extra_library_files%': [],
+ 'v8_experimental_extra_library_files%': [],
'mksnapshot_exec':
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot<(EXECUTABLE_SUFFIX)',
},
'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
@@ -182,6 +183,7 @@
'<(SHARED_INTERMEDIATE_DIR)/code-stub-libraries.cc',
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
'<(INTERMEDIATE_DIR)/snapshot.cc',
],
'actions': [
@@ -228,6 +230,7 @@
'<(SHARED_INTERMEDIATE_DIR)/code-stub-libraries.cc',
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
'../../src/snapshot/snapshot-empty.cc',
],
'conditions': [
@@ -1826,6 +1829,7 @@
'libraries_code_stub_bin_file':
'<(SHARED_INTERMEDIATE_DIR)/libraries-code-stub.bin',
'libraries_experimental_bin_file':
'<(SHARED_INTERMEDIATE_DIR)/libraries-experimental.bin',
'libraries_extras_bin_file':
'<(SHARED_INTERMEDIATE_DIR)/libraries-extras.bin',
+ 'libraries_experimental_extras_bin_file':
'<(SHARED_INTERMEDIATE_DIR)/libraries-experimental-extras.bin',
},
'actions': [
{
@@ -1930,6 +1934,31 @@
}],
],
},
+ {
+ 'action_name': 'js2c_experimental_extras',
+ 'inputs': [
+ '../../tools/js2c.py',
+ '<@(v8_experimental_extra_library_files)',
+ ],
+ 'outputs': [
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
+ ],
+ 'action': [
+ 'python',
+ '../../tools/js2c.py',
+ '<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
+ 'EXPERIMENTAL_EXTRAS',
+ '<@(v8_experimental_extra_library_files)',
+ ],
+ 'conditions': [
+ [ 'v8_use_external_startup_data==1', {
+ 'outputs': ['<@(libraries_experimental_extras_bin_file)'],
+ 'action': [
+ '--startup_blob', '<@(libraries_experimental_extras_bin_file)',
+ ],
+ }],
+ ],
+ },
],
},
{
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.