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

Side by Side Diff: src/bootstrapper.cc

Issue 1475953002: [stubs] A new approach to TF stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 build Created 5 years 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/code-stubs.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/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/extensions/externalize-string-extension.h" 10 #include "src/extensions/externalize-string-extension.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return Handle<String>::cast(cached_source); 52 return Handle<String>::cast(cached_source);
53 } 53 }
54 54
55 55
56 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index); 56 template Handle<String> Bootstrapper::SourceLookup<Natives>(int index);
57 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>( 57 template Handle<String> Bootstrapper::SourceLookup<ExperimentalNatives>(
58 int index); 58 int index);
59 template Handle<String> Bootstrapper::SourceLookup<ExperimentalExtraNatives>( 59 template Handle<String> Bootstrapper::SourceLookup<ExperimentalExtraNatives>(
60 int index); 60 int index);
61 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index); 61 template Handle<String> Bootstrapper::SourceLookup<ExtraNatives>(int index);
62 template Handle<String> Bootstrapper::SourceLookup<CodeStubNatives>(int index);
63 62
64 63
65 void Bootstrapper::Initialize(bool create_heap_objects) { 64 void Bootstrapper::Initialize(bool create_heap_objects) {
66 extensions_cache_.Initialize(isolate_, create_heap_objects); 65 extensions_cache_.Initialize(isolate_, create_heap_objects);
67 } 66 }
68 67
69 68
70 static const char* GCFunctionName() { 69 static const char* GCFunctionName() {
71 bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0; 70 bool flag_given = FLAG_expose_gc_as != NULL && strlen(FLAG_expose_gc_as) != 0;
72 return flag_given ? FLAG_expose_gc_as : "gc"; 71 return flag_given ? FLAG_expose_gc_as : "gc";
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 122 }
124 } 123 }
125 124
126 125
127 void Bootstrapper::TearDown() { 126 void Bootstrapper::TearDown() {
128 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap())); 127 DeleteNativeSources(Natives::GetSourceCache(isolate_->heap()));
129 DeleteNativeSources(ExperimentalNatives::GetSourceCache(isolate_->heap())); 128 DeleteNativeSources(ExperimentalNatives::GetSourceCache(isolate_->heap()));
130 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap())); 129 DeleteNativeSources(ExtraNatives::GetSourceCache(isolate_->heap()));
131 DeleteNativeSources( 130 DeleteNativeSources(
132 ExperimentalExtraNatives::GetSourceCache(isolate_->heap())); 131 ExperimentalExtraNatives::GetSourceCache(isolate_->heap()));
133 DeleteNativeSources(CodeStubNatives::GetSourceCache(isolate_->heap()));
134 132
135 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical 133 extensions_cache_.Initialize(isolate_, false); // Yes, symmetrical
136 } 134 }
137 135
138 136
139 class Genesis BASE_EMBEDDED { 137 class Genesis BASE_EMBEDDED {
140 public: 138 public:
141 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy, 139 Genesis(Isolate* isolate, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
142 v8::Local<v8::ObjectTemplate> global_proxy_template, 140 v8::Local<v8::ObjectTemplate> global_proxy_template,
143 v8::ExtensionConfiguration* extensions, ContextType context_type); 141 v8::ExtensionConfiguration* extensions, ContextType context_type);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 extensions, context_type); 330 extensions, context_type);
333 Handle<Context> env = genesis.result(); 331 Handle<Context> env = genesis.result();
334 if (env.is_null() || 332 if (env.is_null() ||
335 (context_type != THIN_CONTEXT && !InstallExtensions(env, extensions))) { 333 (context_type != THIN_CONTEXT && !InstallExtensions(env, extensions))) {
336 return Handle<Context>(); 334 return Handle<Context>();
337 } 335 }
338 return scope.CloseAndEscape(env); 336 return scope.CloseAndEscape(env);
339 } 337 }
340 338
341 339
342 bool Bootstrapper::CreateCodeStubContext(Isolate* isolate) {
343 HandleScope scope(isolate);
344 SaveContext save_context(isolate);
345 BootstrapperActive active(this);
346
347 v8::ExtensionConfiguration no_extensions;
348 Handle<Context> native_context = CreateEnvironment(
349 MaybeHandle<JSGlobalProxy>(), v8::Local<v8::ObjectTemplate>(),
350 &no_extensions, THIN_CONTEXT);
351 isolate->heap()->SetRootCodeStubContext(*native_context);
352 isolate->set_context(*native_context);
353 Handle<JSObject> code_stub_exports =
354 isolate->factory()->NewJSObject(isolate->object_function());
355 JSObject::NormalizeProperties(code_stub_exports, CLEAR_INOBJECT_PROPERTIES, 2,
356 "container to export to extra natives");
357 isolate->heap()->SetRootCodeStubExportsObject(*code_stub_exports);
358 return InstallCodeStubNatives(isolate);
359 }
360
361
362 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) { 340 static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
363 // object.__proto__ = proto; 341 // object.__proto__ = proto;
364 Handle<Map> old_map = Handle<Map>(object->map()); 342 Handle<Map> old_map = Handle<Map>(object->map());
365 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype"); 343 Handle<Map> new_map = Map::Copy(old_map, "SetObjectPrototype");
366 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE); 344 Map::SetPrototype(new_map, proto, FAST_PROTOTYPE);
367 JSObject::MigrateToMap(object, new_map); 345 JSObject::MigrateToMap(object, new_map);
368 } 346 }
369 347
370 348
371 void Bootstrapper::DetachGlobal(Handle<Context> env) { 349 void Bootstrapper::DetachGlobal(Handle<Context> env) {
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index); 1525 isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index);
1548 Handle<Object> global = isolate->global_object(); 1526 Handle<Object> global = isolate->global_object();
1549 Handle<Object> binding = isolate->extras_binding_object(); 1527 Handle<Object> binding = isolate->extras_binding_object();
1550 Handle<Object> extras_utils = isolate->extras_utils_object(); 1528 Handle<Object> extras_utils = isolate->extras_utils_object();
1551 Handle<Object> args[] = {global, binding, extras_utils}; 1529 Handle<Object> args[] = {global, binding, extras_utils};
1552 return Bootstrapper::CompileNative(isolate, name, source_code, 1530 return Bootstrapper::CompileNative(isolate, name, source_code,
1553 arraysize(args), args); 1531 arraysize(args), args);
1554 } 1532 }
1555 1533
1556 1534
1557 bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) {
1558 HandleScope scope(isolate);
1559 Vector<const char> name = CodeStubNatives::GetScriptName(index);
1560 Handle<String> source_code =
1561 isolate->bootstrapper()->SourceLookup<CodeStubNatives>(index);
1562 Handle<JSObject> global(isolate->global_object());
1563 Handle<JSObject> exports(isolate->heap()->code_stub_exports_object());
1564 Handle<Object> args[] = {global, exports};
1565 bool result =
1566 CompileNative(isolate, name, source_code, arraysize(args), args);
1567 return result;
1568 }
1569
1570
1571 bool Bootstrapper::CompileNative(Isolate* isolate, Vector<const char> name, 1535 bool Bootstrapper::CompileNative(Isolate* isolate, Vector<const char> name,
1572 Handle<String> source, int argc, 1536 Handle<String> source, int argc,
1573 Handle<Object> argv[]) { 1537 Handle<Object> argv[]) {
1574 SuppressDebug compiling_natives(isolate->debug()); 1538 SuppressDebug compiling_natives(isolate->debug());
1575 // During genesis, the boilerplate for stack overflow won't work until the 1539 // During genesis, the boilerplate for stack overflow won't work until the
1576 // environment has been at least partially initialized. Add a stack check 1540 // environment has been at least partially initialized. Add a stack check
1577 // before entering JS code to catch overflow early. 1541 // before entering JS code to catch overflow early.
1578 StackLimitCheck check(isolate); 1542 StackLimitCheck check(isolate);
1579 if (check.JsHasOverflowed(1 * KB)) { 1543 if (check.JsHasOverflowed(1 * KB)) {
1580 isolate->StackOverflow(); 1544 isolate->StackOverflow();
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 2537
2574 2538
2575 bool Genesis::InstallDebuggerNatives() { 2539 bool Genesis::InstallDebuggerNatives() {
2576 for (int i = 0; i < Natives::GetDebuggerCount(); ++i) { 2540 for (int i = 0; i < Natives::GetDebuggerCount(); ++i) {
2577 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false; 2541 if (!Bootstrapper::CompileBuiltin(isolate(), i)) return false;
2578 } 2542 }
2579 return CallUtilsFunction(isolate(), "PostDebug"); 2543 return CallUtilsFunction(isolate(), "PostDebug");
2580 } 2544 }
2581 2545
2582 2546
2583 bool Bootstrapper::InstallCodeStubNatives(Isolate* isolate) {
2584 for (int i = CodeStubNatives::GetDebuggerCount();
2585 i < CodeStubNatives::GetBuiltinsCount(); i++) {
2586 if (!CompileCodeStubBuiltin(isolate, i)) return false;
2587 }
2588
2589 return true;
2590 }
2591
2592
2593 static void InstallBuiltinFunctionId(Handle<JSObject> holder, 2547 static void InstallBuiltinFunctionId(Handle<JSObject> holder,
2594 const char* function_name, 2548 const char* function_name,
2595 BuiltinFunctionId id) { 2549 BuiltinFunctionId id) {
2596 Isolate* isolate = holder->GetIsolate(); 2550 Isolate* isolate = holder->GetIsolate();
2597 Handle<Object> function_object = 2551 Handle<Object> function_object =
2598 Object::GetProperty(isolate, holder, function_name).ToHandleChecked(); 2552 Object::GetProperty(isolate, holder, function_name).ToHandleChecked();
2599 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); 2553 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
2600 function->shared()->set_function_data(Smi::FromInt(id)); 2554 function->shared()->set_function_data(Smi::FromInt(id));
2601 } 2555 }
2602 2556
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 } 3149 }
3196 3150
3197 3151
3198 // Called when the top-level V8 mutex is destroyed. 3152 // Called when the top-level V8 mutex is destroyed.
3199 void Bootstrapper::FreeThreadResources() { 3153 void Bootstrapper::FreeThreadResources() {
3200 DCHECK(!IsActive()); 3154 DCHECK(!IsActive());
3201 } 3155 }
3202 3156
3203 } // namespace internal 3157 } // namespace internal
3204 } // namespace v8 3158 } // namespace v8
OLDNEW
« no previous file with comments | « src/bootstrapper.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698