| 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 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1516 | 1516 |
| 1517 Handle<JSObject> Factory::NewJSObjectWithNullProto() { | 1517 Handle<JSObject> Factory::NewJSObjectWithNullProto() { |
| 1518 Handle<JSObject> result = NewJSObject(isolate()->object_function()); | 1518 Handle<JSObject> result = NewJSObject(isolate()->object_function()); |
| 1519 Handle<Map> new_map = | 1519 Handle<Map> new_map = |
| 1520 Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); | 1520 Map::Copy(Handle<Map>(result->map()), "ObjectWithNullProto"); |
| 1521 Map::SetPrototype(new_map, null_value()); | 1521 Map::SetPrototype(new_map, null_value()); |
| 1522 JSObject::MigrateToMap(result, new_map); | 1522 JSObject::MigrateToMap(result, new_map); |
| 1523 return result; | 1523 return result; |
| 1524 } | 1524 } |
| 1525 | 1525 |
| 1526 Handle<JSModule> Factory::NewJSModule(Handle<Context> context, | |
| 1527 Handle<ScopeInfo> scope_info) { | |
| 1528 // Allocate a fresh map. Modules do not have a prototype. | |
| 1529 Handle<Map> map = NewMap(JS_MODULE_TYPE, JSModule::kSize); | |
| 1530 // Allocate the object based on the map. | |
| 1531 Handle<JSModule> module = | |
| 1532 Handle<JSModule>::cast(NewJSObjectFromMap(map, TENURED)); | |
| 1533 module->set_context(*context); | |
| 1534 module->set_scope_info(*scope_info); | |
| 1535 return module; | |
| 1536 } | |
| 1537 | |
| 1538 | |
| 1539 Handle<JSGlobalObject> Factory::NewJSGlobalObject( | 1526 Handle<JSGlobalObject> Factory::NewJSGlobalObject( |
| 1540 Handle<JSFunction> constructor) { | 1527 Handle<JSFunction> constructor) { |
| 1541 DCHECK(constructor->has_initial_map()); | 1528 DCHECK(constructor->has_initial_map()); |
| 1542 Handle<Map> map(constructor->initial_map()); | 1529 Handle<Map> map(constructor->initial_map()); |
| 1543 DCHECK(map->is_dictionary_map()); | 1530 DCHECK(map->is_dictionary_map()); |
| 1544 | 1531 |
| 1545 // Make sure no field properties are described in the initial map. | 1532 // Make sure no field properties are described in the initial map. |
| 1546 // This guarantees us that normalizing the properties does not | 1533 // This guarantees us that normalizing the properties does not |
| 1547 // require us to change property values to PropertyCells. | 1534 // require us to change property values to PropertyCells. |
| 1548 DCHECK(map->NextFreePropertyIndex() == 0); | 1535 DCHECK(map->NextFreePropertyIndex() == 0); |
| (...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 } | 2379 } |
| 2393 | 2380 |
| 2394 | 2381 |
| 2395 Handle<Object> Factory::ToBoolean(bool value) { | 2382 Handle<Object> Factory::ToBoolean(bool value) { |
| 2396 return value ? true_value() : false_value(); | 2383 return value ? true_value() : false_value(); |
| 2397 } | 2384 } |
| 2398 | 2385 |
| 2399 | 2386 |
| 2400 } // namespace internal | 2387 } // namespace internal |
| 2401 } // namespace v8 | 2388 } // namespace v8 |
| OLD | NEW |