};
+BreakPoint.prototype.updateSourcePosition = function(new_position, script) {
+ this.source_position_ = new_position;
+ // TODO(635): also update line and column.
+};
+
+
BreakPoint.prototype.hit_count = function() {
return this.hit_count_;
};
var position_patch_report;
function PatchPositions(new_info, shared_info) {
if (!shared_info) {
- // TODO: explain what is happening.
+ // TODO(LiveEdit): explain what is happening.
return;
}
- %LiveEditPatchFunctionPositions(shared_info.raw_array,
- position_change_array);
+ var breakpoint_position_update = %LiveEditPatchFunctionPositions(
+ shared_info.raw_array, position_change_array);
+ for (var i = 0; i < breakpoint_position_update.length; i += 2) {
+ var new_pos = breakpoint_position_update[i];
+ var break_point_object = breakpoint_position_update[i + 1];
+ change_log.push( { breakpoint_position_update:
+ { from: break_point_object.source_position(), to: new_pos } } );
+ break_point_object.updateSourcePosition(new_pos, script);
+ }
position_patch_report.push( { name: new_info.function_name } );
}
}
-void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array,
- Handle<JSArray> position_change_array) {
+static Handle<Object> GetBreakPointObjectsForJS(
+ Handle<BreakPointInfo> break_point_info) {
+ if (break_point_info->break_point_objects()->IsFixedArray()) {
+ Handle<FixedArray> fixed_array(
+ FixedArray::cast(break_point_info->break_point_objects()));
+ Handle<Object> array = Factory::NewJSArrayWithElements(fixed_array);
+ return array;
+ } else {
+ return Handle<Object>(break_point_info->break_point_objects());
+ }
+}
+
+
+Handle<JSArray> LiveEdit::PatchFunctionPositions(
+ Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) {
SharedInfoWrapper shared_info_wrapper(shared_info_array);
Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo();
- info->set_start_position(TranslatePosition(info->start_position(),
- position_change_array));
+ int old_function_start = info->start_position();
+ int new_function_start = TranslatePosition(old_function_start,
+ position_change_array);
+ info->set_start_position(new_function_start);
info->set_end_position(TranslatePosition(info->end_position(),
position_change_array));
}
}
+
+ Handle<JSArray> result = Factory::NewJSArray(0);
+ int result_len = 0;
+
if (info->debug_info()->IsDebugInfo()) {
Handle<DebugInfo> debug_info(DebugInfo::cast(info->debug_info()));
Handle<Code> patched_orig_code =
}
Handle<BreakPointInfo> info(
BreakPointInfo::cast(break_point_infos->get(i)));
- int new_position = TranslatePosition(info->source_position()->value(),
+ int old_in_script_position = info->source_position()->value() +
+ old_function_start;
+ int new_in_script_position = TranslatePosition(old_in_script_position,
position_change_array);
- info->set_source_position(Smi::FromInt(new_position));
+ info->set_source_position(
+ Smi::FromInt(new_in_script_position - new_function_start));
+ if (old_in_script_position != new_in_script_position) {
+ SetElement(result, result_len,
+ Handle<Smi>(Smi::FromInt(new_in_script_position)));
+ SetElement(result, result_len + 1,
+ GetBreakPointObjectsForJS(info));
+ result_len += 2;
+ }
}
}
- // TODO(635): Also patch breakpoint objects in JS.
+ return result;
}
static void RelinkFunctionToScript(Handle<JSArray> shared_info_array,
Handle<Script> script_handle);
- static void PatchFunctionPositions(Handle<JSArray> shared_info_array,
- Handle<JSArray> position_change_array);
+ // Returns an array of pairs (new source position, breakpoint_object/array)
+ // so that JS side could update positions in breakpoint objects.
+ static Handle<JSArray> PatchFunctionPositions(
+ Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array);
// Checks listed functions on stack and return array with corresponding
// FunctionPatchabilityStatus statuses; extra array element may
old_script->set_eval_from_instructions_offset(
original_script->eval_from_instructions_offset());
+ // Drop line ends so that they will be recalculated.
+ original_script->set_line_ends(Heap::undefined_value());
Debugger::OnAfterCompile(old_script, Debugger::SEND_WHEN_DEBUGGING);
// array of groups of 3 numbers:
// (change_begin, change_end, change_end_new_position).
// Each group describes a change in text; groups are sorted by change_begin.
+// Returns an array of pairs (new source position, breakpoint_object/array)
+// so that JS side could update positions in breakpoint objects.
static Object* Runtime_LiveEditPatchFunctionPositions(Arguments args) {
ASSERT(args.length() == 2);
HandleScope scope;
CONVERT_ARG_CHECKED(JSArray, shared_array, 0);
CONVERT_ARG_CHECKED(JSArray, position_change_array, 1);
- LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
+ Handle<Object> result =
+ LiveEdit::PatchFunctionPositions(shared_array, position_change_array);
- return Heap::undefined_value();
+ return *result;
}