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 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 ArrayConstructorStub array_constructor_stub(isolate); | 1120 ArrayConstructorStub array_constructor_stub(isolate); |
1121 Handle<Code> code = array_constructor_stub.GetCode(); | 1121 Handle<Code> code = array_constructor_stub.GetCode(); |
1122 array_function->shared()->set_construct_stub(*code); | 1122 array_function->shared()->set_construct_stub(*code); |
1123 | 1123 |
1124 Handle<Map> initial_strong_map = | 1124 Handle<Map> initial_strong_map = |
1125 Map::Copy(initial_map, "SetInstancePrototype"); | 1125 Map::Copy(initial_map, "SetInstancePrototype"); |
1126 initial_strong_map->set_is_strong(); | 1126 initial_strong_map->set_is_strong(); |
1127 CacheInitialJSArrayMaps(native_context(), initial_strong_map); | 1127 CacheInitialJSArrayMaps(native_context(), initial_strong_map); |
1128 | 1128 |
1129 SimpleInstallFunction(array_function, | 1129 SimpleInstallFunction(array_function, |
1130 isolate->factory()->InternalizeUtf8String("isArray"), | 1130 factory->NewStringFromAsciiChecked("isArray"), |
1131 Builtins::kArrayIsArray, 1, true); | 1131 Builtins::kArrayIsArray, 1, true); |
1132 } | 1132 } |
1133 | 1133 |
1134 { // --- N u m b e r --- | 1134 { // --- N u m b e r --- |
1135 Handle<JSFunction> number_fun = | 1135 Handle<JSFunction> number_fun = |
1136 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, | 1136 InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize, |
1137 isolate->initial_object_prototype(), | 1137 isolate->initial_object_prototype(), |
1138 Builtins::kIllegal); | 1138 Builtins::kIllegal); |
1139 InstallWithIntrinsicDefaultProto(isolate, number_fun, | 1139 InstallWithIntrinsicDefaultProto(isolate, number_fun, |
1140 Context::NUMBER_FUNCTION_INDEX); | 1140 Context::NUMBER_FUNCTION_INDEX); |
1141 number_fun->shared()->set_construct_stub( | 1141 number_fun->shared()->set_construct_stub( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 Representation::Tagged()); | 1227 Representation::Tagged()); |
1228 initial_map->AppendDescriptor(&field); | 1228 initial_map->AppendDescriptor(&field); |
1229 | 1229 |
1230 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1230 static const int num_fields = JSRegExp::kInObjectFieldCount; |
1231 initial_map->SetInObjectProperties(num_fields); | 1231 initial_map->SetInObjectProperties(num_fields); |
1232 initial_map->set_unused_property_fields(0); | 1232 initial_map->set_unused_property_fields(0); |
1233 initial_map->set_instance_size(initial_map->instance_size() + | 1233 initial_map->set_instance_size(initial_map->instance_size() + |
1234 num_fields * kPointerSize); | 1234 num_fields * kPointerSize); |
1235 } | 1235 } |
1236 | 1236 |
1237 { // -- E r r o r | |
1238 Handle<JSFunction> error_fun = InstallFunction( | |
1239 global, "Error", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1240 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1241 InstallWithIntrinsicDefaultProto(isolate, error_fun, | |
1242 Context::ERROR_FUNCTION_INDEX); | |
1243 } | |
1244 | |
1245 { // -- E v a l E r r o r | |
1246 Handle<JSFunction> eval_error_fun = InstallFunction( | |
1247 global, "EvalError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1248 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1249 InstallWithIntrinsicDefaultProto(isolate, eval_error_fun, | |
1250 Context::EVAL_ERROR_FUNCTION_INDEX); | |
1251 } | |
1252 | |
1253 { // -- R a n g e E r r o r | |
1254 Handle<JSFunction> range_error_fun = InstallFunction( | |
1255 global, "RangeError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1256 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1257 InstallWithIntrinsicDefaultProto(isolate, range_error_fun, | |
1258 Context::RANGE_ERROR_FUNCTION_INDEX); | |
1259 } | |
1260 | |
1261 { // -- R e f e r e n c e E r r o r | |
1262 Handle<JSFunction> reference_error_fun = InstallFunction( | |
1263 global, "ReferenceError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1264 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1265 InstallWithIntrinsicDefaultProto(isolate, reference_error_fun, | |
1266 Context::REFERENCE_ERROR_FUNCTION_INDEX); | |
1267 } | |
1268 | |
1269 { // -- S y n t a x E r r o r | |
1270 Handle<JSFunction> syntax_error_fun = InstallFunction( | |
1271 global, "SyntaxError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1272 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1273 InstallWithIntrinsicDefaultProto(isolate, syntax_error_fun, | |
1274 Context::SYNTAX_ERROR_FUNCTION_INDEX); | |
1275 } | |
1276 | |
1277 { // -- T y p e E r r o r | |
1278 Handle<JSFunction> type_error_fun = InstallFunction( | |
1279 global, "TypeError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1280 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1281 InstallWithIntrinsicDefaultProto(isolate, type_error_fun, | |
1282 Context::TYPE_ERROR_FUNCTION_INDEX); | |
1283 } | |
1284 | |
1285 { // -- U R I E r r o r | |
1286 Handle<JSFunction> uri_error_fun = InstallFunction( | |
1287 global, "URIError", JS_OBJECT_TYPE, JSObject::kHeaderSize, | |
1288 isolate->initial_object_prototype(), Builtins::kIllegal); | |
1289 InstallWithIntrinsicDefaultProto(isolate, uri_error_fun, | |
1290 Context::URI_ERROR_FUNCTION_INDEX); | |
1291 } | |
1292 | |
1293 // Initialize the embedder data slot. | 1237 // Initialize the embedder data slot. |
1294 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); | 1238 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
1295 native_context()->set_embedder_data(*embedder_data); | 1239 native_context()->set_embedder_data(*embedder_data); |
1296 | 1240 |
1297 if (context_type == THIN_CONTEXT) return; | 1241 if (context_type == THIN_CONTEXT) return; |
1298 | 1242 |
1299 { // -- J S O N | 1243 { // -- J S O N |
1300 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1244 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
1301 Handle<JSFunction> cons = factory->NewFunction(name); | 1245 Handle<JSFunction> cons = factory->NewFunction(name); |
1302 JSFunction::SetInstancePrototype(cons, | 1246 JSFunction::SetInstancePrototype(cons, |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2713 bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { | 2657 bool Genesis::InstallSpecialObjects(Handle<Context> native_context) { |
2714 Isolate* isolate = native_context->GetIsolate(); | 2658 Isolate* isolate = native_context->GetIsolate(); |
2715 // Don't install extensions into the snapshot. | 2659 // Don't install extensions into the snapshot. |
2716 if (isolate->serializer_enabled()) return true; | 2660 if (isolate->serializer_enabled()) return true; |
2717 | 2661 |
2718 Factory* factory = isolate->factory(); | 2662 Factory* factory = isolate->factory(); |
2719 HandleScope scope(isolate); | 2663 HandleScope scope(isolate); |
2720 Handle<JSGlobalObject> global(JSGlobalObject::cast( | 2664 Handle<JSGlobalObject> global(JSGlobalObject::cast( |
2721 native_context->global_object())); | 2665 native_context->global_object())); |
2722 | 2666 |
2723 Handle<JSObject> Error = isolate->error_function(); | 2667 Handle<JSObject> Error = Handle<JSObject>::cast( |
| 2668 Object::GetProperty(isolate, global, "Error").ToHandleChecked()); |
2724 Handle<String> name = | 2669 Handle<String> name = |
2725 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit")); | 2670 factory->InternalizeOneByteString(STATIC_CHAR_VECTOR("stackTraceLimit")); |
2726 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate); | 2671 Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate); |
2727 JSObject::AddProperty(Error, name, stack_trace_limit, NONE); | 2672 JSObject::AddProperty(Error, name, stack_trace_limit, NONE); |
2728 | 2673 |
2729 // Expose the debug global object in global if a name for it is specified. | 2674 // Expose the debug global object in global if a name for it is specified. |
2730 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { | 2675 if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) { |
2731 // If loading fails we just bail out without installing the | 2676 // If loading fails we just bail out without installing the |
2732 // debugger but without tanking the whole context. | 2677 // debugger but without tanking the whole context. |
2733 Debug* debug = isolate->debug(); | 2678 Debug* debug = isolate->debug(); |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3242 } | 3187 } |
3243 | 3188 |
3244 | 3189 |
3245 // Called when the top-level V8 mutex is destroyed. | 3190 // Called when the top-level V8 mutex is destroyed. |
3246 void Bootstrapper::FreeThreadResources() { | 3191 void Bootstrapper::FreeThreadResources() { |
3247 DCHECK(!IsActive()); | 3192 DCHECK(!IsActive()); |
3248 } | 3193 } |
3249 | 3194 |
3250 } // namespace internal | 3195 } // namespace internal |
3251 } // namespace v8 | 3196 } // namespace v8 |
OLD | NEW |