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 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1745 { // Initialize a result array for rempio2 calculation | 1745 { // Initialize a result array for rempio2 calculation |
1746 const size_t num_elements = 2; | 1746 const size_t num_elements = 2; |
1747 double* data = | 1747 double* data = |
1748 SetBuiltinTypedArray<double>(isolate(), builtins, kExternalFloat64Array, | 1748 SetBuiltinTypedArray<double>(isolate(), builtins, kExternalFloat64Array, |
1749 NULL, num_elements, "rempio2result"); | 1749 NULL, num_elements, "rempio2result"); |
1750 for (size_t i = 0; i < num_elements; i++) data[i] = 0; | 1750 for (size_t i = 0; i < num_elements; i++) data[i] = 0; |
1751 } | 1751 } |
1752 } | 1752 } |
1753 | 1753 |
1754 | 1754 |
1755 #define INSTALL_NATIVE(Type, name, var) \ | 1755 #define INSTALL_NATIVE(index, Type, name) \ |
1756 Handle<Object> var##_native = \ | 1756 Handle<Object> name##_native = \ |
1757 Object::GetProperty(isolate, container, name, STRICT).ToHandleChecked(); \ | 1757 Object::GetProperty(isolate, container, #name, STRICT) \ |
1758 DCHECK(var##_native->Is##Type()); \ | 1758 .ToHandleChecked(); \ |
1759 native_context->set_##var(Type::cast(*var##_native)); | 1759 DCHECK(name##_native->Is##Type()); \ |
| 1760 native_context->set_##name(Type::cast(*name##_native)); |
1760 | 1761 |
1761 | 1762 |
1762 void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) { | 1763 void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) { |
1763 HandleScope scope(isolate); | 1764 HandleScope scope(isolate); |
1764 Handle<Context> native_context = isolate->native_context(); | 1765 Handle<Context> native_context = isolate->native_context(); |
1765 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1766 NATIVE_CONTEXT_IMPORTED_FIELDS(INSTALL_NATIVE) |
1766 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | |
1767 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | |
1768 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | |
1769 INSTALL_NATIVE(JSFunction, "NoSideEffectToString", | |
1770 no_side_effect_to_string_fun); | |
1771 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); | |
1772 INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun); | |
1773 | |
1774 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); | |
1775 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); | |
1776 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", | |
1777 to_complete_property_descriptor); | |
1778 INSTALL_NATIVE(JSFunction, "ObjectDefineOwnProperty", | |
1779 object_define_own_property); | |
1780 INSTALL_NATIVE(JSFunction, "ObjectGetOwnPropertyDescriptor", | |
1781 object_get_own_property_descriptor); | |
1782 INSTALL_NATIVE(JSFunction, "MessageGetLineNumber", message_get_line_number); | |
1783 INSTALL_NATIVE(JSFunction, "MessageGetColumnNumber", | |
1784 message_get_column_number); | |
1785 INSTALL_NATIVE(JSFunction, "MessageGetSourceLine", message_get_source_line); | |
1786 INSTALL_NATIVE(JSObject, "StackOverflowBoilerplate", | |
1787 stack_overflow_boilerplate); | |
1788 INSTALL_NATIVE(JSFunction, "JsonSerializeAdapter", json_serialize_adapter); | |
1789 | |
1790 INSTALL_NATIVE(JSFunction, "Error", error_function); | |
1791 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function); | |
1792 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function); | |
1793 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function); | |
1794 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function); | |
1795 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function); | |
1796 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function); | |
1797 INSTALL_NATIVE(JSFunction, "MakeError", make_error_function); | |
1798 | |
1799 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); | |
1800 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); | |
1801 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); | |
1802 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); | |
1803 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); | |
1804 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); | |
1805 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler", | |
1806 promise_has_user_defined_reject_handler); | |
1807 | |
1808 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); | |
1809 INSTALL_NATIVE(JSFunction, "ObserveEnqueueSpliceRecord", | |
1810 observers_enqueue_splice); | |
1811 INSTALL_NATIVE(JSFunction, "ObserveBeginPerformSplice", | |
1812 observers_begin_perform_splice); | |
1813 INSTALL_NATIVE(JSFunction, "ObserveEndPerformSplice", | |
1814 observers_end_perform_splice); | |
1815 INSTALL_NATIVE(JSFunction, "ObserveNativeObjectObserve", | |
1816 native_object_observe); | |
1817 INSTALL_NATIVE(JSFunction, "ObserveNativeObjectGetNotifier", | |
1818 native_object_get_notifier); | |
1819 INSTALL_NATIVE(JSFunction, "ObserveNativeObjectNotifierPerformChange", | |
1820 native_object_notifier_perform_change); | |
1821 | |
1822 INSTALL_NATIVE(JSFunction, "ArrayValues", array_values_iterator); | |
1823 INSTALL_NATIVE(JSFunction, "MapGet", map_get); | |
1824 INSTALL_NATIVE(JSFunction, "MapSet", map_set); | |
1825 INSTALL_NATIVE(JSFunction, "MapHas", map_has); | |
1826 INSTALL_NATIVE(JSFunction, "MapDelete", map_delete); | |
1827 INSTALL_NATIVE(JSFunction, "SetAdd", set_add); | |
1828 INSTALL_NATIVE(JSFunction, "SetHas", set_has); | |
1829 INSTALL_NATIVE(JSFunction, "SetDelete", set_delete); | |
1830 INSTALL_NATIVE(JSFunction, "MapFromArray", map_from_array); | |
1831 INSTALL_NATIVE(JSFunction, "SetFromArray", set_from_array); | |
1832 } | 1767 } |
1833 | 1768 |
1834 | 1769 |
1835 #define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id) \ | 1770 #define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id) \ |
1836 static void InstallExperimentalNatives_##id(Isolate* isolate, \ | 1771 static void InstallExperimentalNatives_##id(Isolate* isolate, \ |
1837 Handle<Context> native_context, \ | 1772 Handle<Context> native_context, \ |
1838 Handle<JSObject> container) {} | 1773 Handle<JSObject> container) {} |
1839 | 1774 |
1840 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules) | 1775 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules) |
1841 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_array_includes) | 1776 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_array_includes) |
(...skipping 16 matching lines...) Expand all Loading... |
1858 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics) | 1793 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics) |
1859 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_new_target) | 1794 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_new_target) |
1860 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_concat_spreadable) | 1795 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_concat_spreadable) |
1861 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_simd) | 1796 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_simd) |
1862 | 1797 |
1863 | 1798 |
1864 static void InstallExperimentalNatives_harmony_proxies( | 1799 static void InstallExperimentalNatives_harmony_proxies( |
1865 Isolate* isolate, Handle<Context> native_context, | 1800 Isolate* isolate, Handle<Context> native_context, |
1866 Handle<JSObject> container) { | 1801 Handle<JSObject> container) { |
1867 if (FLAG_harmony_proxies) { | 1802 if (FLAG_harmony_proxies) { |
1868 INSTALL_NATIVE(JSFunction, "ProxyDerivedGetTrap", derived_get_trap); | 1803 NATIVE_CONTEXT_IMPORTED_FIELDS_FOR_PROXY(INSTALL_NATIVE) |
1869 INSTALL_NATIVE(JSFunction, "ProxyDerivedHasTrap", derived_has_trap); | |
1870 INSTALL_NATIVE(JSFunction, "ProxyDerivedSetTrap", derived_set_trap); | |
1871 INSTALL_NATIVE(JSFunction, "ProxyEnumerate", proxy_enumerate); | |
1872 } | 1804 } |
1873 } | 1805 } |
1874 | 1806 |
1875 | 1807 |
1876 void Bootstrapper::ImportExperimentalNatives(Isolate* isolate, | 1808 void Bootstrapper::ImportExperimentalNatives(Isolate* isolate, |
1877 Handle<JSObject> container) { | 1809 Handle<JSObject> container) { |
1878 HandleScope scope(isolate); | 1810 HandleScope scope(isolate); |
1879 Handle<Context> native_context = isolate->native_context(); | 1811 Handle<Context> native_context = isolate->native_context(); |
1880 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) \ | 1812 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) \ |
1881 InstallExperimentalNatives_##id(isolate, native_context, container); | 1813 InstallExperimentalNatives_##id(isolate, native_context, container); |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3314 } | 3246 } |
3315 | 3247 |
3316 | 3248 |
3317 // Called when the top-level V8 mutex is destroyed. | 3249 // Called when the top-level V8 mutex is destroyed. |
3318 void Bootstrapper::FreeThreadResources() { | 3250 void Bootstrapper::FreeThreadResources() { |
3319 DCHECK(!IsActive()); | 3251 DCHECK(!IsActive()); |
3320 } | 3252 } |
3321 | 3253 |
3322 } // namespace internal | 3254 } // namespace internal |
3323 } // namespace v8 | 3255 } // namespace v8 |
OLD | NEW |