From 7b8afe4c2c70a93d840392eec0b9bd06cf0a93b9 Mon Sep 17 00:00:00 2001 From: "antonm@chromium.org" Date: Fri, 9 Apr 2010 13:51:11 +0000 Subject: [PATCH] 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 --- src/liveedit.cc | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/liveedit.cc b/src/liveedit.cc index 7647f35db8..8e02b5d9e8 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -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 new_compile_info_array, Handle shared_info_array) { HandleScope scope; @@ -456,15 +463,30 @@ void LiveEdit::ReplaceFunctionCode(Handle new_compile_info_array, Handle shared_info = shared_info_wrapper.GetInfo(); - ReplaceCodeObject(shared_info->code(), - *(compile_info_wrapper.GetFunctionCode())); + + if (IsJSFunctionCode(shared_info->code())) { + ReplaceCodeObject(shared_info->code(), + *(compile_info_wrapper.GetFunctionCode())); + } + + if (shared_info->debug_info()->IsDebugInfo()) { + Handle debug_info(DebugInfo::cast(shared_info->debug_info())); + Handle 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 shared_info_array, Handle