Commit 2e23a0ec authored by yangguo's avatar yangguo Committed by Commit bot

[snapshot] full setup delegate should also be able to deserialize.

Also move the responsibility of marking builtins as initialized
to the deserializer.

R=jkummerow@chromium.org

Review-Url: https://codereview.chromium.org/2840493002
Cr-Original-Commit-Position: refs/heads/master@{#44802}
Committed: https://chromium.googlesource.com/v8/v8/+/a2b3a2fbc562584ec298dfe674c97662a125a59e
Review-Url: https://codereview.chromium.org/2840493002
Cr-Commit-Position: refs/heads/master@{#44884}
parent 9c47a061
...@@ -90,6 +90,12 @@ class Builtins { ...@@ -90,6 +90,12 @@ class Builtins {
bool is_initialized() const { return initialized_; } bool is_initialized() const { return initialized_; }
// Used by SetupIsolateDelegate and Deserializer.
void MarkInitialized() {
DCHECK(!initialized_);
initialized_ = true;
}
MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction( MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction(
Isolate* isolate, bool is_construct, Handle<HeapObject> function, Isolate* isolate, bool is_construct, Handle<HeapObject> function,
Handle<Object> receiver, int argc, Handle<Object> args[], Handle<Object> receiver, int argc, Handle<Object> args[],
...@@ -105,11 +111,6 @@ class Builtins { ...@@ -105,11 +111,6 @@ class Builtins {
private: private:
Builtins(); Builtins();
// Used by SetupIsolateDelegate.
void MarkInitialized() {
DCHECK(!initialized_);
initialized_ = true;
}
static void Generate_CallFunction(MacroAssembler* masm, static void Generate_CallFunction(MacroAssembler* masm,
ConvertReceiverMode mode, ConvertReceiverMode mode,
......
...@@ -16,7 +16,6 @@ void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate, ...@@ -16,7 +16,6 @@ void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate,
bool create_heap_objects) { bool create_heap_objects) {
DCHECK(!create_heap_objects); DCHECK(!create_heap_objects);
// No actual work to be done; builtins will be deserialized from the snapshot. // No actual work to be done; builtins will be deserialized from the snapshot.
isolate->builtins()->MarkInitialized();
} }
void SetupIsolateDelegate::SetupInterpreter( void SetupIsolateDelegate::SetupInterpreter(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "src/setup-isolate.h" #include "src/setup-isolate.h"
#include "src/base/logging.h" #include "src/base/logging.h"
#include "src/interpreter/interpreter.h"
#include "src/interpreter/setup-interpreter.h" #include "src/interpreter/setup-interpreter.h"
#include "src/isolate.h" #include "src/isolate.h"
...@@ -13,30 +14,20 @@ namespace internal { ...@@ -13,30 +14,20 @@ namespace internal {
void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate, void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate,
bool create_heap_objects) { bool create_heap_objects) {
#ifdef V8_GYP_BUILD
// Compatibility hack to keep the deprecated GYP build working.
if (create_heap_objects) { if (create_heap_objects) {
SetupBuiltinsInternal(isolate); SetupBuiltinsInternal(isolate);
} else { } else {
isolate->builtins()->MarkInitialized(); DCHECK(isolate->snapshot_available());
} }
return;
#endif
DCHECK(create_heap_objects);
SetupBuiltinsInternal(isolate);
} }
void SetupIsolateDelegate::SetupInterpreter( void SetupIsolateDelegate::SetupInterpreter(
interpreter::Interpreter* interpreter, bool create_heap_objects) { interpreter::Interpreter* interpreter, bool create_heap_objects) {
#ifdef V8_GYP_BUILD
// Compatibility hack to keep the deprecated GYP build working.
if (create_heap_objects) { if (create_heap_objects) {
interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter); interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter);
} else {
DCHECK(interpreter->IsDispatchTableInitialized());
} }
return;
#endif
DCHECK(create_heap_objects);
interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter);
} }
} // namespace internal } // namespace internal
......
...@@ -16,11 +16,12 @@ class Interpreter; ...@@ -16,11 +16,12 @@ class Interpreter;
// This class is an abstraction layer around initialization of components // This class is an abstraction layer around initialization of components
// that are either deserialized from the snapshot or generated from scratch. // that are either deserialized from the snapshot or generated from scratch.
// Currently this includes builtins and interpreter bytecode handlers. // Currently this includes builtins and interpreter bytecode handlers.
// There are three implementations to choose from (at link time): // There are two implementations to choose from at link time:
// - setup-isolate-deserialize.cc: always loads things from snapshot. // - setup-isolate-deserialize.cc: always loads things from snapshot.
// - setup-isolate-full.cc: always generates things. // - setup-isolate-full.cc: loads from snapshot or bootstraps from scratch,
// - setup-isolate-for-tests.cc: does the one or the other, controlled by // controlled by the |create_heap_objects| flag.
// the |create_heap_objects| flag. // For testing, the implementation in setup-isolate-for-tests.cc can be chosen
// to force the behavior of setup-isolate-full.cc at runtime.
// //
// The actual implementations of generation of builtins and handlers is in // The actual implementations of generation of builtins and handlers is in
// setup-builtins-internal.cc and setup-interpreter-internal.cc, and is // setup-builtins-internal.cc and setup-interpreter-internal.cc, and is
......
...@@ -92,6 +92,8 @@ void Deserializer::Deserialize(Isolate* isolate) { ...@@ -92,6 +92,8 @@ void Deserializer::Deserialize(Isolate* isolate) {
DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty()); DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty());
// Partial snapshot cache is not yet populated. // Partial snapshot cache is not yet populated.
DCHECK(isolate_->partial_snapshot_cache()->is_empty()); DCHECK(isolate_->partial_snapshot_cache()->is_empty());
// Builtins are not yet created.
DCHECK(!isolate_->builtins()->is_initialized());
{ {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
...@@ -121,6 +123,8 @@ void Deserializer::Deserialize(Isolate* isolate) { ...@@ -121,6 +123,8 @@ void Deserializer::Deserialize(Isolate* isolate) {
LOG_CODE_EVENT(isolate_, LogCodeObjects()); LOG_CODE_EVENT(isolate_, LogCodeObjects());
LOG_CODE_EVENT(isolate_, LogBytecodeHandlers()); LOG_CODE_EVENT(isolate_, LogBytecodeHandlers());
LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
isolate_->builtins()->MarkInitialized();
} }
MaybeHandle<Object> Deserializer::DeserializePartial( MaybeHandle<Object> Deserializer::DeserializePartial(
......
...@@ -62,8 +62,6 @@ class Snapshot : public AllStatic { ...@@ -62,8 +62,6 @@ class Snapshot : public AllStatic {
size_t context_index, size_t context_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer); v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
static bool HaveASnapshotToStartFrom(Isolate* isolate);
static bool HasContextSnapshot(Isolate* isolate, size_t index); static bool HasContextSnapshot(Isolate* isolate, size_t index);
static bool EmbedsScript(Isolate* isolate); static bool EmbedsScript(Isolate* isolate);
......
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