| 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 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1237 SetBreakPoint(foo, 0); | 1237 SetBreakPoint(foo, 0); |
| 1238 CallWithBreakPoints(env->Global(), foo, 1, 25); | 1238 CallWithBreakPoints(env->Global(), foo, 1, 25); |
| 1239 | 1239 |
| 1240 v8::Debug::SetDebugEventListener(NULL); | 1240 v8::Debug::SetDebugEventListener(NULL); |
| 1241 CheckDebuggerUnloaded(); | 1241 CheckDebuggerUnloaded(); |
| 1242 } | 1242 } |
| 1243 | 1243 |
| 1244 | 1244 |
| 1245 // Call the function three times with different garbage collections in between | 1245 // Call the function three times with different garbage collections in between |
| 1246 // and make sure that the break point survives. | 1246 // and make sure that the break point survives. |
| 1247 static void CallAndGC(v8::Local<v8::Object> recv, v8::Local<v8::Function> f) { | 1247 static void CallAndGC(v8::Local<v8::Object> recv, |
| 1248 v8::Local<v8::Function> f, |
| 1249 bool force_compaction) { |
| 1248 break_point_hit_count = 0; | 1250 break_point_hit_count = 0; |
| 1249 | 1251 |
| 1250 for (int i = 0; i < 3; i++) { | 1252 for (int i = 0; i < 3; i++) { |
| 1251 // Call function. | 1253 // Call function. |
| 1252 f->Call(recv, 0, NULL); | 1254 f->Call(recv, 0, NULL); |
| 1253 CHECK_EQ(1 + i * 3, break_point_hit_count); | 1255 CHECK_EQ(1 + i * 3, break_point_hit_count); |
| 1254 | 1256 |
| 1255 // Scavenge and call function. | 1257 // Scavenge and call function. |
| 1256 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); | 1258 Heap::CollectGarbage(0, v8::internal::NEW_SPACE); |
| 1257 f->Call(recv, 0, NULL); | 1259 f->Call(recv, 0, NULL); |
| 1258 CHECK_EQ(2 + i * 3, break_point_hit_count); | 1260 CHECK_EQ(2 + i * 3, break_point_hit_count); |
| 1259 | 1261 |
| 1260 // Mark sweep (and perhaps compact) and call function. | 1262 // Mark sweep (and perhaps compact) and call function. |
| 1261 Heap::CollectAllGarbage(false); | 1263 Heap::CollectAllGarbage(force_compaction); |
| 1262 f->Call(recv, 0, NULL); | 1264 f->Call(recv, 0, NULL); |
| 1263 CHECK_EQ(3 + i * 3, break_point_hit_count); | 1265 CHECK_EQ(3 + i * 3, break_point_hit_count); |
| 1264 } | 1266 } |
| 1265 } | 1267 } |
| 1266 | 1268 |
| 1267 | 1269 |
| 1268 // Test that a break point can be set at a return store location. | 1270 static void TestBreakPointSurviveGC(bool force_compaction) { |
| 1269 TEST(BreakPointSurviveGC) { | |
| 1270 break_point_hit_count = 0; | 1271 break_point_hit_count = 0; |
| 1271 v8::HandleScope scope; | 1272 v8::HandleScope scope; |
| 1272 DebugLocalContext env; | 1273 DebugLocalContext env; |
| 1273 | 1274 |
| 1274 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, | 1275 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, |
| 1275 v8::Undefined()); | 1276 v8::Undefined()); |
| 1276 v8::Local<v8::Function> foo; | 1277 v8::Local<v8::Function> foo; |
| 1277 | 1278 |
| 1278 // Test IC store break point with garbage collection. | 1279 // Test IC store break point with garbage collection. |
| 1279 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); | 1280 { |
| 1280 SetBreakPoint(foo, 0); | 1281 v8::Local<v8::Function> bar = |
| 1281 CallAndGC(env->Global(), foo); | 1282 CompileFunction(&env, "function foo(){}", "foo"); |
| 1283 foo = CompileFunction(&env, "function foo(){bar=0;}", "foo"); |
| 1284 SetBreakPoint(foo, 0); |
| 1285 } |
| 1286 CallAndGC(env->Global(), foo, force_compaction); |
| 1282 | 1287 |
| 1283 // Test IC load break point with garbage collection. | 1288 // Test IC load break point with garbage collection. |
| 1284 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); | 1289 { |
| 1285 SetBreakPoint(foo, 0); | 1290 v8::Local<v8::Function> bar = |
| 1286 CallAndGC(env->Global(), foo); | 1291 CompileFunction(&env, "function foo(){}", "foo"); |
| 1292 foo = CompileFunction(&env, "bar=1;function foo(){var x=bar;}", "foo"); |
| 1293 SetBreakPoint(foo, 0); |
| 1294 } |
| 1295 CallAndGC(env->Global(), foo, force_compaction); |
| 1287 | 1296 |
| 1288 // Test IC call break point with garbage collection. | 1297 // Test IC call break point with garbage collection. |
| 1289 foo = CompileFunction(&env, "function bar(){};function foo(){bar();}", "foo"); | 1298 { |
| 1290 SetBreakPoint(foo, 0); | 1299 v8::Local<v8::Function> bar = |
| 1291 CallAndGC(env->Global(), foo); | 1300 CompileFunction(&env, "function foo(){}", "foo"); |
| 1301 foo = CompileFunction(&env, |
| 1302 "function bar(){};function foo(){bar();}", |
| 1303 "foo"); |
| 1304 SetBreakPoint(foo, 0); |
| 1305 } |
| 1306 CallAndGC(env->Global(), foo, force_compaction); |
| 1292 | 1307 |
| 1293 // Test return break point with garbage collection. | 1308 // Test return break point with garbage collection. |
| 1294 foo = CompileFunction(&env, "function foo(){}", "foo"); | 1309 { |
| 1295 SetBreakPoint(foo, 0); | 1310 v8::Local<v8::Function> bar = |
| 1296 CallAndGC(env->Global(), foo); | 1311 CompileFunction(&env, "function foo(){}", "foo"); |
| 1312 foo = CompileFunction(&env, "function foo(){}", "foo"); |
| 1313 SetBreakPoint(foo, 0); |
| 1314 } |
| 1315 CallAndGC(env->Global(), foo, force_compaction); |
| 1316 |
| 1317 // Test non IC break point with garbage collection. |
| 1318 { |
| 1319 v8::Local<v8::Function> bar = |
| 1320 CompileFunction(&env, "function foo(){}", "foo"); |
| 1321 foo = CompileFunction(&env, "function foo(){var bar=0;}", "foo"); |
| 1322 SetBreakPoint(foo, 0); |
| 1323 } |
| 1324 CallAndGC(env->Global(), foo, force_compaction); |
| 1325 |
| 1297 | 1326 |
| 1298 v8::Debug::SetDebugEventListener(NULL); | 1327 v8::Debug::SetDebugEventListener(NULL); |
| 1299 CheckDebuggerUnloaded(); | 1328 CheckDebuggerUnloaded(); |
| 1300 } | 1329 } |
| 1301 | 1330 |
| 1302 | 1331 |
| 1332 // Test that a break point can be set at a return store location. |
| 1333 TEST(BreakPointSurviveGC) { |
| 1334 TestBreakPointSurviveGC(false); |
| 1335 TestBreakPointSurviveGC(true); |
| 1336 } |
| 1337 |
| 1338 |
| 1303 // Test that break points can be set using the global Debug object. | 1339 // Test that break points can be set using the global Debug object. |
| 1304 TEST(BreakPointThroughJavaScript) { | 1340 TEST(BreakPointThroughJavaScript) { |
| 1305 break_point_hit_count = 0; | 1341 break_point_hit_count = 0; |
| 1306 v8::HandleScope scope; | 1342 v8::HandleScope scope; |
| 1307 DebugLocalContext env; | 1343 DebugLocalContext env; |
| 1308 env.ExposeDebug(); | 1344 env.ExposeDebug(); |
| 1309 | 1345 |
| 1310 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, | 1346 v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount, |
| 1311 v8::Undefined()); | 1347 v8::Undefined()); |
| 1312 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); | 1348 v8::Script::Compile(v8::String::New("function bar(){}"))->Run(); |
| (...skipping 5396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6709 | 6745 |
| 6710 CHECK_EQ(2, TestClientData::constructor_call_counter); | 6746 CHECK_EQ(2, TestClientData::constructor_call_counter); |
| 6711 CHECK_EQ(TestClientData::constructor_call_counter, | 6747 CHECK_EQ(TestClientData::constructor_call_counter, |
| 6712 TestClientData::destructor_call_counter); | 6748 TestClientData::destructor_call_counter); |
| 6713 | 6749 |
| 6714 v8::Debug::SetDebugEventListener(NULL); | 6750 v8::Debug::SetDebugEventListener(NULL); |
| 6715 CheckDebuggerUnloaded(); | 6751 CheckDebuggerUnloaded(); |
| 6716 } | 6752 } |
| 6717 | 6753 |
| 6718 #endif // ENABLE_DEBUGGER_SUPPORT | 6754 #endif // ENABLE_DEBUGGER_SUPPORT |
| OLD | NEW |