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

Unified Diff: test/mjsunit/debug-liveedit-patch-positions.js

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 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-breakpoints.js ('k') | test/mjsunit/debug-stepout-recursive-function.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/debug-liveedit-patch-positions.js
diff --git a/test/mjsunit/debug-liveedit-patch-positions.js b/test/mjsunit/debug-liveedit-patch-positions.js
index 027987f5e7656f6c3f554b9d63a0bfe73b79c733..b0d3c20d9a745e749e3b87f6a90194f46356137b 100644
--- a/test/mjsunit/debug-liveedit-patch-positions.js
+++ b/test/mjsunit/debug-liveedit-patch-positions.js
@@ -30,7 +30,7 @@
// Scenario: some function is being edited; the outer function has to have its
// positions patched. Accoring to a special markup of function text
-// corresponding byte-code PCs should conicide before change and after it.
+// corresponding byte-code PCs should coincide before change and after it.
Debug = debug.Debug
@@ -62,32 +62,65 @@ function ReadMarkerPositions(func) {
function ReadPCMap(func, positions) {
var res = new Array();
for (var i = 0; i < positions.length; i++) {
- res.push(Debug.LiveEdit.GetPcFromSourcePos(func, positions[i]));
+ var pc = Debug.LiveEdit.GetPcFromSourcePos(func, positions[i]);
+
+ if (typeof pc === 'undefined') {
+ // Function was marked for recompilation and it's code was replaced with a
+ // stub. This can happen at any time especially if we are running with
+ // --stress-opt. There is no way to get PCs now.
+ return;
+ }
+
+ res.push(pc);
}
+
return res;
}
-var res = ChooseAnimal();
-assertEquals("Cat15", res);
+function ApplyPatch(orig_animal, new_animal) {
+ var res = ChooseAnimal();
+ assertEquals(orig_animal + "15", res);
+
+ var script = Debug.findScript(ChooseAnimal);
+
+ var orig_string = "'" + orig_animal + "'";
+ var patch_string = "'" + new_animal + "'";
+ var patch_pos = script.source.indexOf(orig_string);
-var markerPositionsBefore = ReadMarkerPositions(ChooseAnimal);
-var pcArrayBefore = ReadPCMap(ChooseAnimal, markerPositionsBefore);
+ var change_log = new Array();
-var script = Debug.findScript(ChooseAnimal);
+ Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script,
+ patch_pos,
+ orig_string.length,
+ patch_string,
+ change_log);
-var orig_animal = "'Cat'";
-var patch_pos = script.source.indexOf(orig_animal);
-var new_animal_patch = "'Capybara'";
+ print("Change log: " + JSON.stringify(change_log) + "\n");
-var change_log = new Array();
-Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script, patch_pos, orig_animal.length, new_animal_patch, change_log);
-print("Change log: " + JSON.stringify(change_log) + "\n");
+ var markerPositions = ReadMarkerPositions(ChooseAnimal);
+ var pcArray = ReadPCMap(ChooseAnimal, markerPositions);
-var res = ChooseAnimal();
-assertEquals("Capybara15", res);
+ var res = ChooseAnimal();
+ assertEquals(new_animal + "15", res);
-var markerPositionsAfter = ReadMarkerPositions(ChooseAnimal);
-var pcArrayAfter = ReadPCMap(ChooseAnimal, markerPositionsAfter);
+ return pcArray;
+}
+
+var pcArray1 = ApplyPatch('Cat', 'Dog');
+
+// When we patched function for the first time it was deoptimized.
+// Check that after the second patch maping between sources position and
+// pcs will not change.
-assertArrayEquals(pcArrayBefore, pcArrayAfter);
+var pcArray2 = ApplyPatch('Dog', 'Capybara');
+print(pcArray1);
+print(pcArray2);
+
+// Function can be marked for recompilation at any point (especially if we are
+// running with --stress-opt). When we mark function for recompilation we
+// replace it's code with stub. So there is no reliable way to get PCs for
+// function.
+if (pcArray1 && pcArray2) {
+ assertArrayEquals(pcArray1, pcArray2);
+}
« no previous file with comments | « test/mjsunit/debug-liveedit-breakpoints.js ('k') | test/mjsunit/debug-stepout-recursive-function.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698