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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 | 365 |
366 // Check that the debugger has been fully unloaded. | 366 // Check that the debugger has been fully unloaded. |
367 void CheckDebuggerUnloaded(bool check_functions) { | 367 void CheckDebuggerUnloaded(bool check_functions) { |
368 // Check that the debugger context is cleared and that there is no debug | 368 // Check that the debugger context is cleared and that there is no debug |
369 // information stored for the debugger. | 369 // information stored for the debugger. |
370 CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); | 370 CHECK(CcTest::i_isolate()->debug()->debug_context().is_null()); |
371 CHECK(!CcTest::i_isolate()->debug()->debug_info_list_); | 371 CHECK(!CcTest::i_isolate()->debug()->debug_info_list_); |
372 | 372 |
373 // Collect garbage to ensure weak handles are cleared. | 373 // Collect garbage to ensure weak handles are cleared. |
374 CcTest::heap()->CollectAllGarbage(); | 374 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
375 CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask); | 375 CcTest::CollectAllGarbage(Heap::kMakeHeapIterableMask); |
376 | 376 |
377 // Iterate the head and check that there are no debugger related objects left. | 377 // Iterate the head and check that there are no debugger related objects left. |
378 HeapIterator iterator(CcTest::heap()); | 378 HeapIterator iterator(CcTest::heap()); |
379 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 379 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
380 CHECK(!obj->IsDebugInfo()); | 380 CHECK(!obj->IsDebugInfo()); |
381 CHECK(!obj->IsBreakPointInfo()); | 381 CHECK(!obj->IsBreakPointInfo()); |
382 | 382 |
383 // If deep check of functions is requested check that no debug break code | 383 // If deep check of functions is requested check that no debug break code |
384 // is left in all functions. | 384 // is left in all functions. |
385 if (check_functions) { | 385 if (check_functions) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 // When hitting a debug event listener there must be a break set. | 793 // When hitting a debug event listener there must be a break set. |
794 CHECK_NE(debug->break_id(), 0); | 794 CHECK_NE(debug->break_id(), 0); |
795 | 795 |
796 // Perform a garbage collection when break point is hit and continue. Based | 796 // Perform a garbage collection when break point is hit and continue. Based |
797 // on the number of break points hit either scavenge or mark compact | 797 // on the number of break points hit either scavenge or mark compact |
798 // collector is used. | 798 // collector is used. |
799 if (event == v8::Break) { | 799 if (event == v8::Break) { |
800 break_point_hit_count++; | 800 break_point_hit_count++; |
801 if (break_point_hit_count % 2 == 0) { | 801 if (break_point_hit_count % 2 == 0) { |
802 // Scavenge. | 802 // Scavenge. |
803 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 803 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
804 } else { | 804 } else { |
805 // Mark sweep compact. | 805 // Mark sweep compact. |
806 CcTest::heap()->CollectAllGarbage(); | 806 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
807 } | 807 } |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 | 811 |
812 // Debug event handler which re-issues a debug break and calls the garbage | 812 // Debug event handler which re-issues a debug break and calls the garbage |
813 // collector to have the heap verified. | 813 // collector to have the heap verified. |
814 static void DebugEventBreak( | 814 static void DebugEventBreak( |
815 const v8::Debug::EventDetails& event_details) { | 815 const v8::Debug::EventDetails& event_details) { |
816 v8::DebugEvent event = event_details.GetEvent(); | 816 v8::DebugEvent event = event_details.GetEvent(); |
817 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); | 817 v8::internal::Debug* debug = CcTest::i_isolate()->debug(); |
818 // When hitting a debug event listener there must be a break set. | 818 // When hitting a debug event listener there must be a break set. |
819 CHECK_NE(debug->break_id(), 0); | 819 CHECK_NE(debug->break_id(), 0); |
820 | 820 |
821 if (event == v8::Break) { | 821 if (event == v8::Break) { |
822 // Count the number of breaks. | 822 // Count the number of breaks. |
823 break_point_hit_count++; | 823 break_point_hit_count++; |
824 | 824 |
825 // Run the garbage collector to enforce heap verification if option | 825 // Run the garbage collector to enforce heap verification if option |
826 // --verify-heap is set. | 826 // --verify-heap is set. |
827 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 827 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
828 | 828 |
829 // Set the break flag again to come back here as soon as possible. | 829 // Set the break flag again to come back here as soon as possible. |
830 v8::Debug::DebugBreak(CcTest::isolate()); | 830 v8::Debug::DebugBreak(CcTest::isolate()); |
831 } | 831 } |
832 } | 832 } |
833 | 833 |
834 | 834 |
835 // Debug event handler which re-issues a debug break until a limit has been | 835 // Debug event handler which re-issues a debug break until a limit has been |
836 // reached. | 836 // reached. |
837 int max_break_point_hit_count = 0; | 837 int max_break_point_hit_count = 0; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 static void CallAndGC(v8::Local<v8::Context> context, | 1210 static void CallAndGC(v8::Local<v8::Context> context, |
1211 v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { | 1211 v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { |
1212 break_point_hit_count = 0; | 1212 break_point_hit_count = 0; |
1213 | 1213 |
1214 for (int i = 0; i < 3; i++) { | 1214 for (int i = 0; i < 3; i++) { |
1215 // Call function. | 1215 // Call function. |
1216 f->Call(context, recv, 0, NULL).ToLocalChecked(); | 1216 f->Call(context, recv, 0, NULL).ToLocalChecked(); |
1217 CHECK_EQ(1 + i * 3, break_point_hit_count); | 1217 CHECK_EQ(1 + i * 3, break_point_hit_count); |
1218 | 1218 |
1219 // Scavenge and call function. | 1219 // Scavenge and call function. |
1220 CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE); | 1220 CcTest::CollectGarbage(v8::internal::NEW_SPACE); |
1221 f->Call(context, recv, 0, NULL).ToLocalChecked(); | 1221 f->Call(context, recv, 0, NULL).ToLocalChecked(); |
1222 CHECK_EQ(2 + i * 3, break_point_hit_count); | 1222 CHECK_EQ(2 + i * 3, break_point_hit_count); |
1223 | 1223 |
1224 // Mark sweep (and perhaps compact) and call function. | 1224 // Mark sweep (and perhaps compact) and call function. |
1225 CcTest::heap()->CollectAllGarbage(); | 1225 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
1226 f->Call(context, recv, 0, NULL).ToLocalChecked(); | 1226 f->Call(context, recv, 0, NULL).ToLocalChecked(); |
1227 CHECK_EQ(3 + i * 3, break_point_hit_count); | 1227 CHECK_EQ(3 + i * 3, break_point_hit_count); |
1228 } | 1228 } |
1229 } | 1229 } |
1230 | 1230 |
1231 | 1231 |
1232 // Test that a break point can be set at a return store location. | 1232 // Test that a break point can be set at a return store location. |
1233 TEST(BreakPointSurviveGC) { | 1233 TEST(BreakPointSurviveGC) { |
1234 break_point_hit_count = 0; | 1234 break_point_hit_count = 0; |
1235 DebugLocalContext env; | 1235 DebugLocalContext env; |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 v8::Local<v8::Function> f; | 2073 v8::Local<v8::Function> f; |
2074 { | 2074 { |
2075 v8::HandleScope scope(env->GetIsolate()); | 2075 v8::HandleScope scope(env->GetIsolate()); |
2076 CompileRunWithOrigin(script, "test.html"); | 2076 CompileRunWithOrigin(script, "test.html"); |
2077 } | 2077 } |
2078 f = v8::Local<v8::Function>::Cast( | 2078 f = v8::Local<v8::Function>::Cast( |
2079 env->Global() | 2079 env->Global() |
2080 ->Get(context, v8_str(env->GetIsolate(), "f")) | 2080 ->Get(context, v8_str(env->GetIsolate(), "f")) |
2081 .ToLocalChecked()); | 2081 .ToLocalChecked()); |
2082 | 2082 |
2083 CcTest::heap()->CollectAllGarbage(); | 2083 CcTest::CollectAllGarbage(i::Heap::kFinalizeIncrementalMarkingMask); |
2084 | 2084 |
2085 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); | 2085 SetScriptBreakPointByNameFromJS(env->GetIsolate(), "test.html", 3, -1); |
2086 | 2086 |
2087 // Call f and check that there was no break points. | 2087 // Call f and check that there was no break points. |
2088 break_point_hit_count = 0; | 2088 break_point_hit_count = 0; |
2089 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 2089 f->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
2090 CHECK_EQ(0, break_point_hit_count); | 2090 CHECK_EQ(0, break_point_hit_count); |
2091 | 2091 |
2092 // Recompile and run script and check that break point was hit. | 2092 // Recompile and run script and check that break point was hit. |
2093 break_point_hit_count = 0; | 2093 break_point_hit_count = 0; |
(...skipping 6089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8183 "function foo() {\n" | 8183 "function foo() {\n" |
8184 " try { throw new Error(); } catch (e) {}\n" | 8184 " try { throw new Error(); } catch (e) {}\n" |
8185 "}\n" | 8185 "}\n" |
8186 "debugger;\n" | 8186 "debugger;\n" |
8187 "foo();\n" | 8187 "foo();\n" |
8188 "foo();\n"); | 8188 "foo();\n"); |
8189 | 8189 |
8190 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); | 8190 v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr); |
8191 CHECK_EQ(break_point_hit_count, 4); | 8191 CHECK_EQ(break_point_hit_count, 4); |
8192 } | 8192 } |
OLD | NEW |