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

Side by Side Diff: src/bootstrapper.cc

Issue 1293493004: Unify symbols sharing across native scripts and runtime. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
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"
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 1742 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 1769
1769 INSTALL_NATIVE(JSFunction, "Error", error_function); 1770 INSTALL_NATIVE(JSFunction, "Error", error_function);
1770 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function); 1771 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function);
1771 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function); 1772 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function);
1772 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function); 1773 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function);
1773 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function); 1774 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function);
1774 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function); 1775 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function);
1775 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function); 1776 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function);
1776 INSTALL_NATIVE(JSFunction, "MakeError", make_error_function); 1777 INSTALL_NATIVE(JSFunction, "MakeError", make_error_function);
1777 1778
1778 INSTALL_NATIVE(Symbol, "promiseStatus", promise_status);
1779 INSTALL_NATIVE(Symbol, "promiseValue", promise_value);
1780 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); 1779 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create);
1781 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); 1780 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve);
1782 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); 1781 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject);
1783 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); 1782 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain);
1784 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); 1783 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch);
1785 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); 1784 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then);
1786 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler", 1785 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler",
1787 promise_has_user_defined_reject_handler); 1786 promise_has_user_defined_reject_handler);
1788 1787
1789 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); 1788 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 InstallExperimentalNatives_##id(isolate, native_context, container); 1861 InstallExperimentalNatives_##id(isolate, native_context, container);
1863 1862
1864 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) 1863 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR)
1865 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) 1864 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR)
1866 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) 1865 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR)
1867 #undef INSTALL_NATIVE_FUNCTIONS_FOR 1866 #undef INSTALL_NATIVE_FUNCTIONS_FOR
1868 } 1867 }
1869 1868
1870 #undef INSTALL_NATIVE 1869 #undef INSTALL_NATIVE
1871 1870
1871 void Bootstrapper::ExportPrivateSymbols(Isolate* isolate,
1872 Handle<JSObject> container) {
1873 HandleScope scope(isolate);
1874 #define EXPORT_PRIVATE_SYMBOL(NAME) \
1875 Handle<String> NAME##_name = \
1876 isolate->factory()->NewStringFromAsciiChecked(#NAME); \
1877 JSObject::AddProperty(container, NAME##_name, isolate->factory()->NAME(), \
1878 NONE);
1879
1880 PRIVATE_SYMBOL_LIST(EXPORT_PRIVATE_SYMBOL)
1881
1882 #undef EXPORT_PRIVATE_SYMBOL
1883 }
1884
1872 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \ 1885 #define EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(id) \
1873 void Genesis::InitializeGlobal_##id() {} 1886 void Genesis::InitializeGlobal_##id() {}
1874 1887
1875 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules) 1888 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_modules)
1876 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes) 1889 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_array_includes)
1877 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions) 1890 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_arrow_functions)
1878 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies) 1891 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_proxies)
1879 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy) 1892 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy)
1880 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function) 1893 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_function)
1881 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let) 1894 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_sloppy_let)
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 // Expose the natives in global if a name for it is specified. 2747 // Expose the natives in global if a name for it is specified.
2735 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) { 2748 if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
2736 Handle<String> natives_key = 2749 Handle<String> natives_key =
2737 factory->InternalizeUtf8String(FLAG_expose_natives_as); 2750 factory->InternalizeUtf8String(FLAG_expose_natives_as);
2738 uint32_t dummy_index; 2751 uint32_t dummy_index;
2739 if (natives_key->AsArrayIndex(&dummy_index)) return true; 2752 if (natives_key->AsArrayIndex(&dummy_index)) return true;
2740 Handle<JSBuiltinsObject> natives(global->builtins()); 2753 Handle<JSBuiltinsObject> natives(global->builtins());
2741 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM); 2754 JSObject::AddProperty(global, natives_key, natives, DONT_ENUM);
2742 } 2755 }
2743 2756
2744 // Expose the stack trace symbol to native JS.
2745 RETURN_ON_EXCEPTION_VALUE(isolate,
2746 JSObject::SetOwnPropertyIgnoreAttributes(
2747 handle(native_context->builtins(), isolate),
2748 factory->InternalizeOneByteString(
2749 STATIC_CHAR_VECTOR("$stackTraceSymbol")),
2750 factory->stack_trace_symbol(), NONE),
2751 false);
2752
2753 // Expose the internal error symbol to native JS
2754 RETURN_ON_EXCEPTION_VALUE(isolate,
2755 JSObject::SetOwnPropertyIgnoreAttributes(
2756 handle(native_context->builtins(), isolate),
2757 factory->InternalizeOneByteString(
2758 STATIC_CHAR_VECTOR("$internalErrorSymbol")),
2759 factory->internal_error_symbol(), NONE),
2760 false);
2761
2762 // Expose the debug global object in global if a name for it is specified. 2757 // Expose the debug global object in global if a name for it is specified.
2763 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { 2758 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
2764 // If loading fails we just bail out without installing the 2759 // If loading fails we just bail out without installing the
2765 // debugger but without tanking the whole context. 2760 // debugger but without tanking the whole context.
2766 Debug* debug = isolate->debug(); 2761 Debug* debug = isolate->debug();
2767 if (!debug->Load()) return true; 2762 if (!debug->Load()) return true;
2768 Handle<Context> debug_context = debug->debug_context(); 2763 Handle<Context> debug_context = debug->debug_context();
2769 // Set the security token for the debugger context to the same as 2764 // Set the security token for the debugger context to the same as
2770 // the shell native context to allow calling between these (otherwise 2765 // the shell native context to allow calling between these (otherwise
2771 // exposing debug global object doesn't make much sense). 2766 // exposing debug global object doesn't make much sense).
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 } 3273 }
3279 3274
3280 3275
3281 // Called when the top-level V8 mutex is destroyed. 3276 // Called when the top-level V8 mutex is destroyed.
3282 void Bootstrapper::FreeThreadResources() { 3277 void Bootstrapper::FreeThreadResources() {
3283 DCHECK(!IsActive()); 3278 DCHECK(!IsActive());
3284 } 3279 }
3285 3280
3286 } // namespace internal 3281 } // namespace internal
3287 } // namespace v8 3282 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698