| OLD | NEW |
| 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 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) | 1514 HARMONY_STAGED(FEATURE_INITIALIZE_GLOBAL) |
| 1515 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) | 1515 HARMONY_SHIPPING(FEATURE_INITIALIZE_GLOBAL) |
| 1516 #undef FEATURE_INITIALIZE_GLOBAL | 1516 #undef FEATURE_INITIALIZE_GLOBAL |
| 1517 } | 1517 } |
| 1518 | 1518 |
| 1519 | 1519 |
| 1520 bool Bootstrapper::CompileBuiltin(Isolate* isolate, int index) { | 1520 bool Bootstrapper::CompileBuiltin(Isolate* isolate, int index) { |
| 1521 Vector<const char> name = Natives::GetScriptName(index); | 1521 Vector<const char> name = Natives::GetScriptName(index); |
| 1522 Handle<String> source_code = | 1522 Handle<String> source_code = |
| 1523 isolate->bootstrapper()->SourceLookup<Natives>(index); | 1523 isolate->bootstrapper()->SourceLookup<Natives>(index); |
| 1524 |
| 1525 // We pass in extras_utils so that builtin code can set it up for later use |
| 1526 // by actual extras code, compiled with CompileExtraBuiltin. |
| 1524 Handle<Object> global = isolate->global_object(); | 1527 Handle<Object> global = isolate->global_object(); |
| 1525 Handle<Object> utils = isolate->natives_utils_object(); | 1528 Handle<Object> utils = isolate->natives_utils_object(); |
| 1526 Handle<Object> args[] = {global, utils}; | 1529 Handle<Object> extras_utils = isolate->extras_utils_object(); |
| 1530 Handle<Object> args[] = {global, utils, extras_utils}; |
| 1527 | 1531 |
| 1528 return Bootstrapper::CompileNative( | 1532 return Bootstrapper::CompileNative( |
| 1529 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), | 1533 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), |
| 1530 source_code, arraysize(args), args); | 1534 source_code, arraysize(args), args); |
| 1531 } | 1535 } |
| 1532 | 1536 |
| 1533 | 1537 |
| 1534 bool Bootstrapper::CompileExperimentalBuiltin(Isolate* isolate, int index) { | 1538 bool Bootstrapper::CompileExperimentalBuiltin(Isolate* isolate, int index) { |
| 1535 HandleScope scope(isolate); | 1539 HandleScope scope(isolate); |
| 1536 Vector<const char> name = ExperimentalNatives::GetScriptName(index); | 1540 Vector<const char> name = ExperimentalNatives::GetScriptName(index); |
| 1537 Handle<String> source_code = | 1541 Handle<String> source_code = |
| 1538 isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index); | 1542 isolate->bootstrapper()->SourceLookup<ExperimentalNatives>(index); |
| 1539 Handle<Object> global = isolate->global_object(); | 1543 Handle<Object> global = isolate->global_object(); |
| 1540 Handle<Object> utils = isolate->natives_utils_object(); | 1544 Handle<Object> utils = isolate->natives_utils_object(); |
| 1541 Handle<Object> args[] = {global, utils}; | 1545 Handle<Object> args[] = {global, utils}; |
| 1542 return Bootstrapper::CompileNative( | 1546 return Bootstrapper::CompileNative( |
| 1543 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), | 1547 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), |
| 1544 source_code, arraysize(args), args); | 1548 source_code, arraysize(args), args); |
| 1545 } | 1549 } |
| 1546 | 1550 |
| 1547 | 1551 |
| 1548 bool Bootstrapper::CompileExtraBuiltin(Isolate* isolate, int index) { | 1552 bool Bootstrapper::CompileExtraBuiltin(Isolate* isolate, int index) { |
| 1549 HandleScope scope(isolate); | 1553 HandleScope scope(isolate); |
| 1550 Vector<const char> name = ExtraNatives::GetScriptName(index); | 1554 Vector<const char> name = ExtraNatives::GetScriptName(index); |
| 1551 Handle<String> source_code = | 1555 Handle<String> source_code = |
| 1552 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index); | 1556 isolate->bootstrapper()->SourceLookup<ExtraNatives>(index); |
| 1553 Handle<Object> global = isolate->global_object(); | 1557 Handle<Object> global = isolate->global_object(); |
| 1554 Handle<Object> binding = isolate->extras_binding_object(); | 1558 Handle<Object> binding = isolate->extras_binding_object(); |
| 1555 Handle<Object> args[] = {global, binding}; | 1559 Handle<Object> extras_utils = isolate->extras_utils_object(); |
| 1560 Handle<Object> args[] = {global, binding, extras_utils}; |
| 1556 return Bootstrapper::CompileNative( | 1561 return Bootstrapper::CompileNative( |
| 1557 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), | 1562 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), |
| 1558 source_code, arraysize(args), args); | 1563 source_code, arraysize(args), args); |
| 1559 } | 1564 } |
| 1560 | 1565 |
| 1561 | 1566 |
| 1562 bool Bootstrapper::CompileExperimentalExtraBuiltin(Isolate* isolate, | 1567 bool Bootstrapper::CompileExperimentalExtraBuiltin(Isolate* isolate, |
| 1563 int index) { | 1568 int index) { |
| 1564 HandleScope scope(isolate); | 1569 HandleScope scope(isolate); |
| 1565 Vector<const char> name = ExperimentalExtraNatives::GetScriptName(index); | 1570 Vector<const char> name = ExperimentalExtraNatives::GetScriptName(index); |
| 1566 Handle<String> source_code = | 1571 Handle<String> source_code = |
| 1567 isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index); | 1572 isolate->bootstrapper()->SourceLookup<ExperimentalExtraNatives>(index); |
| 1568 Handle<Object> global = isolate->global_object(); | 1573 Handle<Object> global = isolate->global_object(); |
| 1569 Handle<Object> binding = isolate->extras_binding_object(); | 1574 Handle<Object> binding = isolate->extras_binding_object(); |
| 1570 Handle<Object> args[] = {global, binding}; | 1575 Handle<Object> extras_utils = isolate->extras_utils_object(); |
| 1576 Handle<Object> args[] = {global, binding, extras_utils}; |
| 1571 return Bootstrapper::CompileNative( | 1577 return Bootstrapper::CompileNative( |
| 1572 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), | 1578 isolate, name, Handle<JSObject>(isolate->native_context()->builtins()), |
| 1573 source_code, arraysize(args), args); | 1579 source_code, arraysize(args), args); |
| 1574 } | 1580 } |
| 1575 | 1581 |
| 1576 | 1582 |
| 1577 bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) { | 1583 bool Bootstrapper::CompileCodeStubBuiltin(Isolate* isolate, int index) { |
| 1578 HandleScope scope(isolate); | 1584 HandleScope scope(isolate); |
| 1579 Vector<const char> name = CodeStubNatives::GetScriptName(index); | 1585 Vector<const char> name = CodeStubNatives::GetScriptName(index); |
| 1580 Handle<String> source_code = | 1586 Handle<String> source_code = |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2000 context->set_global_object(*builtins); // override builtins global object | 2006 context->set_global_object(*builtins); // override builtins global object |
| 2001 | 2007 |
| 2002 native_context()->set_runtime_context(*context); | 2008 native_context()->set_runtime_context(*context); |
| 2003 | 2009 |
| 2004 // Set up the utils object as shared container between native scripts. | 2010 // Set up the utils object as shared container between native scripts. |
| 2005 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); | 2011 Handle<JSObject> utils = factory()->NewJSObject(isolate()->object_function()); |
| 2006 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, | 2012 JSObject::NormalizeProperties(utils, CLEAR_INOBJECT_PROPERTIES, 16, |
| 2007 "utils container for native scripts"); | 2013 "utils container for native scripts"); |
| 2008 native_context()->set_natives_utils_object(*utils); | 2014 native_context()->set_natives_utils_object(*utils); |
| 2009 | 2015 |
| 2016 // Set up the extras utils object as a shared container between native |
| 2017 // scripts and extras. (Extras consume things added there by native scripts.) |
| 2018 Handle<JSObject> extras_utils = |
| 2019 factory()->NewJSObject(isolate()->object_function()); |
| 2020 native_context()->set_extras_utils_object(*extras_utils); |
| 2021 |
| 2022 InstallInternalArray(extras_utils, "InternalPackedArray", FAST_ELEMENTS); |
| 2023 |
| 2010 int builtin_index = Natives::GetDebuggerCount(); | 2024 int builtin_index = Natives::GetDebuggerCount(); |
| 2011 // Only run prologue.js and runtime.js at this point. | 2025 // Only run prologue.js and runtime.js at this point. |
| 2012 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); | 2026 DCHECK_EQ(builtin_index, Natives::GetIndex("prologue")); |
| 2013 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 2027 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2014 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); | 2028 DCHECK_EQ(builtin_index, Natives::GetIndex("runtime")); |
| 2015 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; | 2029 if (!Bootstrapper::CompileBuiltin(isolate(), builtin_index++)) return false; |
| 2016 | 2030 |
| 2017 // A thin context is ready at this point. | 2031 // A thin context is ready at this point. |
| 2018 if (context_type == THIN_CONTEXT) return true; | 2032 if (context_type == THIN_CONTEXT) return true; |
| 2019 | 2033 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 InstallExperimentalBuiltinFunctionIds(); | 2571 InstallExperimentalBuiltinFunctionIds(); |
| 2558 return true; | 2572 return true; |
| 2559 } | 2573 } |
| 2560 | 2574 |
| 2561 | 2575 |
| 2562 bool Genesis::InstallExtraNatives() { | 2576 bool Genesis::InstallExtraNatives() { |
| 2563 HandleScope scope(isolate()); | 2577 HandleScope scope(isolate()); |
| 2564 | 2578 |
| 2565 Handle<JSObject> extras_binding = | 2579 Handle<JSObject> extras_binding = |
| 2566 factory()->NewJSObject(isolate()->object_function()); | 2580 factory()->NewJSObject(isolate()->object_function()); |
| 2567 JSObject::NormalizeProperties(extras_binding, CLEAR_INOBJECT_PROPERTIES, 2, | |
| 2568 "container for binding to/from extra natives"); | |
| 2569 native_context()->set_extras_binding_object(*extras_binding); | 2581 native_context()->set_extras_binding_object(*extras_binding); |
| 2570 | 2582 |
| 2571 for (int i = ExtraNatives::GetDebuggerCount(); | 2583 for (int i = ExtraNatives::GetDebuggerCount(); |
| 2572 i < ExtraNatives::GetBuiltinsCount(); i++) { | 2584 i < ExtraNatives::GetBuiltinsCount(); i++) { |
| 2573 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; | 2585 if (!Bootstrapper::CompileExtraBuiltin(isolate(), i)) return false; |
| 2574 } | 2586 } |
| 2575 | 2587 |
| 2576 return true; | 2588 return true; |
| 2577 } | 2589 } |
| 2578 | 2590 |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3225 } | 3237 } |
| 3226 | 3238 |
| 3227 | 3239 |
| 3228 // Called when the top-level V8 mutex is destroyed. | 3240 // Called when the top-level V8 mutex is destroyed. |
| 3229 void Bootstrapper::FreeThreadResources() { | 3241 void Bootstrapper::FreeThreadResources() { |
| 3230 DCHECK(!IsActive()); | 3242 DCHECK(!IsActive()); |
| 3231 } | 3243 } |
| 3232 | 3244 |
| 3233 } // namespace internal | 3245 } // namespace internal |
| 3234 } // namespace v8 | 3246 } // namespace v8 |
| OLD | NEW |