| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 390 | 390 | 
| 391 | 391 | 
| 392 // Check that the debugger has been fully unloaded. | 392 // Check that the debugger has been fully unloaded. | 
| 393 void CheckDebuggerUnloaded(bool check_functions) { | 393 void CheckDebuggerUnloaded(bool check_functions) { | 
| 394   // Check that the debugger context is cleared and that there is no debug | 394   // Check that the debugger context is cleared and that there is no debug | 
| 395   // information stored for the debugger. | 395   // information stored for the debugger. | 
| 396   CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); | 396   CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); | 
| 397   CHECK(!CcTest::i_isolate()->debug()->debug_info_list_); | 397   CHECK(!CcTest::i_isolate()->debug()->debug_info_list_); | 
| 398 | 398 | 
| 399   // Collect garbage to ensure weak handles are cleared. | 399   // Collect garbage to ensure weak handles are cleared. | 
| 400   CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 400   CcTest::heap()->CollectAllGarbage(); | 
| 401   CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 401   CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 
| 402 | 402 | 
| 403   // Iterate the head and check that there are no debugger related objects left. | 403   // Iterate the head and check that there are no debugger related objects left. | 
| 404   HeapIterator iterator(CcTest::heap()); | 404   HeapIterator iterator(CcTest::heap()); | 
| 405   for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 405   for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 
| 406     CHECK(!obj->IsDebugInfo()); | 406     CHECK(!obj->IsDebugInfo()); | 
| 407     CHECK(!obj->IsBreakPointInfo()); | 407     CHECK(!obj->IsBreakPointInfo()); | 
| 408 | 408 | 
| 409     // If deep check of functions is requested check that no debug break code | 409     // If deep check of functions is requested check that no debug break code | 
| 410     // is left in all functions. | 410     // is left in all functions. | 
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 863   // Perform a garbage collection when break point is hit and continue. Based | 863   // Perform a garbage collection when break point is hit and continue. Based | 
| 864   // on the number of break points hit either scavenge or mark compact | 864   // on the number of break points hit either scavenge or mark compact | 
| 865   // collector is used. | 865   // collector is used. | 
| 866   if (event == v8::Break) { | 866   if (event == v8::Break) { | 
| 867     break_point_hit_count++; | 867     break_point_hit_count++; | 
| 868     if (break_point_hit_count % 2 == 0) { | 868     if (break_point_hit_count % 2 == 0) { | 
| 869       // Scavenge. | 869       // Scavenge. | 
| 870       CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 870       CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 
| 871     } else { | 871     } else { | 
| 872       // Mark sweep compact. | 872       // Mark sweep compact. | 
| 873       CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 873       CcTest::heap()->CollectAllGarbage(); | 
| 874     } | 874     } | 
| 875   } | 875   } | 
| 876 } | 876 } | 
| 877 | 877 | 
| 878 | 878 | 
| 879 // Debug event handler which re-issues a debug break and calls the garbage | 879 // Debug event handler which re-issues a debug break and calls the garbage | 
| 880 // collector to have the heap verified. | 880 // collector to have the heap verified. | 
| 881 static void DebugEventBreak( | 881 static void DebugEventBreak( | 
| 882     const v8::Debug::EventDetails& event_details) { | 882     const v8::Debug::EventDetails& event_details) { | 
| 883   v8::DebugEvent event = event_details.GetEvent(); | 883   v8::DebugEvent event = event_details.GetEvent(); | 
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1369     // Call function. | 1369     // Call function. | 
| 1370     f->Call(recv, 0, NULL); | 1370     f->Call(recv, 0, NULL); | 
| 1371     CHECK_EQ(1 + i * 3, break_point_hit_count); | 1371     CHECK_EQ(1 + i * 3, break_point_hit_count); | 
| 1372 | 1372 | 
| 1373     // Scavenge and call function. | 1373     // Scavenge and call function. | 
| 1374     CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 1374     CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 
| 1375     f->Call(recv, 0, NULL); | 1375     f->Call(recv, 0, NULL); | 
| 1376     CHECK_EQ(2 + i * 3, break_point_hit_count); | 1376     CHECK_EQ(2 + i * 3, break_point_hit_count); | 
| 1377 | 1377 | 
| 1378     // Mark sweep (and perhaps compact) and call function. | 1378     // Mark sweep (and perhaps compact) and call function. | 
| 1379     CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 1379     CcTest::heap()->CollectAllGarbage(); | 
| 1380     f->Call(recv, 0, NULL); | 1380     f->Call(recv, 0, NULL); | 
| 1381     CHECK_EQ(3 + i * 3, break_point_hit_count); | 1381     CHECK_EQ(3 + i * 3, break_point_hit_count); | 
| 1382   } | 1382   } | 
| 1383 } | 1383 } | 
| 1384 | 1384 | 
| 1385 | 1385 | 
| 1386 // Test that a break point can be set at a return store location. | 1386 // Test that a break point can be set at a return store location. | 
| 1387 TEST(BreakPointSurviveGC) { | 1387 TEST(BreakPointSurviveGC) { | 
| 1388   break_point_hit_count = 0; | 1388   break_point_hit_count = 0; | 
| 1389   DebugLocalContext env; | 1389   DebugLocalContext env; | 
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2213                               "}\n" | 2213                               "}\n" | 
| 2214                               "a = 2;                     // line 3\n"); | 2214                               "a = 2;                     // line 3\n"); | 
| 2215   v8::Local<v8::Function> f; | 2215   v8::Local<v8::Function> f; | 
| 2216   { | 2216   { | 
| 2217     v8::HandleScope scope(env->GetIsolate()); | 2217     v8::HandleScope scope(env->GetIsolate()); | 
| 2218     CompileRunWithOrigin(script, "test.html"); | 2218     CompileRunWithOrigin(script, "test.html"); | 
| 2219   } | 2219   } | 
| 2220   f = v8::Local<v8::Function>::Cast( | 2220   f = v8::Local<v8::Function>::Cast( | 
| 2221       env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 2221       env->Global()->Get(v8::String::NewFromUtf8(env->GetIsolate(), "f"))); | 
| 2222 | 2222 | 
| 2223   CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2223   CcTest::heap()->CollectAllGarbage(); | 
| 2224 | 2224 | 
| 2225   SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); | 2225   SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); | 
| 2226 | 2226 | 
| 2227   // Call f and check that there was no break points. | 2227   // Call f and check that there was no break points. | 
| 2228   break_point_hit_count = 0; | 2228   break_point_hit_count = 0; | 
| 2229   f->Call(env->Global(), 0, NULL); | 2229   f->Call(env->Global(), 0, NULL); | 
| 2230   CHECK_EQ(0, break_point_hit_count); | 2230   CHECK_EQ(0, break_point_hit_count); | 
| 2231 | 2231 | 
| 2232   // Recompile and run script and check that break point was hit. | 2232   // Recompile and run script and check that break point was hit. | 
| 2233   break_point_hit_count = 0; | 2233   break_point_hit_count = 0; | 
| (...skipping 5355 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 7589       "let y = 2;               \n" | 7589       "let y = 2;               \n" | 
| 7590       "debugger;                \n" | 7590       "debugger;                \n" | 
| 7591       "x * y", | 7591       "x * y", | 
| 7592       30); | 7592       30); | 
| 7593   ExpectInt32( | 7593   ExpectInt32( | 
| 7594       "x = 1; y = 2; \n" | 7594       "x = 1; y = 2; \n" | 
| 7595       "debugger;" | 7595       "debugger;" | 
| 7596       "x * y", | 7596       "x * y", | 
| 7597       30); | 7597       30); | 
| 7598 } | 7598 } | 
| OLD | NEW | 
|---|