| 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/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/extensions/externalize-string-extension.h" | 10 #include "src/extensions/externalize-string-extension.h" |
| (...skipping 2801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2812 HeapObject::cast(object_function->initial_map()->prototype())->map()); | 2812 HeapObject::cast(object_function->initial_map()->prototype())->map()); |
| 2813 | 2813 |
| 2814 // Store the map for the %StringPrototype% after the natives has been compiled | 2814 // Store the map for the %StringPrototype% after the natives has been compiled |
| 2815 // and the String function has been set up. | 2815 // and the String function has been set up. |
| 2816 Handle<JSFunction> string_function(native_context()->string_function()); | 2816 Handle<JSFunction> string_function(native_context()->string_function()); |
| 2817 DCHECK(JSObject::cast( | 2817 DCHECK(JSObject::cast( |
| 2818 string_function->initial_map()->prototype())->HasFastProperties()); | 2818 string_function->initial_map()->prototype())->HasFastProperties()); |
| 2819 native_context()->set_string_function_prototype_map( | 2819 native_context()->set_string_function_prototype_map( |
| 2820 HeapObject::cast(string_function->initial_map()->prototype())->map()); | 2820 HeapObject::cast(string_function->initial_map()->prototype())->map()); |
| 2821 | 2821 |
| 2822 Handle<JSGlobalObject> global_object = |
| 2823 handle(native_context()->global_object()); |
| 2824 |
| 2825 // Install Global.encodeURI. |
| 2826 SimpleInstallFunction(global_object, "encodeURI", Builtins::kGlobalEncodeURI, |
| 2827 1, false); |
| 2828 |
| 2829 // Install Global.encodeURIComponent. |
| 2830 SimpleInstallFunction(global_object, "encodeURIComponent", |
| 2831 Builtins::kGlobalEncodeURIComponent, 1, false); |
| 2832 |
| 2822 // Install Global.eval. | 2833 // Install Global.eval. |
| 2823 { | 2834 { |
| 2824 Handle<JSFunction> eval = SimpleInstallFunction( | 2835 Handle<JSFunction> eval = |
| 2825 handle(native_context()->global_object()), factory()->eval_string(), | 2836 SimpleInstallFunction(global_object, factory()->eval_string(), |
| 2826 Builtins::kGlobalEval, 1, false); | 2837 Builtins::kGlobalEval, 1, false); |
| 2827 native_context()->set_global_eval_fun(*eval); | 2838 native_context()->set_global_eval_fun(*eval); |
| 2828 } | 2839 } |
| 2829 | 2840 |
| 2830 // Install Array.prototype.concat | 2841 // Install Array.prototype.concat |
| 2831 { | 2842 { |
| 2832 Handle<JSFunction> array_constructor(native_context()->array_function()); | 2843 Handle<JSFunction> array_constructor(native_context()->array_function()); |
| 2833 Handle<JSObject> proto(JSObject::cast(array_constructor->prototype())); | 2844 Handle<JSObject> proto(JSObject::cast(array_constructor->prototype())); |
| 2834 Handle<JSFunction> concat = | 2845 Handle<JSFunction> concat = |
| 2835 InstallFunction(proto, "concat", JS_OBJECT_TYPE, JSObject::kHeaderSize, | 2846 InstallFunction(proto, "concat", JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 2836 MaybeHandle<JSObject>(), Builtins::kArrayConcat); | 2847 MaybeHandle<JSObject>(), Builtins::kArrayConcat); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2859 concat->shared()->DontAdaptArguments(); | 2870 concat->shared()->DontAdaptArguments(); |
| 2860 DCHECK(concat->is_compiled()); | 2871 DCHECK(concat->is_compiled()); |
| 2861 // Set the lengths for the functions to satisfy ECMA-262. | 2872 // Set the lengths for the functions to satisfy ECMA-262. |
| 2862 concat->shared()->set_length(1); | 2873 concat->shared()->set_length(1); |
| 2863 } | 2874 } |
| 2864 | 2875 |
| 2865 // Set up the Promise constructor. | 2876 // Set up the Promise constructor. |
| 2866 { | 2877 { |
| 2867 Handle<String> key = factory()->Promise_string(); | 2878 Handle<String> key = factory()->Promise_string(); |
| 2868 Handle<JSFunction> function = Handle<JSFunction>::cast( | 2879 Handle<JSFunction> function = Handle<JSFunction>::cast( |
| 2869 JSReceiver::GetProperty(handle(native_context()->global_object()), key) | 2880 JSReceiver::GetProperty(global_object, key).ToHandleChecked()); |
| 2870 .ToHandleChecked()); | |
| 2871 JSFunction::EnsureHasInitialMap(function); | 2881 JSFunction::EnsureHasInitialMap(function); |
| 2872 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); | 2882 function->initial_map()->set_instance_type(JS_PROMISE_TYPE); |
| 2873 function->shared()->set_construct_stub( | 2883 function->shared()->set_construct_stub( |
| 2874 *isolate()->builtins()->JSBuiltinsConstructStub()); | 2884 *isolate()->builtins()->JSBuiltinsConstructStub()); |
| 2875 InstallWithIntrinsicDefaultProto(isolate(), function, | 2885 InstallWithIntrinsicDefaultProto(isolate(), function, |
| 2876 Context::PROMISE_FUNCTION_INDEX); | 2886 Context::PROMISE_FUNCTION_INDEX); |
| 2877 } | 2887 } |
| 2878 | 2888 |
| 2879 InstallBuiltinFunctionIds(); | 2889 InstallBuiltinFunctionIds(); |
| 2880 | 2890 |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3767 } | 3777 } |
| 3768 | 3778 |
| 3769 | 3779 |
| 3770 // Called when the top-level V8 mutex is destroyed. | 3780 // Called when the top-level V8 mutex is destroyed. |
| 3771 void Bootstrapper::FreeThreadResources() { | 3781 void Bootstrapper::FreeThreadResources() { |
| 3772 DCHECK(!IsActive()); | 3782 DCHECK(!IsActive()); |
| 3773 } | 3783 } |
| 3774 | 3784 |
| 3775 } // namespace internal | 3785 } // namespace internal |
| 3776 } // namespace v8 | 3786 } // namespace v8 |
| OLD | NEW |