Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: test/cctest/test-unboxed-doubles.cc

Issue 1144183004: [strong] Refactor ObjectStrength into a replacement for strong boolean args (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: cl feedback and rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 CHECK(field_index.is_inobject() && field_index.is_double()); 1028 CHECK(field_index.is_inobject() && field_index.is_double());
1029 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index)); 1029 CHECK_EQ(FLAG_unbox_double_fields, map->IsUnboxedDoubleField(field_index));
1030 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index)); 1030 CHECK_EQ(42.5, GetDoubleFieldValue(*obj, field_index));
1031 } 1031 }
1032 CHECK(isolate->heap()->new_space()->Contains(*obj)); 1032 CHECK(isolate->heap()->new_space()->Contains(*obj));
1033 1033
1034 // Do scavenge so that |obj| is moved to survivor space. 1034 // Do scavenge so that |obj| is moved to survivor space.
1035 CcTest::heap()->CollectGarbage(i::NEW_SPACE); 1035 CcTest::heap()->CollectGarbage(i::NEW_SPACE);
1036 1036
1037 // Create temp object in the new space. 1037 // Create temp object in the new space.
1038 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, WEAK, NOT_TENURED); 1038 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS);
1039 CHECK(isolate->heap()->new_space()->Contains(*temp)); 1039 CHECK(isolate->heap()->new_space()->Contains(*temp));
1040 1040
1041 // Construct a double value that looks like a pointer to the new space object 1041 // Construct a double value that looks like a pointer to the new space object
1042 // and store it into the obj. 1042 // and store it into the obj.
1043 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; 1043 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize;
1044 double boom_value = bit_cast<double>(fake_object); 1044 double boom_value = bit_cast<double>(fake_object);
1045 1045
1046 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); 1046 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0);
1047 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); 1047 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE);
1048 obj->FastPropertyAtPut(field_index, *boom_number); 1048 obj->FastPropertyAtPut(field_index, *boom_number);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 Representation::Tagged(), 1081 Representation::Tagged(),
1082 INSERT_TRANSITION).ToHandleChecked(); 1082 INSERT_TRANSITION).ToHandleChecked();
1083 1083
1084 // Create |obj_value| in old space. 1084 // Create |obj_value| in old space.
1085 Handle<HeapObject> obj_value; 1085 Handle<HeapObject> obj_value;
1086 Page* ec_page; 1086 Page* ec_page;
1087 { 1087 {
1088 AlwaysAllocateScope always_allocate(isolate); 1088 AlwaysAllocateScope always_allocate(isolate);
1089 // Make sure |obj_value| is placed on an old-space evacuation candidate. 1089 // Make sure |obj_value| is placed on an old-space evacuation candidate.
1090 SimulateFullSpace(old_space); 1090 SimulateFullSpace(old_space);
1091 obj_value = 1091 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS,
1092 factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, WEAK, TENURED); 1092 Strength::WEAK, TENURED);
1093 ec_page = Page::FromAddress(obj_value->address()); 1093 ec_page = Page::FromAddress(obj_value->address());
1094 } 1094 }
1095 1095
1096 // Create object in new space. 1096 // Create object in new space.
1097 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED, false); 1097 Handle<JSObject> obj = factory->NewJSObjectFromMap(map, NOT_TENURED, false);
1098 1098
1099 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5); 1099 Handle<HeapNumber> heap_number = factory->NewHeapNumber(42.5);
1100 obj->WriteToField(0, *heap_number); 1100 obj->WriteToField(0, *heap_number);
1101 obj->WriteToField(1, *obj_value); 1101 obj->WriteToField(1, *obj_value);
1102 1102
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 } 1367 }
1368 CHECK(isolate->heap()->new_space()->Contains(*obj)); 1368 CHECK(isolate->heap()->new_space()->Contains(*obj));
1369 1369
1370 // Trigger GCs so that the newly allocated object moves to old gen. 1370 // Trigger GCs so that the newly allocated object moves to old gen.
1371 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now 1371 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
1372 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now 1372 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
1373 1373
1374 CHECK(isolate->heap()->old_space()->Contains(*obj)); 1374 CHECK(isolate->heap()->old_space()->Contains(*obj));
1375 1375
1376 // Create temp object in the new space. 1376 // Create temp object in the new space.
1377 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS, WEAK, NOT_TENURED); 1377 Handle<JSArray> temp = factory->NewJSArray(FAST_ELEMENTS);
1378 CHECK(isolate->heap()->new_space()->Contains(*temp)); 1378 CHECK(isolate->heap()->new_space()->Contains(*temp));
1379 1379
1380 // Construct a double value that looks like a pointer to the new space object 1380 // Construct a double value that looks like a pointer to the new space object
1381 // and store it into the obj. 1381 // and store it into the obj.
1382 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize; 1382 Address fake_object = reinterpret_cast<Address>(*temp) + kPointerSize;
1383 double boom_value = bit_cast<double>(fake_object); 1383 double boom_value = bit_cast<double>(fake_object);
1384 1384
1385 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0); 1385 FieldIndex field_index = FieldIndex::ForDescriptor(obj->map(), 0);
1386 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE); 1386 Handle<HeapNumber> boom_number = factory->NewHeapNumber(boom_value, MUTABLE);
1387 obj->FastPropertyAtPut(field_index, *boom_number); 1387 obj->FastPropertyAtPut(field_index, *boom_number);
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 Handle<JSObject> obj; 1566 Handle<JSObject> obj;
1567 Handle<HeapObject> obj_value; 1567 Handle<HeapObject> obj_value;
1568 Page* ec_page; 1568 Page* ec_page;
1569 { 1569 {
1570 AlwaysAllocateScope always_allocate(isolate); 1570 AlwaysAllocateScope always_allocate(isolate);
1571 obj = factory->NewJSObjectFromMap(map, TENURED, false); 1571 obj = factory->NewJSObjectFromMap(map, TENURED, false);
1572 CHECK(old_space->Contains(*obj)); 1572 CHECK(old_space->Contains(*obj));
1573 1573
1574 // Make sure |obj_value| is placed on an old-space evacuation candidate. 1574 // Make sure |obj_value| is placed on an old-space evacuation candidate.
1575 SimulateFullSpace(old_space); 1575 SimulateFullSpace(old_space);
1576 obj_value = 1576 obj_value = factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS,
1577 factory->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, WEAK, TENURED); 1577 Strength::WEAK, TENURED);
1578 ec_page = Page::FromAddress(obj_value->address()); 1578 ec_page = Page::FromAddress(obj_value->address());
1579 CHECK_NE(ec_page, Page::FromAddress(obj->address())); 1579 CHECK_NE(ec_page, Page::FromAddress(obj->address()));
1580 } 1580 }
1581 1581
1582 // Heap is ready, force |ec_page| to become an evacuation candidate and 1582 // Heap is ready, force |ec_page| to become an evacuation candidate and
1583 // simulate incremental marking. 1583 // simulate incremental marking.
1584 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING); 1584 ec_page->SetFlag(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING);
1585 SimulateIncrementalMarking(heap); 1585 SimulateIncrementalMarking(heap);
1586 1586
1587 // Check that everything is ready for triggering incremental write barrier 1587 // Check that everything is ready for triggering incremental write barrier
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1683
1684 // TODO(ishell): add respective tests for property kind reconfiguring from 1684 // TODO(ishell): add respective tests for property kind reconfiguring from
1685 // accessor field to double, once accessor fields are supported by 1685 // accessor field to double, once accessor fields are supported by
1686 // Map::ReconfigureProperty(). 1686 // Map::ReconfigureProperty().
1687 1687
1688 1688
1689 // TODO(ishell): add respective tests for fast property removal case once 1689 // TODO(ishell): add respective tests for fast property removal case once
1690 // Map::ReconfigureProperty() supports that. 1690 // Map::ReconfigureProperty() supports that.
1691 1691
1692 #endif 1692 #endif
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698