From f2270b2c5504a1f516f3bf4e1bf282e916f61790 Mon Sep 17 00:00:00 2001 From: "peter.rybin@gmail.com" Date: Thu, 12 Aug 2010 16:01:56 +0000 Subject: [PATCH] LiveEdit: reflect scope_info moving out of Code Review URL: http://codereview.chromium.org/3131008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5255 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/liveedit-debugger.js | 7 ++++--- src/liveedit.cc | 40 ++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/liveedit-debugger.js b/src/liveedit-debugger.js index c8c6f08..be97989 100644 --- a/src/liveedit-debugger.js +++ b/src/liveedit-debugger.js @@ -800,9 +800,10 @@ Debug.LiveEdit = new function() { this.end_position = raw_array[2]; this.param_num = raw_array[3]; this.code = raw_array[4]; - this.scope_info = raw_array[5]; - this.outer_index = raw_array[6]; - this.shared_function_info = raw_array[7]; + this.code_scope_info = raw_array[5]; + this.scope_info = raw_array[6]; + this.outer_index = raw_array[7]; + this.shared_function_info = raw_array[8]; this.next_sibling_index = null; this.raw_array = raw_array; } diff --git a/src/liveedit.cc b/src/liveedit.cc index 346d9ea..2ac24fb 100644 --- a/src/liveedit.cc +++ b/src/liveedit.cc @@ -32,6 +32,7 @@ #include "compiler.h" #include "oprofile-agent.h" #include "scopes.h" +#include "scopeinfo.h" #include "global-handles.h" #include "debug.h" #include "memory.h" @@ -500,12 +501,16 @@ class FunctionInfoWrapper : public JSArrayBasedStruct { this->SetSmiValueField(kParamNumOffset_, param_num); this->SetSmiValueField(kParentIndexOffset_, parent_index); } - void SetFunctionCode(Handle function_code) { - Handle wrapper = WrapInJSValue(*function_code); - this->SetField(kCodeOffset_, wrapper); + void SetFunctionCode(Handle function_code, + Handle code_scope_info) { + Handle code_wrapper = WrapInJSValue(*function_code); + this->SetField(kCodeOffset_, code_wrapper); + + Handle scope_wrapper = WrapInJSValue(*code_scope_info); + this->SetField(kCodeScopeInfoOffset_, scope_wrapper); } - void SetScopeInfo(Handle scope_info_array) { - this->SetField(kScopeInfoOffset_, scope_info_array); + void SetOuterScopeInfo(Handle scope_info_array) { + this->SetField(kOuterScopeInfoOffset_, scope_info_array); } void SetSharedFunctionInfo(Handle info) { Handle info_holder = WrapInJSValue(*info); @@ -519,6 +524,11 @@ class FunctionInfoWrapper : public JSArrayBasedStruct { JSValue::cast(this->GetField(kCodeOffset_)))); return Handle::cast(raw_result); } + Handle GetCodeScopeInfo() { + Handle raw_result = UnwrapJSValue(Handle( + JSValue::cast(this->GetField(kCodeScopeInfoOffset_)))); + return raw_result; + } int GetStartPosition() { return this->GetSmiValueField(kStartPositionOffset_); } @@ -532,10 +542,11 @@ class FunctionInfoWrapper : public JSArrayBasedStruct { static const int kEndPositionOffset_ = 2; static const int kParamNumOffset_ = 3; static const int kCodeOffset_ = 4; - static const int kScopeInfoOffset_ = 5; - static const int kParentIndexOffset_ = 6; - static const int kSharedFunctionInfoOffset_ = 7; - static const int kSize_ = 8; + static const int kCodeScopeInfoOffset_ = 5; + static const int kOuterScopeInfoOffset_ = 6; + static const int kParentIndexOffset_ = 7; + static const int kSharedFunctionInfoOffset_ = 8; + static const int kSize_ = 9; friend class JSArrayBasedStruct; }; @@ -671,7 +682,7 @@ class FunctionInfoListener { void FunctionCode(Handle function_code) { FunctionInfoWrapper info = FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_)); - info.SetFunctionCode(function_code); + info.SetFunctionCode(function_code, Handle(Heap::null_value())); } // Saves full information about a function: its code, its scope info @@ -682,11 +693,12 @@ class FunctionInfoListener { } FunctionInfoWrapper info = FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_)); - info.SetFunctionCode(Handle(shared->code())); + info.SetFunctionCode(Handle(shared->code()), + Handle(shared->scope_info())); info.SetSharedFunctionInfo(shared); Handle scope_info_list(SerializeFunctionScope(scope)); - info.SetScopeInfo(scope_info_list); + info.SetOuterScopeInfo(scope_info_list); } Handle GetResult() { @@ -855,6 +867,10 @@ Object* LiveEdit::ReplaceFunctionCode(Handle new_compile_info_array, if (IsJSFunctionCode(shared_info->code())) { ReplaceCodeObject(shared_info->code(), *(compile_info_wrapper.GetFunctionCode())); + Handle code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); + if (code_scope_info->IsFixedArray()) { + shared_info->set_scope_info(SerializedScopeInfo::cast(*code_scope_info)); + } } if (shared_info->debug_info()->IsDebugInfo()) { -- 2.7.4