| 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 "factory.h" | 5 #include "factory.h" |
| 6 | 6 |
| 7 #include "macro-assembler.h" | 7 #include "macro-assembler.h" |
| 8 #include "isolate-inl.h" | 8 #include "isolate-inl.h" |
| 9 #include "v8conversions.h" | 9 #include "v8conversions.h" |
| 10 | 10 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 CALL_HEAP_FUNCTION( | 120 CALL_HEAP_FUNCTION( |
| 121 isolate(), | 121 isolate(), |
| 122 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries, | 122 isolate()->heap()->AllocateConstantPoolArray(number_of_int64_entries, |
| 123 number_of_code_ptr_entries, | 123 number_of_code_ptr_entries, |
| 124 number_of_heap_ptr_entries, | 124 number_of_heap_ptr_entries, |
| 125 number_of_int32_entries), | 125 number_of_int32_entries), |
| 126 ConstantPoolArray); | 126 ConstantPoolArray); |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 Handle<NameDictionary> Factory::NewNameDictionary(int at_least_space_for) { | |
| 131 ASSERT(0 <= at_least_space_for); | |
| 132 CALL_HEAP_FUNCTION(isolate(), | |
| 133 NameDictionary::Allocate(isolate()->heap(), | |
| 134 at_least_space_for), | |
| 135 NameDictionary); | |
| 136 } | |
| 137 | |
| 138 | |
| 139 Handle<SeededNumberDictionary> Factory::NewSeededNumberDictionary( | |
| 140 int at_least_space_for) { | |
| 141 ASSERT(0 <= at_least_space_for); | |
| 142 CALL_HEAP_FUNCTION(isolate(), | |
| 143 SeededNumberDictionary::Allocate(isolate()->heap(), | |
| 144 at_least_space_for), | |
| 145 SeededNumberDictionary); | |
| 146 } | |
| 147 | |
| 148 | |
| 149 Handle<UnseededNumberDictionary> Factory::NewUnseededNumberDictionary( | |
| 150 int at_least_space_for) { | |
| 151 ASSERT(0 <= at_least_space_for); | |
| 152 CALL_HEAP_FUNCTION(isolate(), | |
| 153 UnseededNumberDictionary::Allocate(isolate()->heap(), | |
| 154 at_least_space_for), | |
| 155 UnseededNumberDictionary); | |
| 156 } | |
| 157 | |
| 158 | |
| 159 Handle<OrderedHashSet> Factory::NewOrderedHashSet() { | 130 Handle<OrderedHashSet> Factory::NewOrderedHashSet() { |
| 160 return OrderedHashSet::Allocate(isolate(), 4); | 131 return OrderedHashSet::Allocate(isolate(), 4); |
| 161 } | 132 } |
| 162 | 133 |
| 163 | 134 |
| 164 Handle<OrderedHashMap> Factory::NewOrderedHashMap() { | 135 Handle<OrderedHashMap> Factory::NewOrderedHashMap() { |
| 165 return OrderedHashMap::Allocate(isolate(), 4); | 136 return OrderedHashMap::Allocate(isolate(), 4); |
| 166 } | 137 } |
| 167 | 138 |
| 168 | 139 |
| (...skipping 1308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 ASSERT(map->unused_property_fields() == 0); | 1448 ASSERT(map->unused_property_fields() == 0); |
| 1478 ASSERT(map->inobject_properties() == 0); | 1449 ASSERT(map->inobject_properties() == 0); |
| 1479 | 1450 |
| 1480 // Initial size of the backing store to avoid resize of the storage during | 1451 // Initial size of the backing store to avoid resize of the storage during |
| 1481 // bootstrapping. The size differs between the JS global object ad the | 1452 // bootstrapping. The size differs between the JS global object ad the |
| 1482 // builtins object. | 1453 // builtins object. |
| 1483 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; | 1454 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; |
| 1484 | 1455 |
| 1485 // Allocate a dictionary object for backing storage. | 1456 // Allocate a dictionary object for backing storage. |
| 1486 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size; | 1457 int at_least_space_for = map->NumberOfOwnDescriptors() * 2 + initial_size; |
| 1487 Handle<NameDictionary> dictionary = NewNameDictionary(at_least_space_for); | 1458 Handle<NameDictionary> dictionary = |
| 1459 NameDictionary::New(isolate(), at_least_space_for); |
| 1488 | 1460 |
| 1489 // The global object might be created from an object template with accessors. | 1461 // The global object might be created from an object template with accessors. |
| 1490 // Fill these accessors into the dictionary. | 1462 // Fill these accessors into the dictionary. |
| 1491 Handle<DescriptorArray> descs(map->instance_descriptors()); | 1463 Handle<DescriptorArray> descs(map->instance_descriptors()); |
| 1492 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 1464 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
| 1493 PropertyDetails details = descs->GetDetails(i); | 1465 PropertyDetails details = descs->GetDetails(i); |
| 1494 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. | 1466 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. |
| 1495 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); | 1467 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); |
| 1496 Handle<Name> name(descs->GetKey(i)); | 1468 Handle<Name> name(descs->GetKey(i)); |
| 1497 Handle<Object> value(descs->GetCallbacksObject(i), isolate()); | 1469 Handle<Object> value(descs->GetCallbacksObject(i), isolate()); |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 return Handle<Object>::null(); | 2293 return Handle<Object>::null(); |
| 2322 } | 2294 } |
| 2323 | 2295 |
| 2324 | 2296 |
| 2325 Handle<Object> Factory::ToBoolean(bool value) { | 2297 Handle<Object> Factory::ToBoolean(bool value) { |
| 2326 return value ? true_value() : false_value(); | 2298 return value ? true_value() : false_value(); |
| 2327 } | 2299 } |
| 2328 | 2300 |
| 2329 | 2301 |
| 2330 } } // namespace v8::internal | 2302 } } // namespace v8::internal |
| OLD | NEW |