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

Side by Side Diff: src/bootstrapper.h

Issue 219233002: Cleanup bootstrapper, execution and factory modules. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Use of this source code is governed by a BSD-style license that can be
3 // modification, are permitted provided that the following conditions are 3 // found in the LICENSE file.
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 4
29 #ifndef V8_BOOTSTRAPPER_H_ 5 #ifndef V8_BOOTSTRAPPER_H_
30 #define V8_BOOTSTRAPPER_H_ 6 #define V8_BOOTSTRAPPER_H_
31 7
32 #include "allocation.h" 8 #include "factory.h"
33 9
34 namespace v8 { 10 namespace v8 {
35 namespace internal { 11 namespace internal {
36 12
37
38 // A SourceCodeCache uses a FixedArray to store pairs of 13 // A SourceCodeCache uses a FixedArray to store pairs of
39 // (AsciiString*, JSFunction*), mapping names of native code files 14 // (AsciiString*, JSFunction*), mapping names of native code files
40 // (runtime.js, etc.) to precompiled functions. Instead of mapping 15 // (runtime.js, etc.) to precompiled functions. Instead of mapping
41 // names to functions it might make sense to let the JS2C tool 16 // names to functions it might make sense to let the JS2C tool
42 // generate an index for each native JS file. 17 // generate an index for each native JS file.
43 class SourceCodeCache BASE_EMBEDDED { 18 class SourceCodeCache V8_FINAL BASE_EMBEDDED {
44 public: 19 public:
45 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } 20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
46 21
47 void Initialize(Isolate* isolate, bool create_heap_objects) { 22 void Initialize(Isolate* isolate, bool create_heap_objects) {
48 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; 23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL;
49 } 24 }
50 25
51 void Iterate(ObjectVisitor* v) { 26 void Iterate(ObjectVisitor* v) {
52 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_)); 27 v->VisitPointer(BitCast<Object**, FixedArray**>(&cache_));
53 } 28 }
(...skipping 27 matching lines...) Expand all
81 56
82 private: 57 private:
83 Script::Type type_; 58 Script::Type type_;
84 FixedArray* cache_; 59 FixedArray* cache_;
85 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); 60 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
86 }; 61 };
87 62
88 63
89 // The Boostrapper is the public interface for creating a JavaScript global 64 // The Boostrapper is the public interface for creating a JavaScript global
90 // context. 65 // context.
91 class Bootstrapper { 66 class Bootstrapper V8_FINAL {
92 public: 67 public:
93 static void InitializeOncePerProcess(); 68 static void InitializeOncePerProcess();
94 static void TearDownExtensions(); 69 static void TearDownExtensions();
95 70
96 // Requires: Heap::SetUp has been called. 71 // Requires: Heap::SetUp has been called.
97 void Initialize(bool create_heap_objects); 72 void Initialize(bool create_heap_objects);
98 void TearDown(); 73 void TearDown();
99 74
100 // Creates a JavaScript Global Context with initial object graph. 75 // Creates a JavaScript Global Context with initial object graph.
101 // The returned value is a global handle casted to V8Environment*. 76 // The returned value is a global handle casted to V8Environment*.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 static v8::Extension* free_buffer_extension_; 126 static v8::Extension* free_buffer_extension_;
152 static v8::Extension* gc_extension_; 127 static v8::Extension* gc_extension_;
153 static v8::Extension* externalize_string_extension_; 128 static v8::Extension* externalize_string_extension_;
154 static v8::Extension* statistics_extension_; 129 static v8::Extension* statistics_extension_;
155 static v8::Extension* trigger_failure_extension_; 130 static v8::Extension* trigger_failure_extension_;
156 131
157 DISALLOW_COPY_AND_ASSIGN(Bootstrapper); 132 DISALLOW_COPY_AND_ASSIGN(Bootstrapper);
158 }; 133 };
159 134
160 135
161 class BootstrapperActive BASE_EMBEDDED { 136 class BootstrapperActive V8_FINAL BASE_EMBEDDED {
162 public: 137 public:
163 explicit BootstrapperActive(Bootstrapper* bootstrapper) 138 explicit BootstrapperActive(Bootstrapper* bootstrapper)
164 : bootstrapper_(bootstrapper) { 139 : bootstrapper_(bootstrapper) {
165 ++bootstrapper_->nesting_; 140 ++bootstrapper_->nesting_;
166 } 141 }
167 142
168 ~BootstrapperActive() { 143 ~BootstrapperActive() {
169 --bootstrapper_->nesting_; 144 --bootstrapper_->nesting_;
170 } 145 }
171 146
172 private: 147 private:
173 Bootstrapper* bootstrapper_; 148 Bootstrapper* bootstrapper_;
174 149
175 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); 150 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive);
176 }; 151 };
177 152
178 153
179 class NativesExternalStringResource 154 class NativesExternalStringResource V8_FINAL
180 : public v8::String::ExternalAsciiStringResource { 155 : public v8::String::ExternalAsciiStringResource {
181 public: 156 public:
182 NativesExternalStringResource(Bootstrapper* bootstrapper, 157 NativesExternalStringResource(Bootstrapper* bootstrapper,
183 const char* source, 158 const char* source,
184 size_t length); 159 size_t length);
160 virtual const char* data() const V8_OVERRIDE { return data_; }
161 virtual size_t length() const V8_OVERRIDE { return length_; }
185 162
186 const char* data() const {
187 return data_;
188 }
189
190 size_t length() const {
191 return length_;
192 }
193 private: 163 private:
194 const char* data_; 164 const char* data_;
195 size_t length_; 165 size_t length_;
196 }; 166 };
197 167
198 }} // namespace v8::internal 168 }} // namespace v8::internal
199 169
200 #endif // V8_BOOTSTRAPPER_H_ 170 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « no previous file | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698