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

Side by Side Diff: src/bootstrapper.cc

Issue 1284413002: Add experimental, non-snapshotted V8 extras (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@non-experimental-extras
Patch Set: Missing gn entries Created 5 years, 4 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/bootstrapper.h ('k') | src/flag-definitions.h » ('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 #include "src/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api-natives.h" 8 #include "src/api-natives.h"
9 #include "src/base/utils/random-number-generator.h" 9 #include "src/base/utils/random-number-generator.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index), 45 Handle<Object> cached_source(Source::GetSourceCache(heap)->get(index),
46 isolate_); 46 isolate_);
47 return Handle<String>::cast(cached_source); 47 return Handle<String>::cast(cached_source);
48 } 48 }
49 49
50 50
51 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index); 51 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index);
52 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>( 52 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>(
53 int index); 53 int index);
54 template Handle<String> Bootstrapper::SourceLookup<ExperimentalExtraNatives>(
55 int index);
54 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index); 56 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index);
55 template Handle<String> Bootstrapper::SourceLookup<CodeStubNatives>(int index); 57 template Handle<String> Bootstrapper::SourceLookup<CodeStubNatives>(int index);
56 58
57 59
58 void Bootstrapper::Initialize(bool create_heap_objects) { 60 void Bootstrapper::Initialize(bool create_heap_objects) {
59 extensions_cache_.Initialize(isolate_, create_heap_objects); 61 extensions_cache_.Initialize(isolate_, create_heap_objects);
60 } 62 }
61 63
62 64
63 static const char* GCFunctionName() { 65 static const char* GCFunctionName() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 116 }
115 } 117 }
116 } 118 }
117 } 119 }
118 120
119 121
120 void Bootstrapper::TearDown() { 122 void Bootstrapper::TearDown() {
121 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap())); 123 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap()));
122 DeleteNativeSources(ExperimentalNatives::GetSourceCache(isolate_->heap())); 124 DeleteNativeSources(ExperimentalNatives::GetSourceCache(isolate_->heap()));
123 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap())); 125 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap()));
126 DeleteNativeSources(
127 ExperimentalExtraNatives::GetSourceCache(isolate_->heap()));
124 DeleteNativeSources(CodeStubNatives::GetSourceCache(isolate_->heap())); 128 DeleteNativeSources(CodeStubNatives::GetSourceCache(isolate_->heap()));
129
125 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical 130 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical
126 } 131 }
127 132
128 133
129 class Genesis BASE_EMBEDDED { 134 class Genesis BASE_EMBEDDED {
130 public: 135 public:
131 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, 136 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
132 v8::Local<v8::ObjectTemplate> global_proxy_template, 137 v8::Local<v8::ObjectTemplate> global_proxy_template,
133 v8::ExtensionConfiguration* extensions, ContextType context_type); 138 v8::ExtensionConfiguration* extensions, ContextType context_type);
134 ~Genesis() { } 139 ~Genesis() { }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 204
200 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, 205 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target,
201 const char* name, 206 const char* name,
202 ElementsKind elements_kind); 207 ElementsKind elements_kind);
203 bool InstallNatives(ContextType context_type); 208 bool InstallNatives(ContextType context_type);
204 209
205 void InstallTypedArray(const char* name, ElementsKind elements_kind, 210 void InstallTypedArray(const char* name, ElementsKind elements_kind,
206 Handle<JSFunction>* fun); 211 Handle<JSFunction>* fun);
207 bool InstallExperimentalNatives(); 212 bool InstallExperimentalNatives();
208 bool InstallExtraNatives(); 213 bool InstallExtraNatives();
214 bool InstallExperimentalExtraNatives();
209 bool InstallDebuggerNatives(); 215 bool InstallDebuggerNatives();
210 void InstallBuiltinFunctionIds(); 216 void InstallBuiltinFunctionIds();
211 void InstallExperimentalBuiltinFunctionIds(); 217 void InstallExperimentalBuiltinFunctionIds();
212 void InitializeNormalizedMapCaches(); 218 void InitializeNormalizedMapCaches();
213 219
214 enum ExtensionTraversalState { 220 enum ExtensionTraversalState {
215 UNVISITED, VISITED, INSTALLED 221 UNVISITED, VISITED, INSTALLED
216 }; 222 };
217 223
218 class ExtensionStates { 224 class ExtensionStates {
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index); 1531 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index);
1526 Handle<Object> global = isolate->global_object(); 1532 Handle<Object> global = isolate->global_object();
1527 Handle<Object> binding = isolate->extras_binding_object(); 1533 Handle<Object> binding = isolate->extras_binding_object();
1528 Handle<Object> args[] = {global, binding}; 1534 Handle<Object> args[] = {global, binding};
1529 return Bootstrapper::CompileNative( 1535 return Bootstrapper::CompileNative(
1530 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), 1536 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()),
1531 source_code, arraysize(args), args); 1537 source_code, arraysize(args), args);
1532 } 1538 }
1533 1539
1534 1540
1541 bool Bootstrapper::CompileExperimentalExtraBuiltin(Isolate* isolate,
1542 int index) {
1543 HandleScope scope(isolate);
1544 Vector<const char> name = ExperimentalExtraNatives::GetScriptName(index);
1545 Handle<String> source_code =
1546 isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index);
1547 Handle<Object> global = isolate->global_object();
1548 Handle<Object> binding = isolate->extras_binding_object();
1549 Handle<Object> args[] = {global, binding};
1550 return Bootstrapper::CompileNative(
1551 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()),
1552 source_code, arraysize(args), args);
1553 }
1554
1555
1535 bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) { 1556 bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) {
1536 HandleScope scope(isolate); 1557 HandleScope scope(isolate);
1537 Vector<const char> name = CodeStubNatives::GetScriptName(index); 1558 Vector<const char> name = CodeStubNatives::GetScriptName(index);
1538 Handle<String> source_code = 1559 Handle<String> source_code =
1539 isolate->bootstrapper()->SourceLookup<CodeStubNatives>(index); 1560 isolate->bootstrapper()->SourceLookup<CodeStubNatives>(index);
1540 Handle<JSObject> global(isolate->global_object()); 1561 Handle<JSObject> global(isolate->global_object());
1541 Handle<JSObject> exports(isolate->heap()->code_stub_exports_object()); 1562 Handle<JSObject> exports(isolate->heap()->code_stub_exports_object());
1542 Handle<Object> args[] = {global, exports}; 1563 Handle<Object> args[] = {global, exports};
1543 bool result = 1564 bool result =
1544 CompileNative(isolate, name, global, source_code, arraysize(args), args); 1565 CompileNative(isolate, name, global, source_code, arraysize(args), args);
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2631 2652
2632 for (int i = ExtraNatives::GetDebuggerCount(); 2653 for (int i = ExtraNatives::GetDebuggerCount();
2633 i < ExtraNatives::GetBuiltinsCount(); i++) { 2654 i < ExtraNatives::GetBuiltinsCount(); i++) {
2634 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; 2655 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false;
2635 } 2656 }
2636 2657
2637 return true; 2658 return true;
2638 } 2659 }
2639 2660
2640 2661
2662 bool Genesis::InstallExperimentalExtraNatives() {
2663 for (int i = ExperimentalExtraNatives::GetDebuggerCount();
2664 i < ExperimentalExtraNatives::GetBuiltinsCount(); i++) {
2665 if (!Bootstrapper::CompileExperimentalExtraBuiltin(isolate(), i))
2666 return false;
2667 }
2668
2669 return true;
2670 }
2671
2672
2641 bool Genesis::InstallDebuggerNatives() { 2673 bool Genesis::InstallDebuggerNatives() {
2642 for (int i = 0; i < Natives::GetDebuggerCount(); ++i) { 2674 for (int i = 0; i < Natives::GetDebuggerCount(); ++i) {
2643 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false; 2675 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false;
2644 } 2676 }
2645 return CallUtilsFunction(isolate(), "PostDebug"); 2677 return CallUtilsFunction(isolate(), "PostDebug");
2646 } 2678 }
2647 2679
2648 2680
2649 bool Bootstrapper::InstallCodeStubNatives(Isolate* isolate) { 2681 bool Bootstrapper::InstallCodeStubNatives(Isolate* isolate) {
2650 for (int i = CodeStubNatives::GetDebuggerCount(); 2682 for (int i = CodeStubNatives::GetDebuggerCount();
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 isolate->counters()->contexts_created_from_scratch()->Increment(); 3262 isolate->counters()->contexts_created_from_scratch()->Increment();
3231 } 3263 }
3232 3264
3233 // Install experimental natives. Do not include them into the 3265 // Install experimental natives. Do not include them into the
3234 // snapshot as we should be able to turn them off at runtime. Re-installing 3266 // snapshot as we should be able to turn them off at runtime. Re-installing
3235 // them after they have already been deserialized would also fail. 3267 // them after they have already been deserialized would also fail.
3236 if (context_type == FULL_CONTEXT) { 3268 if (context_type == FULL_CONTEXT) {
3237 if (!isolate->serializer_enabled()) { 3269 if (!isolate->serializer_enabled()) {
3238 InitializeExperimentalGlobal(); 3270 InitializeExperimentalGlobal();
3239 if (!InstallExperimentalNatives()) return; 3271 if (!InstallExperimentalNatives()) return;
3272
3273 if (FLAG_experimental_extras) {
3274 if (!InstallExperimentalExtraNatives()) return;
3275 }
3276
3240 // By now the utils object is useless and can be removed. 3277 // By now the utils object is useless and can be removed.
3241 native_context()->set_natives_utils_object( 3278 native_context()->set_natives_utils_object(
3242 isolate->heap()->undefined_value()); 3279 isolate->heap()->undefined_value());
3243 } 3280 }
3244 // The serializer cannot serialize typed arrays. Reset those typed arrays 3281 // The serializer cannot serialize typed arrays. Reset those typed arrays
3245 // for each new context. 3282 // for each new context.
3246 InitializeBuiltinTypedArrays(); 3283 InitializeBuiltinTypedArrays();
3247 } else if (context_type == DEBUG_CONTEXT) { 3284 } else if (context_type == DEBUG_CONTEXT) {
3248 DCHECK(!isolate->serializer_enabled()); 3285 DCHECK(!isolate->serializer_enabled());
3249 InitializeExperimentalGlobal(); 3286 InitializeExperimentalGlobal();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3281 } 3318 }
3282 3319
3283 3320
3284 // Called when the top-level V8 mutex is destroyed. 3321 // Called when the top-level V8 mutex is destroyed.
3285 void Bootstrapper::FreeThreadResources() { 3322 void Bootstrapper::FreeThreadResources() {
3286 DCHECK(!IsActive()); 3323 DCHECK(!IsActive());
3287 } 3324 }
3288 3325
3289 } // namespace internal 3326 } // namespace internal
3290 } // namespace v8 3327 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698