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/factory.h" | 5 #include "src/factory.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 | 1503 |
1504 Handle<JSObject> Factory::NewJSObjectWithNullProto() { | 1504 Handle<JSObject> Factory::NewJSObjectWithNullProto() { |
1505 Handle<JSObject> result = NewJSObject(isolate()->object_function()); | 1505 Handle<JSObject> result = NewJSObject(isolate()->object_function()); |
1506 Handle<Map> new_map = | 1506 Handle<Map> new_map = |
1507 Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); | 1507 Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); |
1508 Map::SetPrototype(new_map, null_value()); | 1508 Map::SetPrototype(new_map, null_value()); |
1509 JSObject::MigrateToMap(result, new_map); | 1509 JSObject::MigrateToMap(result, new_map); |
1510 return result; | 1510 return result; |
1511 } | 1511 } |
1512 | 1512 |
1513 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, | |
1514 Handle<ScopeInfo> scope_info) { | |
1515 // Allocate a fresh map. Modules do not have a prototype. | |
1516 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize); | |
1517 // Allocate the object based on the map. | |
1518 Handle<JSModule> module = | |
1519 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED)); | |
1520 module->set_context(*context); | |
1521 module->set_scope_info(*scope_info); | |
1522 return module; | |
1523 } | |
1524 | |
1525 | |
1526 Handle<JSGlobalObject> Factory::NewJSGlobalObject( | 1513 Handle<JSGlobalObject> Factory::NewJSGlobalObject( |
1527 Handle<JSFunction> constructor) { | 1514 Handle<JSFunction> constructor) { |
1528 DCHECK(constructor->has_initial_map()); | 1515 DCHECK(constructor->has_initial_map()); |
1529 Handle<Map> map(constructor->initial_map()); | 1516 Handle<Map> map(constructor->initial_map()); |
1530 DCHECK(map->is_dictionary_map()); | 1517 DCHECK(map->is_dictionary_map()); |
1531 | 1518 |
1532 // Make sure no field properties are described in the initial map. | 1519 // Make sure no field properties are described in the initial map. |
1533 // This guarantees us that normalizing the properties does not | 1520 // This guarantees us that normalizing the properties does not |
1534 // require us to change property values to PropertyCells. | 1521 // require us to change property values to PropertyCells. |
1535 DCHECK(map->NextFreePropertyIndex() == 0); | 1522 DCHECK(map->NextFreePropertyIndex() == 0); |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2379 } | 2366 } |
2380 | 2367 |
2381 | 2368 |
2382 Handle<Object> Factory::ToBoolean(bool value) { | 2369 Handle<Object> Factory::ToBoolean(bool value) { |
2383 return value ? true_value() : false_value(); | 2370 return value ? true_value() : false_value(); |
2384 } | 2371 } |
2385 | 2372 |
2386 | 2373 |
2387 } // namespace internal | 2374 } // namespace internal |
2388 } // namespace v8 | 2375 } // namespace v8 |
OLD | NEW |