[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: a2b3a2fbc5
Review-Url: https://codereview.chromium.org/2840493002
Cr-Commit-Position: refs/heads/master@{#44884}
This commit is contained in:
yangguo 2017-04-26 03:44:44 -07:00 committed by Commit bot
parent 9c47a061cf
commit 2e23a0eca4
6 changed files with 19 additions and 25 deletions

View File

@ -90,6 +90,12 @@ class Builtins {
bool is_initialized() const { return initialized_; }
// Used by SetupIsolateDelegate and Deserializer.
void MarkInitialized() {
DCHECK(!initialized_);
initialized_ = true;
}
MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction(
Isolate* isolate, bool is_construct, Handle<HeapObject> function,
Handle<Object> receiver, int argc, Handle<Object> args[],
@ -105,11 +111,6 @@ class Builtins {
private:
Builtins();
// Used by SetupIsolateDelegate.
void MarkInitialized() {
DCHECK(!initialized_);
initialized_ = true;
}
static void Generate_CallFunction(MacroAssembler* masm,
ConvertReceiverMode mode,

View File

@ -16,7 +16,6 @@ void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate,
bool create_heap_objects) {
DCHECK(!create_heap_objects);
// No actual work to be done; builtins will be deserialized from the snapshot.
isolate->builtins()->MarkInitialized();
}
void SetupIsolateDelegate::SetupInterpreter(

View File

@ -5,6 +5,7 @@
#include "src/setup-isolate.h"
#include "src/base/logging.h"
#include "src/interpreter/interpreter.h"
#include "src/interpreter/setup-interpreter.h"
#include "src/isolate.h"
@ -13,30 +14,20 @@ namespace internal {
void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate,
bool create_heap_objects) {
#ifdef V8_GYP_BUILD
// Compatibility hack to keep the deprecated GYP build working.
if (create_heap_objects) {
SetupBuiltinsInternal(isolate);
} else {
isolate->builtins()->MarkInitialized();
DCHECK(isolate->snapshot_available());
}
return;
#endif
DCHECK(create_heap_objects);
SetupBuiltinsInternal(isolate);
}
void SetupIsolateDelegate::SetupInterpreter(
interpreter::Interpreter* interpreter, bool create_heap_objects) {
#ifdef V8_GYP_BUILD
// Compatibility hack to keep the deprecated GYP build working.
if (create_heap_objects) {
interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter);
} else {
DCHECK(interpreter->IsDispatchTableInitialized());
}
return;
#endif
DCHECK(create_heap_objects);
interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter);
}
} // namespace internal

View File

@ -16,11 +16,12 @@ class Interpreter;
// This class is an abstraction layer around initialization of components
// that are either deserialized from the snapshot or generated from scratch.
// 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-full.cc: always generates things.
// - setup-isolate-for-tests.cc: does the one or the other, controlled by
// the |create_heap_objects| flag.
// - setup-isolate-full.cc: loads from snapshot or bootstraps from scratch,
// controlled by 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
// setup-builtins-internal.cc and setup-interpreter-internal.cc, and is

View File

@ -92,6 +92,8 @@ void Deserializer::Deserialize(Isolate* isolate) {
DCHECK(isolate_->handle_scope_implementer()->blocks()->is_empty());
// Partial snapshot cache is not yet populated.
DCHECK(isolate_->partial_snapshot_cache()->is_empty());
// Builtins are not yet created.
DCHECK(!isolate_->builtins()->is_initialized());
{
DisallowHeapAllocation no_gc;
@ -121,6 +123,8 @@ void Deserializer::Deserialize(Isolate* isolate) {
LOG_CODE_EVENT(isolate_, LogCodeObjects());
LOG_CODE_EVENT(isolate_, LogBytecodeHandlers());
LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
isolate_->builtins()->MarkInitialized();
}
MaybeHandle<Object> Deserializer::DeserializePartial(

View File

@ -62,8 +62,6 @@ class Snapshot : public AllStatic {
size_t context_index,
v8::DeserializeEmbedderFieldsCallback embedder_fields_deserializer);
static bool HaveASnapshotToStartFrom(Isolate* isolate);
static bool HasContextSnapshot(Isolate* isolate, size_t index);
static bool EmbedsScript(Isolate* isolate);