| 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 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 DCHECK(map->unused_property_fields() == 0); | 1576 DCHECK(map->unused_property_fields() == 0); |
| 1577 DCHECK(map->inobject_properties() == 0); | 1577 DCHECK(map->inobject_properties() == 0); |
| 1578 | 1578 |
| 1579 // Initial size of the backing store to avoid resize of the storage during | 1579 // Initial size of the backing store to avoid resize of the storage during |
| 1580 // bootstrapping. The size differs between the JS global object ad the | 1580 // bootstrapping. The size differs between the JS global object ad the |
| 1581 // builtins object. | 1581 // builtins object. |
| 1582 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; | 1582 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; |
| 1583 | 1583 |
| 1584 // Allocate a dictionary object for backing storage. | 1584 // Allocate a dictionary object for backing storage. |
| 1585 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size; | 1585 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size; |
| 1586 Handle<NameDictionary> dictionary = | 1586 Handle<GlobalDictionary> dictionary = |
| 1587 NameDictionary::New(isolate(), at_least_space_for); | 1587 GlobalDictionary::New(isolate(), at_least_space_for); |
| 1588 | 1588 |
| 1589 // The global object might be created from an object template with accessors. | 1589 // The global object might be created from an object template with accessors. |
| 1590 // Fill these accessors into the dictionary. | 1590 // Fill these accessors into the dictionary. |
| 1591 Handle<DescriptorArray> descs(map->instance_descriptors()); | 1591 Handle<DescriptorArray> descs(map->instance_descriptors()); |
| 1592 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 1592 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
| 1593 PropertyDetails details = descs->GetDetails(i); | 1593 PropertyDetails details = descs->GetDetails(i); |
| 1594 // Only accessors are expected. | 1594 // Only accessors are expected. |
| 1595 DCHECK_EQ(ACCESSOR_CONSTANT, details.type()); | 1595 DCHECK_EQ(ACCESSOR_CONSTANT, details.type()); |
| 1596 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, | 1596 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, |
| 1597 PropertyCellType::kMutable); | 1597 PropertyCellType::kMutable); |
| 1598 Handle<Name> name(descs->GetKey(i)); | 1598 Handle<Name> name(descs->GetKey(i)); |
| 1599 Handle<PropertyCell> cell = NewPropertyCell(); | 1599 Handle<PropertyCell> cell = NewPropertyCell(); |
| 1600 cell->set_value(descs->GetCallbacksObject(i)); | 1600 cell->set_value(descs->GetCallbacksObject(i)); |
| 1601 // |dictionary| already contains enough space for all properties. | 1601 // |dictionary| already contains enough space for all properties. |
| 1602 USE(NameDictionary::Add(dictionary, name, cell, d)); | 1602 USE(GlobalDictionary::Add(dictionary, name, cell, d)); |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 // Allocate the global object and initialize it with the backing store. | 1605 // Allocate the global object and initialize it with the backing store. |
| 1606 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_SPACE); | 1606 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_SPACE); |
| 1607 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); | 1607 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); |
| 1608 | 1608 |
| 1609 // Create a new map for the global object. | 1609 // Create a new map for the global object. |
| 1610 Handle<Map> new_map = Map::CopyDropDescriptors(map); | 1610 Handle<Map> new_map = Map::CopyDropDescriptors(map); |
| 1611 new_map->set_dictionary_map(true); | 1611 new_map->set_dictionary_map(true); |
| 1612 | 1612 |
| (...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2448 return Handle<Object>::null(); | 2448 return Handle<Object>::null(); |
| 2449 } | 2449 } |
| 2450 | 2450 |
| 2451 | 2451 |
| 2452 Handle<Object> Factory::ToBoolean(bool value) { | 2452 Handle<Object> Factory::ToBoolean(bool value) { |
| 2453 return value ? true_value() : false_value(); | 2453 return value ? true_value() : false_value(); |
| 2454 } | 2454 } |
| 2455 | 2455 |
| 2456 | 2456 |
| 2457 } } // namespace v8::internal | 2457 } } // namespace v8::internal |
| OLD | NEW |