Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: src/v8.cc

Issue 345903004: Split out libplatform into a separate libary (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "src/debug.h" 11 #include "src/debug.h"
12 #include "src/deoptimizer.h" 12 #include "src/deoptimizer.h"
13 #include "src/elements.h" 13 #include "src/elements.h"
14 #include "src/frames.h" 14 #include "src/frames.h"
15 #include "src/heap-profiler.h" 15 #include "src/heap-profiler.h"
16 #include "src/hydrogen.h" 16 #include "src/hydrogen.h"
17 #include "src/isolate.h" 17 #include "src/isolate.h"
18 #ifdef V8_USE_DEFAULT_PLATFORM
19 #include "src/libplatform/default-platform.h"
20 #endif
21 #include "src/lithium-allocator.h" 18 #include "src/lithium-allocator.h"
22 #include "src/objects.h" 19 #include "src/objects.h"
23 #include "src/runtime-profiler.h" 20 #include "src/runtime-profiler.h"
24 #include "src/sampler.h" 21 #include "src/sampler.h"
25 #include "src/serialize.h" 22 #include "src/serialize.h"
26 #include "src/store-buffer.h" 23 #include "src/store-buffer.h"
27 24
28 namespace v8 { 25 namespace v8 {
29 namespace internal { 26 namespace internal {
30 27
31 V8_DECLARE_ONCE(init_once); 28 V8_DECLARE_ONCE(init_once);
32 29
33 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL; 30 v8::ArrayBuffer::Allocator* V8::array_buffer_allocator_ = NULL;
34 v8::Platform* V8::platform_ = NULL; 31 v8::Platform* V8::platform_ = NULL;
35 32
36 33
37 bool V8::Initialize(Deserializer* des) { 34 bool V8::Initialize(Deserializer* des) {
38 InitializeOncePerProcess(); 35 InitializeOncePerProcess();
39 Isolate* isolate = Isolate::UncheckedCurrent(); 36 Isolate* isolate = Isolate::UncheckedCurrent();
40 if (isolate == NULL) return true; 37 if (isolate == NULL) return true;
41 if (isolate->IsDead()) return false; 38 if (isolate->IsDead()) return false;
42 if (isolate->IsInitialized()) return true; 39 if (isolate->IsInitialized()) return true;
43 40
44 #ifdef V8_USE_DEFAULT_PLATFORM
45 platform::DefaultPlatform* platform =
46 static_cast<platform::DefaultPlatform*>(platform_);
47 platform->SetThreadPoolSize(isolate->max_available_threads());
48 // We currently only start the threads early, if we know that we'll use them.
49 if (FLAG_job_based_sweeping) platform->EnsureInitialized();
50 #endif
51
52 return isolate->Init(des); 41 return isolate->Init(des);
53 } 42 }
54 43
55 44
56 void V8::TearDown() { 45 void V8::TearDown() {
57 Bootstrapper::TearDownExtensions(); 46 Bootstrapper::TearDownExtensions();
58 ElementsAccessor::TearDown(); 47 ElementsAccessor::TearDown();
59 LOperand::TearDownCaches(); 48 LOperand::TearDownCaches();
60 ExternalReference::TearDownMathExpData(); 49 ExternalReference::TearDownMathExpData();
61 RegisteredExtension::UnregisterAll(); 50 RegisteredExtension::UnregisterAll();
62 Isolate::GlobalTearDown(); 51 Isolate::GlobalTearDown();
63 52
64 Sampler::TearDown(); 53 Sampler::TearDown();
65
66 #ifdef V8_USE_DEFAULT_PLATFORM
67 platform::DefaultPlatform* platform =
68 static_cast<platform::DefaultPlatform*>(platform_);
69 platform_ = NULL;
70 delete platform;
71 #endif
72 } 54 }
73 55
74 56
75 void V8::SetReturnAddressLocationResolver( 57 void V8::SetReturnAddressLocationResolver(
76 ReturnAddressLocationResolver resolver) { 58 ReturnAddressLocationResolver resolver) {
77 StackFrame::SetReturnAddressLocationResolver(resolver); 59 StackFrame::SetReturnAddressLocationResolver(resolver);
78 } 60 }
79 61
80 62
81 void V8::InitializeOncePerProcessImpl() { 63 void V8::InitializeOncePerProcessImpl() {
82 FlagList::EnforceFlagImplications(); 64 FlagList::EnforceFlagImplications();
83 65
84 if (FLAG_predictable && FLAG_random_seed == 0) { 66 if (FLAG_predictable && FLAG_random_seed == 0) {
85 // Avoid random seeds in predictable mode. 67 // Avoid random seeds in predictable mode.
86 FLAG_random_seed = 12347; 68 FLAG_random_seed = 12347;
87 } 69 }
88 70
89 if (FLAG_stress_compaction) { 71 if (FLAG_stress_compaction) {
90 FLAG_force_marking_deque_overflows = true; 72 FLAG_force_marking_deque_overflows = true;
91 FLAG_gc_global = true; 73 FLAG_gc_global = true;
92 FLAG_max_semi_space_size = 1; 74 FLAG_max_semi_space_size = 1;
93 } 75 }
94 76
95 base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); 77 base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap);
96 78
97 #ifdef V8_USE_DEFAULT_PLATFORM
98 platform_ = new platform::DefaultPlatform;
99 #endif
100 Sampler::SetUp(); 79 Sampler::SetUp();
101 CpuFeatures::Probe(false); 80 CpuFeatures::Probe(false);
102 init_memcopy_functions(); 81 init_memcopy_functions();
103 // The custom exp implementation needs 16KB of lookup data; initialize it 82 // The custom exp implementation needs 16KB of lookup data; initialize it
104 // on demand. 83 // on demand.
105 init_fast_sqrt_function(); 84 init_fast_sqrt_function();
106 #ifdef _WIN64 85 #ifdef _WIN64
107 init_modulo_function(); 86 init_modulo_function();
108 #endif 87 #endif
109 ElementsAccessor::InitializeOncePerProcess(); 88 ElementsAccessor::InitializeOncePerProcess();
(...skipping 21 matching lines...) Expand all
131 platform_ = NULL; 110 platform_ = NULL;
132 } 111 }
133 112
134 113
135 v8::Platform* V8::GetCurrentPlatform() { 114 v8::Platform* V8::GetCurrentPlatform() {
136 ASSERT(platform_); 115 ASSERT(platform_);
137 return platform_; 116 return platform_;
138 } 117 }
139 118
140 } } // namespace v8::internal 119 } } // namespace v8::internal
OLDNEW
« samples/process.cc ('K') | « src/mksnapshot.cc ('k') | test/cctest/cctest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698