| OLD | NEW | 
|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 637   } else { | 637   } else { | 
| 638     // Relocation info section now has different size. We cannot simply | 638     // Relocation info section now has different size. We cannot simply | 
| 639     // rewrite it inside code object. Instead we have to create a new | 639     // rewrite it inside code object. Instead we have to create a new | 
| 640     // code object. | 640     // code object. | 
| 641     Handle<Code> result(Factory::CopyCode(code, buffer)); | 641     Handle<Code> result(Factory::CopyCode(code, buffer)); | 
| 642     return result; | 642     return result; | 
| 643   } | 643   } | 
| 644 } | 644 } | 
| 645 | 645 | 
| 646 | 646 | 
| 647 void LiveEdit::PatchFunctionPositions(Handle<JSArray> shared_info_array, | 647 static Handle<Object> GetBreakPointObjectsForJS( | 
| 648                                       Handle<JSArray> position_change_array) { | 648     Handle<BreakPointInfo> break_point_info) { | 
|  | 649   if (break_point_info->break_point_objects()->IsFixedArray()) { | 
|  | 650     Handle<FixedArray> fixed_array( | 
|  | 651         FixedArray::cast(break_point_info->break_point_objects())); | 
|  | 652     Handle<Object> array = Factory::NewJSArrayWithElements(fixed_array); | 
|  | 653     return array; | 
|  | 654   } else { | 
|  | 655     return Handle<Object>(break_point_info->break_point_objects()); | 
|  | 656   } | 
|  | 657 } | 
|  | 658 | 
|  | 659 | 
|  | 660 Handle<JSArray> LiveEdit::PatchFunctionPositions( | 
|  | 661     Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) { | 
| 649   SharedInfoWrapper shared_info_wrapper(shared_info_array); | 662   SharedInfoWrapper shared_info_wrapper(shared_info_array); | 
| 650   Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); | 663   Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo(); | 
| 651 | 664 | 
| 652   info->set_start_position(TranslatePosition(info->start_position(), | 665   int old_function_start = info->start_position(); | 
| 653                                              position_change_array)); | 666   int new_function_start = TranslatePosition(old_function_start, | 
|  | 667                                              position_change_array); | 
|  | 668   info->set_start_position(new_function_start); | 
| 654   info->set_end_position(TranslatePosition(info->end_position(), | 669   info->set_end_position(TranslatePosition(info->end_position(), | 
| 655                                            position_change_array)); | 670                                            position_change_array)); | 
| 656 | 671 | 
| 657   info->set_function_token_position( | 672   info->set_function_token_position( | 
| 658       TranslatePosition(info->function_token_position(), | 673       TranslatePosition(info->function_token_position(), | 
| 659       position_change_array)); | 674       position_change_array)); | 
| 660 | 675 | 
| 661   if (IsJSFunctionCode(info->code())) { | 676   if (IsJSFunctionCode(info->code())) { | 
| 662     // Patch relocation info section of the code. | 677     // Patch relocation info section of the code. | 
| 663     Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 678     Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()), | 
| 664                                                      position_change_array); | 679                                                      position_change_array); | 
| 665     if (*patched_code != info->code()) { | 680     if (*patched_code != info->code()) { | 
| 666       // Replace all references to the code across the heap. In particular, | 681       // Replace all references to the code across the heap. In particular, | 
| 667       // some stubs may refer to this code and this code may be being executed | 682       // some stubs may refer to this code and this code may be being executed | 
| 668       // on stack (it is safe to substitute the code object on stack, because | 683       // on stack (it is safe to substitute the code object on stack, because | 
| 669       // we only change the structure of rinfo and leave instructions | 684       // we only change the structure of rinfo and leave instructions | 
| 670       // untouched). | 685       // untouched). | 
| 671       ReplaceCodeObject(info->code(), *patched_code); | 686       ReplaceCodeObject(info->code(), *patched_code); | 
| 672     } | 687     } | 
| 673   } | 688   } | 
| 674 | 689 | 
|  | 690 | 
|  | 691   Handle<JSArray> result = Factory::NewJSArray(0); | 
|  | 692   int result_len = 0; | 
|  | 693 | 
| 675   if (info->debug_info()->IsDebugInfo()) { | 694   if (info->debug_info()->IsDebugInfo()) { | 
| 676     Handle<DebugInfo> debug_info(DebugInfo::cast(info->debug_info())); | 695     Handle<DebugInfo> debug_info(DebugInfo::cast(info->debug_info())); | 
| 677     Handle<Code> patched_orig_code = | 696     Handle<Code> patched_orig_code = | 
| 678         PatchPositionsInCode(Handle<Code>(debug_info->original_code()), | 697         PatchPositionsInCode(Handle<Code>(debug_info->original_code()), | 
| 679                              position_change_array); | 698                              position_change_array); | 
| 680     if (*patched_orig_code != debug_info->original_code()) { | 699     if (*patched_orig_code != debug_info->original_code()) { | 
| 681       // Do not use expensive ReplaceCodeObject for original_code, because we | 700       // Do not use expensive ReplaceCodeObject for original_code, because we | 
| 682       // do not expect any other references except this one. | 701       // do not expect any other references except this one. | 
| 683       debug_info->set_original_code(*patched_orig_code); | 702       debug_info->set_original_code(*patched_orig_code); | 
| 684     } | 703     } | 
| 685 | 704 | 
| 686     Handle<FixedArray> break_point_infos(debug_info->break_points()); | 705     Handle<FixedArray> break_point_infos(debug_info->break_points()); | 
| 687     for (int i = 0; i < break_point_infos->length(); i++) { | 706     for (int i = 0; i < break_point_infos->length(); i++) { | 
| 688       if (!break_point_infos->get(i)->IsBreakPointInfo()) { | 707       if (!break_point_infos->get(i)->IsBreakPointInfo()) { | 
| 689         continue; | 708         continue; | 
| 690       } | 709       } | 
| 691       Handle<BreakPointInfo> info( | 710       Handle<BreakPointInfo> info( | 
| 692           BreakPointInfo::cast(break_point_infos->get(i))); | 711           BreakPointInfo::cast(break_point_infos->get(i))); | 
| 693       int new_position = TranslatePosition(info->source_position()->value(), | 712       int old_in_script_position = info->source_position()->value() + | 
|  | 713           old_function_start; | 
|  | 714       int new_in_script_position = TranslatePosition(old_in_script_position, | 
| 694           position_change_array); | 715           position_change_array); | 
| 695       info->set_source_position(Smi::FromInt(new_position)); | 716       info->set_source_position( | 
|  | 717           Smi::FromInt(new_in_script_position - new_function_start)); | 
|  | 718       if (old_in_script_position != new_in_script_position) { | 
|  | 719         SetElement(result, result_len, | 
|  | 720                    Handle<Smi>(Smi::FromInt(new_in_script_position))); | 
|  | 721         SetElement(result, result_len + 1, | 
|  | 722                    GetBreakPointObjectsForJS(info)); | 
|  | 723         result_len += 2; | 
|  | 724       } | 
| 696     } | 725     } | 
| 697   } | 726   } | 
| 698   // TODO(635): Also patch breakpoint objects in JS. | 727   return result; | 
| 699 } | 728 } | 
| 700 | 729 | 
| 701 | 730 | 
| 702 // Check an activation against list of functions. If there is a function | 731 // Check an activation against list of functions. If there is a function | 
| 703 // that matches, its status in result array is changed to status argument value. | 732 // that matches, its status in result array is changed to status argument value. | 
| 704 static bool CheckActivation(Handle<JSArray> shared_info_array, | 733 static bool CheckActivation(Handle<JSArray> shared_info_array, | 
| 705                             Handle<JSArray> result, StackFrame* frame, | 734                             Handle<JSArray> result, StackFrame* frame, | 
| 706                             LiveEdit::FunctionPatchabilityStatus status) { | 735                             LiveEdit::FunctionPatchabilityStatus status) { | 
| 707   if (!frame->is_java_script()) { | 736   if (!frame->is_java_script()) { | 
| 708     return false; | 737     return false; | 
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1020 | 1049 | 
| 1021 bool LiveEditFunctionTracker::IsActive() { | 1050 bool LiveEditFunctionTracker::IsActive() { | 
| 1022   return false; | 1051   return false; | 
| 1023 } | 1052 } | 
| 1024 | 1053 | 
| 1025 #endif  // ENABLE_DEBUGGER_SUPPORT | 1054 #endif  // ENABLE_DEBUGGER_SUPPORT | 
| 1026 | 1055 | 
| 1027 | 1056 | 
| 1028 | 1057 | 
| 1029 } }  // namespace v8::internal | 1058 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|