Commit 0e5c107c authored by baixo's avatar baixo Committed by Commit bot

Ensure external snapshot is only set once.

BUG=421063

Review URL: https://codereview.chromium.org/746263002

Cr-Commit-Position: refs/heads/master@{#25481}
parent 009fe698
......@@ -197,20 +197,12 @@ static inline bool IsExecutionTerminatingCheck(i::Isolate* isolate) {
void V8::SetNativesDataBlob(StartupData* natives_blob) {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
i::SetNativesFromFile(natives_blob);
#else
CHECK(false);
#endif
i::V8::SetNativesBlob(natives_blob);
}
void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
i::SetSnapshotFromFile(snapshot_blob);
#else
CHECK(false);
#endif
i::V8::SetSnapshotBlob(snapshot_blob);
}
......
......@@ -18,10 +18,12 @@
#include "src/hydrogen.h"
#include "src/isolate.h"
#include "src/lithium-allocator.h"
#include "src/natives.h"
#include "src/objects.h"
#include "src/runtime-profiler.h"
#include "src/sampler.h"
#include "src/serialize.h"
#include "src/snapshot.h"
namespace v8 {
......@@ -29,6 +31,11 @@ namespace internal {
V8_DECLARE_ONCE(init_once);
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
V8_DECLARE_ONCE(init_natives_once);
V8_DECLARE_ONCE(init_snapshot_once);
#endif
v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
v8::Platform* V8::platform_ = NULL;
......@@ -117,4 +124,21 @@ v8::Platform* V8::GetCurrentPlatform() {
return platform_;
}
void V8::SetNativesBlob(StartupData* natives_blob) {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
base::CallOnce(&init_natives_once, &SetNativesFromFile, natives_blob);
#else
CHECK(false);
#endif
}
void V8::SetSnapshotBlob(StartupData* snapshot_blob) {
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
base::CallOnce(&init_snapshot_once, &SetSnapshotFromFile, snapshot_blob);
#else
CHECK(false);
#endif
}
} } // namespace v8::internal
......@@ -82,6 +82,9 @@ class V8 : public AllStatic {
static void ShutdownPlatform();
static v8::Platform* GetCurrentPlatform();
static void SetNativesBlob(StartupData* natives_blob);
static void SetSnapshotBlob(StartupData* snapshot_blob);
private:
static void InitializeOncePerProcessImpl();
static void InitializeOncePerProcess();
......
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