OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // LiveEdit feature implementation. The script should be executed after | 5 // LiveEdit feature implementation. The script should be executed after |
6 // debug.js. | 6 // debug.js. |
7 | 7 |
8 // A LiveEdit namespace. It contains functions that modifies JavaScript code | 8 // A LiveEdit namespace. It contains functions that modifies JavaScript code |
9 // according to changes of script source (if possible). | 9 // according to changes of script source (if possible). |
10 // | 10 // |
(...skipping 12 matching lines...) Expand all Loading... | |
23 (function(global, utils) { | 23 (function(global, utils) { |
24 "use strict"; | 24 "use strict"; |
25 | 25 |
26 // ------------------------------------------------------------------- | 26 // ------------------------------------------------------------------- |
27 // Imports | 27 // Imports |
28 | 28 |
29 var FindScriptSourcePosition = global.Debug.findScriptSourcePosition; | 29 var FindScriptSourcePosition = global.Debug.findScriptSourcePosition; |
30 var GetScriptBreakPoints; | 30 var GetScriptBreakPoints; |
31 var GlobalArray = global.Array; | 31 var GlobalArray = global.Array; |
32 var MathFloor = global.Math.floor; | 32 var MathFloor = global.Math.floor; |
33 var MathMax = global.Math.max; | |
33 var SyntaxError = global.SyntaxError; | 34 var SyntaxError = global.SyntaxError; |
34 | 35 |
35 utils.Import(function(from) { | 36 utils.Import(function(from) { |
36 GetScriptBreakPoints = from.GetScriptBreakPoints; | 37 GetScriptBreakPoints = from.GetScriptBreakPoints; |
37 }); | 38 }); |
38 | 39 |
39 // ------------------------------------------------------------------- | 40 // ------------------------------------------------------------------- |
40 | 41 |
41 // Forward declaration for minifier. | 42 // Forward declaration for minifier. |
42 var FunctionStatus; | 43 var FunctionStatus; |
(...skipping 30 matching lines...) Expand all Loading... | |
73 if (e instanceof SyntaxError) { | 74 if (e instanceof SyntaxError) { |
74 var details = { | 75 var details = { |
75 type: "liveedit_compile_error", | 76 type: "liveedit_compile_error", |
76 syntaxErrorMessage: e.message | 77 syntaxErrorMessage: e.message |
77 }; | 78 }; |
78 CopyErrorPositionToDetails(e, details); | 79 CopyErrorPositionToDetails(e, details); |
79 failure.details = details; | 80 failure.details = details; |
80 } | 81 } |
81 throw failure; | 82 throw failure; |
82 } | 83 } |
84 | |
85 var max_function_literal_id = | |
86 MathMax.apply(null, new_compile_info.map(i => i.function_literal_id)); | |
jochen (gone - plz use gerrit)
2016/12/01 10:30:56
https://bugs.chromium.org/p/v8/issues/detail?id=57
| |
87 | |
83 var root_new_node = BuildCodeInfoTree(new_compile_info); | 88 var root_new_node = BuildCodeInfoTree(new_compile_info); |
84 | 89 |
85 // Link recompiled script data with other data. | 90 // Link recompiled script data with other data. |
86 FindCorrespondingFunctions(root_old_node, root_new_node); | 91 FindCorrespondingFunctions(root_old_node, root_new_node); |
87 | 92 |
88 // Prepare to-do lists. | 93 // Prepare to-do lists. |
89 var replace_code_list = new GlobalArray(); | 94 var replace_code_list = new GlobalArray(); |
90 var link_to_old_script_list = new GlobalArray(); | 95 var link_to_old_script_list = new GlobalArray(); |
91 var link_to_original_script_list = new GlobalArray(); | 96 var link_to_original_script_list = new GlobalArray(); |
92 var update_positions_list = new GlobalArray(); | 97 var update_positions_list = new GlobalArray(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 177 |
173 // Start with breakpoints. Convert their line/column positions and | 178 // Start with breakpoints. Convert their line/column positions and |
174 // temporary remove. | 179 // temporary remove. |
175 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); | 180 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); |
176 | 181 |
177 var old_script; | 182 var old_script; |
178 | 183 |
179 // Create an old script only if there are function that should be linked | 184 // Create an old script only if there are function that should be linked |
180 // to old version. | 185 // to old version. |
181 if (link_to_old_script_list.length == 0) { | 186 if (link_to_old_script_list.length == 0) { |
182 %LiveEditReplaceScript(script, new_source, null); | 187 %LiveEditReplaceScript(script, max_function_literal_id, new_source, null); |
183 old_script = UNDEFINED; | 188 old_script = UNDEFINED; |
184 } else { | 189 } else { |
185 var old_script_name = CreateNameForOldScript(script); | 190 var old_script_name = CreateNameForOldScript(script); |
186 | 191 |
187 // Update the script text and create a new script representing an old | 192 // Update the script text and create a new script representing an old |
188 // version of the script. | 193 // version of the script. |
189 old_script = %LiveEditReplaceScript(script, new_source, | 194 old_script = %LiveEditReplaceScript(script, max_function_literal_id, |
190 old_script_name); | 195 new_source, old_script_name); |
191 | 196 |
192 var link_to_old_script_report = new GlobalArray(); | 197 var link_to_old_script_report = new GlobalArray(); |
193 change_log.push( { linked_to_old_script: link_to_old_script_report } ); | 198 change_log.push( { linked_to_old_script: link_to_old_script_report } ); |
194 | 199 |
195 // We need to link to old script all former nested functions. | 200 // We need to link to old script all former nested functions. |
196 for (var i = 0; i < link_to_old_script_list.length; i++) { | 201 for (var i = 0; i < link_to_old_script_list.length; i++) { |
197 LinkToOldScript(link_to_old_script_list[i], old_script, | 202 LinkToOldScript(link_to_old_script_list[i], old_script, |
198 link_to_old_script_report); | 203 link_to_old_script_report); |
199 } | 204 } |
200 | 205 |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 // An object describing function compilation details. Its index fields | 843 // An object describing function compilation details. Its index fields |
839 // apply to indexes inside array that stores these objects. | 844 // apply to indexes inside array that stores these objects. |
840 function FunctionCompileInfo(raw_array) { | 845 function FunctionCompileInfo(raw_array) { |
841 this.function_name = raw_array[0]; | 846 this.function_name = raw_array[0]; |
842 this.start_position = raw_array[1]; | 847 this.start_position = raw_array[1]; |
843 this.end_position = raw_array[2]; | 848 this.end_position = raw_array[2]; |
844 this.param_num = raw_array[3]; | 849 this.param_num = raw_array[3]; |
845 this.scope_info = raw_array[4]; | 850 this.scope_info = raw_array[4]; |
846 this.outer_index = raw_array[5]; | 851 this.outer_index = raw_array[5]; |
847 this.shared_function_info = raw_array[6]; | 852 this.shared_function_info = raw_array[6]; |
853 this.function_literal_id = raw_array[8]; | |
848 this.next_sibling_index = null; | 854 this.next_sibling_index = null; |
849 this.raw_array = raw_array; | 855 this.raw_array = raw_array; |
850 } | 856 } |
851 | 857 |
852 function SharedInfoWrapper(raw_array) { | 858 function SharedInfoWrapper(raw_array) { |
853 this.function_name = raw_array[0]; | 859 this.function_name = raw_array[0]; |
854 this.start_position = raw_array[1]; | 860 this.start_position = raw_array[1]; |
855 this.end_position = raw_array[2]; | 861 this.end_position = raw_array[2]; |
856 this.info = raw_array[3]; | 862 this.info = raw_array[3]; |
857 this.raw_array = raw_array; | 863 this.raw_array = raw_array; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1115 | 1121 |
1116 LiveEdit.TestApi = { | 1122 LiveEdit.TestApi = { |
1117 PosTranslator: PosTranslator, | 1123 PosTranslator: PosTranslator, |
1118 CompareStrings: CompareStrings, | 1124 CompareStrings: CompareStrings, |
1119 ApplySingleChunkPatch: ApplySingleChunkPatch | 1125 ApplySingleChunkPatch: ApplySingleChunkPatch |
1120 }; | 1126 }; |
1121 | 1127 |
1122 global.Debug.LiveEdit = LiveEdit; | 1128 global.Debug.LiveEdit = LiveEdit; |
1123 | 1129 |
1124 }) | 1130 }) |
OLD | NEW |