| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 #include "src/v8.h" | 6 #include "src/v8.h" |
| 7 | 7 |
| 8 #include "src/liveedit.h" | 8 #include "src/liveedit.h" |
| 9 | 9 |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 void LiveEdit::ReplaceFunctionCode( | 1181 void LiveEdit::ReplaceFunctionCode( |
| 1182 Handle<JSArray> new_compile_info_array, | 1182 Handle<JSArray> new_compile_info_array, |
| 1183 Handle<JSArray> shared_info_array) { | 1183 Handle<JSArray> shared_info_array) { |
| 1184 Isolate* isolate = new_compile_info_array->GetIsolate(); | 1184 Isolate* isolate = new_compile_info_array->GetIsolate(); |
| 1185 | 1185 |
| 1186 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); | 1186 FunctionInfoWrapper compile_info_wrapper(new_compile_info_array); |
| 1187 SharedInfoWrapper shared_info_wrapper(shared_info_array); | 1187 SharedInfoWrapper shared_info_wrapper(shared_info_array); |
| 1188 | 1188 |
| 1189 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); | 1189 Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo(); |
| 1190 | 1190 |
| 1191 isolate->heap()->MakeHeapIterable(); | |
| 1192 | |
| 1193 if (IsJSFunctionCode(shared_info->code())) { | 1191 if (IsJSFunctionCode(shared_info->code())) { |
| 1194 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); | 1192 Handle<Code> code = compile_info_wrapper.GetFunctionCode(); |
| 1195 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); | 1193 ReplaceCodeObject(Handle<Code>(shared_info->code()), code); |
| 1196 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); | 1194 Handle<Object> code_scope_info = compile_info_wrapper.GetCodeScopeInfo(); |
| 1197 if (code_scope_info->IsFixedArray()) { | 1195 if (code_scope_info->IsFixedArray()) { |
| 1198 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); | 1196 shared_info->set_scope_info(ScopeInfo::cast(*code_scope_info)); |
| 1199 } | 1197 } |
| 1200 shared_info->DisableOptimization(kLiveEdit); | 1198 shared_info->DisableOptimization(kLiveEdit); |
| 1201 // Update the type feedback vector | 1199 // Update the type feedback vector |
| 1202 Handle<FixedArray> feedback_vector = | 1200 Handle<FixedArray> feedback_vector = |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 position_change_array); | 1416 position_change_array); |
| 1419 int new_function_end = TranslatePosition(info->end_position(), | 1417 int new_function_end = TranslatePosition(info->end_position(), |
| 1420 position_change_array); | 1418 position_change_array); |
| 1421 int new_function_token_pos = | 1419 int new_function_token_pos = |
| 1422 TranslatePosition(info->function_token_position(), position_change_array); | 1420 TranslatePosition(info->function_token_position(), position_change_array); |
| 1423 | 1421 |
| 1424 info->set_start_position(new_function_start); | 1422 info->set_start_position(new_function_start); |
| 1425 info->set_end_position(new_function_end); | 1423 info->set_end_position(new_function_end); |
| 1426 info->set_function_token_position(new_function_token_pos); | 1424 info->set_function_token_position(new_function_token_pos); |
| 1427 | 1425 |
| 1428 info->GetIsolate()->heap()->MakeHeapIterable(); | |
| 1429 | |
| 1430 if (IsJSFunctionCode(info->code())) { | 1426 if (IsJSFunctionCode(info->code())) { |
| 1431 // Patch relocation info section of the code. | 1427 // Patch relocation info section of the code. |
| 1432 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 1428 Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), |
| 1433 position_change_array); | 1429 position_change_array); |
| 1434 if (*patched_code != info->code()) { | 1430 if (*patched_code != info->code()) { |
| 1435 // Replace all references to the code across the heap. In particular, | 1431 // Replace all references to the code across the heap. In particular, |
| 1436 // some stubs may refer to this code and this code may be being executed | 1432 // some stubs may refer to this code and this code may be being executed |
| 1437 // on stack (it is safe to substitute the code object on stack, because | 1433 // on stack (it is safe to substitute the code object on stack, because |
| 1438 // we only change the structure of rinfo and leave instructions | 1434 // we only change the structure of rinfo and leave instructions |
| 1439 // untouched). | 1435 // untouched). |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2076 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { | 2072 void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) { |
| 2077 isolate_->active_function_info_listener()->FunctionCode(code); | 2073 isolate_->active_function_info_listener()->FunctionCode(code); |
| 2078 } | 2074 } |
| 2079 | 2075 |
| 2080 | 2076 |
| 2081 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2077 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 2082 return isolate->active_function_info_listener() != NULL; | 2078 return isolate->active_function_info_listener() != NULL; |
| 2083 } | 2079 } |
| 2084 | 2080 |
| 2085 } } // namespace v8::internal | 2081 } } // namespace v8::internal |
| OLD | NEW |