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

Side by Side Diff: src/bootstrapper.h

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « src/api-arguments.h ('k') | 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #ifndef V8_BOOTSTRAPPER_H_ 5 #ifndef V8_BOOTSTRAPPER_H_
6 #define V8_BOOTSTRAPPER_H_ 6 #define V8_BOOTSTRAPPER_H_
7 7
8 #include "src/factory.h" 8 #include "src/factory.h"
9 #include "src/snapshot/natives.h" 9 #include "src/snapshot/natives.h"
10 #include "src/visitors.h"
10 11
11 namespace v8 { 12 namespace v8 {
12 namespace internal { 13 namespace internal {
13 14
14 // A SourceCodeCache uses a FixedArray to store pairs of 15 // A SourceCodeCache uses a FixedArray to store pairs of
15 // (OneByteString*, JSFunction*), mapping names of native code files 16 // (OneByteString*, JSFunction*), mapping names of native code files
16 // (array.js, etc.) to precompiled functions. Instead of mapping 17 // (array.js, etc.) to precompiled functions. Instead of mapping
17 // names to functions it might make sense to let the JS2C tool 18 // names to functions it might make sense to let the JS2C tool
18 // generate an index for each native JS file. 19 // generate an index for each native JS file.
19 class SourceCodeCache final BASE_EMBEDDED { 20 class SourceCodeCache final BASE_EMBEDDED {
20 public: 21 public:
21 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } 22 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
22 23
23 void Initialize(Isolate* isolate, bool create_heap_objects) { 24 void Initialize(Isolate* isolate, bool create_heap_objects) {
24 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; 25 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL;
25 } 26 }
26 27
27 void Iterate(ObjectVisitor* v) { 28 void Iterate(RootVisitor* v) {
28 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); 29 v->VisitRootPointer(Root::kExtensions,
30 bit_cast<Object**, FixedArray**>(&cache_));
29 } 31 }
30 32
31 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { 33 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) {
32 for (int i = 0; i < cache_->length(); i+=2) { 34 for (int i = 0; i < cache_->length(); i+=2) {
33 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); 35 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i));
34 if (str->IsUtf8EqualTo(name)) { 36 if (str->IsUtf8EqualTo(name)) {
35 *handle = Handle<SharedFunctionInfo>( 37 *handle = Handle<SharedFunctionInfo>(
36 SharedFunctionInfo::cast(cache_->get(i + 1))); 38 SharedFunctionInfo::cast(cache_->get(i + 1)));
37 return true; 39 return true;
38 } 40 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 GlobalContextType context_type = FULL_CONTEXT); 89 GlobalContextType context_type = FULL_CONTEXT);
88 90
89 Handle<JSGlobalProxy> NewRemoteContext( 91 Handle<JSGlobalProxy> NewRemoteContext(
90 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 92 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
91 v8::Local<v8::ObjectTemplate> global_object_template); 93 v8::Local<v8::ObjectTemplate> global_object_template);
92 94
93 // Detach the environment from its outer global object. 95 // Detach the environment from its outer global object.
94 void DetachGlobal(Handle<Context> env); 96 void DetachGlobal(Handle<Context> env);
95 97
96 // Traverses the pointers for memory management. 98 // Traverses the pointers for memory management.
97 void Iterate(ObjectVisitor* v); 99 void Iterate(RootVisitor* v);
98 100
99 // Accessor for the native scripts source code. 101 // Accessor for the native scripts source code.
100 Handle<String> GetNativeSource(NativeType type, int index); 102 Handle<String> GetNativeSource(NativeType type, int index);
101 103
102 // Tells whether bootstrapping is active. 104 // Tells whether bootstrapping is active.
103 bool IsActive() const { return nesting_ != 0; } 105 bool IsActive() const { return nesting_ != 0; }
104 106
105 // Support for thread preemption. 107 // Support for thread preemption.
106 static int ArchiveSpacePerThread(); 108 static int ArchiveSpacePerThread();
107 char* ArchiveState(char* to); 109 char* ArchiveState(char* to);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 private: 162 private:
161 Bootstrapper* bootstrapper_; 163 Bootstrapper* bootstrapper_;
162 164
163 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive); 165 DISALLOW_COPY_AND_ASSIGN(BootstrapperActive);
164 }; 166 };
165 167
166 } // namespace internal 168 } // namespace internal
167 } // namespace v8 169 } // namespace v8
168 170
169 #endif // V8_BOOTSTRAPPER_H_ 171 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « src/api-arguments.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698