Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: test/mjsunit/debug-script-breakpoints-nested.js

Issue 10543141: Enable lazy compilation for non-trivial outer contexts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Ulan Degenbaev. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/debug-script-breakpoints-closure.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-script-breakpoints-nested.js
diff --git a/test/mjsunit/debug-ignore-breakpoints.js b/test/mjsunit/debug-script-breakpoints-nested.js
similarity index 63%
copy from test/mjsunit/debug-ignore-breakpoints.js
copy to test/mjsunit/debug-script-breakpoints-nested.js
index 96c6044e7b0291b7f9be60cb2fdad0891c790d28..ce25c1781418f850e7860b6c8255aed8455f7469 100644
--- a/test/mjsunit/debug-ignore-breakpoints.js
+++ b/test/mjsunit/debug-script-breakpoints-nested.js
@@ -1,4 +1,4 @@
-// Copyright 2008 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -30,7 +30,7 @@
Debug = debug.Debug
// Simple debug event handler which just counts the number of break points hit.
-var break_point_hit_count;
+var break_point_hit_count = 0;
function listener(event, exec_state, event_data, data) {
if (event == Debug.DebugEvent.Break) {
@@ -41,49 +41,42 @@ function listener(event, exec_state, event_data, data) {
// Add the debug event listener.
Debug.setListener(listener);
-// Test function.
-function f() {};
+eval(
+ "var inner;\n" +
+ "function outer() {\n" + // Non-trivial outer closure.
+ " var x = 5;\n" +
+ " function a() {\n" +
+ " var foo = 0, y = 7;\n" +
+ " function b() {\n" +
+ " var bar = 0, baz = 0, z = 11;\n" +
+ " function c() {\n" +
+ " return x + y + z;\n" + // Breakpoint line ( #8 )
+ " }\n" +
+ " inner = c;\n" +
+ " return c();\n" +
+ " }\n" +
+ " return b();\n" +
+ " }\n" +
+ " return a();\n" +
+ "}"
+);
-// This tests ignore of break points including the case with several
-// break points in the same location.
-break_point_hit_count = 0;
+var script = Debug.findScript(outer);
-// Set a breakpoint in f.
-bp1 = Debug.setBreakPoint(f);
+// The debugger triggers compilation of inner closures.
+assertEquals(0, Debug.scriptBreakPoints().length);
+var sbp = Debug.setScriptBreakPointById(script.id, 8);
+assertEquals(1, Debug.scriptBreakPoints().length);
-// Try ignore count of 1.
-Debug.changeBreakPointIgnoreCount(bp1, 1);
-f();
-assertEquals(0, break_point_hit_count);
-f();
+// The compiled outer closure should behave correctly.
+assertEquals(23, outer());
assertEquals(1, break_point_hit_count);
-// Set another breakpoint in f at the same place.
-bp2 = Debug.setBreakPoint(f);
-f();
+// The compiled inner closure should behave correctly.
+assertEquals(23, inner());
assertEquals(2, break_point_hit_count);
-// Set different ignore counts.
-Debug.changeBreakPointIgnoreCount(bp1, 2);
-Debug.changeBreakPointIgnoreCount(bp2, 4);
-f();
-assertEquals(2, break_point_hit_count);
-f();
-assertEquals(2, break_point_hit_count);
-f();
-assertEquals(3, break_point_hit_count);
-f();
-assertEquals(4, break_point_hit_count);
-
-// Set different ignore counts (opposite).
-Debug.changeBreakPointIgnoreCount(bp1, 4);
-Debug.changeBreakPointIgnoreCount(bp2, 2);
-f();
-assertEquals(4, break_point_hit_count);
-f();
-assertEquals(4, break_point_hit_count);
-f();
-assertEquals(5, break_point_hit_count);
-f();
-assertEquals(6, break_point_hit_count);
-
+// Remove script break point.
+assertEquals(1, Debug.scriptBreakPoints().length);
+Debug.clearBreakPoint(sbp);
+assertEquals(0, Debug.scriptBreakPoints().length);
« no previous file with comments | « test/mjsunit/debug-script-breakpoints-closure.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698