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 #include "src/debug/liveedit.h" | 5 #include "src/debug/liveedit.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compilation-cache.h" | 9 #include "src/compilation-cache.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 element = JSReceiver::GetElement(isolate, position_change_array, i + 2) | 1095 element = JSReceiver::GetElement(isolate, position_change_array, i + 2) |
1096 .ToHandleChecked(); | 1096 .ToHandleChecked(); |
1097 CHECK(element->IsSmi()); | 1097 CHECK(element->IsSmi()); |
1098 int chunk_changed_end = Handle<Smi>::cast(element)->value(); | 1098 int chunk_changed_end = Handle<Smi>::cast(element)->value(); |
1099 position_diff = chunk_changed_end - chunk_end; | 1099 position_diff = chunk_changed_end - chunk_end; |
1100 } | 1100 } |
1101 | 1101 |
1102 return original_position + position_diff; | 1102 return original_position + position_diff; |
1103 } | 1103 } |
1104 | 1104 |
1105 Handle<ByteArray> TranslateSourcePositionTable( | 1105 void TranslateSourcePositionTable(Handle<AbstractCode> code, |
1106 Handle<ByteArray> source_position_table, | 1106 Handle<JSArray> position_change_array) { |
1107 Handle<JSArray> position_change_array) { | 1107 Isolate* isolate = code->GetIsolate(); |
1108 Isolate* isolate = source_position_table->GetIsolate(); | |
1109 Zone zone(isolate->allocator()); | 1108 Zone zone(isolate->allocator()); |
1110 SourcePositionTableBuilder builder(isolate, &zone); | 1109 SourcePositionTableBuilder builder(&zone); |
1111 | 1110 |
| 1111 Handle<ByteArray> source_position_table(code->source_position_table()); |
1112 for (SourcePositionTableIterator iterator(*source_position_table); | 1112 for (SourcePositionTableIterator iterator(*source_position_table); |
1113 !iterator.done(); iterator.Advance()) { | 1113 !iterator.done(); iterator.Advance()) { |
1114 int position = iterator.source_position(); | 1114 int position = iterator.source_position(); |
1115 int new_position = TranslatePosition(position, position_change_array); | 1115 int new_position = TranslatePosition(position, position_change_array); |
1116 builder.AddPosition(iterator.code_offset(), new_position, | 1116 builder.AddPosition(iterator.code_offset(), new_position, |
1117 iterator.is_statement()); | 1117 iterator.is_statement()); |
1118 } | 1118 } |
1119 | 1119 |
1120 return builder.ToSourcePositionTable(); | 1120 Handle<ByteArray> new_source_position_table( |
| 1121 builder.ToSourcePositionTable(isolate, code)); |
| 1122 code->set_source_position_table(*new_source_position_table); |
1121 } | 1123 } |
1122 } // namespace | 1124 } // namespace |
1123 | 1125 |
1124 void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array, | 1126 void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array, |
1125 Handle<JSArray> position_change_array) { | 1127 Handle<JSArray> position_change_array) { |
1126 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1128 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
1127 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); | 1129 Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); |
1128 | 1130 |
1129 int old_function_start = info->start_position(); | 1131 int old_function_start = info->start_position(); |
1130 int new_function_start = TranslatePosition(old_function_start, | 1132 int new_function_start = TranslatePosition(old_function_start, |
1131 position_change_array); | 1133 position_change_array); |
1132 int new_function_end = TranslatePosition(info->end_position(), | 1134 int new_function_end = TranslatePosition(info->end_position(), |
1133 position_change_array); | 1135 position_change_array); |
1134 int new_function_token_pos = | 1136 int new_function_token_pos = |
1135 TranslatePosition(info->function_token_position(), position_change_array); | 1137 TranslatePosition(info->function_token_position(), position_change_array); |
1136 | 1138 |
1137 info->set_start_position(new_function_start); | 1139 info->set_start_position(new_function_start); |
1138 info->set_end_position(new_function_end); | 1140 info->set_end_position(new_function_end); |
1139 info->set_function_token_position(new_function_token_pos); | 1141 info->set_function_token_position(new_function_token_pos); |
1140 | 1142 |
1141 if (info->HasBytecodeArray()) { | 1143 if (info->HasBytecodeArray()) { |
1142 Handle<ByteArray> new_source_position_table = TranslateSourcePositionTable( | 1144 TranslateSourcePositionTable( |
1143 Handle<ByteArray>(info->bytecode_array()->source_position_table()), | 1145 Handle<AbstractCode>(AbstractCode::cast(info->bytecode_array())), |
1144 position_change_array); | 1146 position_change_array); |
1145 info->bytecode_array()->set_source_position_table( | |
1146 *new_source_position_table); | |
1147 } | 1147 } |
1148 if (info->code()->kind() == Code::FUNCTION) { | 1148 if (info->code()->kind() == Code::FUNCTION) { |
1149 Handle<ByteArray> new_source_position_table = TranslateSourcePositionTable( | 1149 TranslateSourcePositionTable( |
1150 Handle<ByteArray>(info->code()->source_position_table()), | 1150 Handle<AbstractCode>(AbstractCode::cast(info->code())), |
1151 position_change_array); | 1151 position_change_array); |
1152 info->code()->set_source_position_table(*new_source_position_table); | |
1153 } | 1152 } |
1154 if (info->HasDebugInfo()) { | 1153 if (info->HasDebugInfo()) { |
1155 // Existing break points will be re-applied. Reset the debug info here. | 1154 // Existing break points will be re-applied. Reset the debug info here. |
1156 info->GetIsolate()->debug()->RemoveDebugInfoAndClearFromShared( | 1155 info->GetIsolate()->debug()->RemoveDebugInfoAndClearFromShared( |
1157 handle(info->GetDebugInfo())); | 1156 handle(info->GetDebugInfo())); |
1158 } | 1157 } |
1159 } | 1158 } |
1160 | 1159 |
1161 | 1160 |
1162 static Handle<Script> CreateScriptCopy(Handle<Script> original) { | 1161 static Handle<Script> CreateScriptCopy(Handle<Script> original) { |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1923 scope_info_length++; | 1922 scope_info_length++; |
1924 | 1923 |
1925 current_scope = current_scope->outer_scope(); | 1924 current_scope = current_scope->outer_scope(); |
1926 } | 1925 } |
1927 | 1926 |
1928 return scope_info_list; | 1927 return scope_info_list; |
1929 } | 1928 } |
1930 | 1929 |
1931 } // namespace internal | 1930 } // namespace internal |
1932 } // namespace v8 | 1931 } // namespace v8 |
OLD | NEW |