LiveEdit: update breakpoint positions for non-changed functions
Review URL: http://codereview.chromium.org/1090003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4359 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
f6fd7d4145
commit
4e6a738e63
@ -124,6 +124,12 @@ BreakPoint.prototype.source_position = function() {
|
||||
};
|
||||
|
||||
|
||||
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_;
|
||||
};
|
||||
|
@ -180,11 +180,18 @@ Debug.LiveEditChangeScript = function(script, change_pos, change_len, new_str,
|
||||
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 } );
|
||||
}
|
||||
|
||||
|
@ -644,13 +644,28 @@ static Handle<Code> PatchPositionsInCode(Handle<Code> code,
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
|
||||
@ -672,6 +687,10 @@ void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_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 =
|
||||
@ -690,12 +709,22 @@ void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array,
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,8 +88,10 @@ class LiveEdit : AllStatic {
|
||||
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
|
||||
|
@ -9656,6 +9656,8 @@ static Object* Runtime_LiveEditReplaceScript(Arguments args) {
|
||||
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);
|
||||
|
||||
@ -9692,15 +9694,18 @@ static Object* Runtime_LiveEditRelinkFunctionToScript(Arguments args) {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user