| 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 <stdlib.h> | 5 #include <stdlib.h> | 
| 6 #include <utility> | 6 #include <utility> | 
| 7 | 7 | 
| 8 #include "src/v8.h" | 8 #include "src/v8.h" | 
| 9 | 9 | 
| 10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 63 static double GetDoubleFieldValue(JSObject* obj, FieldIndex field_index) { | 63 static double GetDoubleFieldValue(JSObject* obj, FieldIndex field_index) { | 
| 64   if (obj->IsUnboxedDoubleField(field_index)) { | 64   if (obj->IsUnboxedDoubleField(field_index)) { | 
| 65     return obj->RawFastDoublePropertyAt(field_index); | 65     return obj->RawFastDoublePropertyAt(field_index); | 
| 66   } else { | 66   } else { | 
| 67     Object* value = obj->RawFastPropertyAt(field_index); | 67     Object* value = obj->RawFastPropertyAt(field_index); | 
| 68     CHECK(value->IsMutableHeapNumber()); | 68     CHECK(value->IsMutableHeapNumber()); | 
| 69     return HeapNumber::cast(value)->value(); | 69     return HeapNumber::cast(value)->value(); | 
| 70   } | 70   } | 
| 71 } | 71 } | 
| 72 | 72 | 
|  | 73 void WriteToField(JSObject* object, int descriptor, Object* value) { | 
|  | 74   DescriptorArray* descriptors = object->map()->instance_descriptors(); | 
|  | 75   PropertyDetails details = descriptors->GetDetails(descriptor); | 
|  | 76   object->WriteToField(descriptor, details, value); | 
|  | 77 } | 
|  | 78 | 
| 73 const int kNumberOfBits = 32; | 79 const int kNumberOfBits = 32; | 
| 74 | 80 | 
| 75 | 81 | 
| 76 enum TestPropertyKind { | 82 enum TestPropertyKind { | 
| 77   PROP_CONSTANT, | 83   PROP_CONSTANT, | 
| 78   PROP_SMI, | 84   PROP_SMI, | 
| 79   PROP_DOUBLE, | 85   PROP_DOUBLE, | 
| 80   PROP_TAGGED, | 86   PROP_TAGGED, | 
| 81   PROP_KIND_NUMBER | 87   PROP_KIND_NUMBER | 
| 82 }; | 88 }; | 
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1040   Handle<FieldType> any_type = FieldType::Any(isolate); | 1046   Handle<FieldType> any_type = FieldType::Any(isolate); | 
| 1041   Handle<Map> map = Map::Create(isolate, 10); | 1047   Handle<Map> map = Map::Create(isolate, 10); | 
| 1042   map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, | 1048   map = Map::CopyWithField(map, MakeName("prop", 0), any_type, NONE, | 
| 1043                            Representation::Double(), | 1049                            Representation::Double(), | 
| 1044                            INSERT_TRANSITION).ToHandleChecked(); | 1050                            INSERT_TRANSITION).ToHandleChecked(); | 
| 1045 | 1051 | 
| 1046   // Create object in new space. | 1052   // Create object in new space. | 
| 1047   Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 1053   Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 
| 1048 | 1054 | 
| 1049   Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1055   Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 
| 1050   obj->WriteToField(0, *heap_number); | 1056   WriteToField(*obj, 0, *heap_number); | 
| 1051 | 1057 | 
| 1052   { | 1058   { | 
| 1053     // Ensure the object is properly set up. | 1059     // Ensure the object is properly set up. | 
| 1054     FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); | 1060     FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); | 
| 1055     CHECK(field_index.is_inobject() && field_index.is_double()); | 1061     CHECK(field_index.is_inobject() && field_index.is_double()); | 
| 1056     CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 1062     CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 
| 1057     CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 1063     CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 
| 1058   } | 1064   } | 
| 1059   CHECK(isolate->heap()->new_space()->Contains(*obj)); | 1065   CHECK(isolate->heap()->new_space()->Contains(*obj)); | 
| 1060 | 1066 | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1116     // Make sure |obj_value| is placed on an old-space evacuation candidate. | 1122     // Make sure |obj_value| is placed on an old-space evacuation candidate. | 
| 1117     heap::SimulateFullSpace(old_space); | 1123     heap::SimulateFullSpace(old_space); | 
| 1118     obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 1124     obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED); | 
| 1119     ec_page = Page::FromAddress(obj_value->address()); | 1125     ec_page = Page::FromAddress(obj_value->address()); | 
| 1120   } | 1126   } | 
| 1121 | 1127 | 
| 1122   // Create object in new space. | 1128   // Create object in new space. | 
| 1123   Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 1129   Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED); | 
| 1124 | 1130 | 
| 1125   Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 1131   Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); | 
| 1126   obj->WriteToField(0, *heap_number); | 1132   WriteToField(*obj, 0, *heap_number); | 
| 1127   obj->WriteToField(1, *obj_value); | 1133   WriteToField(*obj, 1, *obj_value); | 
| 1128 | 1134 | 
| 1129   { | 1135   { | 
| 1130     // Ensure the object is properly set up. | 1136     // Ensure the object is properly set up. | 
| 1131     FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); | 1137     FieldIndex field_index = FieldIndex::ForDescriptor(*map, 0); | 
| 1132     CHECK(field_index.is_inobject() && field_index.is_double()); | 1138     CHECK(field_index.is_inobject() && field_index.is_double()); | 
| 1133     CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 1139     CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 
| 1134     CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 1140     CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 
| 1135 | 1141 | 
| 1136     field_index = FieldIndex::ForDescriptor(*map, 1); | 1142     field_index = FieldIndex::ForDescriptor(*map, 1); | 
| 1137     CHECK(field_index.is_inobject() && !field_index.is_double()); | 1143     CHECK(field_index.is_inobject() && !field_index.is_double()); | 
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1556 | 1562 | 
| 1557 // TODO(ishell): add respective tests for property kind reconfiguring from | 1563 // TODO(ishell): add respective tests for property kind reconfiguring from | 
| 1558 // accessor field to double, once accessor fields are supported by | 1564 // accessor field to double, once accessor fields are supported by | 
| 1559 // Map::ReconfigureProperty(). | 1565 // Map::ReconfigureProperty(). | 
| 1560 | 1566 | 
| 1561 | 1567 | 
| 1562 // TODO(ishell): add respective tests for fast property removal case once | 1568 // TODO(ishell): add respective tests for fast property removal case once | 
| 1563 // Map::ReconfigureProperty() supports that. | 1569 // Map::ReconfigureProperty() supports that. | 
| 1564 | 1570 | 
| 1565 #endif | 1571 #endif | 
| OLD | NEW | 
|---|