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(index, Type, name) \ | |
1756 Handle<Object> name##_native = \ | |
1757 Object::GetProperty(isolate, container, #name, STRICT) \ | |
1758 .ToHandleChecked(); \ | |
1759 DCHECK(name##_native->Is##Type()); \ | |
1760 native_context->set_##name(Type::cast(*name##_native)); | |
1761 | |
1762 | |
1763 void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) { | |
1764 HandleScope scope(isolate); | |
1765 Handle<Context> native_context = isolate->native_context(); | |
1766 NATIVE_CONTEXT_IMPORTED_FIELDS(INSTALL_NATIVE) | |
1767 } | |
1768 | |
1769 | |
1770 #define EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(id) \ | |
1771 static void InstallExperimentalNatives_##id(Isolate* isolate, \ | |
1772 Handle<Context> native_context, \ | |
1773 Handle<JSObject> container) {} | |
1774 | |
1775 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_modules) | |
1776 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_array_includes) | |
1777 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_regexps) | |
1778 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_arrow_functions) | |
1779 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_tostring) | |
1780 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy) | |
1781 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy_function) | |
1782 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sloppy_let) | |
1783 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_unicode_regexps) | |
1784 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_rest_parameters) | |
1785 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_default_parameters) | |
1786 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_reflect) | |
1787 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spreadcalls) | |
1788 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_destructuring) | |
1789 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object) | |
1790 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_object_observe) | |
1791 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_spread_arrays) | |
1792 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_sharedarraybuffer) | |
1793 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_atomics) | |
1794 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_new_target) | |
1795 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_concat_spreadable) | |
1796 EMPTY_NATIVE_FUNCTIONS_FOR_FEATURE(harmony_simd) | |
1797 | |
1798 | |
1799 static void InstallExperimentalNatives_harmony_proxies( | |
1800 Isolate* isolate, Handle<Context> native_context, | |
1801 Handle<JSObject> container) { | |
1802 if (FLAG_harmony_proxies) { | |
1803 NATIVE_CONTEXT_IMPORTED_FIELDS_FOR_PROXY(INSTALL_NATIVE) | |
1804 } | |
1805 } | |
1806 | |
1807 | |
1808 void Bootstrapper::ImportExperimentalNatives(Isolate* isolate, | |
1809 Handle<JSObject> container) { | |
1810 HandleScope scope(isolate); | |
1811 Handle<Context> native_context = isolate->native_context(); | |
1812 #define INSTALL_NATIVE_FUNCTIONS_FOR(id, descr) \ | |
1813 InstallExperimentalNatives_##id(isolate, native_context, container); | |
1814 | |
1815 HARMONY_INPROGRESS(INSTALL_NATIVE_FUNCTIONS_FOR) | |
1816 HARMONY_STAGED(INSTALL_NATIVE_FUNCTIONS_FOR) | |
1817 HARMONY_SHIPPING(INSTALL_NATIVE_FUNCTIONS_FOR) | |
1818 #undef INSTALL_NATIVE_FUNCTIONS_FOR | |
1819 } | |
1820 | |
1821 #undef INSTALL_NATIVE | |
1822 | |
1823 | |
1824 bool Bootstrapper::InstallJSBuiltins(Isolate* isolate, | 1755 bool Bootstrapper::InstallJSBuiltins(Isolate* isolate, |
1825 Handle<JSObject> container) { | 1756 Handle<JSObject> container) { |
1826 HandleScope scope(isolate); | 1757 HandleScope scope(isolate); |
1827 Handle<JSBuiltinsObject> builtins = isolate->js_builtins_object(); | 1758 Handle<JSBuiltinsObject> builtins = isolate->js_builtins_object(); |
1828 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { | 1759 for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) { |
1829 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); | 1760 Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i); |
1830 Handle<Object> function_object = | 1761 Handle<Object> function_object = |
1831 Object::GetProperty(isolate, container, Builtins::GetName(id)) | 1762 Object::GetProperty(isolate, container, Builtins::GetName(id)) |
1832 .ToHandleChecked(); | 1763 .ToHandleChecked(); |
1833 DCHECK(function_object->IsJSFunction()); | 1764 DCHECK(function_object->IsJSFunction()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 | 1829 |
1899 void Genesis::InitializeGlobal_harmony_reflect() { | 1830 void Genesis::InitializeGlobal_harmony_reflect() { |
1900 Handle<JSObject> builtins(native_context()->builtins()); | 1831 Handle<JSObject> builtins(native_context()->builtins()); |
1901 | 1832 |
1902 Handle<JSFunction> apply = InstallFunction( | 1833 Handle<JSFunction> apply = InstallFunction( |
1903 builtins, "$reflectApply", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1834 builtins, "$reflectApply", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1904 MaybeHandle<JSObject>(), Builtins::kReflectApply); | 1835 MaybeHandle<JSObject>(), Builtins::kReflectApply); |
1905 apply->shared()->set_internal_formal_parameter_count(3); | 1836 apply->shared()->set_internal_formal_parameter_count(3); |
1906 apply->shared()->set_length(3); | 1837 apply->shared()->set_length(3); |
1907 | 1838 |
| 1839 native_context()->set_reflect_apply(*apply); |
| 1840 |
1908 Handle<JSFunction> construct = InstallFunction( | 1841 Handle<JSFunction> construct = InstallFunction( |
1909 builtins, "$reflectConstruct", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 1842 builtins, "$reflectConstruct", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
1910 MaybeHandle<JSObject>(), Builtins::kReflectConstruct); | 1843 MaybeHandle<JSObject>(), Builtins::kReflectConstruct); |
1911 construct->shared()->set_internal_formal_parameter_count(3); | 1844 construct->shared()->set_internal_formal_parameter_count(3); |
1912 construct->shared()->set_length(2); | 1845 construct->shared()->set_length(2); |
1913 | 1846 |
| 1847 native_context()->set_reflect_construct(*construct); |
| 1848 |
1914 if (!FLAG_harmony_reflect) return; | 1849 if (!FLAG_harmony_reflect) return; |
1915 | 1850 |
1916 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 1851 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
1917 native_context()->global_object())); | 1852 native_context()->global_object())); |
1918 Handle<String> reflect_string = | 1853 Handle<String> reflect_string = |
1919 factory()->NewStringFromStaticChars("Reflect"); | 1854 factory()->NewStringFromStaticChars("Reflect"); |
1920 Handle<Object> reflect = | 1855 Handle<Object> reflect = |
1921 factory()->NewJSObject(isolate()->object_function(), TENURED); | 1856 factory()->NewJSObject(isolate()->object_function(), TENURED); |
1922 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); | 1857 JSObject::AddProperty(global, reflect_string, reflect, DONT_ENUM); |
1923 } | 1858 } |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3246 } | 3181 } |
3247 | 3182 |
3248 | 3183 |
3249 // Called when the top-level V8 mutex is destroyed. | 3184 // Called when the top-level V8 mutex is destroyed. |
3250 void Bootstrapper::FreeThreadResources() { | 3185 void Bootstrapper::FreeThreadResources() { |
3251 DCHECK(!IsActive()); | 3186 DCHECK(!IsActive()); |
3252 } | 3187 } |
3253 | 3188 |
3254 } // namespace internal | 3189 } // namespace internal |
3255 } // namespace v8 | 3190 } // namespace v8 |
OLD | NEW |