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/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 | 902 |
903 Handle<Cell> Factory::NewCell(Handle<Object> value) { | 903 Handle<Cell> Factory::NewCell(Handle<Object> value) { |
904 AllowDeferredHandleDereference convert_to_cell; | 904 AllowDeferredHandleDereference convert_to_cell; |
905 CALL_HEAP_FUNCTION( | 905 CALL_HEAP_FUNCTION( |
906 isolate(), | 906 isolate(), |
907 isolate()->heap()->AllocateCell(*value), | 907 isolate()->heap()->AllocateCell(*value), |
908 Cell); | 908 Cell); |
909 } | 909 } |
910 | 910 |
911 | 911 |
912 Handle<PropertyCell> Factory::NewPropertyCellWithHole() { | 912 Handle<PropertyCell> Factory::NewPropertyCell() { |
913 CALL_HEAP_FUNCTION( | 913 CALL_HEAP_FUNCTION( |
914 isolate(), | 914 isolate(), |
915 isolate()->heap()->AllocatePropertyCell(), | 915 isolate()->heap()->AllocatePropertyCell(), |
916 PropertyCell); | 916 PropertyCell); |
917 } | 917 } |
918 | 918 |
919 | 919 |
920 Handle<PropertyCell> Factory::NewPropertyCell(Handle<Object> value) { | |
921 AllowDeferredHandleDereference convert_to_cell; | |
922 Handle<PropertyCell> cell = NewPropertyCellWithHole(); | |
923 PropertyCell::SetValueInferType(cell, value); | |
924 return cell; | |
925 } | |
926 | |
927 | |
928 Handle<WeakCell> Factory::NewWeakCell(Handle<HeapObject> value) { | 920 Handle<WeakCell> Factory::NewWeakCell(Handle<HeapObject> value) { |
929 AllowDeferredHandleDereference convert_to_cell; | 921 AllowDeferredHandleDereference convert_to_cell; |
930 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateWeakCell(*value), | 922 CALL_HEAP_FUNCTION(isolate(), isolate()->heap()->AllocateWeakCell(*value), |
931 WeakCell); | 923 WeakCell); |
932 } | 924 } |
933 | 925 |
934 | 926 |
935 Handle<AllocationSite> Factory::NewAllocationSite() { | 927 Handle<AllocationSite> Factory::NewAllocationSite() { |
936 Handle<Map> map = allocation_site_map(); | 928 Handle<Map> map = allocation_site_map(); |
937 Handle<AllocationSite> site = New<AllocationSite>(map, OLD_POINTER_SPACE); | 929 Handle<AllocationSite> site = New<AllocationSite>(map, OLD_POINTER_SPACE); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 Handle<NameDictionary> dictionary = | 1557 Handle<NameDictionary> dictionary = |
1566 NameDictionary::New(isolate(), at_least_space_for); | 1558 NameDictionary::New(isolate(), at_least_space_for); |
1567 | 1559 |
1568 // The global object might be created from an object template with accessors. | 1560 // The global object might be created from an object template with accessors. |
1569 // Fill these accessors into the dictionary. | 1561 // Fill these accessors into the dictionary. |
1570 Handle<DescriptorArray> descs(map->instance_descriptors()); | 1562 Handle<DescriptorArray> descs(map->instance_descriptors()); |
1571 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { | 1563 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { |
1572 PropertyDetails details = descs->GetDetails(i); | 1564 PropertyDetails details = descs->GetDetails(i); |
1573 // Only accessors are expected. | 1565 // Only accessors are expected. |
1574 DCHECK_EQ(ACCESSOR_CONSTANT, details.type()); | 1566 DCHECK_EQ(ACCESSOR_CONSTANT, details.type()); |
1575 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1); | 1567 PropertyDetails d(details.attributes(), ACCESSOR_CONSTANT, i + 1, |
| 1568 PropertyCellType::kMutable); |
1576 Handle<Name> name(descs->GetKey(i)); | 1569 Handle<Name> name(descs->GetKey(i)); |
1577 Handle<Object> value(descs->GetCallbacksObject(i), isolate()); | 1570 Handle<PropertyCell> cell = NewPropertyCell(); |
1578 Handle<PropertyCell> cell = NewPropertyCell(value); | 1571 cell->set_value(descs->GetCallbacksObject(i)); |
1579 // |dictionary| already contains enough space for all properties. | 1572 // |dictionary| already contains enough space for all properties. |
1580 USE(NameDictionary::Add(dictionary, name, cell, d)); | 1573 USE(NameDictionary::Add(dictionary, name, cell, d)); |
1581 } | 1574 } |
1582 | 1575 |
1583 // Allocate the global object and initialize it with the backing store. | 1576 // Allocate the global object and initialize it with the backing store. |
1584 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_POINTER_SPACE); | 1577 Handle<GlobalObject> global = New<GlobalObject>(map, OLD_POINTER_SPACE); |
1585 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); | 1578 isolate()->heap()->InitializeJSObjectFromMap(*global, *dictionary, *map); |
1586 | 1579 |
1587 // Create a new map for the global object. | 1580 // Create a new map for the global object. |
1588 Handle<Map> new_map = Map::CopyDropDescriptors(map); | 1581 Handle<Map> new_map = Map::CopyDropDescriptors(map); |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 return Handle<Object>::null(); | 2316 return Handle<Object>::null(); |
2324 } | 2317 } |
2325 | 2318 |
2326 | 2319 |
2327 Handle<Object> Factory::ToBoolean(bool value) { | 2320 Handle<Object> Factory::ToBoolean(bool value) { |
2328 return value ? true_value() : false_value(); | 2321 return value ? true_value() : false_value(); |
2329 } | 2322 } |
2330 | 2323 |
2331 | 2324 |
2332 } } // namespace v8::internal | 2325 } } // namespace v8::internal |
OLD | NEW |