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

Side by Side Diff: src/bootstrapper.h

Issue 1213203007: Create a internal, global native context used only for generated code stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 5 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
« no previous file with comments | « BUILD.gn ('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 9
10 namespace v8 { 10 namespace v8 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 cache_->set(length + 1, *shared); 54 cache_->set(length + 1, *shared);
55 Script::cast(shared->script())->set_type(Smi::FromInt(type_)); 55 Script::cast(shared->script())->set_type(Smi::FromInt(type_));
56 } 56 }
57 57
58 private: 58 private:
59 Script::Type type_; 59 Script::Type type_;
60 FixedArray* cache_; 60 FixedArray* cache_;
61 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache); 61 DISALLOW_COPY_AND_ASSIGN(SourceCodeCache);
62 }; 62 };
63 63
64 enum ContextType { FULL_CONTEXT, THIN_CONTEXT };
64 65
65 // The Boostrapper is the public interface for creating a JavaScript global 66 // The Boostrapper is the public interface for creating a JavaScript global
66 // context. 67 // context.
67 class Bootstrapper final { 68 class Bootstrapper final {
68 public: 69 public:
69 static void InitializeOncePerProcess(); 70 static void InitializeOncePerProcess();
70 static void TearDownExtensions(); 71 static void TearDownExtensions();
71 72
72 // Requires: Heap::SetUp has been called. 73 // Requires: Heap::SetUp has been called.
73 void Initialize(bool create_heap_objects); 74 void Initialize(bool create_heap_objects);
74 void TearDown(); 75 void TearDown();
75 76
76 // Creates a JavaScript Global Context with initial object graph. 77 // Creates a JavaScript Global Context with initial object graph.
77 // The returned value is a global handle casted to V8Environment*. 78 // The returned value is a global handle casted to V8Environment*.
78 Handle<Context> CreateEnvironment( 79 Handle<Context> CreateEnvironment(
79 MaybeHandle<JSGlobalProxy> maybe_global_proxy, 80 MaybeHandle<JSGlobalProxy> maybe_global_proxy,
80 v8::Local<v8::ObjectTemplate> global_object_template, 81 v8::Local<v8::ObjectTemplate> global_object_template,
81 v8::ExtensionConfiguration* extensions); 82 v8::ExtensionConfiguration* extensions,
83 ContextType context_type = FULL_CONTEXT);
84
85 bool CreateCodeStubContext(Isolate* isolate);
82 86
83 // Detach the environment from its outer global object. 87 // Detach the environment from its outer global object.
84 void DetachGlobal(Handle<Context> env); 88 void DetachGlobal(Handle<Context> env);
85 89
86 // Traverses the pointers for memory management. 90 // Traverses the pointers for memory management.
87 void Iterate(ObjectVisitor* v); 91 void Iterate(ObjectVisitor* v);
88 92
89 // Accessor for the native scripts source code. 93 // Accessor for the native scripts source code.
90 template <class Source> 94 template <class Source>
91 Handle<String> SourceLookup(int index); 95 Handle<String> SourceLookup(int index);
92 96
93 // Tells whether bootstrapping is active. 97 // Tells whether bootstrapping is active.
94 bool IsActive() const { return nesting_ != 0; } 98 bool IsActive() const { return nesting_ != 0; }
95 99
96 // Support for thread preemption. 100 // Support for thread preemption.
97 static int ArchiveSpacePerThread(); 101 static int ArchiveSpacePerThread();
98 char* ArchiveState(char* to); 102 char* ArchiveState(char* to);
99 char* RestoreState(char* from); 103 char* RestoreState(char* from);
100 void FreeThreadResources(); 104 void FreeThreadResources();
101 105
102 // Used for new context creation. 106 // Used for new context creation.
103 bool InstallExtensions(Handle<Context> native_context, 107 bool InstallExtensions(Handle<Context> native_context,
104 v8::ExtensionConfiguration* extensions); 108 v8::ExtensionConfiguration* extensions);
105 109
106 SourceCodeCache* extensions_cache() { return &extensions_cache_; } 110 SourceCodeCache* extensions_cache() { return &extensions_cache_; }
107 111
112 static bool CompileNative(Isolate* isolate, Vector<const char> name,
113 Handle<JSObject> receiver, Handle<String> source,
114 int argc, Handle<Object> argv[]);
115 static bool CompileBuiltin(Isolate* isolate, int index);
116 static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
117 static bool CompileExtraBuiltin(Isolate* isolate, int index);
118 static bool CompileCodeStubBuiltin(Isolate* isolate, int index);
119 static bool InstallCodeStubNatives(Isolate* isolate);
120
108 private: 121 private:
109 Isolate* isolate_; 122 Isolate* isolate_;
110 typedef int NestingCounterType; 123 typedef int NestingCounterType;
111 NestingCounterType nesting_; 124 NestingCounterType nesting_;
112 SourceCodeCache extensions_cache_; 125 SourceCodeCache extensions_cache_;
113 126
114 friend class BootstrapperActive; 127 friend class BootstrapperActive;
115 friend class Isolate; 128 friend class Isolate;
116 friend class NativesExternalStringResource; 129 friend class NativesExternalStringResource;
117 130
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 size_t length() const override { return length_; } 167 size_t length() const override { return length_; }
155 168
156 private: 169 private:
157 const char* data_; 170 const char* data_;
158 size_t length_; 171 size_t length_;
159 }; 172 };
160 173
161 }} // namespace v8::internal 174 }} // namespace v8::internal
162 175
163 #endif // V8_BOOTSTRAPPER_H_ 176 #endif // V8_BOOTSTRAPPER_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698