Commit 82ca5146 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

Harden isolate initialization

In the case of a corrupted snapshot we fall back to initializing the isolate
from scratch. Howver, we don't ship the full SetupIsolateDelegate. This causes
spurious failures during later initialization.

This CL mostly turns the DCHECKs in SetupIsolateDelegate into hard CHECKs making
it easier to spot these kind of failures.


Bug: chromium:767846
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng
Change-Id: Ibe8a5beece27433439b1b09412f6110be703ff86
Reviewed-on: https://chromium-review.googlesource.com/779189Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49533}
parent ffd36179
...@@ -8609,6 +8609,9 @@ Isolate* IsolateNewImpl(internal::Isolate* isolate, ...@@ -8609,6 +8609,9 @@ Isolate* IsolateNewImpl(internal::Isolate* isolate,
// TODO(jochen): Once we got rid of Isolate::Current(), we can remove this. // TODO(jochen): Once we got rid of Isolate::Current(), we can remove this.
Isolate::Scope isolate_scope(v8_isolate); Isolate::Scope isolate_scope(v8_isolate);
if (params.entry_hook || !i::Snapshot::Initialize(isolate)) { if (params.entry_hook || !i::Snapshot::Initialize(isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
CHECK_NULL(isolate->snapshot_blob());
base::ElapsedTimer timer; base::ElapsedTimer timer;
if (i::FLAG_profile_deserialization) timer.Start(); if (i::FLAG_profile_deserialization) timer.Start();
isolate->Init(nullptr); isolate->Init(nullptr);
......
...@@ -13,7 +13,7 @@ namespace v8 { ...@@ -13,7 +13,7 @@ namespace v8 {
namespace internal { namespace internal {
void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate) { void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate) {
DCHECK(!create_heap_objects_); CHECK(!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.
} }
...@@ -27,11 +27,11 @@ void SetupIsolateDelegate::SetupInterpreter( ...@@ -27,11 +27,11 @@ void SetupIsolateDelegate::SetupInterpreter(
<< std::endl; << std::endl;
} }
#endif #endif
DCHECK(interpreter->IsDispatchTableInitialized()); CHECK(interpreter->IsDispatchTableInitialized());
} }
bool SetupIsolateDelegate::SetupHeap(Heap* heap) { bool SetupIsolateDelegate::SetupHeap(Heap* heap) {
DCHECK(!create_heap_objects_); CHECK(!create_heap_objects_);
// No actual work to be done; heap will be deserialized from the snapshot. // No actual work to be done; heap will be deserialized from the snapshot.
return true; return true;
} }
......
...@@ -17,7 +17,7 @@ void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate) { ...@@ -17,7 +17,7 @@ void SetupIsolateDelegate::SetupBuiltins(Isolate* isolate) {
if (create_heap_objects_) { if (create_heap_objects_) {
SetupBuiltinsInternal(isolate); SetupBuiltinsInternal(isolate);
} else { } else {
DCHECK(isolate->snapshot_available()); CHECK(isolate->snapshot_available());
} }
} }
...@@ -26,7 +26,7 @@ void SetupIsolateDelegate::SetupInterpreter( ...@@ -26,7 +26,7 @@ void SetupIsolateDelegate::SetupInterpreter(
if (create_heap_objects_) { if (create_heap_objects_) {
interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter); interpreter::SetupInterpreter::InstallBytecodeHandlers(interpreter);
} else { } else {
DCHECK(interpreter->IsDispatchTableInitialized()); CHECK(interpreter->IsDispatchTableInitialized());
} }
} }
...@@ -34,7 +34,7 @@ bool SetupIsolateDelegate::SetupHeap(Heap* heap) { ...@@ -34,7 +34,7 @@ bool SetupIsolateDelegate::SetupHeap(Heap* heap) {
if (create_heap_objects_) { if (create_heap_objects_) {
return SetupHeapInternal(heap); return SetupHeapInternal(heap);
} else { } else {
DCHECK(heap->isolate()->snapshot_available()); CHECK(heap->isolate()->snapshot_available());
return true; return true;
} }
} }
......
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