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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 862 |
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 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); | 870 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); |
871 } else { | 871 } else { |
872 // Mark sweep (and perhaps compact). | 872 // Mark sweep compact. |
873 Heap::CollectAllGarbage(true); | 873 Heap::CollectAllGarbage(true); |
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(v8::DebugEvent event, | 881 static void DebugEventBreak(v8::DebugEvent event, |
882 v8::Handle<v8::Object> exec_state, | 882 v8::Handle<v8::Object> exec_state, |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 // Run without breakpoints. | 1170 // Run without breakpoints. |
1171 ClearBreakPoint(bp); | 1171 ClearBreakPoint(bp); |
1172 foo->Call(env->Global(), 0, NULL); | 1172 foo->Call(env->Global(), 0, NULL); |
1173 CHECK_EQ(2, break_point_hit_count); | 1173 CHECK_EQ(2, break_point_hit_count); |
1174 | 1174 |
1175 v8::Debug::SetDebugEventListener(NULL); | 1175 v8::Debug::SetDebugEventListener(NULL); |
1176 CheckDebuggerUnloaded(); | 1176 CheckDebuggerUnloaded(); |
1177 } | 1177 } |
1178 | 1178 |
1179 | 1179 |
| 1180 // Test that a break point can be set at an IC call location and survive a GC. |
| 1181 TEST(BreakPointConstructCallWithGC) { |
| 1182 break_point_hit_count = 0; |
| 1183 v8::HandleScope scope; |
| 1184 DebugLocalContext env; |
| 1185 v8::Debug::SetDebugEventListener(DebugEventBreakPointCollectGarbage, |
| 1186 v8::Undefined()); |
| 1187 v8::Script::Compile(v8::String::New("function bar(){ this.x = 1;}"))->Run(); |
| 1188 v8::Script::Compile(v8::String::New( |
| 1189 "function foo(){return new bar(1).x;}"))->Run(); |
| 1190 v8::Local<v8::Function> foo = |
| 1191 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo"))); |
| 1192 |
| 1193 // Run without breakpoints. |
| 1194 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
| 1195 CHECK_EQ(0, break_point_hit_count); |
| 1196 |
| 1197 // Run with breakpoint. |
| 1198 int bp = SetBreakPoint(foo, 0); |
| 1199 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
| 1200 CHECK_EQ(1, break_point_hit_count); |
| 1201 CHECK_EQ(1, foo->Call(env->Global(), 0, NULL)->Int32Value()); |
| 1202 CHECK_EQ(2, break_point_hit_count); |
| 1203 |
| 1204 // Run without breakpoints. |
| 1205 ClearBreakPoint(bp); |
| 1206 foo->Call(env->Global(), 0, NULL); |
| 1207 CHECK_EQ(2, break_point_hit_count); |
| 1208 |
| 1209 v8::Debug::SetDebugEventListener(NULL); |
| 1210 CheckDebuggerUnloaded(); |
| 1211 } |
| 1212 |
| 1213 |
1180 // Test that a break point can be set at a return store location. | 1214 // Test that a break point can be set at a return store location. |
1181 TEST(BreakPointReturn) { | 1215 TEST(BreakPointReturn) { |
1182 break_point_hit_count = 0; | 1216 break_point_hit_count = 0; |
1183 v8::HandleScope scope; | 1217 v8::HandleScope scope; |
1184 DebugLocalContext env; | 1218 DebugLocalContext env; |
1185 | 1219 |
1186 // Create a functions for checking the source line and column when hitting | 1220 // Create a functions for checking the source line and column when hitting |
1187 // a break point. | 1221 // a break point. |
1188 frame_source_line = CompileFunction(&env, | 1222 frame_source_line = CompileFunction(&env, |
1189 frame_source_line_source, | 1223 frame_source_line_source, |
(...skipping 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6837 | 6871 |
6838 CHECK_EQ(2, TestClientData::constructor_call_counter); | 6872 CHECK_EQ(2, TestClientData::constructor_call_counter); |
6839 CHECK_EQ(TestClientData::constructor_call_counter, | 6873 CHECK_EQ(TestClientData::constructor_call_counter, |
6840 TestClientData::destructor_call_counter); | 6874 TestClientData::destructor_call_counter); |
6841 | 6875 |
6842 v8::Debug::SetDebugEventListener(NULL); | 6876 v8::Debug::SetDebugEventListener(NULL); |
6843 CheckDebuggerUnloaded(); | 6877 CheckDebuggerUnloaded(); |
6844 } | 6878 } |
6845 | 6879 |
6846 #endif // ENABLE_DEBUGGER_SUPPORT | 6880 #endif // ENABLE_DEBUGGER_SUPPORT |
OLD | NEW |