Commit 7b8afe4c authored by antonm@chromium.org's avatar antonm@chromium.org

Restore r4358 which was reverted by 4366.

Review URL: http://codereview.chromium.org/1594023

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4379 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 16799e20
......@@ -447,6 +447,13 @@ static void ReplaceCodeObject(Code* original, Code* substitution) {
}
// Check whether the code is natural function code (not a lazy-compile stub
// code).
static bool IsJSFunctionCode(Code* code) {
return code->kind() == Code::FUNCTION;
}
void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
Handle<JSArray> shared_info_array) {
HandleScope scope;
......@@ -456,15 +463,30 @@ void LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
if (IsJSFunctionCode(shared_info->code())) {
ReplaceCodeObject(shared_info->code(),
*(compile_info_wrapper.GetFunctionCode()));
}
if (shared_info->debug_info()->IsDebugInfo()) {
Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info()));
Handle<Code> new_original_code =
Factory::CopyCode(compile_info_wrapper.GetFunctionCode());
debug_info->set_original_code(*new_original_code);
}
shared_info->set_start_position(compile_info_wrapper.GetStartPosition());
shared_info->set_end_position(compile_info_wrapper.GetEndPosition());
// update breakpoints, original code, constructor stub
shared_info->set_construct_stub(
Builtins::builtin(Builtins::JSConstructStubGeneric));
// update breakpoints
}
// TODO(635): Eval caches its scripts (same text -- same compiled info).
// Make sure we clear such caches.
void LiveEdit::RelinkFunctionToScript(Handle<JSArray> shared_info_array,
Handle<Script> script_handle) {
SharedInfoWrapper shared_info_wrapper(shared_info_array);
......@@ -651,6 +673,7 @@ Handle<JSArray> LiveEdit::PatchFunctionPositions(
TranslatePosition(info->function_token_position(),
position_change_array));
if (IsJSFunctionCode(info->code())) {
// Patch relocation info section of the code.
Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()),
position_change_array);
......@@ -658,9 +681,11 @@ Handle<JSArray> LiveEdit::PatchFunctionPositions(
// Replace all references to the code across the heap. In particular,
// some stubs may refer to this code and this code may be being executed
// on stack (it is safe to substitute the code object on stack, because
// we only change the structure of rinfo and leave instructions untouched).
// we only change the structure of rinfo and leave instructions
// untouched).
ReplaceCodeObject(info->code(), *patched_code);
}
}
Handle<JSArray> result = Factory::NewJSArray(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment