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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 updated: false | 135 updated: false |
136 }; | 136 }; |
137 | 137 |
138 if (preview_only) { | 138 if (preview_only) { |
139 return preview_description; | 139 return preview_description; |
140 } | 140 } |
141 | 141 |
142 HarvestTodo(root_old_node); | 142 HarvestTodo(root_old_node); |
143 | 143 |
144 // Collect shared infos for functions whose code need to be patched. | 144 // Collect shared infos for functions whose code need to be patched. |
145 var replaced_function_infos = new GlobalArray(); | 145 var replaced_function_old_infos = new GlobalArray(); |
| 146 var replaced_function_new_infos = new GlobalArray(); |
146 for (var i = 0; i < replace_code_list.length; i++) { | 147 for (var i = 0; i < replace_code_list.length; i++) { |
147 var live_shared_function_infos = | 148 var old_infos = replace_code_list[i].live_shared_function_infos; |
148 replace_code_list[i].live_shared_function_infos; | 149 var new_info = |
| 150 replace_code_list[i].corresponding_node.info.shared_function_info; |
149 | 151 |
150 if (live_shared_function_infos) { | 152 if (old_infos) { |
151 for (var j = 0; j < live_shared_function_infos.length; j++) { | 153 for (var j = 0; j < old_infos.length; j++) { |
152 replaced_function_infos.push(live_shared_function_infos[j]); | 154 replaced_function_old_infos.push(old_infos[j]); |
| 155 replaced_function_new_infos.push(new_info); |
153 } | 156 } |
154 } | 157 } |
155 } | 158 } |
156 | 159 |
157 // We haven't changed anything before this line yet. | 160 // We haven't changed anything before this line yet. |
158 // Committing all changes. | 161 // Committing all changes. |
159 | 162 |
160 // Check that function being patched is not currently on stack or drop them. | 163 // Check that function being patched is not currently on stack or drop them. |
161 var dropped_functions_number = | 164 var dropped_functions_number = |
162 CheckStackActivations(replaced_function_infos, change_log); | 165 CheckStackActivations(replaced_function_old_infos, |
| 166 replaced_function_new_infos, |
| 167 change_log); |
163 | 168 |
164 // Our current implementation requires client to manually issue "step in" | 169 // Our current implementation requires client to manually issue "step in" |
165 // command for correct stack state if the stack was modified. | 170 // command for correct stack state if the stack was modified. |
166 preview_description.stack_modified = dropped_functions_number != 0; | 171 preview_description.stack_modified = dropped_functions_number != 0; |
167 | 172 |
168 // Start with breakpoints. Convert their line/column positions and | 173 // Start with breakpoints. Convert their line/column positions and |
169 // temporary remove. | 174 // temporary remove. |
170 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); | 175 var break_points_restorer = TemporaryRemoveBreakPoints(script, change_log); |
171 | 176 |
172 var old_script; | 177 var old_script; |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 // No differences. Return undefined. | 908 // No differences. Return undefined. |
904 return; | 909 return; |
905 } | 910 } |
906 | 911 |
907 // Minifier forward declaration. | 912 // Minifier forward declaration. |
908 var FunctionPatchabilityStatus; | 913 var FunctionPatchabilityStatus; |
909 | 914 |
910 // For array of wrapped shared function infos checks that none of them | 915 // For array of wrapped shared function infos checks that none of them |
911 // have activations on stack (of any thread). Throws a Failure exception | 916 // have activations on stack (of any thread). Throws a Failure exception |
912 // if this proves to be false. | 917 // if this proves to be false. |
913 function CheckStackActivations(shared_wrapper_list, change_log) { | 918 function CheckStackActivations(old_shared_wrapper_list, |
914 var shared_list = new GlobalArray(); | 919 new_shared_list, |
915 for (var i = 0; i < shared_wrapper_list.length; i++) { | 920 change_log) { |
916 shared_list[i] = shared_wrapper_list[i].info; | 921 var old_shared_list = new GlobalArray(); |
| 922 for (var i = 0; i < old_shared_wrapper_list.length; i++) { |
| 923 old_shared_list[i] = old_shared_wrapper_list[i].info; |
917 } | 924 } |
918 var result = %LiveEditCheckAndDropActivations(shared_list, true); | 925 var result = %LiveEditCheckAndDropActivations( |
919 if (result[shared_list.length]) { | 926 old_shared_list, new_shared_list, true); |
| 927 if (result[old_shared_wrapper_list.length]) { |
920 // Extra array element may contain error message. | 928 // Extra array element may contain error message. |
921 throw new Failure(result[shared_list.length]); | 929 throw new Failure(result[old_shared_wrapper_list.length]); |
922 } | 930 } |
923 | 931 |
924 var problems = new GlobalArray(); | 932 var problems = new GlobalArray(); |
925 var dropped = new GlobalArray(); | 933 var dropped = new GlobalArray(); |
926 for (var i = 0; i < shared_list.length; i++) { | 934 for (var i = 0; i < old_shared_list.length; i++) { |
927 var shared = shared_wrapper_list[i]; | 935 var shared = old_shared_wrapper_list[i]; |
928 if (result[i] == FunctionPatchabilityStatus.REPLACED_ON_ACTIVE_STACK) { | 936 if (result[i] == FunctionPatchabilityStatus.REPLACED_ON_ACTIVE_STACK) { |
929 dropped.push({ name: shared.function_name } ); | 937 dropped.push({ name: shared.function_name } ); |
930 } else if (result[i] != FunctionPatchabilityStatus.AVAILABLE_FOR_PATCH) { | 938 } else if (result[i] != FunctionPatchabilityStatus.AVAILABLE_FOR_PATCH) { |
931 var description = { | 939 var description = { |
932 name: shared.function_name, | 940 name: shared.function_name, |
933 start_pos: shared.start_position, | 941 start_pos: shared.start_position, |
934 end_pos: shared.end_position, | 942 end_pos: shared.end_position, |
935 replace_problem: | 943 replace_problem: |
936 FunctionPatchabilityStatus.SymbolName(result[i]) | 944 FunctionPatchabilityStatus.SymbolName(result[i]) |
937 }; | 945 }; |
(...skipping 12 matching lines...) Expand all Loading... |
950 } | 958 } |
951 | 959 |
952 // A copy of the FunctionPatchabilityStatus enum from liveedit.h | 960 // A copy of the FunctionPatchabilityStatus enum from liveedit.h |
953 var FunctionPatchabilityStatus = { | 961 var FunctionPatchabilityStatus = { |
954 AVAILABLE_FOR_PATCH: 1, | 962 AVAILABLE_FOR_PATCH: 1, |
955 BLOCKED_ON_ACTIVE_STACK: 2, | 963 BLOCKED_ON_ACTIVE_STACK: 2, |
956 BLOCKED_ON_OTHER_STACK: 3, | 964 BLOCKED_ON_OTHER_STACK: 3, |
957 BLOCKED_UNDER_NATIVE_CODE: 4, | 965 BLOCKED_UNDER_NATIVE_CODE: 4, |
958 REPLACED_ON_ACTIVE_STACK: 5, | 966 REPLACED_ON_ACTIVE_STACK: 5, |
959 BLOCKED_UNDER_GENERATOR: 6, | 967 BLOCKED_UNDER_GENERATOR: 6, |
960 BLOCKED_ACTIVE_GENERATOR: 7 | 968 BLOCKED_ACTIVE_GENERATOR: 7, |
| 969 BLOCKED_NO_NEW_TARGET_ON_RESTART: 8 |
961 }; | 970 }; |
962 | 971 |
963 FunctionPatchabilityStatus.SymbolName = function(code) { | 972 FunctionPatchabilityStatus.SymbolName = function(code) { |
964 var enumeration = FunctionPatchabilityStatus; | 973 var enumeration = FunctionPatchabilityStatus; |
965 for (var name in enumeration) { | 974 for (var name in enumeration) { |
966 if (enumeration[name] == code) { | 975 if (enumeration[name] == code) { |
967 return name; | 976 return name; |
968 } | 977 } |
969 } | 978 } |
970 }; | 979 }; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1123 |
1115 LiveEdit.TestApi = { | 1124 LiveEdit.TestApi = { |
1116 PosTranslator: PosTranslator, | 1125 PosTranslator: PosTranslator, |
1117 CompareStrings: CompareStrings, | 1126 CompareStrings: CompareStrings, |
1118 ApplySingleChunkPatch: ApplySingleChunkPatch | 1127 ApplySingleChunkPatch: ApplySingleChunkPatch |
1119 }; | 1128 }; |
1120 | 1129 |
1121 global.Debug.LiveEdit = LiveEdit; | 1130 global.Debug.LiveEdit = LiveEdit; |
1122 | 1131 |
1123 }) | 1132 }) |
OLD | NEW |