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

Side by Side Diff: test/cctest/test-debug.cc

Issue 7689002: Remove obsolete kForceCompactionMask flag for GC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Do meaningful work on LowMemoryNotification. Created 9 years, 3 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 | « test/cctest/test-api.cc ('k') | test/cctest/test-heap.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 // Perform a garbage collection when break point is hit and continue. Based 936 // Perform a garbage collection when break point is hit and continue. Based
937 // on the number of break points hit either scavenge or mark compact 937 // on the number of break points hit either scavenge or mark compact
938 // collector is used. 938 // collector is used.
939 if (event == v8::Break) { 939 if (event == v8::Break) {
940 break_point_hit_count++; 940 break_point_hit_count++;
941 if (break_point_hit_count % 2 == 0) { 941 if (break_point_hit_count % 2 == 0) {
942 // Scavenge. 942 // Scavenge.
943 HEAP->CollectGarbage(v8::internal::NEW_SPACE); 943 HEAP->CollectGarbage(v8::internal::NEW_SPACE);
944 } else { 944 } else {
945 // Mark sweep compact. 945 // Mark sweep compact.
946 HEAP->CollectAllGarbage(Heap::kForceCompactionMask); 946 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
947 } 947 }
948 } 948 }
949 } 949 }
950 950
951 951
952 // Debug event handler which re-issues a debug break and calls the garbage 952 // Debug event handler which re-issues a debug break and calls the garbage
953 // collector to have the heap verified. 953 // collector to have the heap verified.
954 static void DebugEventBreak(v8::DebugEvent event, 954 static void DebugEventBreak(v8::DebugEvent event,
955 v8::Handle<v8::Object> exec_state, 955 v8::Handle<v8::Object> exec_state,
956 v8::Handle<v8::Object> event_data, 956 v8::Handle<v8::Object> event_data,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 CallWithBreakPoints(env->Global(), foo, 1, 25); 1409 CallWithBreakPoints(env->Global(), foo, 1, 25);
1410 1410
1411 v8::Debug::SetDebugEventListener(NULL); 1411 v8::Debug::SetDebugEventListener(NULL);
1412 CheckDebuggerUnloaded(); 1412 CheckDebuggerUnloaded();
1413 } 1413 }
1414 1414
1415 1415
1416 // Call the function three times with different garbage collections in between 1416 // Call the function three times with different garbage collections in between
1417 // and make sure that the break point survives. 1417 // and make sure that the break point survives.
1418 static void CallAndGC(v8::Local<v8::Object> recv, 1418 static void CallAndGC(v8::Local<v8::Object> recv,
1419 v8::Local<v8::Function> f, 1419 v8::Local<v8::Function> f) {
1420 int gc_flags) {
1421 break_point_hit_count = 0; 1420 break_point_hit_count = 0;
1422 1421
1423 for (int i = 0; i < 3; i++) { 1422 for (int i = 0; i < 3; i++) {
1424 // Call function. 1423 // Call function.
1425 f->Call(recv, 0, NULL); 1424 f->Call(recv, 0, NULL);
1426 CHECK_EQ(1 + i * 3, break_point_hit_count); 1425 CHECK_EQ(1 + i * 3, break_point_hit_count);
1427 1426
1428 // Scavenge and call function. 1427 // Scavenge and call function.
1429 HEAP->CollectGarbage(v8::internal::NEW_SPACE); 1428 HEAP->CollectGarbage(v8::internal::NEW_SPACE);
1430 f->Call(recv, 0, NULL); 1429 f->Call(recv, 0, NULL);
1431 CHECK_EQ(2 + i * 3, break_point_hit_count); 1430 CHECK_EQ(2 + i * 3, break_point_hit_count);
1432 1431
1433 // Mark sweep (and perhaps compact) and call function. 1432 // Mark sweep (and perhaps compact) and call function.
1434 HEAP->CollectAllGarbage(gc_flags); 1433 HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1435 f->Call(recv, 0, NULL); 1434 f->Call(recv, 0, NULL);
1436 CHECK_EQ(3 + i * 3, break_point_hit_count); 1435 CHECK_EQ(3 + i * 3, break_point_hit_count);
1437 } 1436 }
1438 } 1437 }
1439 1438
1440 1439
1441 static void TestBreakPointSurviveGC(int gc_flags) { 1440 // Test that a break point can be set at a return store location.
1441 TEST(BreakPointSurviveGC) {
1442 break_point_hit_count = 0; 1442 break_point_hit_count = 0;
1443 v8::HandleScope scope; 1443 v8::HandleScope scope;
1444 DebugLocalContext env; 1444 DebugLocalContext env;
1445 1445
1446 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, 1446 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1447 v8::Undefined()); 1447 v8::Undefined());
1448 v8::Local<v8::Function> foo; 1448 v8::Local<v8::Function> foo;
1449 1449
1450 // Test IC store break point with garbage collection. 1450 // Test IC store break point with garbage collection.
1451 { 1451 {
1452 v8::Local<v8::Function> bar = 1452 v8::Local<v8::Function> bar =
1453 CompileFunction(&env, "function foo(){}", "foo"); 1453 CompileFunction(&env, "function foo(){}", "foo");
1454 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); 1454 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo");
1455 SetBreakPoint(foo, 0); 1455 SetBreakPoint(foo, 0);
1456 } 1456 }
1457 CallAndGC(env->Global(), foo, gc_flags); 1457 CallAndGC(env->Global(), foo);
1458 1458
1459 // Test IC load break point with garbage collection. 1459 // Test IC load break point with garbage collection.
1460 { 1460 {
1461 v8::Local<v8::Function> bar = 1461 v8::Local<v8::Function> bar =
1462 CompileFunction(&env, "function foo(){}", "foo"); 1462 CompileFunction(&env, "function foo(){}", "foo");
1463 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); 1463 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo");
1464 SetBreakPoint(foo, 0); 1464 SetBreakPoint(foo, 0);
1465 } 1465 }
1466 CallAndGC(env->Global(), foo, gc_flags); 1466 CallAndGC(env->Global(), foo);
1467 1467
1468 // Test IC call break point with garbage collection. 1468 // Test IC call break point with garbage collection.
1469 { 1469 {
1470 v8::Local<v8::Function> bar = 1470 v8::Local<v8::Function> bar =
1471 CompileFunction(&env, "function foo(){}", "foo"); 1471 CompileFunction(&env, "function foo(){}", "foo");
1472 foo = CompileFunction(&env, 1472 foo = CompileFunction(&env,
1473 "function bar(){};function foo(){bar();}", 1473 "function bar(){};function foo(){bar();}",
1474 "foo"); 1474 "foo");
1475 SetBreakPoint(foo, 0); 1475 SetBreakPoint(foo, 0);
1476 } 1476 }
1477 CallAndGC(env->Global(), foo, gc_flags); 1477 CallAndGC(env->Global(), foo);
1478 1478
1479 // Test return break point with garbage collection. 1479 // Test return break point with garbage collection.
1480 { 1480 {
1481 v8::Local<v8::Function> bar = 1481 v8::Local<v8::Function> bar =
1482 CompileFunction(&env, "function foo(){}", "foo"); 1482 CompileFunction(&env, "function foo(){}", "foo");
1483 foo = CompileFunction(&env, "function foo(){}", "foo"); 1483 foo = CompileFunction(&env, "function foo(){}", "foo");
1484 SetBreakPoint(foo, 0); 1484 SetBreakPoint(foo, 0);
1485 } 1485 }
1486 CallAndGC(env->Global(), foo, gc_flags); 1486 CallAndGC(env->Global(), foo);
1487 1487
1488 // Test non IC break point with garbage collection. 1488 // Test non IC break point with garbage collection.
1489 { 1489 {
1490 v8::Local<v8::Function> bar = 1490 v8::Local<v8::Function> bar =
1491 CompileFunction(&env, "function foo(){}", "foo"); 1491 CompileFunction(&env, "function foo(){}", "foo");
1492 foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); 1492 foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo");
1493 SetBreakPoint(foo, 0); 1493 SetBreakPoint(foo, 0);
1494 } 1494 }
1495 CallAndGC(env->Global(), foo, gc_flags); 1495 CallAndGC(env->Global(), foo);
1496 1496
1497 1497
1498 v8::Debug::SetDebugEventListener(NULL); 1498 v8::Debug::SetDebugEventListener(NULL);
1499 CheckDebuggerUnloaded(); 1499 CheckDebuggerUnloaded();
1500 } 1500 }
1501 1501
1502 1502
1503 // Test that a break point can be set at a return store location.
1504 TEST(BreakPointSurviveGC) {
1505 TestBreakPointSurviveGC(Heap::kNoGCFlags);
1506 TestBreakPointSurviveGC(Heap::kForceCompactionMask);
1507 }
1508
1509
1510 // Test that break points can be set using the global Debug object. 1503 // Test that break points can be set using the global Debug object.
1511 TEST(BreakPointThroughJavaScript) { 1504 TEST(BreakPointThroughJavaScript) {
1512 break_point_hit_count = 0; 1505 break_point_hit_count = 0;
1513 v8::HandleScope scope; 1506 v8::HandleScope scope;
1514 DebugLocalContext env; 1507 DebugLocalContext env;
1515 env.ExposeDebug(); 1508 env.ExposeDebug();
1516 1509
1517 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, 1510 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
1518 v8::Undefined()); 1511 v8::Undefined());
1519 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); 1512 v8::Script::Compile(v8::String::New("function bar(){}"))->Run();
(...skipping 5775 matching lines...) Expand 10 before | Expand all | Expand 10 after
7295 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}"); 7288 TestDebugBreakInLoop("for (;;) {", loop_bodies, "}");
7296 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}"); 7289 TestDebugBreakInLoop("for (;a == 1;) {", loop_bodies, "}");
7297 7290
7298 // Get rid of the debug event listener. 7291 // Get rid of the debug event listener.
7299 v8::Debug::SetDebugEventListener(NULL); 7292 v8::Debug::SetDebugEventListener(NULL);
7300 CheckDebuggerUnloaded(); 7293 CheckDebuggerUnloaded();
7301 } 7294 }
7302 7295
7303 7296
7304 #endif // ENABLE_DEBUGGER_SUPPORT 7297 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698