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

Side by Side Diff: vm/dart_api_impl_test.cc

Issue 10748006: Disable heap growth during weak handle processing unit test in order to avoid triggering of old spa… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | vm/heap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 TEST_CASE(WeakPersistentHandle) { 1300 TEST_CASE(WeakPersistentHandle) {
1301 Dart_Handle weak_new_ref = Dart_Null(); 1301 Dart_Handle weak_new_ref = Dart_Null();
1302 EXPECT(Dart_IsNull(weak_new_ref)); 1302 EXPECT(Dart_IsNull(weak_new_ref));
1303 1303
1304 Dart_Handle weak_old_ref = Dart_Null(); 1304 Dart_Handle weak_old_ref = Dart_Null();
1305 EXPECT(Dart_IsNull(weak_old_ref)); 1305 EXPECT(Dart_IsNull(weak_old_ref));
1306 1306
1307 { 1307 {
1308 Dart_EnterScope(); 1308 Dart_EnterScope();
1309 1309
1310 // create an object in new space 1310 // create an object in new space.
cshapiro 2012/07/10 21:15:39 Presumably the periods are being added to make the
siva 2012/07/10 21:27:16 Done.
1311 Dart_Handle new_ref = Dart_NewString("new string"); 1311 Dart_Handle new_ref = Dart_NewString("new string");
1312 EXPECT_VALID(new_ref); 1312 EXPECT_VALID(new_ref);
1313 1313
1314 // create an object in old space 1314 // create an object in old space.
1315 Dart_Handle old_ref; 1315 Dart_Handle old_ref;
1316 { 1316 {
1317 Isolate* isolate = Isolate::Current(); 1317 Isolate* isolate = Isolate::Current();
1318 DARTSCOPE(isolate); 1318 DARTSCOPE(isolate);
1319 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld)); 1319 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld));
1320 EXPECT_VALID(old_ref); 1320 EXPECT_VALID(old_ref);
1321 } 1321 }
1322 1322
1323 // create a weak ref to the new space object 1323 // create a weak ref to the new space object.
1324 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL); 1324 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL);
1325 EXPECT_VALID(weak_new_ref); 1325 EXPECT_VALID(weak_new_ref);
1326 EXPECT(!Dart_IsNull(weak_new_ref)); 1326 EXPECT(!Dart_IsNull(weak_new_ref));
1327 1327
1328 // create a weak ref to the old space object 1328 // create a weak ref to the old space object.
1329 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL); 1329 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL);
1330 EXPECT_VALID(weak_old_ref); 1330 EXPECT_VALID(weak_old_ref);
1331 EXPECT(!Dart_IsNull(weak_old_ref)); 1331 EXPECT(!Dart_IsNull(weak_old_ref));
1332 1332
1333 // garbage collect new space 1333 // garbage collect new space.
1334 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1334 Isolate::Current()->heap()->Scavenge();
cshapiro 2012/07/10 21:15:39 I think it would be helpful to expand the comment
siva 2012/07/10 21:27:16 As discussed I have added a class called GCTestHel
1335 1335
1336 // nothing should be invalidated or cleared 1336 // nothing should be invalidated or cleared.
1337 EXPECT_VALID(new_ref); 1337 EXPECT_VALID(new_ref);
1338 EXPECT(!Dart_IsNull(new_ref)); 1338 EXPECT(!Dart_IsNull(new_ref));
1339 EXPECT_VALID(old_ref); 1339 EXPECT_VALID(old_ref);
1340 EXPECT(!Dart_IsNull(old_ref)); 1340 EXPECT(!Dart_IsNull(old_ref));
1341 1341
1342 EXPECT_VALID(weak_new_ref); 1342 EXPECT_VALID(weak_new_ref);
1343 EXPECT(!Dart_IsNull(weak_new_ref)); 1343 EXPECT(!Dart_IsNull(weak_new_ref));
1344 EXPECT(Dart_IdentityEquals(new_ref, weak_new_ref)); 1344 EXPECT(Dart_IdentityEquals(new_ref, weak_new_ref));
1345 1345
1346 EXPECT_VALID(weak_old_ref); 1346 EXPECT_VALID(weak_old_ref);
1347 EXPECT(!Dart_IsNull(weak_old_ref)); 1347 EXPECT(!Dart_IsNull(weak_old_ref));
1348 EXPECT(Dart_IdentityEquals(old_ref, weak_old_ref)); 1348 EXPECT(Dart_IdentityEquals(old_ref, weak_old_ref));
1349 1349
1350 // garbage collect old space 1350 // garbage collect old space.
1351 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1351 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1352 1352
1353 // nothing should be invalidated or cleared 1353 // nothing should be invalidated or cleared.
1354 EXPECT_VALID(new_ref); 1354 EXPECT_VALID(new_ref);
1355 EXPECT(!Dart_IsNull(new_ref)); 1355 EXPECT(!Dart_IsNull(new_ref));
1356 EXPECT_VALID(old_ref); 1356 EXPECT_VALID(old_ref);
1357 EXPECT(!Dart_IsNull(old_ref)); 1357 EXPECT(!Dart_IsNull(old_ref));
1358 1358
1359 EXPECT_VALID(weak_new_ref); 1359 EXPECT_VALID(weak_new_ref);
1360 EXPECT(!Dart_IsNull(weak_new_ref)); 1360 EXPECT(!Dart_IsNull(weak_new_ref));
1361 EXPECT(Dart_IdentityEquals(new_ref, weak_new_ref)); 1361 EXPECT(Dart_IdentityEquals(new_ref, weak_new_ref));
1362 1362
1363 EXPECT_VALID(weak_old_ref); 1363 EXPECT_VALID(weak_old_ref);
1364 EXPECT(!Dart_IsNull(weak_old_ref)); 1364 EXPECT(!Dart_IsNull(weak_old_ref));
1365 EXPECT(Dart_IdentityEquals(old_ref, weak_old_ref)); 1365 EXPECT(Dart_IdentityEquals(old_ref, weak_old_ref));
1366 1366
1367 // delete local (strong) references 1367 // delete local (strong) references
1368 Dart_ExitScope(); 1368 Dart_ExitScope();
1369 } 1369 }
1370 1370
1371 // garbage collect new space again 1371 // garbage collect new space again.
1372 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1372 Isolate::Current()->heap()->Scavenge();
cshapiro 2012/07/10 21:15:39 Ditto.
siva 2012/07/10 21:27:16 Ditto. On 2012/07/10 21:15:39, cshapiro wrote:
1373 1373
1374 // weak ref to new space object should now be cleared 1374 // weak ref to new space object should now be cleared.
1375 EXPECT_VALID(weak_new_ref); 1375 EXPECT_VALID(weak_new_ref);
1376 EXPECT(Dart_IsNull(weak_new_ref)); 1376 EXPECT(Dart_IsNull(weak_new_ref));
1377 EXPECT_VALID(weak_old_ref); 1377 EXPECT_VALID(weak_old_ref);
1378 EXPECT(!Dart_IsNull(weak_old_ref)); 1378 EXPECT(!Dart_IsNull(weak_old_ref));
1379 1379
1380 // garbage collect old space again 1380 // garbage collect old space again.
1381 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1381 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1382 1382
1383 // weak ref to old space object should now be cleared 1383 // weak ref to old space object should now be cleared.
1384 EXPECT_VALID(weak_new_ref); 1384 EXPECT_VALID(weak_new_ref);
1385 EXPECT(Dart_IsNull(weak_new_ref)); 1385 EXPECT(Dart_IsNull(weak_new_ref));
1386 EXPECT_VALID(weak_old_ref); 1386 EXPECT_VALID(weak_old_ref);
1387 EXPECT(Dart_IsNull(weak_old_ref)); 1387 EXPECT(Dart_IsNull(weak_old_ref));
1388 1388
1389 Dart_DeletePersistentHandle(weak_new_ref); 1389 Dart_DeletePersistentHandle(weak_new_ref);
1390 Dart_DeletePersistentHandle(weak_old_ref); 1390 Dart_DeletePersistentHandle(weak_old_ref);
1391 1391
1392 // garbage collect one last time to revisit deleted handles 1392 // garbage collect one last time to revisit deleted handles.
1393 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1393 Isolate::Current()->heap()->CollectGarbage(Heap::kNew);
1394 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1394 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1395 } 1395 }
1396 1396
1397 1397
1398 static void WeakPersistentHandlePeerFinalizer(Dart_Handle handle, void* peer) { 1398 static void WeakPersistentHandlePeerFinalizer(Dart_Handle handle, void* peer) {
1399 *static_cast<int*>(peer) = 42; 1399 *static_cast<int*>(peer) = 42;
1400 } 1400 }
1401 1401
1402 1402
1403 TEST_CASE(WeakPersistentHandleCallback) { 1403 TEST_CASE(WeakPersistentHandleCallback) {
1404 Dart_Handle weak_ref = Dart_Null(); 1404 Dart_Handle weak_ref = Dart_Null();
1405 EXPECT(Dart_IsNull(weak_ref)); 1405 EXPECT(Dart_IsNull(weak_ref));
1406 int* peer = new int(); 1406 int* peer = new int();
1407 { 1407 {
1408 Dart_EnterScope(); 1408 Dart_EnterScope();
1409 Dart_Handle obj = Dart_NewString("new string"); 1409 Dart_Handle obj = Dart_NewString("new string");
1410 EXPECT_VALID(obj); 1410 EXPECT_VALID(obj);
1411 weak_ref = Dart_NewWeakPersistentHandle(obj, peer, 1411 weak_ref = Dart_NewWeakPersistentHandle(obj, peer,
1412 WeakPersistentHandlePeerFinalizer); 1412 WeakPersistentHandlePeerFinalizer);
1413 Dart_ExitScope(); 1413 Dart_ExitScope();
1414 } 1414 }
1415 EXPECT_VALID(weak_ref); 1415 EXPECT_VALID(weak_ref);
1416 EXPECT(*peer == 0); 1416 EXPECT(*peer == 0);
1417 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 1417 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
1418 EXPECT(*peer == 0); 1418 EXPECT(*peer == 0);
1419 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1419 Isolate::Current()->heap()->Scavenge();
1420 EXPECT(*peer == 42); 1420 EXPECT(*peer == 42);
1421 delete peer; 1421 delete peer;
1422 Dart_DeletePersistentHandle(weak_ref); 1422 Dart_DeletePersistentHandle(weak_ref);
1423 } 1423 }
1424 1424
1425 1425
1426 TEST_CASE(ObjectGroups) { 1426 TEST_CASE(ObjectGroups) {
1427 Dart_Handle strong = Dart_Null(); 1427 Dart_Handle strong = Dart_Null();
1428 EXPECT(Dart_IsNull(strong)); 1428 EXPECT(Dart_IsNull(strong));
1429 1429
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 } 1475 }
1476 Dart_ExitScope(); 1476 Dart_ExitScope();
1477 1477
1478 EXPECT_VALID(strong); 1478 EXPECT_VALID(strong);
1479 1479
1480 EXPECT_VALID(weak1); 1480 EXPECT_VALID(weak1);
1481 EXPECT_VALID(weak2); 1481 EXPECT_VALID(weak2);
1482 EXPECT_VALID(weak3); 1482 EXPECT_VALID(weak3);
1483 EXPECT_VALID(weak4); 1483 EXPECT_VALID(weak4);
1484 1484
1485 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1485 Isolate::Current()->heap()->Scavenge();
1486 1486
1487 // New space collection should not affect old space objects 1487 // New space collection should not affect old space objects
1488 EXPECT(!Dart_IsNull(weak1)); 1488 EXPECT(!Dart_IsNull(weak1));
1489 EXPECT(!Dart_IsNull(weak2)); 1489 EXPECT(!Dart_IsNull(weak2));
1490 EXPECT(!Dart_IsNull(weak3)); 1490 EXPECT(!Dart_IsNull(weak3));
1491 EXPECT(!Dart_IsNull(weak4)); 1491 EXPECT(!Dart_IsNull(weak4));
1492 1492
1493 { 1493 {
1494 Dart_Handle array1[] = { weak1, strong }; 1494 Dart_Handle array1[] = { weak1, strong };
1495 EXPECT_VALID(Dart_NewWeakReferenceSet(array1, ARRAY_SIZE(array1), 1495 EXPECT_VALID(Dart_NewWeakReferenceSet(array1, ARRAY_SIZE(array1),
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 EXPECT(!Dart_IsNull(old_pwph)); 1639 EXPECT(!Dart_IsNull(old_pwph));
1640 } 1640 }
1641 Dart_ExitScope(); 1641 Dart_ExitScope();
1642 EXPECT_VALID(new_pwph); 1642 EXPECT_VALID(new_pwph);
1643 EXPECT(!Dart_IsNull(new_pwph)); 1643 EXPECT(!Dart_IsNull(new_pwph));
1644 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); 1644 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph));
1645 EXPECT_VALID(old_pwph); 1645 EXPECT_VALID(old_pwph);
1646 EXPECT(!Dart_IsNull(old_pwph)); 1646 EXPECT(!Dart_IsNull(old_pwph));
1647 EXPECT(Dart_IsPrologueWeakPersistentHandle(old_pwph)); 1647 EXPECT(Dart_IsPrologueWeakPersistentHandle(old_pwph));
1648 // Garbage collect new space without invoking API callbacks. 1648 // Garbage collect new space without invoking API callbacks.
1649 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1649 Isolate::Current()->heap()->Scavenge();
1650 Heap::kIgnoreApiCallbacks); 1650
1651 // Both prologue weak handles should be preserved. 1651 // Both prologue weak handles should be preserved.
1652 EXPECT(!Dart_IsNull(new_pwph)); 1652 EXPECT(!Dart_IsNull(new_pwph));
1653 EXPECT(!Dart_IsNull(old_pwph)); 1653 EXPECT(!Dart_IsNull(old_pwph));
1654 // Garbage collect old space without invoking API callbacks. 1654 // Garbage collect old space without invoking API callbacks.
1655 Isolate::Current()->heap()->CollectGarbage(Heap::kOld, 1655 Isolate::Current()->heap()->CollectGarbage(Heap::kOld,
1656 Heap::kIgnoreApiCallbacks); 1656 Heap::kIgnoreApiCallbacks);
1657 // Both prologue weak handles should be preserved. 1657 // Both prologue weak handles should be preserved.
1658 EXPECT(!Dart_IsNull(new_pwph)); 1658 EXPECT(!Dart_IsNull(new_pwph));
1659 EXPECT(!Dart_IsNull(old_pwph)); 1659 EXPECT(!Dart_IsNull(old_pwph));
1660 // Garbage collect new space invoking API callbacks. 1660 // Garbage collect new space invoking API callbacks.
1661 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1661 Isolate::Current()->heap()->Scavenge(Heap::kInvokeApiCallbacks);
1662 Heap::kInvokeApiCallbacks); 1662
1663 // The prologue weak handle with a new space referent should now be 1663 // The prologue weak handle with a new space referent should now be
1664 // cleared. The old space referent should be preserved. 1664 // cleared. The old space referent should be preserved.
1665 EXPECT(Dart_IsNull(new_pwph)); 1665 EXPECT(Dart_IsNull(new_pwph));
1666 EXPECT(!Dart_IsNull(old_pwph)); 1666 EXPECT(!Dart_IsNull(old_pwph));
1667 Isolate::Current()->heap()->CollectGarbage(Heap::kOld, 1667 Isolate::Current()->heap()->CollectGarbage(Heap::kOld,
1668 Heap::kInvokeApiCallbacks); 1668 Heap::kInvokeApiCallbacks);
1669 // The prologue weak handle with an old space referent should now be 1669 // The prologue weak handle with an old space referent should now be
1670 // cleared. The new space referent should remain cleared. 1670 // cleared. The new space referent should remain cleared.
1671 EXPECT(Dart_IsNull(new_pwph)); 1671 EXPECT(Dart_IsNull(new_pwph));
1672 EXPECT(Dart_IsNull(old_pwph)); 1672 EXPECT(Dart_IsNull(old_pwph));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 EXPECT_VALID(weak3); 1715 EXPECT_VALID(weak3);
1716 } 1716 }
1717 Dart_ExitScope(); 1717 Dart_ExitScope();
1718 1718
1719 EXPECT_VALID(strong); 1719 EXPECT_VALID(strong);
1720 1720
1721 EXPECT_VALID(weak1); 1721 EXPECT_VALID(weak1);
1722 EXPECT_VALID(weak2); 1722 EXPECT_VALID(weak2);
1723 EXPECT_VALID(weak3); 1723 EXPECT_VALID(weak3);
1724 1724
1725 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1725 Isolate::Current()->heap()->Scavenge();
1726 1726
1727 // New space collection should not affect old space objects 1727 // New space collection should not affect old space objects
1728 EXPECT(!Dart_IsNull(weak1)); 1728 EXPECT(!Dart_IsNull(weak1));
1729 EXPECT(!Dart_IsNull(weak2)); 1729 EXPECT(!Dart_IsNull(weak2));
1730 EXPECT(!Dart_IsNull(weak3)); 1730 EXPECT(!Dart_IsNull(weak3));
1731 1731
1732 // A strongly referenced key should preserve all the values. 1732 // A strongly referenced key should preserve all the values.
1733 { 1733 {
1734 Dart_Handle keys[] = { strong }; 1734 Dart_Handle keys[] = { strong };
1735 Dart_Handle values[] = { weak1, weak2, weak3 }; 1735 Dart_Handle values[] = { weak1, weak2, weak3 };
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1817 EXPECT(!Dart_IsNull(weak2)); 1817 EXPECT(!Dart_IsNull(weak2));
1818 EXPECT(!Dart_IsNull(weak3)); 1818 EXPECT(!Dart_IsNull(weak3));
1819 1819
1820 // A strongly referenced key should preserve all the values. 1820 // A strongly referenced key should preserve all the values.
1821 { 1821 {
1822 Dart_Handle keys[] = { strong }; 1822 Dart_Handle keys[] = { strong };
1823 Dart_Handle values[] = { weak1, weak2, weak3 }; 1823 Dart_Handle values[] = { weak1, weak2, weak3 };
1824 EXPECT_VALID(Dart_NewWeakReferenceSet(keys, ARRAY_SIZE(keys), 1824 EXPECT_VALID(Dart_NewWeakReferenceSet(keys, ARRAY_SIZE(keys),
1825 values, ARRAY_SIZE(values))); 1825 values, ARRAY_SIZE(values)));
1826 1826
1827 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1827 Isolate::Current()->heap()->Scavenge(Heap::kInvokeApiCallbacks);
1828 Heap::kInvokeApiCallbacks);
1829 } 1828 }
1830 1829
1831 // All weak references should be preserved. 1830 // All weak references should be preserved.
1832 EXPECT(!Dart_IsNull(weak1)); 1831 EXPECT(!Dart_IsNull(weak1));
1833 EXPECT(!Dart_IsNull(weak2)); 1832 EXPECT(!Dart_IsNull(weak2));
1834 EXPECT(!Dart_IsNull(weak3)); 1833 EXPECT(!Dart_IsNull(weak3));
1835 1834
1836 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1835 Isolate::Current()->heap()->Scavenge();
1837 Heap::kIgnoreApiCallbacks);
1838 1836
1839 // No weak references should be preserved. 1837 // No weak references should be preserved.
1840 EXPECT(Dart_IsNull(weak1)); 1838 EXPECT(Dart_IsNull(weak1));
1841 EXPECT(Dart_IsNull(weak2)); 1839 EXPECT(Dart_IsNull(weak2));
1842 EXPECT(Dart_IsNull(weak3)); 1840 EXPECT(Dart_IsNull(weak3));
1843 } 1841 }
1844 1842
1845 1843
1846 static int global_prologue_callback_status; 1844 static int global_prologue_callback_status;
1847 1845
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 1946
1949 1947
1950 TEST_CASE(SingleGarbageCollectionCallback) { 1948 TEST_CASE(SingleGarbageCollectionCallback) {
1951 // Add a prologue callback. 1949 // Add a prologue callback.
1952 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes2)); 1950 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes2));
1953 1951
1954 // Garbage collect new space ignoring callbacks. This should not 1952 // Garbage collect new space ignoring callbacks. This should not
1955 // invoke the prologue callback. No status values should change. 1953 // invoke the prologue callback. No status values should change.
1956 global_prologue_callback_status = 3; 1954 global_prologue_callback_status = 3;
1957 global_epilogue_callback_status = 7; 1955 global_epilogue_callback_status = 7;
1958 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1956 Isolate::Current()->heap()->Scavenge();
1959 EXPECT_EQ(3, global_prologue_callback_status); 1957 EXPECT_EQ(3, global_prologue_callback_status);
1960 EXPECT_EQ(7, global_epilogue_callback_status); 1958 EXPECT_EQ(7, global_epilogue_callback_status);
1961 1959
1962 // Garbage collect new space invoking callbacks. This should 1960 // Garbage collect new space invoking callbacks. This should
1963 // invoke the prologue callback. No status values should change. 1961 // invoke the prologue callback. No status values should change.
1964 global_prologue_callback_status = 3; 1962 global_prologue_callback_status = 3;
1965 global_epilogue_callback_status = 7; 1963 global_epilogue_callback_status = 7;
1966 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1964 Isolate::Current()->heap()->Scavenge(Heap::kInvokeApiCallbacks);
1967 Heap::kInvokeApiCallbacks);
1968 EXPECT_EQ(6, global_prologue_callback_status); 1965 EXPECT_EQ(6, global_prologue_callback_status);
1969 EXPECT_EQ(7, global_epilogue_callback_status); 1966 EXPECT_EQ(7, global_epilogue_callback_status);
1970 1967
1971 // Garbage collect old space ignoring callbacks. This should invoke 1968 // Garbage collect old space ignoring callbacks. This should invoke
1972 // the prologue callback. The prologue status value should change. 1969 // the prologue callback. The prologue status value should change.
1973 global_prologue_callback_status = 3; 1970 global_prologue_callback_status = 3;
1974 global_epilogue_callback_status = 7; 1971 global_epilogue_callback_status = 7;
1975 Isolate::Current()->heap()->CollectGarbage(Heap::kOld, 1972 Isolate::Current()->heap()->CollectGarbage(Heap::kOld,
1976 Heap::kIgnoreApiCallbacks); 1973 Heap::kIgnoreApiCallbacks);
1977 EXPECT_EQ(3, global_prologue_callback_status); 1974 EXPECT_EQ(3, global_prologue_callback_status);
(...skipping 13 matching lines...) Expand all
1991 EXPECT_EQ(12, global_prologue_callback_status); 1988 EXPECT_EQ(12, global_prologue_callback_status);
1992 EXPECT_EQ(7, global_epilogue_callback_status); 1989 EXPECT_EQ(7, global_epilogue_callback_status);
1993 1990
1994 // Add an epilogue callback. 1991 // Add an epilogue callback.
1995 EXPECT_VALID(Dart_AddGcEpilogueCallback(&EpilogueCallbackTimes4)); 1992 EXPECT_VALID(Dart_AddGcEpilogueCallback(&EpilogueCallbackTimes4));
1996 1993
1997 // Garbage collect new space. This should not invoke the prologue 1994 // Garbage collect new space. This should not invoke the prologue
1998 // or the epilogue callback. No status values should change. 1995 // or the epilogue callback. No status values should change.
1999 global_prologue_callback_status = 3; 1996 global_prologue_callback_status = 3;
2000 global_epilogue_callback_status = 7; 1997 global_epilogue_callback_status = 7;
2001 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 1998 Isolate::Current()->heap()->Scavenge();
2002 EXPECT_EQ(3, global_prologue_callback_status); 1999 EXPECT_EQ(3, global_prologue_callback_status);
2003 EXPECT_EQ(7, global_epilogue_callback_status); 2000 EXPECT_EQ(7, global_epilogue_callback_status);
2004 2001
2005 // Garbage collect new space. This should invoke the prologue and 2002 // Garbage collect new space. This should invoke the prologue and
2006 // the epilogue callback. The prologue and epilogue status values 2003 // the epilogue callback. The prologue and epilogue status values
2007 // should change. 2004 // should change.
2008 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 2005 Isolate::Current()->heap()->Scavenge(Heap::kInvokeApiCallbacks);
2009 Heap::kInvokeApiCallbacks);
2010 EXPECT_EQ(6, global_prologue_callback_status); 2006 EXPECT_EQ(6, global_prologue_callback_status);
2011 EXPECT_EQ(28, global_epilogue_callback_status); 2007 EXPECT_EQ(28, global_epilogue_callback_status);
2012 2008
2013 // Garbage collect old space. This should invoke the prologue and 2009 // Garbage collect old space. This should invoke the prologue and
2014 // the epilogue callbacks. The prologue and epilogue status values 2010 // the epilogue callbacks. The prologue and epilogue status values
2015 // should change. 2011 // should change.
2016 global_prologue_callback_status = 3; 2012 global_prologue_callback_status = 3;
2017 global_epilogue_callback_status = 7; 2013 global_epilogue_callback_status = 7;
2018 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2014 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2019 EXPECT_EQ(6, global_prologue_callback_status); 2015 EXPECT_EQ(6, global_prologue_callback_status);
(...skipping 30 matching lines...) Expand all
2050 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes2)); 2046 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes2));
2051 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes3)); 2047 EXPECT_VALID(Dart_AddGcPrologueCallback(&PrologueCallbackTimes3));
2052 2048
2053 // Add an epilogue callback. 2049 // Add an epilogue callback.
2054 EXPECT_VALID(Dart_AddGcEpilogueCallback(&EpilogueCallbackTimes4)); 2050 EXPECT_VALID(Dart_AddGcEpilogueCallback(&EpilogueCallbackTimes4));
2055 2051
2056 // Garbage collect new space. This should not invoke the prologue 2052 // Garbage collect new space. This should not invoke the prologue
2057 // or epilogue callbacks. No status values should change. 2053 // or epilogue callbacks. No status values should change.
2058 global_prologue_callback_status = 3; 2054 global_prologue_callback_status = 3;
2059 global_epilogue_callback_status = 7; 2055 global_epilogue_callback_status = 7;
2060 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); 2056 Isolate::Current()->heap()->Scavenge();
2061 EXPECT_EQ(3, global_prologue_callback_status); 2057 EXPECT_EQ(3, global_prologue_callback_status);
2062 EXPECT_EQ(7, global_epilogue_callback_status); 2058 EXPECT_EQ(7, global_epilogue_callback_status);
2063 2059
2064 // Garbage collect old space. This should invoke both prologue 2060 // Garbage collect old space. This should invoke both prologue
2065 // callbacks and the epilogue callback. The prologue and epilogue 2061 // callbacks and the epilogue callback. The prologue and epilogue
2066 // status values should change. 2062 // status values should change.
2067 global_prologue_callback_status = 3; 2063 global_prologue_callback_status = 3;
2068 global_epilogue_callback_status = 7; 2064 global_epilogue_callback_status = 7;
2069 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); 2065 Isolate::Current()->heap()->CollectGarbage(Heap::kOld);
2070 EXPECT_EQ(18, global_prologue_callback_status); 2066 EXPECT_EQ(18, global_prologue_callback_status);
(...skipping 3492 matching lines...) Expand 10 before | Expand all | Expand 10 after
5563 EXPECT_VALID(result); 5559 EXPECT_VALID(result);
5564 EXPECT(Dart_IsInteger(result)); 5560 EXPECT(Dart_IsInteger(result));
5565 int64_t value = 0; 5561 int64_t value = 0;
5566 EXPECT_VALID(Dart_IntegerToInt64(result, &value)); 5562 EXPECT_VALID(Dart_IntegerToInt64(result, &value));
5567 EXPECT_EQ(0, value); 5563 EXPECT_EQ(0, value);
5568 } 5564 }
5569 5565
5570 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 5566 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
5571 5567
5572 } // namespace dart 5568 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/heap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698