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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Flags: --expose-debug-as debug 28 // Flags: --expose-debug-as debug
29 // Get the Debug object exposed from the debug context global object. 29 // Get the Debug object exposed from the debug context global object.
30 30
31 // Scenario: some function is being edited; the outer function has to have its 31 // Scenario: some function is being edited; the outer function has to have its
32 // positions patched. Accoring to a special markup of function text 32 // positions patched. Accoring to a special markup of function text
33 // corresponding byte-code PCs should conicide before change and after it. 33 // corresponding byte-code PCs should coincide before change and after it.
34 34
35 Debug = debug.Debug 35 Debug = debug.Debug
36 36
37 eval( 37 eval(
38 "function F1() { return 5; }\n" + 38 "function F1() { return 5; }\n" +
39 "function ChooseAnimal(/*$*/ ) {\n" + 39 "function ChooseAnimal(/*$*/ ) {\n" +
40 "/*$*/ var x = F1(/*$*/ );\n" + 40 "/*$*/ var x = F1(/*$*/ );\n" +
41 "/*$*/ var res/*$*/ =/*$*/ (function() { return 'Cat'; } )();\n" + 41 "/*$*/ var res/*$*/ =/*$*/ (function() { return 'Cat'; } )();\n" +
42 "/*$*/ var y/*$*/ = F2(/*$*/ F1()/*$*/ , F1(/*$*/ )/*$*/ );\n" + 42 "/*$*/ var y/*$*/ = F2(/*$*/ F1()/*$*/ , F1(/*$*/ )/*$*/ );\n" +
43 "/*$*/ if (/*$*/ x.toString(/*$*/ )) { /*$*/ y = 3;/*$*/ } else {/*$*/ y = 8;/*$*/ }\n" + 43 "/*$*/ if (/*$*/ x.toString(/*$*/ )) { /*$*/ y = 3;/*$*/ } else {/*$*/ y = 8;/*$*/ }\n" +
(...skipping 11 matching lines...) Expand all
55 var pattern = /\/\*\$\*\//g; 55 var pattern = /\/\*\$\*\//g;
56 while ((match = pattern.exec(text)) != null) { 56 while ((match = pattern.exec(text)) != null) {
57 positions.push(match.index); 57 positions.push(match.index);
58 } 58 }
59 return positions; 59 return positions;
60 } 60 }
61 61
62 function ReadPCMap(func, positions) { 62 function ReadPCMap(func, positions) {
63 var res = new Array(); 63 var res = new Array();
64 for (var i = 0; i < positions.length; i++) { 64 for (var i = 0; i < positions.length; i++) {
65 res.push(Debug.LiveEdit.GetPcFromSourcePos(func, positions[i])); 65 var pc = Debug.LiveEdit.GetPcFromSourcePos(func, positions[i]);
66
67 if (typeof pc === 'undefined') {
68 // Function was marked for recompilation and it's code was replaced with a
69 // stub. This can happen at any time especially if we are running with
70 // --stress-opt. There is no way to get PCs now.
71 return;
72 }
73
74 res.push(pc);
66 } 75 }
76
67 return res; 77 return res;
68 } 78 }
69 79
70 var res = ChooseAnimal(); 80 function ApplyPatch(orig_animal, new_animal) {
71 assertEquals("Cat15", res); 81 var res = ChooseAnimal();
82 assertEquals(orig_animal + "15", res);
72 83
73 var markerPositionsBefore = ReadMarkerPositions(ChooseAnimal); 84 var script = Debug.findScript(ChooseAnimal);
74 var pcArrayBefore = ReadPCMap(ChooseAnimal, markerPositionsBefore);
75 85
76 var script = Debug.findScript(ChooseAnimal); 86 var orig_string = "'" + orig_animal + "'";
87 var patch_string = "'" + new_animal + "'";
88 var patch_pos = script.source.indexOf(orig_string);
77 89
78 var orig_animal = "'Cat'"; 90 var change_log = new Array();
79 var patch_pos = script.source.indexOf(orig_animal);
80 var new_animal_patch = "'Capybara'";
81 91
82 var change_log = new Array(); 92 Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script,
83 Debug.LiveEdit.TestApi.ApplySingleChunkPatch(script, patch_pos, orig_animal.leng th, new_animal_patch, change_log); 93 patch_pos,
84 print("Change log: " + JSON.stringify(change_log) + "\n"); 94 orig_string.length,
95 patch_string,
96 change_log);
85 97
86 var res = ChooseAnimal(); 98 print("Change log: " + JSON.stringify(change_log) + "\n");
87 assertEquals("Capybara15", res);
88 99
89 var markerPositionsAfter = ReadMarkerPositions(ChooseAnimal); 100 var markerPositions = ReadMarkerPositions(ChooseAnimal);
90 var pcArrayAfter = ReadPCMap(ChooseAnimal, markerPositionsAfter); 101 var pcArray = ReadPCMap(ChooseAnimal, markerPositions);
91 102
92 assertArrayEquals(pcArrayBefore, pcArrayAfter); 103 var res = ChooseAnimal();
104 assertEquals(new_animal + "15", res);
93 105
106 return pcArray;
107 }
108
109 var pcArray1 = ApplyPatch('Cat', 'Dog');
110
111 // When we patched function for the first time it was deoptimized.
112 // Check that after the second patch maping between sources position and
113 // pcs will not change.
114
115 var pcArray2 = ApplyPatch('Dog', 'Capybara');
116
117 print(pcArray1);
118 print(pcArray2);
119
120 // Function can be marked for recompilation at any point (especially if we are
121 // running with --stress-opt). When we mark function for recompilation we
122 // replace it's code with stub. So there is no reliable way to get PCs for
123 // function.
124 if (pcArray1 && pcArray2) {
125 assertArrayEquals(pcArray1, pcArray2);
126 }
OLDNEW
« 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