1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "src/assembler.h"
8 #include "src/base/once.h"
9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h"
11 #include "src/compiler/pipeline.h"
12 #include "src/debug.h"
13 #include "src/deoptimizer.h"
14 #include "src/elements.h"
15 #include "src/frames.h"
16 #include "src/heap/store-buffer.h"
17 #include "src/heap-profiler.h"
18 #include "src/hydrogen.h"
19 #include "src/isolate.h"
20 #include "src/lithium-allocator.h"
21 #include "src/objects.h"
22 #include "src/runtime-profiler.h"
23 #include "src/sampler.h"
24 #include "src/serialize.h"
30 V8_DECLARE_ONCE(init_once);
32 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
33 v8::Platform* V8::platform_ = NULL;
36 bool V8::Initialize(Deserializer* des) {
37 InitializeOncePerProcess();
38 Isolate* isolate = Isolate::UncheckedCurrent();
39 if (isolate == NULL) return true;
40 if (isolate->IsDead()) return false;
41 if (isolate->IsInitialized()) return true;
43 return isolate->Init(des);
48 Bootstrapper::TearDownExtensions();
49 ElementsAccessor::TearDown();
50 LOperand::TearDownCaches();
51 compiler::Pipeline::TearDown();
52 ExternalReference::TearDownMathExpData();
53 RegisteredExtension::UnregisterAll();
54 Isolate::GlobalTearDown();
60 void V8::SetReturnAddressLocationResolver(
61 ReturnAddressLocationResolver resolver) {
62 StackFrame::SetReturnAddressLocationResolver(resolver);
66 void V8::InitializeOncePerProcessImpl() {
67 FlagList::EnforceFlagImplications();
69 if (FLAG_predictable && FLAG_random_seed == 0) {
70 // Avoid random seeds in predictable mode.
71 FLAG_random_seed = 12347;
74 if (FLAG_stress_compaction) {
75 FLAG_force_marking_deque_overflows = true;
76 FLAG_gc_global = true;
77 FLAG_max_semi_space_size = 1;
80 base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
83 CpuFeatures::Probe(false);
84 init_memcopy_functions();
85 // The custom exp implementation needs 16KB of lookup data; initialize it
87 init_fast_sqrt_function();
89 init_modulo_function();
91 ElementsAccessor::InitializeOncePerProcess();
92 LOperand::SetUpCaches();
93 compiler::Pipeline::SetUp();
94 SetUpJSCallerSavedCodeData();
95 ExternalReference::SetUp();
96 Bootstrapper::InitializeOncePerProcess();
100 void V8::InitializeOncePerProcess() {
101 base::CallOnce(&init_once, &InitializeOncePerProcessImpl);
105 void V8::InitializePlatform(v8::Platform* platform) {
108 platform_ = platform;
112 void V8::ShutdownPlatform() {
118 v8::Platform* V8::GetCurrentPlatform() {
123 } } // namespace v8::internal