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/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 2089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2100 static const PropertyAttributes attributes = | 2100 static const PropertyAttributes attributes = |
2101 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); | 2101 static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); |
2102 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ | 2102 #define INSTALL_PUBLIC_SYMBOL(name, varname, description) \ |
2103 Handle<String> varname = factory()->NewStringFromStaticChars(#varname); \ | 2103 Handle<String> varname = factory()->NewStringFromStaticChars(#varname); \ |
2104 JSObject::AddProperty(builtins, varname, factory()->name(), attributes); | 2104 JSObject::AddProperty(builtins, varname, factory()->name(), attributes); |
2105 PUBLIC_SYMBOL_LIST(INSTALL_PUBLIC_SYMBOL) | 2105 PUBLIC_SYMBOL_LIST(INSTALL_PUBLIC_SYMBOL) |
2106 #undef INSTALL_PUBLIC_SYMBOL | 2106 #undef INSTALL_PUBLIC_SYMBOL |
2107 } | 2107 } |
2108 | 2108 |
2109 // Install natives. | 2109 // Install natives. |
2110 for (int i = Natives::GetDebuggerCount(); | 2110 int i = Natives::GetDebuggerCount(); |
2111 i < Natives::GetBuiltinsCount(); | 2111 if (!CompileBuiltin(isolate(), i)) return false; |
2112 i++) { | 2112 if (!InstallJSBuiltins(builtins)) return false; |
| 2113 |
| 2114 for (++i; i < Natives::GetBuiltinsCount(); ++i) { |
2113 if (!CompileBuiltin(isolate(), i)) return false; | 2115 if (!CompileBuiltin(isolate(), i)) return false; |
2114 // TODO(ager): We really only need to install the JS builtin | |
2115 // functions on the builtins object after compiling and running | |
2116 // runtime.js. | |
2117 if (!InstallJSBuiltins(builtins)) return false; | |
2118 } | 2116 } |
2119 | 2117 |
2120 InstallNativeFunctions(); | 2118 InstallNativeFunctions(); |
2121 | 2119 |
2122 native_context()->set_function_cache(heap()->empty_fixed_array()); | 2120 native_context()->set_function_cache(heap()->empty_fixed_array()); |
2123 | 2121 |
2124 // Store the map for the string prototype after the natives has been compiled | 2122 // Store the map for the string prototype after the natives has been compiled |
2125 // and the String function has been set up. | 2123 // and the String function has been set up. |
2126 Handle<JSFunction> string_function(native_context()->string_function()); | 2124 Handle<JSFunction> string_function(native_context()->string_function()); |
2127 DCHECK(JSObject::cast( | 2125 DCHECK(JSObject::cast( |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 } | 2601 } |
2604 | 2602 |
2605 | 2603 |
2606 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { | 2604 bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) { |
2607 HandleScope scope(isolate()); | 2605 HandleScope scope(isolate()); |
2608 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 2606 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
2609 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 2607 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
2610 Handle<Object> function_object = Object::GetProperty( | 2608 Handle<Object> function_object = Object::GetProperty( |
2611 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); | 2609 isolate(), builtins, Builtins::GetName(id)).ToHandleChecked(); |
2612 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 2610 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
2613 // TODO(mstarzinger): This is just a temporary hack to make TurboFan work, | |
2614 // the correct solution is to restore the context register after invoking | |
2615 // builtins from full-codegen. | |
2616 function->shared()->DisableOptimization(kBuiltinFunctionCannotBeOptimized); | |
2617 builtins->set_javascript_builtin(id, *function); | 2611 builtins->set_javascript_builtin(id, *function); |
2618 if (!Compiler::EnsureCompiled(function, CLEAR_EXCEPTION)) { | |
2619 return false; | |
2620 } | |
2621 builtins->set_javascript_builtin_code(id, function->shared()->code()); | |
2622 } | 2612 } |
2623 return true; | 2613 return true; |
2624 } | 2614 } |
2625 | 2615 |
2626 | 2616 |
2627 bool Genesis::ConfigureGlobalObjects( | 2617 bool Genesis::ConfigureGlobalObjects( |
2628 v8::Handle<v8::ObjectTemplate> global_proxy_template) { | 2618 v8::Handle<v8::ObjectTemplate> global_proxy_template) { |
2629 Handle<JSObject> global_proxy( | 2619 Handle<JSObject> global_proxy( |
2630 JSObject::cast(native_context()->global_proxy())); | 2620 JSObject::cast(native_context()->global_proxy())); |
2631 Handle<JSObject> global_object( | 2621 Handle<JSObject> global_object( |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2932 return from + sizeof(NestingCounterType); | 2922 return from + sizeof(NestingCounterType); |
2933 } | 2923 } |
2934 | 2924 |
2935 | 2925 |
2936 // Called when the top-level V8 mutex is destroyed. | 2926 // Called when the top-level V8 mutex is destroyed. |
2937 void Bootstrapper::FreeThreadResources() { | 2927 void Bootstrapper::FreeThreadResources() { |
2938 DCHECK(!IsActive()); | 2928 DCHECK(!IsActive()); |
2939 } | 2929 } |
2940 | 2930 |
2941 } } // namespace v8::internal | 2931 } } // namespace v8::internal |
OLD | NEW |