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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 // Set extension and global object. | 1091 // Set extension and global object. |
1092 native_context()->set_extension(*global_object); | 1092 native_context()->set_extension(*global_object); |
1093 native_context()->set_global_object(*global_object); | 1093 native_context()->set_global_object(*global_object); |
1094 // Security setup: Set the security token of the native context to the global | 1094 // Security setup: Set the security token of the native context to the global |
1095 // object. This makes the security check between two different contexts fail | 1095 // object. This makes the security check between two different contexts fail |
1096 // by default even in case of global object reinitialization. | 1096 // by default even in case of global object reinitialization. |
1097 native_context()->set_security_token(*global_object); | 1097 native_context()->set_security_token(*global_object); |
1098 | 1098 |
1099 Isolate* isolate = global_object->GetIsolate(); | 1099 Isolate* isolate = global_object->GetIsolate(); |
1100 Factory* factory = isolate->factory(); | 1100 Factory* factory = isolate->factory(); |
1101 Heap* heap = isolate->heap(); | |
1102 | 1101 |
1103 Handle<ScriptContextTable> script_context_table = | 1102 Handle<ScriptContextTable> script_context_table = |
1104 factory->NewScriptContextTable(); | 1103 factory->NewScriptContextTable(); |
1105 native_context()->set_script_context_table(*script_context_table); | 1104 native_context()->set_script_context_table(*script_context_table); |
1106 InstallGlobalThisBinding(); | 1105 InstallGlobalThisBinding(); |
1107 | 1106 |
1108 Handle<String> object_name = factory->Object_string(); | 1107 Handle<String> object_name = factory->Object_string(); |
1109 JSObject::AddProperty( | 1108 JSObject::AddProperty( |
1110 global_object, object_name, isolate->object_function(), DONT_ENUM); | 1109 global_object, object_name, isolate->object_function(), DONT_ENUM); |
1111 | 1110 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 JSRegExp::kLastIndexFieldIndex, writable, | 1279 JSRegExp::kLastIndexFieldIndex, writable, |
1281 Representation::Tagged()); | 1280 Representation::Tagged()); |
1282 initial_map->AppendDescriptor(&field); | 1281 initial_map->AppendDescriptor(&field); |
1283 } | 1282 } |
1284 | 1283 |
1285 static const int num_fields = JSRegExp::kInObjectFieldCount; | 1284 static const int num_fields = JSRegExp::kInObjectFieldCount; |
1286 initial_map->SetInObjectProperties(num_fields); | 1285 initial_map->SetInObjectProperties(num_fields); |
1287 initial_map->set_unused_property_fields(0); | 1286 initial_map->set_unused_property_fields(0); |
1288 initial_map->set_instance_size(initial_map->instance_size() + | 1287 initial_map->set_instance_size(initial_map->instance_size() + |
1289 num_fields * kPointerSize); | 1288 num_fields * kPointerSize); |
1290 | |
1291 // RegExp prototype object is itself a RegExp. | |
1292 Handle<Map> proto_map = Map::Copy(initial_map, "RegExpPrototype"); | |
1293 DCHECK(proto_map->prototype() == *isolate->initial_object_prototype()); | |
1294 Handle<JSObject> proto = factory->NewJSObjectFromMap(proto_map); | |
1295 proto->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, | |
1296 heap->query_colon_string()); | |
1297 proto->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, | |
1298 heap->false_value()); | |
1299 proto->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, | |
1300 heap->false_value()); | |
1301 proto->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, | |
1302 heap->false_value()); | |
1303 proto->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, | |
1304 Smi::FromInt(0), | |
1305 SKIP_WRITE_BARRIER); // It's a Smi. | |
1306 proto_map->set_is_prototype_map(true); | |
1307 Map::SetPrototype(initial_map, proto); | |
1308 factory->SetRegExpIrregexpData(Handle<JSRegExp>::cast(proto), | |
1309 JSRegExp::IRREGEXP, factory->empty_string(), | |
1310 JSRegExp::Flags(0), 0); | |
1311 } | 1289 } |
1312 | 1290 |
1313 // Initialize the embedder data slot. | 1291 // Initialize the embedder data slot. |
1314 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); | 1292 Handle<FixedArray> embedder_data = factory->NewFixedArray(3); |
1315 native_context()->set_embedder_data(*embedder_data); | 1293 native_context()->set_embedder_data(*embedder_data); |
1316 | 1294 |
1317 if (context_type == THIN_CONTEXT) return; | 1295 if (context_type == THIN_CONTEXT) return; |
1318 | 1296 |
1319 { // -- J S O N | 1297 { // -- J S O N |
1320 Handle<String> name = factory->InternalizeUtf8String("JSON"); | 1298 Handle<String> name = factory->InternalizeUtf8String("JSON"); |
(...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3322 } | 3300 } |
3323 | 3301 |
3324 | 3302 |
3325 // Called when the top-level V8 mutex is destroyed. | 3303 // Called when the top-level V8 mutex is destroyed. |
3326 void Bootstrapper::FreeThreadResources() { | 3304 void Bootstrapper::FreeThreadResources() { |
3327 DCHECK(!IsActive()); | 3305 DCHECK(!IsActive()); |
3328 } | 3306 } |
3329 | 3307 |
3330 } // namespace internal | 3308 } // namespace internal |
3331 } // namespace v8 | 3309 } // namespace v8 |
OLD | NEW |