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/ieee754.h" | 9 #include "src/base/ieee754.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void ConfigureUtilsObject(GlobalContextType context_type); | 209 void ConfigureUtilsObject(GlobalContextType context_type); |
210 | 210 |
211 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ | 211 #define DECLARE_FEATURE_INITIALIZATION(id, descr) \ |
212 void InitializeGlobal_##id(); | 212 void InitializeGlobal_##id(); |
213 | 213 |
214 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) | 214 HARMONY_INPROGRESS(DECLARE_FEATURE_INITIALIZATION) |
215 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) | 215 HARMONY_STAGED(DECLARE_FEATURE_INITIALIZATION) |
216 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) | 216 HARMONY_SHIPPING(DECLARE_FEATURE_INITIALIZATION) |
217 #undef DECLARE_FEATURE_INITIALIZATION | 217 #undef DECLARE_FEATURE_INITIALIZATION |
218 | 218 |
219 void InstallOneBuiltinFunction(const char* object, const char* method, | 219 void InstallOneBuiltinFunction(Handle<Object> prototype, const char* method, |
220 Builtins::Name name); | 220 Builtins::Name name); |
221 void InitializeGlobal_experimental_fast_array_builtins(); | 221 void InitializeGlobal_experimental_fast_array_builtins(); |
222 | 222 |
223 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, | 223 Handle<JSFunction> InstallArrayBuffer(Handle<JSObject> target, |
224 const char* name, | 224 const char* name, |
225 Builtins::Name call_byteLength, | 225 Builtins::Name call_byteLength, |
226 BuiltinFunctionId byteLength_id, | 226 BuiltinFunctionId byteLength_id, |
227 Builtins::Name call_slice); | 227 Builtins::Name call_slice); |
228 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, | 228 Handle<JSFunction> InstallInternalArray(Handle<JSObject> target, |
229 const char* name, | 229 const char* name, |
(...skipping 3590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3820 JSGlobalObject::cast(native_context->global_object())); | 3820 JSGlobalObject::cast(native_context->global_object())); |
3821 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); | 3821 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); |
3822 Handle<JSObject> symbol = Handle<JSObject>::cast( | 3822 Handle<JSObject> symbol = Handle<JSObject>::cast( |
3823 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); | 3823 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); |
3824 Handle<String> name_string = factory->InternalizeUtf8String(name); | 3824 Handle<String> name_string = factory->InternalizeUtf8String(name); |
3825 PropertyAttributes attributes = | 3825 PropertyAttributes attributes = |
3826 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 3826 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
3827 JSObject::AddProperty(symbol, name_string, value, attributes); | 3827 JSObject::AddProperty(symbol, name_string, value, attributes); |
3828 } | 3828 } |
3829 | 3829 |
3830 void Genesis::InstallOneBuiltinFunction(const char* object_name, | 3830 void Genesis::InstallOneBuiltinFunction(Handle<Object> prototype, |
3831 const char* method_name, | 3831 const char* method_name, |
3832 Builtins::Name builtin_name) { | 3832 Builtins::Name builtin_name) { |
3833 Handle<JSGlobalObject> global(native_context()->global_object()); | 3833 LookupIterator it( |
3834 Isolate* isolate = global->GetIsolate(); | 3834 prototype, isolate()->factory()->NewStringFromAsciiChecked(method_name), |
3835 Factory* factory = isolate->factory(); | 3835 LookupIterator::OWN_SKIP_INTERCEPTOR); |
3836 | 3836 Handle<Object> function = Object::GetProperty(&it).ToHandleChecked(); |
3837 LookupIterator it1(global, factory->NewStringFromAsciiChecked(object_name), | |
3838 LookupIterator::OWN_SKIP_INTERCEPTOR); | |
3839 Handle<Object> object = Object::GetProperty(&it1).ToHandleChecked(); | |
3840 LookupIterator it2(object, factory->NewStringFromAsciiChecked("prototype"), | |
3841 LookupIterator::OWN_SKIP_INTERCEPTOR); | |
3842 Handle<Object> prototype = Object::GetProperty(&it2).ToHandleChecked(); | |
3843 | |
3844 LookupIterator it3(prototype, factory->NewStringFromAsciiChecked(method_name), | |
3845 LookupIterator::OWN_SKIP_INTERCEPTOR); | |
3846 Handle<Object> function = Object::GetProperty(&it3).ToHandleChecked(); | |
3847 Handle<JSFunction>::cast(function)->set_code( | 3837 Handle<JSFunction>::cast(function)->set_code( |
3848 isolate->builtins()->builtin(builtin_name)); | 3838 isolate()->builtins()->builtin(builtin_name)); |
3849 Handle<JSFunction>::cast(function)->shared()->set_code( | 3839 Handle<JSFunction>::cast(function)->shared()->set_code( |
3850 isolate->builtins()->builtin(builtin_name)); | 3840 isolate()->builtins()->builtin(builtin_name)); |
3851 } | 3841 } |
3852 | 3842 |
3853 void Genesis::InitializeGlobal_experimental_fast_array_builtins() { | 3843 void Genesis::InitializeGlobal_experimental_fast_array_builtins() { |
3854 if (!FLAG_experimental_fast_array_builtins) return; | 3844 if (!FLAG_experimental_fast_array_builtins) return; |
3855 | 3845 { |
3856 // Insert experimental fast array builtins here. | 3846 Handle<JSFunction> array_constructor(native_context()->array_function()); |
3857 InstallOneBuiltinFunction("Array", "filter", Builtins::kArrayFilter); | 3847 Handle<Object> array_prototype(array_constructor->prototype(), isolate()); |
3858 InstallOneBuiltinFunction("Array", "map", Builtins::kArrayMap); | 3848 // Insert experimental fast Array builtins here. |
| 3849 InstallOneBuiltinFunction(array_prototype, "filter", |
| 3850 Builtins::kArrayFilter); |
| 3851 InstallOneBuiltinFunction(array_prototype, "map", Builtins::kArrayMap); |
| 3852 } |
| 3853 { |
| 3854 Handle<Object> typed_array_prototype( |
| 3855 native_context()->typed_array_prototype(), isolate()); |
| 3856 // Insert experimental fast TypedArray builtins here. |
| 3857 InstallOneBuiltinFunction(typed_array_prototype, "every", |
| 3858 Builtins::kTypedArrayPrototypeEvery); |
| 3859 InstallOneBuiltinFunction(typed_array_prototype, "some", |
| 3860 Builtins::kTypedArrayPrototypeSome); |
| 3861 } |
3859 } | 3862 } |
3860 | 3863 |
3861 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { | 3864 void Genesis::InitializeGlobal_harmony_sharedarraybuffer() { |
3862 if (!FLAG_harmony_sharedarraybuffer) return; | 3865 if (!FLAG_harmony_sharedarraybuffer) return; |
3863 | 3866 |
3864 Handle<JSGlobalObject> global(native_context()->global_object()); | 3867 Handle<JSGlobalObject> global(native_context()->global_object()); |
3865 Isolate* isolate = global->GetIsolate(); | 3868 Isolate* isolate = global->GetIsolate(); |
3866 Factory* factory = isolate->factory(); | 3869 Factory* factory = isolate->factory(); |
3867 | 3870 |
3868 Handle<JSFunction> shared_array_buffer_fun = | 3871 Handle<JSFunction> shared_array_buffer_fun = |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5241 } | 5244 } |
5242 | 5245 |
5243 | 5246 |
5244 // Called when the top-level V8 mutex is destroyed. | 5247 // Called when the top-level V8 mutex is destroyed. |
5245 void Bootstrapper::FreeThreadResources() { | 5248 void Bootstrapper::FreeThreadResources() { |
5246 DCHECK(!IsActive()); | 5249 DCHECK(!IsActive()); |
5247 } | 5250 } |
5248 | 5251 |
5249 } // namespace internal | 5252 } // namespace internal |
5250 } // namespace v8 | 5253 } // namespace v8 |
OLD | NEW |