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

Side by Side Diff: src/isolate.cc

Issue 2310003: Create a new class v8::internal::Isolate in isolate.h/isolate.cc.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 10 years, 6 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
« no previous file with comments | « src/isolate.h ('k') | src/v8.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2006-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include <stdlib.h>
29
30 #include "v8.h"
31
32 #include "bootstrapper.h"
33 #include "debug.h"
34 #include "log.h"
35 #include "isolate.h"
36 #include "serialize.h"
37 #include "simulator.h"
38 #include "stub-cache.h"
39 #include "oprofile-agent.h"
40
41 namespace v8 {
42 namespace internal {
43
44
45 Isolate* Isolate::global_isolate = NULL;
46
47
48 void Isolate::InitOnce() {
49 }
50
51
52 Isolate* Isolate::Create(Deserializer* des) {
53 // While we're still building out support for isolates, only support
54 // one single global isolate.
55 ASSERT(global_isolate == NULL);
56 Isolate* new_isolate = new Isolate();
57 if (new_isolate->Init(des)) {
58 global_isolate = new_isolate;
59 return new_isolate;
60 } else {
61 delete new_isolate;
62 return NULL;
63 }
64 }
65
66
67 Isolate::Isolate() {
68 }
69
70
71 Isolate::~Isolate() {
72 }
73
74 bool Isolate::Init(Deserializer* des) {
75 bool create_heap_objects = des == NULL;
76
77 #ifdef DEBUG
78 // The initialization process does not handle memory exhaustion.
79 DisallowAllocationFailure disallow_allocation_failure;
80 #endif
81
82 // Enable logging before setting up the heap
83 Logger::Setup();
84
85 CpuProfiler::Setup();
86
87 // Setup the platform OS support.
88 OS::Setup();
89
90 // Initialize other runtime facilities
91 #if !V8_HOST_ARCH_ARM && V8_TARGET_ARCH_ARM
92 ::assembler::arm::Simulator::Initialize();
93 #endif
94
95 { // NOLINT
96 // Ensure that the thread has a valid stack guard. The v8::Locker object
97 // will ensure this too, but we don't have to use lockers if we are only
98 // using one thread.
99 ExecutionAccess lock;
100 StackGuard::InitThread(lock);
101 }
102
103 // Setup the object heap
104 ASSERT(!Heap::HasBeenSetup());
105 if (!Heap::Setup(create_heap_objects)) {
106 V8::SetFatalError();
107 return false;
108 }
109
110 Bootstrapper::Initialize(create_heap_objects);
111 Builtins::Setup(create_heap_objects);
112 Top::Initialize();
113
114 if (FLAG_preemption) {
115 v8::Locker locker;
116 v8::Locker::StartPreemption(100);
117 }
118
119 #ifdef ENABLE_DEBUGGER_SUPPORT
120 Debug::Setup(create_heap_objects);
121 #endif
122 StubCache::Initialize(create_heap_objects);
123
124 // If we are deserializing, read the state into the now-empty heap.
125 if (des != NULL) {
126 des->Deserialize();
127 StubCache::Clear();
128 }
129
130 // Deserializing may put strange things in the root array's copy of the
131 // stack guard.
132 Heap::SetStackLimits();
133
134 // Setup the CPU support. Must be done after heap setup and after
135 // any deserialization because we have to have the initial heap
136 // objects in place for creating the code object used for probing.
137 CPU::Setup();
138
139 OProfileAgent::Initialize();
140
141 // If we are deserializing, log non-function code objects and compiled
142 // functions found in the snapshot.
143 if (des != NULL && FLAG_log_code) {
144 HandleScope scope;
145 LOG(LogCodeObjects());
146 LOG(LogCompiledFunctions());
147 }
148
149 return true;
150 }
151
152
153 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | src/v8.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698