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

Side by Side Diff: src/bootstrapper.h

Issue 2801073006: Decouple root visitors from object visitors. (Closed)
Patch Set: rebase Created 3 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
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/visitors.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 13
13 // A SourceCodeCache uses a FixedArray to store pairs of 14 // A SourceCodeCache uses a FixedArray to store pairs of
14 // (OneByteString*, JSFunction*), mapping names of native code files 15 // (OneByteString*, JSFunction*), mapping names of native code files
15 // (runtime.js, etc.) to precompiled functions. Instead of mapping 16 // (runtime.js, etc.) to precompiled functions. Instead of mapping
16 // names to functions it might make sense to let the JS2C tool 17 // names to functions it might make sense to let the JS2C tool
17 // generate an index for each native JS file. 18 // generate an index for each native JS file.
18 class SourceCodeCache final BASE_EMBEDDED { 19 class SourceCodeCache final BASE_EMBEDDED {
19 public: 20 public:
20 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { } 21 explicit SourceCodeCache(Script::Type type): type_(type), cache_(NULL) { }
21 22
22 void Initialize(Isolate* isolate, bool create_heap_objects) { 23 void Initialize(Isolate* isolate, bool create_heap_objects) {
23 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL; 24 cache_ = create_heap_objects ? isolate->heap()->empty_fixed_array() : NULL;
24 } 25 }
25 26
26 void Iterate(ObjectVisitor* v) { 27 void Iterate(RootVisitor* v) {
27 v->VisitPointer(bit_cast<Object**, FixedArray**>(&cache_)); 28 v->VisitRootPointer(Root::kExtensions,
29 bit_cast<Object**, FixedArray**>(&cache_));
28 } 30 }
29 31
30 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) { 32 bool Lookup(Vector<const char> name, Handle<SharedFunctionInfo>* handle) {
31 for (int i = 0; i < cache_->length(); i+=2) { 33 for (int i = 0; i < cache_->length(); i+=2) {
32 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i)); 34 SeqOneByteString* str = SeqOneByteString::cast(cache_->get(i));
33 if (str->IsUtf8EqualTo(name)) { 35 if (str->IsUtf8EqualTo(name)) {
34 *handle = Handle<SharedFunctionInfo>( 36 *handle = Handle<SharedFunctionInfo>(
35 SharedFunctionInfo::cast(cache_->get(i + 1))); 37 SharedFunctionInfo::cast(cache_->get(i + 1)));
36 return true; 38 return true;
37 } 39 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 GlobalContextType context_type = FULL_CONTEXT); 88 GlobalContextType context_type = FULL_CONTEXT);
87 89
88 Handle<JSGlobalProxy> NewRemoteContext( 90 Handle<JSGlobalProxy> NewRemoteContext(
89 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 91 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
90 v8::Local<v8::ObjectTemplate> global_object_template); 92 v8::Local<v8::ObjectTemplate> global_object_template);
91 93
92 // Detach the environment from its outer global object. 94 // Detach the environment from its outer global object.
93 void DetachGlobal(Handle<Context> env); 95 void DetachGlobal(Handle<Context> env);
94 96
95 // Traverses the pointers for memory management. 97 // Traverses the pointers for memory management.
96 void Iterate(ObjectVisitor* v); 98 void Iterate(RootVisitor* v);
97 99
98 // Accessor for the native scripts source code. 100 // Accessor for the native scripts source code.
99 template <class Source> 101 template <class Source>
100 Handle<String> SourceLookup(int index); 102 Handle<String> SourceLookup(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();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 176
175 private: 177 private:
176 const char* data_; 178 const char* data_;
177 size_t length_; 179 size_t length_;
178 }; 180 };
179 181
180 } // namespace internal 182 } // namespace internal
181 } // namespace v8 183 } // namespace v8
182 184
183 #endif // V8_BOOTSTRAPPER_H_ 185 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « src/api-arguments.h ('k') | src/bootstrapper.cc » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698