| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 436 | 436 | 
| 437 | 437 | 
| 438 // Check that the debugger has been fully unloaded. | 438 // Check that the debugger has been fully unloaded. | 
| 439 void CheckDebuggerUnloaded(bool check_functions) { | 439 void CheckDebuggerUnloaded(bool check_functions) { | 
| 440   // Check that the debugger context is cleared and that there is no debug | 440   // Check that the debugger context is cleared and that there is no debug | 
| 441   // information stored for the debugger. | 441   // information stored for the debugger. | 
| 442   CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); | 442   CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); | 
| 443   CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_); | 443   CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_); | 
| 444 | 444 | 
| 445   // Collect garbage to ensure weak handles are cleared. | 445   // Collect garbage to ensure weak handles are cleared. | 
| 446   HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 446   CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 
| 447   HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 447   CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 
| 448 | 448 | 
| 449   // Iterate the head and check that there are no debugger related objects left. | 449   // Iterate the head and check that there are no debugger related objects left. | 
| 450   HeapIterator iterator(HEAP); | 450   HeapIterator iterator(CcTest::heap()); | 
| 451   for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 451   for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 
| 452     CHECK(!obj->IsDebugInfo()); | 452     CHECK(!obj->IsDebugInfo()); | 
| 453     CHECK(!obj->IsBreakPointInfo()); | 453     CHECK(!obj->IsBreakPointInfo()); | 
| 454 | 454 | 
| 455     // If deep check of functions is requested check that no debug break code | 455     // If deep check of functions is requested check that no debug break code | 
| 456     // is left in all functions. | 456     // is left in all functions. | 
| 457     if (check_functions) { | 457     if (check_functions) { | 
| 458       if (obj->IsJSFunction()) { | 458       if (obj->IsJSFunction()) { | 
| 459         JSFunction* fun = JSFunction::cast(obj); | 459         JSFunction* fun = JSFunction::cast(obj); | 
| 460         for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) { | 460         for (RelocIterator it(fun->shared()->code()); !it.done(); it.next()) { | 
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 954   // When hitting a debug event listener there must be a break set. | 954   // When hitting a debug event listener there must be a break set. | 
| 955   CHECK_NE(debug->break_id(), 0); | 955   CHECK_NE(debug->break_id(), 0); | 
| 956 | 956 | 
| 957   // Perform a garbage collection when break point is hit and continue. Based | 957   // Perform a garbage collection when break point is hit and continue. Based | 
| 958   // on the number of break points hit either scavenge or mark compact | 958   // on the number of break points hit either scavenge or mark compact | 
| 959   // collector is used. | 959   // collector is used. | 
| 960   if (event == v8::Break) { | 960   if (event == v8::Break) { | 
| 961     break_point_hit_count++; | 961     break_point_hit_count++; | 
| 962     if (break_point_hit_count % 2 == 0) { | 962     if (break_point_hit_count % 2 == 0) { | 
| 963       // Scavenge. | 963       // Scavenge. | 
| 964       HEAP->CollectGarbage(v8::internal::NEW_SPACE); | 964       CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 
| 965     } else { | 965     } else { | 
| 966       // Mark sweep compact. | 966       // Mark sweep compact. | 
| 967       HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 967       CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 
| 968     } | 968     } | 
| 969   } | 969   } | 
| 970 } | 970 } | 
| 971 | 971 | 
| 972 | 972 | 
| 973 // Debug event handler which re-issues a debug break and calls the garbage | 973 // Debug event handler which re-issues a debug break and calls the garbage | 
| 974 // collector to have the heap verified. | 974 // collector to have the heap verified. | 
| 975 static void DebugEventBreak( | 975 static void DebugEventBreak( | 
| 976     const v8::Debug::EventDetails& event_details) { | 976     const v8::Debug::EventDetails& event_details) { | 
| 977   v8::DebugEvent event = event_details.GetEvent(); | 977   v8::DebugEvent event = event_details.GetEvent(); | 
| 978   v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 978   v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 
| 979   // When hitting a debug event listener there must be a break set. | 979   // When hitting a debug event listener there must be a break set. | 
| 980   CHECK_NE(debug->break_id(), 0); | 980   CHECK_NE(debug->break_id(), 0); | 
| 981 | 981 | 
| 982   if (event == v8::Break) { | 982   if (event == v8::Break) { | 
| 983     // Count the number of breaks. | 983     // Count the number of breaks. | 
| 984     break_point_hit_count++; | 984     break_point_hit_count++; | 
| 985 | 985 | 
| 986     // Run the garbage collector to enforce heap verification if option | 986     // Run the garbage collector to enforce heap verification if option | 
| 987     // --verify-heap is set. | 987     // --verify-heap is set. | 
| 988     HEAP->CollectGarbage(v8::internal::NEW_SPACE); | 988     CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 
| 989 | 989 | 
| 990     // Set the break flag again to come back here as soon as possible. | 990     // Set the break flag again to come back here as soon as possible. | 
| 991     v8::Debug::DebugBreak(CcTest::isolate()); | 991     v8::Debug::DebugBreak(CcTest::isolate()); | 
| 992   } | 992   } | 
| 993 } | 993 } | 
| 994 | 994 | 
| 995 | 995 | 
| 996 // Debug event handler which re-issues a debug break until a limit has been | 996 // Debug event handler which re-issues a debug break until a limit has been | 
| 997 // reached. | 997 // reached. | 
| 998 int max_break_point_hit_count = 0; | 998 int max_break_point_hit_count = 0; | 
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1443 static void CallAndGC(v8::Local<v8::Object> recv, | 1443 static void CallAndGC(v8::Local<v8::Object> recv, | 
| 1444                       v8::Local<v8::Function> f) { | 1444                       v8::Local<v8::Function> f) { | 
| 1445   break_point_hit_count = 0; | 1445   break_point_hit_count = 0; | 
| 1446 | 1446 | 
| 1447   for (int i = 0; i < 3; i++) { | 1447   for (int i = 0; i < 3; i++) { | 
| 1448     // Call function. | 1448     // Call function. | 
| 1449     f->Call(recv, 0, NULL); | 1449     f->Call(recv, 0, NULL); | 
| 1450     CHECK_EQ(1 + i * 3, break_point_hit_count); | 1450     CHECK_EQ(1 + i * 3, break_point_hit_count); | 
| 1451 | 1451 | 
| 1452     // Scavenge and call function. | 1452     // Scavenge and call function. | 
| 1453     HEAP->CollectGarbage(v8::internal::NEW_SPACE); | 1453     CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 
| 1454     f->Call(recv, 0, NULL); | 1454     f->Call(recv, 0, NULL); | 
| 1455     CHECK_EQ(2 + i * 3, break_point_hit_count); | 1455     CHECK_EQ(2 + i * 3, break_point_hit_count); | 
| 1456 | 1456 | 
| 1457     // Mark sweep (and perhaps compact) and call function. | 1457     // Mark sweep (and perhaps compact) and call function. | 
| 1458     HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 1458     CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 
| 1459     f->Call(recv, 0, NULL); | 1459     f->Call(recv, 0, NULL); | 
| 1460     CHECK_EQ(3 + i * 3, break_point_hit_count); | 1460     CHECK_EQ(3 + i * 3, break_point_hit_count); | 
| 1461   } | 1461   } | 
| 1462 } | 1462 } | 
| 1463 | 1463 | 
| 1464 | 1464 | 
| 1465 // Test that a break point can be set at a return store location. | 1465 // Test that a break point can be set at a return store location. | 
| 1466 TEST(BreakPointSurviveGC) { | 1466 TEST(BreakPointSurviveGC) { | 
| 1467   break_point_hit_count = 0; | 1467   break_point_hit_count = 0; | 
| 1468   DebugLocalContext env; | 1468   DebugLocalContext env; | 
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2252     "  a = 1;                   // line 1\n" | 2252     "  a = 1;                   // line 1\n" | 
| 2253     "}\n" | 2253     "}\n" | 
| 2254     "a = 2;                     // line 3\n"); | 2254     "a = 2;                     // line 3\n"); | 
| 2255   v8::Local<v8::Function> f; | 2255   v8::Local<v8::Function> f; | 
| 2256   { | 2256   { | 
| 2257     v8::HandleScope scope(env->GetIsolate()); | 2257     v8::HandleScope scope(env->GetIsolate()); | 
| 2258     v8::Script::Compile(script, v8::String::New("test.html"))->Run(); | 2258     v8::Script::Compile(script, v8::String::New("test.html"))->Run(); | 
| 2259   } | 2259   } | 
| 2260   f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 2260   f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 
| 2261 | 2261 | 
| 2262   HEAP->CollectAllGarbage(Heap::kNoGCFlags); | 2262   CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 
| 2263 | 2263 | 
| 2264   SetScriptBreakPointByNameFromJS("test.html", 3, -1); | 2264   SetScriptBreakPointByNameFromJS("test.html", 3, -1); | 
| 2265 | 2265 | 
| 2266   // Call f and check that there was no break points. | 2266   // Call f and check that there was no break points. | 
| 2267   break_point_hit_count = 0; | 2267   break_point_hit_count = 0; | 
| 2268   f->Call(env->Global(), 0, NULL); | 2268   f->Call(env->Global(), 0, NULL); | 
| 2269   CHECK_EQ(0, break_point_hit_count); | 2269   CHECK_EQ(0, break_point_hit_count); | 
| 2270 | 2270 | 
| 2271   // Recompile and run script and check that break point was hit. | 2271   // Recompile and run script and check that break point was hit. | 
| 2272   break_point_hit_count = 0; | 2272   break_point_hit_count = 0; | 
| (...skipping 4267 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 6540   break_point_hit_count = 0; | 6540   break_point_hit_count = 0; | 
| 6541   script_collected_count = 0; | 6541   script_collected_count = 0; | 
| 6542   DebugLocalContext env; | 6542   DebugLocalContext env; | 
| 6543   v8::HandleScope scope(env->GetIsolate()); | 6543   v8::HandleScope scope(env->GetIsolate()); | 
| 6544 | 6544 | 
| 6545   // Request the loaded scripts to initialize the debugger script cache. | 6545   // Request the loaded scripts to initialize the debugger script cache. | 
| 6546   debug->GetLoadedScripts(); | 6546   debug->GetLoadedScripts(); | 
| 6547 | 6547 | 
| 6548   // Do garbage collection to ensure that only the script in this test will be | 6548   // Do garbage collection to ensure that only the script in this test will be | 
| 6549   // collected afterwards. | 6549   // collected afterwards. | 
| 6550   HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6550   CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 
| 6551 | 6551 | 
| 6552   script_collected_count = 0; | 6552   script_collected_count = 0; | 
| 6553   v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent); | 6553   v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent); | 
| 6554   { | 6554   { | 
| 6555     v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 6555     v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 
| 6556     v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 6556     v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 
| 6557   } | 6557   } | 
| 6558 | 6558 | 
| 6559   // Do garbage collection to collect the script above which is no longer | 6559   // Do garbage collection to collect the script above which is no longer | 
| 6560   // referenced. | 6560   // referenced. | 
| 6561   HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6561   CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 
| 6562 | 6562 | 
| 6563   CHECK_EQ(2, script_collected_count); | 6563   CHECK_EQ(2, script_collected_count); | 
| 6564 | 6564 | 
| 6565   v8::Debug::SetDebugEventListener2(NULL); | 6565   v8::Debug::SetDebugEventListener2(NULL); | 
| 6566   CheckDebuggerUnloaded(); | 6566   CheckDebuggerUnloaded(); | 
| 6567 } | 6567 } | 
| 6568 | 6568 | 
| 6569 | 6569 | 
| 6570 // Debug event listener which counts the script collected events. | 6570 // Debug event listener which counts the script collected events. | 
| 6571 int script_collected_message_count = 0; | 6571 int script_collected_message_count = 0; | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 6602     v8::Local<v8::Context> local_context = | 6602     v8::Local<v8::Context> local_context = | 
| 6603         v8::Local<v8::Context>::New(isolate, context); | 6603         v8::Local<v8::Context>::New(isolate, context); | 
| 6604     local_context->Enter(); | 6604     local_context->Enter(); | 
| 6605   } | 6605   } | 
| 6606 | 6606 | 
| 6607   // Request the loaded scripts to initialize the debugger script cache. | 6607   // Request the loaded scripts to initialize the debugger script cache. | 
| 6608   debug->GetLoadedScripts(); | 6608   debug->GetLoadedScripts(); | 
| 6609 | 6609 | 
| 6610   // Do garbage collection to ensure that only the script in this test will be | 6610   // Do garbage collection to ensure that only the script in this test will be | 
| 6611   // collected afterwards. | 6611   // collected afterwards. | 
| 6612   HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6612   CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 
| 6613 | 6613 | 
| 6614   v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); | 6614   v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); | 
| 6615   v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 6615   v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 
| 6616   v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 6616   v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 
| 6617 | 6617 | 
| 6618   // Leave context | 6618   // Leave context | 
| 6619   { | 6619   { | 
| 6620     v8::HandleScope scope(isolate); | 6620     v8::HandleScope scope(isolate); | 
| 6621     v8::Local<v8::Context> local_context = | 6621     v8::Local<v8::Context> local_context = | 
| 6622         v8::Local<v8::Context>::New(isolate, context); | 6622         v8::Local<v8::Context>::New(isolate, context); | 
| 6623     local_context->Exit(); | 6623     local_context->Exit(); | 
| 6624   } | 6624   } | 
| 6625   context.Dispose(); | 6625   context.Dispose(); | 
| 6626 | 6626 | 
| 6627   // Do garbage collection to collect the script above which is no longer | 6627   // Do garbage collection to collect the script above which is no longer | 
| 6628   // referenced. | 6628   // referenced. | 
| 6629   HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 6629   CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 
| 6630 | 6630 | 
| 6631   CHECK_EQ(2, script_collected_message_count); | 6631   CHECK_EQ(2, script_collected_message_count); | 
| 6632 | 6632 | 
| 6633   v8::Debug::SetMessageHandler2(NULL); | 6633   v8::Debug::SetMessageHandler2(NULL); | 
| 6634 } | 6634 } | 
| 6635 | 6635 | 
| 6636 | 6636 | 
| 6637 // Debug event listener which counts the after compile events. | 6637 // Debug event listener which counts the after compile events. | 
| 6638 int after_compile_message_count = 0; | 6638 int after_compile_message_count = 0; | 
| 6639 static void AfterCompileMessageHandler(const v8::Debug::Message& message) { | 6639 static void AfterCompileMessageHandler(const v8::Debug::Message& message) { | 
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 7549 TEST(LiveEditDisabled) { | 7549 TEST(LiveEditDisabled) { | 
| 7550   v8::internal::FLAG_allow_natives_syntax = true; | 7550   v8::internal::FLAG_allow_natives_syntax = true; | 
| 7551   LocalContext env; | 7551   LocalContext env; | 
| 7552   v8::HandleScope scope(env->GetIsolate()); | 7552   v8::HandleScope scope(env->GetIsolate()); | 
| 7553   v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); | 7553   v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); | 
| 7554   CompileRun("%LiveEditCompareStrings('', '')"); | 7554   CompileRun("%LiveEditCompareStrings('', '')"); | 
| 7555 } | 7555 } | 
| 7556 | 7556 | 
| 7557 | 7557 | 
| 7558 #endif  // ENABLE_DEBUGGER_SUPPORT | 7558 #endif  // ENABLE_DEBUGGER_SUPPORT | 
| OLD | NEW | 
|---|