OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 | 408 |
409 // Check that the debugger has been fully unloaded. | 409 // Check that the debugger has been fully unloaded. |
410 void CheckDebuggerUnloaded(bool check_functions) { | 410 void CheckDebuggerUnloaded(bool check_functions) { |
411 // Check that the debugger context is cleared and that there is no debug | 411 // Check that the debugger context is cleared and that there is no debug |
412 // information stored for the debugger. | 412 // information stored for the debugger. |
413 CHECK(Debug::debug_context().is_null()); | 413 CHECK(Debug::debug_context().is_null()); |
414 CHECK_EQ(NULL, Debug::debug_info_list_); | 414 CHECK_EQ(NULL, Debug::debug_info_list_); |
415 | 415 |
416 // Collect garbage to ensure weak handles are cleared. | 416 // Collect garbage to ensure weak handles are cleared. |
417 Heap::CollectAllGarbage(); | 417 Heap::CollectAllGarbage(false); |
418 Heap::CollectAllGarbage(); | 418 Heap::CollectAllGarbage(false); |
419 | 419 |
420 // Iterate the head and check that there are no debugger related objects left. | 420 // Iterate the head and check that there are no debugger related objects left. |
421 HeapIterator iterator; | 421 HeapIterator iterator; |
422 while (iterator.has_next()) { | 422 while (iterator.has_next()) { |
423 HeapObject* obj = iterator.next(); | 423 HeapObject* obj = iterator.next(); |
424 CHECK(obj != NULL); | 424 CHECK(obj != NULL); |
425 CHECK(!obj->IsDebugInfo()); | 425 CHECK(!obj->IsDebugInfo()); |
426 CHECK(!obj->IsBreakPointInfo()); | 426 CHECK(!obj->IsBreakPointInfo()); |
427 | 427 |
428 // If deep check of functions is requested check that no debug break code | 428 // If deep check of functions is requested check that no debug break code |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 // Perform a garbage collection when break point is hit and continue. Based | 836 // Perform a garbage collection when break point is hit and continue. Based |
837 // on the number of break points hit either scavenge or mark compact | 837 // on the number of break points hit either scavenge or mark compact |
838 // collector is used. | 838 // collector is used. |
839 if (event == v8::Break) { | 839 if (event == v8::Break) { |
840 break_point_hit_count++; | 840 break_point_hit_count++; |
841 if (break_point_hit_count % 2 == 0) { | 841 if (break_point_hit_count % 2 == 0) { |
842 // Scavenge. | 842 // Scavenge. |
843 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); | 843 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); |
844 } else { | 844 } else { |
845 // Mark sweep (and perhaps compact). | 845 // Mark sweep (and perhaps compact). |
846 Heap::CollectAllGarbage(); | 846 Heap::CollectAllGarbage(false); |
847 } | 847 } |
848 } | 848 } |
849 } | 849 } |
850 | 850 |
851 | 851 |
852 // Debug event handler which re-issues a debug break and calls the garbage | 852 // Debug event handler which re-issues a debug break and calls the garbage |
853 // collector to have the heap verified. | 853 // collector to have the heap verified. |
854 static void DebugEventBreak(v8::DebugEvent event, | 854 static void DebugEventBreak(v8::DebugEvent event, |
855 v8::Handle<v8::Object> exec_state, | 855 v8::Handle<v8::Object> exec_state, |
856 v8::Handle<v8::Object> event_data, | 856 v8::Handle<v8::Object> event_data, |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 // Call function. | 1199 // Call function. |
1200 f->Call(recv, 0, NULL); | 1200 f->Call(recv, 0, NULL); |
1201 CHECK_EQ(1 + i * 3, break_point_hit_count); | 1201 CHECK_EQ(1 + i * 3, break_point_hit_count); |
1202 | 1202 |
1203 // Scavenge and call function. | 1203 // Scavenge and call function. |
1204 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); | 1204 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); |
1205 f->Call(recv, 0, NULL); | 1205 f->Call(recv, 0, NULL); |
1206 CHECK_EQ(2 + i * 3, break_point_hit_count); | 1206 CHECK_EQ(2 + i * 3, break_point_hit_count); |
1207 | 1207 |
1208 // Mark sweep (and perhaps compact) and call function. | 1208 // Mark sweep (and perhaps compact) and call function. |
1209 Heap::CollectAllGarbage(); | 1209 Heap::CollectAllGarbage(false); |
1210 f->Call(recv, 0, NULL); | 1210 f->Call(recv, 0, NULL); |
1211 CHECK_EQ(3 + i * 3, break_point_hit_count); | 1211 CHECK_EQ(3 + i * 3, break_point_hit_count); |
1212 } | 1212 } |
1213 } | 1213 } |
1214 | 1214 |
1215 | 1215 |
1216 // Test that a break point can be set at a return store location. | 1216 // Test that a break point can be set at a return store location. |
1217 TEST(BreakPointSurviveGC) { | 1217 TEST(BreakPointSurviveGC) { |
1218 break_point_hit_count = 0; | 1218 break_point_hit_count = 0; |
1219 v8::HandleScope scope; | 1219 v8::HandleScope scope; |
(...skipping 3867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5087 break_point_hit_count = 0; | 5087 break_point_hit_count = 0; |
5088 script_collected_count = 0; | 5088 script_collected_count = 0; |
5089 v8::HandleScope scope; | 5089 v8::HandleScope scope; |
5090 DebugLocalContext env; | 5090 DebugLocalContext env; |
5091 | 5091 |
5092 // Request the loaded scripts to initialize the debugger script cache. | 5092 // Request the loaded scripts to initialize the debugger script cache. |
5093 Debug::GetLoadedScripts(); | 5093 Debug::GetLoadedScripts(); |
5094 | 5094 |
5095 // Do garbage collection to ensure that only the script in this test will be | 5095 // Do garbage collection to ensure that only the script in this test will be |
5096 // collected afterwards. | 5096 // collected afterwards. |
5097 Heap::CollectAllGarbage(); | 5097 Heap::CollectAllGarbage(false); |
5098 | 5098 |
5099 script_collected_count = 0; | 5099 script_collected_count = 0; |
5100 v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent, | 5100 v8::Debug::SetDebugEventListener(DebugEventScriptCollectedEvent, |
5101 v8::Undefined()); | 5101 v8::Undefined()); |
5102 { | 5102 { |
5103 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 5103 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); |
5104 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 5104 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); |
5105 } | 5105 } |
5106 | 5106 |
5107 // Do garbage collection to collect the script above which is no longer | 5107 // Do garbage collection to collect the script above which is no longer |
5108 // referenced. | 5108 // referenced. |
5109 Heap::CollectAllGarbage(); | 5109 Heap::CollectAllGarbage(false); |
5110 | 5110 |
5111 CHECK_EQ(2, script_collected_count); | 5111 CHECK_EQ(2, script_collected_count); |
5112 | 5112 |
5113 v8::Debug::SetDebugEventListener(NULL); | 5113 v8::Debug::SetDebugEventListener(NULL); |
5114 CheckDebuggerUnloaded(); | 5114 CheckDebuggerUnloaded(); |
5115 } | 5115 } |
5116 | 5116 |
5117 | 5117 |
5118 // Debug event listener which counts the script collected events. | 5118 // Debug event listener which counts the script collected events. |
5119 int script_collected_message_count = 0; | 5119 int script_collected_message_count = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
5134 v8::HandleScope scope; | 5134 v8::HandleScope scope; |
5135 | 5135 |
5136 { // Scope for the DebugLocalContext. | 5136 { // Scope for the DebugLocalContext. |
5137 DebugLocalContext env; | 5137 DebugLocalContext env; |
5138 | 5138 |
5139 // Request the loaded scripts to initialize the debugger script cache. | 5139 // Request the loaded scripts to initialize the debugger script cache. |
5140 Debug::GetLoadedScripts(); | 5140 Debug::GetLoadedScripts(); |
5141 | 5141 |
5142 // Do garbage collection to ensure that only the script in this test will be | 5142 // Do garbage collection to ensure that only the script in this test will be |
5143 // collected afterwards. | 5143 // collected afterwards. |
5144 Heap::CollectAllGarbage(); | 5144 Heap::CollectAllGarbage(false); |
5145 | 5145 |
5146 v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); | 5146 v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler); |
5147 { | 5147 { |
5148 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); | 5148 v8::Script::Compile(v8::String::New("eval('a=1')"))->Run(); |
5149 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); | 5149 v8::Script::Compile(v8::String::New("eval('a=2')"))->Run(); |
5150 } | 5150 } |
5151 } | 5151 } |
5152 | 5152 |
5153 // Do garbage collection to collect the script above which is no longer | 5153 // Do garbage collection to collect the script above which is no longer |
5154 // referenced. | 5154 // referenced. |
5155 Heap::CollectAllGarbage(); | 5155 Heap::CollectAllGarbage(false); |
5156 | 5156 |
5157 CHECK_EQ(2, script_collected_message_count); | 5157 CHECK_EQ(2, script_collected_message_count); |
5158 | 5158 |
5159 v8::Debug::SetMessageHandler2(NULL); | 5159 v8::Debug::SetMessageHandler2(NULL); |
5160 } | 5160 } |
5161 | 5161 |
5162 | 5162 |
5163 // Debug event listener which counts the after compile events. | 5163 // Debug event listener which counts the after compile events. |
5164 int after_compile_message_count = 0; | 5164 int after_compile_message_count = 0; |
5165 static void AfterCompileMessageHandler(const v8::Debug::Message& message) { | 5165 static void AfterCompileMessageHandler(const v8::Debug::Message& message) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5363 v8::Script::New( | 5363 v8::Script::New( |
5364 v8::String::New( | 5364 v8::String::New( |
5365 "function runTest(mirror) {" | 5365 "function runTest(mirror) {" |
5366 " return mirror.isString() && (mirror.length() == 5);" | 5366 " return mirror.isString() && (mirror.length() == 5);" |
5367 "}" | 5367 "}" |
5368 "" | 5368 "" |
5369 "runTest;"))->Run()); | 5369 "runTest;"))->Run()); |
5370 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); | 5370 v8::Handle<v8::Value> result = run_test->Call(env->Global(), 1, &obj); |
5371 CHECK(result->IsTrue()); | 5371 CHECK(result->IsTrue()); |
5372 } | 5372 } |
OLD | NEW |