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 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 { | 1141 { |
1142 // --- S y m b o l --- | 1142 // --- S y m b o l --- |
1143 Handle<JSFunction> symbol_fun = InstallFunction( | 1143 Handle<JSFunction> symbol_fun = InstallFunction( |
1144 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, | 1144 global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, |
1145 isolate->initial_object_prototype(), Builtins::kIllegal); | 1145 isolate->initial_object_prototype(), Builtins::kIllegal); |
1146 native_context()->set_symbol_function(*symbol_fun); | 1146 native_context()->set_symbol_function(*symbol_fun); |
1147 } | 1147 } |
1148 | 1148 |
1149 { // --- D a t e --- | 1149 { // --- D a t e --- |
1150 // Builtin functions for Date.prototype. | 1150 // Builtin functions for Date.prototype. |
1151 Handle<JSFunction> date_fun = | 1151 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, |
1152 InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize, | 1152 isolate->initial_object_prototype(), Builtins::kIllegal); |
1153 isolate->initial_object_prototype(), | |
1154 Builtins::kIllegal); | |
1155 | |
1156 native_context()->set_date_function(*date_fun); | |
1157 } | 1153 } |
1158 | 1154 |
1159 | 1155 |
1160 { // -- R e g E x p | 1156 { // -- R e g E x p |
1161 // Builtin functions for RegExp.prototype. | 1157 // Builtin functions for RegExp.prototype. |
1162 Handle<JSFunction> regexp_fun = | 1158 Handle<JSFunction> regexp_fun = |
1163 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, | 1159 InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize, |
1164 isolate->initial_object_prototype(), | 1160 isolate->initial_object_prototype(), |
1165 Builtins::kIllegal); | 1161 Builtins::kIllegal); |
1166 native_context()->set_regexp_function(*regexp_fun); | 1162 native_context()->set_regexp_function(*regexp_fun); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 | 1244 |
1249 { // -- J S O N | 1245 { // -- J S O N |
1250 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1246 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
1251 Handle<JSFunction> cons = factory->NewFunction(name); | 1247 Handle<JSFunction> cons = factory->NewFunction(name); |
1252 JSFunction::SetInstancePrototype(cons, | 1248 JSFunction::SetInstancePrototype(cons, |
1253 Handle<Object>(native_context()->initial_object_prototype(), isolate)); | 1249 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
1254 cons->SetInstanceClassName(*name); | 1250 cons->SetInstanceClassName(*name); |
1255 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); | 1251 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
1256 DCHECK(json_object->IsJSObject()); | 1252 DCHECK(json_object->IsJSObject()); |
1257 JSObject::AddProperty(global, name, json_object, DONT_ENUM); | 1253 JSObject::AddProperty(global, name, json_object, DONT_ENUM); |
1258 native_context()->set_json_object(*json_object); | 1254 } |
| 1255 |
| 1256 { // -- M a t h |
| 1257 Handle<String> name = factory->InternalizeUtf8String("Math"); |
| 1258 Handle<JSFunction> cons = factory->NewFunction(name); |
| 1259 JSFunction::SetInstancePrototype( |
| 1260 cons, |
| 1261 Handle<Object>(native_context()->initial_object_prototype(), isolate)); |
| 1262 cons->SetInstanceClassName(*name); |
| 1263 Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED); |
| 1264 DCHECK(json_object->IsJSObject()); |
| 1265 JSObject::AddProperty(global, name, json_object, DONT_ENUM); |
1259 } | 1266 } |
1260 | 1267 |
1261 { // -- A r r a y B u f f e r | 1268 { // -- A r r a y B u f f e r |
1262 Handle<JSFunction> array_buffer_fun = | 1269 Handle<JSFunction> array_buffer_fun = |
1263 InstallFunction( | 1270 InstallFunction( |
1264 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, | 1271 global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE, |
1265 JSArrayBuffer::kSizeWithInternalFields, | 1272 JSArrayBuffer::kSizeWithInternalFields, |
1266 isolate->initial_object_prototype(), | 1273 isolate->initial_object_prototype(), |
1267 Builtins::kIllegal); | 1274 Builtins::kIllegal); |
1268 native_context()->set_array_buffer_fun(*array_buffer_fun); | 1275 native_context()->set_array_buffer_fun(*array_buffer_fun); |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 native_context->set_##var(Type::cast(*var##_native)); | 1766 native_context->set_##var(Type::cast(*var##_native)); |
1760 | 1767 |
1761 | 1768 |
1762 void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) { | 1769 void Bootstrapper::ImportNatives(Isolate* isolate, Handle<JSObject> container) { |
1763 HandleScope scope(isolate); | 1770 HandleScope scope(isolate); |
1764 Handle<Context> native_context = isolate->native_context(); | 1771 Handle<Context> native_context = isolate->native_context(); |
1765 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); | 1772 INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun); |
1766 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); | 1773 INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun); |
1767 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); | 1774 INSTALL_NATIVE(JSFunction, "ToString", to_string_fun); |
1768 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); | 1775 INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun); |
| 1776 INSTALL_NATIVE(JSFunction, "NoSideEffectToString", |
| 1777 no_side_effect_to_string_fun); |
1769 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); | 1778 INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun); |
1770 INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun); | 1779 INSTALL_NATIVE(JSFunction, "ToLength", to_length_fun); |
1771 | 1780 |
1772 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); | 1781 INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun); |
1773 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); | 1782 INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun); |
1774 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", | 1783 INSTALL_NATIVE(JSFunction, "ToCompletePropertyDescriptor", |
1775 to_complete_property_descriptor); | 1784 to_complete_property_descriptor); |
| 1785 INSTALL_NATIVE(JSFunction, "JsonSerializeAdapter", json_serialize_adapter); |
| 1786 |
| 1787 INSTALL_NATIVE(JSFunction, "Error", error_function); |
| 1788 INSTALL_NATIVE(JSFunction, "EvalError", eval_error_function); |
| 1789 INSTALL_NATIVE(JSFunction, "RangeError", range_error_function); |
| 1790 INSTALL_NATIVE(JSFunction, "ReferenceError", reference_error_function); |
| 1791 INSTALL_NATIVE(JSFunction, "SyntaxError", syntax_error_function); |
| 1792 INSTALL_NATIVE(JSFunction, "TypeError", type_error_function); |
| 1793 INSTALL_NATIVE(JSFunction, "URIError", uri_error_function); |
1776 | 1794 |
1777 INSTALL_NATIVE(Symbol, "promiseStatus", promise_status); | 1795 INSTALL_NATIVE(Symbol, "promiseStatus", promise_status); |
1778 INSTALL_NATIVE(Symbol, "promiseValue", promise_value); | 1796 INSTALL_NATIVE(Symbol, "promiseValue", promise_value); |
1779 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); | 1797 INSTALL_NATIVE(JSFunction, "PromiseCreate", promise_create); |
1780 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); | 1798 INSTALL_NATIVE(JSFunction, "PromiseResolve", promise_resolve); |
1781 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); | 1799 INSTALL_NATIVE(JSFunction, "PromiseReject", promise_reject); |
1782 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); | 1800 INSTALL_NATIVE(JSFunction, "PromiseChain", promise_chain); |
1783 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); | 1801 INSTALL_NATIVE(JSFunction, "PromiseCatch", promise_catch); |
1784 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); | 1802 INSTALL_NATIVE(JSFunction, "PromiseThen", promise_then); |
| 1803 INSTALL_NATIVE(JSFunction, "PromiseHasUserDefinedRejectHandler", |
| 1804 promise_has_user_defined_reject_handler); |
1785 | 1805 |
1786 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); | 1806 INSTALL_NATIVE(JSFunction, "ObserveNotifyChange", observers_notify_change); |
1787 INSTALL_NATIVE(JSFunction, "ObserveEnqueueSpliceRecord", | 1807 INSTALL_NATIVE(JSFunction, "ObserveEnqueueSpliceRecord", |
1788 observers_enqueue_splice); | 1808 observers_enqueue_splice); |
1789 INSTALL_NATIVE(JSFunction, "ObserveBeginPerformSplice", | 1809 INSTALL_NATIVE(JSFunction, "ObserveBeginPerformSplice", |
1790 observers_begin_perform_splice); | 1810 observers_begin_perform_splice); |
1791 INSTALL_NATIVE(JSFunction, "ObserveEndPerformSplice", | 1811 INSTALL_NATIVE(JSFunction, "ObserveEndPerformSplice", |
1792 observers_end_perform_splice); | 1812 observers_end_perform_splice); |
1793 INSTALL_NATIVE(JSFunction, "ObserveNativeObjectObserve", | 1813 INSTALL_NATIVE(JSFunction, "ObserveNativeObjectObserve", |
1794 native_object_observe); | 1814 native_object_observe); |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3268 } | 3288 } |
3269 | 3289 |
3270 | 3290 |
3271 // Called when the top-level V8 mutex is destroyed. | 3291 // Called when the top-level V8 mutex is destroyed. |
3272 void Bootstrapper::FreeThreadResources() { | 3292 void Bootstrapper::FreeThreadResources() { |
3273 DCHECK(!IsActive()); | 3293 DCHECK(!IsActive()); |
3274 } | 3294 } |
3275 | 3295 |
3276 } // namespace internal | 3296 } // namespace internal |
3277 } // namespace v8 | 3297 } // namespace v8 |
OLD | NEW |