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 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 double boom_value = bit_cast<double>(fake_object); | 954 double boom_value = bit_cast<double>(fake_object); |
955 | 955 |
956 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); | 956 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); |
957 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); | 957 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); |
958 obj->FastPropertyAtPut(field_index, *boom_number); | 958 obj->FastPropertyAtPut(field_index, *boom_number); |
959 | 959 |
960 // Now the object moves to old gen and it has a double field that looks like | 960 // Now the object moves to old gen and it has a double field that looks like |
961 // a pointer to a from semi-space. | 961 // a pointer to a from semi-space. |
962 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 962 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
963 | 963 |
964 CHECK(isolate->heap()->old_pointer_space()->Contains(*obj)); | 964 CHECK(isolate->heap()->old_space()->Contains(*obj)); |
965 | 965 |
966 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); | 966 CHECK_EQ(boom_value, GetDoubleFieldValue(*obj, field_index)); |
967 } | 967 } |
968 | 968 |
969 | 969 |
970 static void TestLayoutDescriptorHelper(Isolate* isolate, | 970 static void TestLayoutDescriptorHelper(Isolate* isolate, |
971 int inobject_properties, | 971 int inobject_properties, |
972 Handle<DescriptorArray> descriptors, | 972 Handle<DescriptorArray> descriptors, |
973 int number_of_descriptors) { | 973 int number_of_descriptors) { |
974 Handle<Map> map = Map::Create(isolate, inobject_properties); | 974 Handle<Map> map = Map::Create(isolate, inobject_properties); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 CHECK(field_index.is_inobject() && field_index.is_double()); | 1188 CHECK(field_index.is_inobject() && field_index.is_double()); |
1189 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); | 1189 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); |
1190 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); | 1190 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); |
1191 } | 1191 } |
1192 CHECK(isolate->heap()->new_space()->Contains(*obj)); | 1192 CHECK(isolate->heap()->new_space()->Contains(*obj)); |
1193 | 1193 |
1194 // Trigger GCs so that the newly allocated object moves to old gen. | 1194 // Trigger GCs so that the newly allocated object moves to old gen. |
1195 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now | 1195 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
1196 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now | 1196 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
1197 | 1197 |
1198 CHECK(isolate->heap()->old_pointer_space()->Contains(*obj)); | 1198 CHECK(isolate->heap()->old_space()->Contains(*obj)); |
1199 | 1199 |
1200 // Create temp object in the new space. | 1200 // Create temp object in the new space. |
1201 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, NOT_TENURED); | 1201 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, NOT_TENURED); |
1202 CHECK(isolate->heap()->new_space()->Contains(*temp)); | 1202 CHECK(isolate->heap()->new_space()->Contains(*temp)); |
1203 | 1203 |
1204 // Construct a double value that looks like a pointer to the new space object | 1204 // Construct a double value that looks like a pointer to the new space object |
1205 // and store it into the obj. | 1205 // and store it into the obj. |
1206 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; | 1206 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; |
1207 double boom_value = bit_cast<double>(fake_object); | 1207 double boom_value = bit_cast<double>(fake_object); |
1208 | 1208 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 FieldIndex index = FieldIndex::ForDescriptor(*my_map, 0); | 1290 FieldIndex index = FieldIndex::ForDescriptor(*my_map, 0); |
1291 jsobject->RawFastDoublePropertyAtPut(index, boom_value); | 1291 jsobject->RawFastDoublePropertyAtPut(index, boom_value); |
1292 | 1292 |
1293 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); | 1293 CHECK_EQ(0, static_cast<int>(*limit_addr - *top_addr)); |
1294 | 1294 |
1295 // Step 4: clone jsobject, but force always allocate first to create a clone | 1295 // Step 4: clone jsobject, but force always allocate first to create a clone |
1296 // in old pointer space. | 1296 // in old pointer space. |
1297 AlwaysAllocateScope aa_scope(isolate); | 1297 AlwaysAllocateScope aa_scope(isolate); |
1298 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); | 1298 Object* clone_obj = heap->CopyJSObject(jsobject).ToObjectChecked(); |
1299 Handle<JSObject> clone(JSObject::cast(clone_obj)); | 1299 Handle<JSObject> clone(JSObject::cast(clone_obj)); |
1300 CHECK(heap->old_pointer_space()->Contains(clone->address())); | 1300 CHECK(heap->old_space()->Contains(clone->address())); |
1301 | 1301 |
1302 CcTest::heap()->CollectGarbage(NEW_SPACE, "boom"); | 1302 CcTest::heap()->CollectGarbage(NEW_SPACE, "boom"); |
1303 | 1303 |
1304 // The value in cloned object should not be corrupted by GC. | 1304 // The value in cloned object should not be corrupted by GC. |
1305 CHECK_EQ(boom_value, clone->RawFastDoublePropertyAt(index)); | 1305 CHECK_EQ(boom_value, clone->RawFastDoublePropertyAt(index)); |
1306 } | 1306 } |
1307 | 1307 |
1308 #endif | 1308 #endif |
OLD | NEW |