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

Unified Diff: test/mjsunit/debug-liveedit-2.js

Issue 546125: A brutal approach to V8 script liveedit (Closed)
Patch Set: merge Created 10 years, 10 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-liveedit-1.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-liveedit-2.js
diff --git a/test/mjsunit/debug-liveedit-2.js b/test/mjsunit/debug-liveedit-2.js
new file mode 100644
index 0000000000000000000000000000000000000000..70ff5a6b8e8b062cf7929f7ebbd4bdc463242045
--- /dev/null
+++ b/test/mjsunit/debug-liveedit-2.js
@@ -0,0 +1,39 @@
+// Flags: --expose-debug-as debug
+// Get the Debug object exposed from the debug context global object.
+
+Debug = debug.Debug
+
+eval(
+ "function ChooseAnimal(p) { " +
+ " if (p == 7) {" + // Use p
+ " return;" +
+ " }" +
+ " return function Chooser() {" +
+ " return 'Cat';" +
+ " };" +
+ "}"
+);
+
+var old_closure = ChooseAnimal(19);
+
+assertEquals("Cat", old_closure());
+
+var script = Debug.findScript(ChooseAnimal);
+
+var orig_animal = "'Cat'";
+var patch_pos = script.source.indexOf(orig_animal);
+var new_animal_patch = "'Capybara' + p";
+
+// We patch innermost function "Chooser".
+// However, this does not actually patch existing "Chooser" instances,
+// because old value of parameter "p" was not saved.
+// Instead it patches ChooseAnimal.
+Debug.change_script_live(script, patch_pos, orig_animal.length, new_animal_patch);
+
+var new_closure = ChooseAnimal(19);
+// New instance of closure is patched.
+assertEquals("Capybara19", new_closure());
+
+// Old instance of closure is not patched.
+assertEquals("Cat", old_closure());
+
« no previous file with comments | « test/mjsunit/debug-liveedit-1.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698