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" |
11 #include "src/extensions/externalize-string-extension.h" | 11 #include "src/extensions/externalize-string-extension.h" |
12 #include "src/extensions/free-buffer-extension.h" | 12 #include "src/extensions/free-buffer-extension.h" |
13 #include "src/extensions/gc-extension.h" | 13 #include "src/extensions/gc-extension.h" |
14 #include "src/extensions/statistics-extension.h" | 14 #include "src/extensions/statistics-extension.h" |
15 #include "src/extensions/trigger-failure-extension.h" | 15 #include "src/extensions/trigger-failure-extension.h" |
| 16 #include "src/heap/heap.h" |
16 #include "src/snapshot/natives.h" | 17 #include "src/snapshot/natives.h" |
17 #include "src/snapshot/snapshot.h" | 18 #include "src/snapshot/snapshot.h" |
18 #include "third_party/fdlibm/fdlibm.h" | 19 #include "third_party/fdlibm/fdlibm.h" |
19 | 20 |
20 namespace v8 { | 21 namespace v8 { |
21 namespace internal { | 22 namespace internal { |
22 | 23 |
23 Bootstrapper::Bootstrapper(Isolate* isolate) | 24 Bootstrapper::Bootstrapper(Isolate* isolate) |
24 : isolate_(isolate), | 25 : isolate_(isolate), |
25 nesting_(0), | 26 nesting_(0), |
(...skipping 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 | 1789 |
1789 INSTALL_NATIVE(JSFunction, "Error", error_function); | 1790 INSTALL_NATIVE(JSFunction, "Error", error_function); |
1790 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function); | 1791 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function); |
1791 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function); | 1792 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function); |
1792 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function); | 1793 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function); |
1793 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function); | 1794 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function); |
1794 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function); | 1795 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function); |
1795 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function); | 1796 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function); |
1796 INSTALL_NATIVE(JSFunction, "MakeError", make_error_function); | 1797 INSTALL_NATIVE(JSFunction, "MakeError", make_error_function); |
1797 | 1798 |
1798 INSTALL_NATIVE(Symbol, "promiseStatus", promise_status); | |
1799 INSTALL_NATIVE(Symbol, "promiseValue", promise_value); | |
1800 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); | 1799 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); |
1801 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); | 1800 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); |
1802 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); | 1801 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); |
1803 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); | 1802 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); |
1804 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); | 1803 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); |
1805 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); | 1804 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); |
1806 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler", | 1805 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler", |
1807 promise_has_user_defined_reject_handler); | 1806 promise_has_user_defined_reject_handler); |
1808 | 1807 |
1809 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); | 1808 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 Object::GetProperty(isolate, container, Builtins::GetName(id)) | 1899 Object::GetProperty(isolate, container, Builtins::GetName(id)) |
1901 .ToHandleChecked(); | 1900 .ToHandleChecked(); |
1902 DCHECK(function_object->IsJSFunction()); | 1901 DCHECK(function_object->IsJSFunction()); |
1903 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); | 1902 Handle<JSFunction> function = Handle<JSFunction>::cast(function_object); |
1904 builtins->set_javascript_builtin(id, *function); | 1903 builtins->set_javascript_builtin(id, *function); |
1905 } | 1904 } |
1906 return true; | 1905 return true; |
1907 } | 1906 } |
1908 | 1907 |
1909 | 1908 |
| 1909 void Bootstrapper::ExportPrivateSymbols(Isolate* isolate, |
| 1910 Handle<JSObject> container) { |
| 1911 HandleScope scope(isolate); |
| 1912 #define EXPORT_PRIVATE_SYMBOL(NAME) \ |
| 1913 Handle<String> NAME##_name = \ |
| 1914 isolate->factory()->NewStringFromAsciiChecked(#NAME); \ |
| 1915 JSObject::AddProperty(container, NAME##_name, isolate->factory()->NAME(), \ |
| 1916 NONE); |
| 1917 |
| 1918 PRIVATE_SYMBOL_LIST(EXPORT_PRIVATE_SYMBOL) |
| 1919 |
| 1920 #undef EXPORT_PRIVATE_SYMBOL |
| 1921 } |
| 1922 |
| 1923 |
1910 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ | 1924 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ |
1911 void Genesis::InitializeGlobal_##id() {} | 1925 void Genesis::InitializeGlobal_##id() {} |
1912 | 1926 |
1913 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) | 1927 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) |
1914 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) | 1928 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) |
1915 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) | 1929 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) |
1916 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) | 1930 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) |
1917 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) | 1931 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) |
1918 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) | 1932 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) |
1919 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) | 1933 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 // Expose the natives in global if a name for it is specified. | 2796 // Expose the natives in global if a name for it is specified. |
2783 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { | 2797 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { |
2784 Handle<String> natives_key = | 2798 Handle<String> natives_key = |
2785 factory->InternalizeUtf8String(FLAG_expose_natives_as); | 2799 factory->InternalizeUtf8String(FLAG_expose_natives_as); |
2786 uint32_t dummy_index; | 2800 uint32_t dummy_index; |
2787 if (natives_key->AsArrayIndex(&dummy_index)) return true; | 2801 if (natives_key->AsArrayIndex(&dummy_index)) return true; |
2788 Handle<JSBuiltinsObject> natives(global->builtins()); | 2802 Handle<JSBuiltinsObject> natives(global->builtins()); |
2789 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM); | 2803 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM); |
2790 } | 2804 } |
2791 | 2805 |
2792 // Expose the stack trace symbol to native JS. | |
2793 RETURN_ON_EXCEPTION_VALUE(isolate, | |
2794 JSObject::SetOwnPropertyIgnoreAttributes( | |
2795 handle(native_context->builtins(), isolate), | |
2796 factory->InternalizeOneByteString( | |
2797 STATIC_CHAR_VECTOR("$stackTraceSymbol")), | |
2798 factory->stack_trace_symbol(), NONE), | |
2799 false); | |
2800 | |
2801 // Expose the internal error symbol to native JS | |
2802 RETURN_ON_EXCEPTION_VALUE(isolate, | |
2803 JSObject::SetOwnPropertyIgnoreAttributes( | |
2804 handle(native_context->builtins(), isolate), | |
2805 factory->InternalizeOneByteString( | |
2806 STATIC_CHAR_VECTOR("$internalErrorSymbol")), | |
2807 factory->internal_error_symbol(), NONE), | |
2808 false); | |
2809 | |
2810 // Expose the debug global object in global if a name for it is specified. | 2806 // Expose the debug global object in global if a name for it is specified. |
2811 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2807 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
2812 // If loading fails we just bail out without installing the | 2808 // If loading fails we just bail out without installing the |
2813 // debugger but without tanking the whole context. | 2809 // debugger but without tanking the whole context. |
2814 Debug* debug = isolate->debug(); | 2810 Debug* debug = isolate->debug(); |
2815 if (!debug->Load()) return true; | 2811 if (!debug->Load()) return true; |
2816 Handle<Context> debug_context = debug->debug_context(); | 2812 Handle<Context> debug_context = debug->debug_context(); |
2817 // Set the security token for the debugger context to the same as | 2813 // Set the security token for the debugger context to the same as |
2818 // the shell native context to allow calling between these (otherwise | 2814 // the shell native context to allow calling between these (otherwise |
2819 // exposing debug global object doesn't make much sense). | 2815 // exposing debug global object doesn't make much sense). |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 } | 3314 } |
3319 | 3315 |
3320 | 3316 |
3321 // Called when the top-level V8 mutex is destroyed. | 3317 // Called when the top-level V8 mutex is destroyed. |
3322 void Bootstrapper::FreeThreadResources() { | 3318 void Bootstrapper::FreeThreadResources() { |
3323 DCHECK(!IsActive()); | 3319 DCHECK(!IsActive()); |
3324 } | 3320 } |
3325 | 3321 |
3326 } // namespace internal | 3322 } // namespace internal |
3327 } // namespace v8 | 3323 } // namespace v8 |
OLD | NEW |