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 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 Handle<JSGlobalObject> global_object_from_snapshot( | 1007 Handle<JSGlobalObject> global_object_from_snapshot( |
1008 JSGlobalObject::cast(native_context()->extension())); | 1008 JSGlobalObject::cast(native_context()->extension())); |
1009 native_context()->set_extension(*global_object); | 1009 native_context()->set_extension(*global_object); |
1010 native_context()->set_security_token(*global_object); | 1010 native_context()->set_security_token(*global_object); |
1011 | 1011 |
1012 TransferNamedProperties(global_object_from_snapshot, global_object); | 1012 TransferNamedProperties(global_object_from_snapshot, global_object); |
1013 TransferIndexedProperties(global_object_from_snapshot, global_object); | 1013 TransferIndexedProperties(global_object_from_snapshot, global_object); |
1014 } | 1014 } |
1015 | 1015 |
1016 | 1016 |
| 1017 static void SimpleInstallFunction(Handle<JSObject> base, Handle<Name> name, |
| 1018 Builtins::Name call, int len, bool adapt) { |
| 1019 Handle<JSFunction> fun = |
| 1020 InstallFunction(base, name, JS_OBJECT_TYPE, JSObject::kHeaderSize, |
| 1021 MaybeHandle<JSObject>(), call, DONT_ENUM); |
| 1022 if (adapt) { |
| 1023 fun->shared()->set_internal_formal_parameter_count(len); |
| 1024 } else { |
| 1025 fun->shared()->DontAdaptArguments(); |
| 1026 } |
| 1027 fun->shared()->set_length(len); |
| 1028 } |
| 1029 |
| 1030 |
1017 // This is only called if we are not using snapshots. The equivalent | 1031 // This is only called if we are not using snapshots. The equivalent |
1018 // work in the snapshot case is done in HookUpGlobalObject. | 1032 // work in the snapshot case is done in HookUpGlobalObject. |
1019 void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, | 1033 void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object, |
1020 Handle<JSFunction> empty_function, | 1034 Handle<JSFunction> empty_function, |
1021 ContextType context_type) { | 1035 ContextType context_type) { |
1022 // --- N a t i v e C o n t e x t --- | 1036 // --- N a t i v e C o n t e x t --- |
1023 // Use the empty function as closure (no scope info). | 1037 // Use the empty function as closure (no scope info). |
1024 native_context()->set_closure(*empty_function); | 1038 native_context()->set_closure(*empty_function); |
1025 native_context()->set_previous(NULL); | 1039 native_context()->set_previous(NULL); |
1026 // Set extension and global object. | 1040 // Set extension and global object. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 // Cache the array maps, needed by ArrayConstructorStub | 1107 // Cache the array maps, needed by ArrayConstructorStub |
1094 CacheInitialJSArrayMaps(native_context(), initial_map); | 1108 CacheInitialJSArrayMaps(native_context(), initial_map); |
1095 ArrayConstructorStub array_constructor_stub(isolate); | 1109 ArrayConstructorStub array_constructor_stub(isolate); |
1096 Handle<Code> code = array_constructor_stub.GetCode(); | 1110 Handle<Code> code = array_constructor_stub.GetCode(); |
1097 array_function->shared()->set_construct_stub(*code); | 1111 array_function->shared()->set_construct_stub(*code); |
1098 | 1112 |
1099 Handle<Map> initial_strong_map = | 1113 Handle<Map> initial_strong_map = |
1100 Map::Copy(initial_map, "SetInstancePrototype"); | 1114 Map::Copy(initial_map, "SetInstancePrototype"); |
1101 initial_strong_map->set_is_strong(); | 1115 initial_strong_map->set_is_strong(); |
1102 CacheInitialJSArrayMaps(native_context(), initial_strong_map); | 1116 CacheInitialJSArrayMaps(native_context(), initial_strong_map); |
| 1117 |
| 1118 SimpleInstallFunction(array_function, |
| 1119 factory->NewStringFromAsciiChecked("isArray"), |
| 1120 Builtins::kArrayIsArray, 1, true); |
1103 } | 1121 } |
1104 | 1122 |
1105 { // --- N u m b e r --- | 1123 { // --- N u m b e r --- |
1106 Handle<JSFunction> number_fun = | 1124 Handle<JSFunction> number_fun = |
1107 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 1125 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
1108 isolate->initial_object_prototype(), | 1126 isolate->initial_object_prototype(), |
1109 Builtins::kIllegal); | 1127 Builtins::kIllegal); |
1110 native_context()->set_number_function(*number_fun); | 1128 native_context()->set_number_function(*number_fun); |
1111 number_fun->shared()->set_construct_stub( | 1129 number_fun->shared()->set_construct_stub( |
1112 *isolate->builtins()->JSBuiltinsConstructStub()); | 1130 *isolate->builtins()->JSBuiltinsConstructStub()); |
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring_bind) | 1980 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_destructuring_bind) |
1963 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe) | 1981 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_object_observe) |
1964 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps) | 1982 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexps) |
1965 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) | 1983 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_unicode_regexps) |
1966 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion) | 1984 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_completion) |
1967 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength) | 1985 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_tolength) |
1968 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) | 1986 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_do_expressions) |
1969 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) | 1987 EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_regexp_lookbehind) |
1970 | 1988 |
1971 | 1989 |
1972 static void SimpleInstallFunction(Handle<JSObject> base, Handle<Name> name, | |
1973 Builtins::Name call, int len, bool adapt) { | |
1974 Handle<JSFunction> fun = | |
1975 InstallFunction(base, name, JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1976 MaybeHandle<JSObject>(), call, DONT_ENUM); | |
1977 if (adapt) { | |
1978 fun->shared()->set_internal_formal_parameter_count(len); | |
1979 } else { | |
1980 fun->shared()->DontAdaptArguments(); | |
1981 } | |
1982 fun->shared()->set_length(len); | |
1983 } | |
1984 | |
1985 | |
1986 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, | 1990 void InstallPublicSymbol(Factory* factory, Handle<Context> native_context, |
1987 const char* name, Handle<Symbol> value) { | 1991 const char* name, Handle<Symbol> value) { |
1988 Handle<JSGlobalObject> global( | 1992 Handle<JSGlobalObject> global( |
1989 JSGlobalObject::cast(native_context->global_object())); | 1993 JSGlobalObject::cast(native_context->global_object())); |
1990 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); | 1994 Handle<String> symbol_string = factory->InternalizeUtf8String("Symbol"); |
1991 Handle<JSObject> symbol = Handle<JSObject>::cast( | 1995 Handle<JSObject> symbol = Handle<JSObject>::cast( |
1992 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); | 1996 JSObject::GetProperty(global, symbol_string).ToHandleChecked()); |
1993 Handle<String> name_string = factory->InternalizeUtf8String(name); | 1997 Handle<String> name_string = factory->InternalizeUtf8String(name); |
1994 PropertyAttributes attributes = | 1998 PropertyAttributes attributes = |
1995 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); | 1999 static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY); |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3145 } | 3149 } |
3146 | 3150 |
3147 | 3151 |
3148 // Called when the top-level V8 mutex is destroyed. | 3152 // Called when the top-level V8 mutex is destroyed. |
3149 void Bootstrapper::FreeThreadResources() { | 3153 void Bootstrapper::FreeThreadResources() { |
3150 DCHECK(!IsActive()); | 3154 DCHECK(!IsActive()); |
3151 } | 3155 } |
3152 | 3156 |
3153 } // namespace internal | 3157 } // namespace internal |
3154 } // namespace v8 | 3158 } // namespace v8 |
OLD | NEW |