OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/base/once.h" | 8 #include "src/base/once.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 | 36 |
37 bool V8::Initialize(Deserializer* des) { | 37 bool V8::Initialize(Deserializer* des) { |
38 InitializeOncePerProcess(); | 38 InitializeOncePerProcess(); |
39 Isolate* isolate = Isolate::UncheckedCurrent(); | 39 Isolate* isolate = Isolate::UncheckedCurrent(); |
40 if (isolate == NULL) return true; | 40 if (isolate == NULL) return true; |
41 if (isolate->IsDead()) return false; | 41 if (isolate->IsDead()) return false; |
42 if (isolate->IsInitialized()) return true; | 42 if (isolate->IsInitialized()) return true; |
43 | 43 |
44 #ifdef V8_USE_DEFAULT_PLATFORM | 44 #ifdef V8_USE_DEFAULT_PLATFORM |
45 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); | 45 platform::DefaultPlatform* platform = |
| 46 static_cast<platform::DefaultPlatform*>(platform_); |
46 platform->SetThreadPoolSize(isolate->max_available_threads()); | 47 platform->SetThreadPoolSize(isolate->max_available_threads()); |
47 // We currently only start the threads early, if we know that we'll use them. | 48 // We currently only start the threads early, if we know that we'll use them. |
48 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); | 49 if (FLAG_job_based_sweeping) platform->EnsureInitialized(); |
49 #endif | 50 #endif |
50 | 51 |
51 return isolate->Init(des); | 52 return isolate->Init(des); |
52 } | 53 } |
53 | 54 |
54 | 55 |
55 void V8::TearDown() { | 56 void V8::TearDown() { |
56 Bootstrapper::TearDownExtensions(); | 57 Bootstrapper::TearDownExtensions(); |
57 ElementsAccessor::TearDown(); | 58 ElementsAccessor::TearDown(); |
58 LOperand::TearDownCaches(); | 59 LOperand::TearDownCaches(); |
59 ExternalReference::TearDownMathExpData(); | 60 ExternalReference::TearDownMathExpData(); |
60 RegisteredExtension::UnregisterAll(); | 61 RegisteredExtension::UnregisterAll(); |
61 Isolate::GlobalTearDown(); | 62 Isolate::GlobalTearDown(); |
62 | 63 |
63 Sampler::TearDown(); | 64 Sampler::TearDown(); |
64 | 65 |
65 #ifdef V8_USE_DEFAULT_PLATFORM | 66 #ifdef V8_USE_DEFAULT_PLATFORM |
66 DefaultPlatform* platform = static_cast<DefaultPlatform*>(platform_); | 67 platform::DefaultPlatform* platform = |
| 68 static_cast<platform::DefaultPlatform*>(platform_); |
67 platform_ = NULL; | 69 platform_ = NULL; |
68 delete platform; | 70 delete platform; |
69 #endif | 71 #endif |
70 } | 72 } |
71 | 73 |
72 | 74 |
73 void V8::SetReturnAddressLocationResolver( | 75 void V8::SetReturnAddressLocationResolver( |
74 ReturnAddressLocationResolver resolver) { | 76 ReturnAddressLocationResolver resolver) { |
75 StackFrame::SetReturnAddressLocationResolver(resolver); | 77 StackFrame::SetReturnAddressLocationResolver(resolver); |
76 } | 78 } |
77 | 79 |
78 | 80 |
79 void V8::InitializeOncePerProcessImpl() { | 81 void V8::InitializeOncePerProcessImpl() { |
80 FlagList::EnforceFlagImplications(); | 82 FlagList::EnforceFlagImplications(); |
81 | 83 |
82 if (FLAG_predictable && FLAG_random_seed == 0) { | 84 if (FLAG_predictable && FLAG_random_seed == 0) { |
83 // Avoid random seeds in predictable mode. | 85 // Avoid random seeds in predictable mode. |
84 FLAG_random_seed = 12347; | 86 FLAG_random_seed = 12347; |
85 } | 87 } |
86 | 88 |
87 if (FLAG_stress_compaction) { | 89 if (FLAG_stress_compaction) { |
88 FLAG_force_marking_deque_overflows = true; | 90 FLAG_force_marking_deque_overflows = true; |
89 FLAG_gc_global = true; | 91 FLAG_gc_global = true; |
90 FLAG_max_semi_space_size = 1; | 92 FLAG_max_semi_space_size = 1; |
91 } | 93 } |
92 | 94 |
93 base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); | 95 base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); |
94 | 96 |
95 #ifdef V8_USE_DEFAULT_PLATFORM | 97 #ifdef V8_USE_DEFAULT_PLATFORM |
96 platform_ = new DefaultPlatform; | 98 platform_ = new platform::DefaultPlatform; |
97 #endif | 99 #endif |
98 Sampler::SetUp(); | 100 Sampler::SetUp(); |
99 CpuFeatures::Probe(false); | 101 CpuFeatures::Probe(false); |
100 init_memcopy_functions(); | 102 init_memcopy_functions(); |
101 // The custom exp implementation needs 16KB of lookup data; initialize it | 103 // The custom exp implementation needs 16KB of lookup data; initialize it |
102 // on demand. | 104 // on demand. |
103 init_fast_sqrt_function(); | 105 init_fast_sqrt_function(); |
104 #ifdef _WIN64 | 106 #ifdef _WIN64 |
105 init_modulo_function(); | 107 init_modulo_function(); |
106 #endif | 108 #endif |
(...skipping 22 matching lines...) Expand all Loading... |
129 platform_ = NULL; | 131 platform_ = NULL; |
130 } | 132 } |
131 | 133 |
132 | 134 |
133 v8::Platform* V8::GetCurrentPlatform() { | 135 v8::Platform* V8::GetCurrentPlatform() { |
134 ASSERT(platform_); | 136 ASSERT(platform_); |
135 return platform_; | 137 return platform_; |
136 } | 138 } |
137 | 139 |
138 } } // namespace v8::internal | 140 } } // namespace v8::internal |
OLD | NEW |