Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 1703453002: [interpreter, debugger] support debug breaks via bytecode array copy (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // Push dispatch table pointer. 549 // Push dispatch table pointer.
550 __ mov(eax, Immediate(ExternalReference::interpreter_dispatch_table_address( 550 __ mov(eax, Immediate(ExternalReference::interpreter_dispatch_table_address(
551 masm->isolate()))); 551 masm->isolate())));
552 __ push(eax); 552 __ push(eax);
553 // Push zero for bytecode array offset. 553 // Push zero for bytecode array offset.
554 __ push(Immediate(0)); 554 __ push(Immediate(0));
555 555
556 // Get the bytecode array from the function object and load the pointer to the 556 // Get the bytecode array from the function object and load the pointer to the
557 // first entry into edi (InterpreterBytecodeRegister). 557 // first entry into edi (InterpreterBytecodeRegister).
558 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 558 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
559
560 Label load_debug_bytecode_array, bytecode_array_loaded;
561 __ cmp(FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset),
562 Immediate(DebugInfo::uninitialized()));
563 __ j(not_equal, &load_debug_bytecode_array);
559 __ mov(kInterpreterBytecodeArrayRegister, 564 __ mov(kInterpreterBytecodeArrayRegister,
560 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset)); 565 FieldOperand(eax, SharedFunctionInfo::kFunctionDataOffset));
566 __ bind(&bytecode_array_loaded);
561 567
562 if (FLAG_debug_code) { 568 if (FLAG_debug_code) {
563 // Check function data field is actually a BytecodeArray object. 569 // Check function data field is actually a BytecodeArray object.
564 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); 570 __ AssertNotSmi(kInterpreterBytecodeArrayRegister);
565 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, 571 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE,
566 eax); 572 eax);
567 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); 573 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
568 } 574 }
569 575
570 // Allocate the local and temporary register file on the stack. 576 // Allocate the local and temporary register file on the stack.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // TODO(rmcilroy): Remove this once we move the dispatch table back into a 632 // TODO(rmcilroy): Remove this once we move the dispatch table back into a
627 // register. 633 // register.
628 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); 634 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value()));
629 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging 635 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
630 // and header removal. 636 // and header removal.
631 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); 637 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag));
632 __ call(ebx); 638 __ call(ebx);
633 639
634 // Even though the first bytecode handler was called, we will never return. 640 // Even though the first bytecode handler was called, we will never return.
635 __ Abort(kUnexpectedReturnFromBytecodeHandler); 641 __ Abort(kUnexpectedReturnFromBytecodeHandler);
642
643 // Load debug copy of the bytecode array.
644 __ bind(&load_debug_bytecode_array);
645 Register debug_info = kInterpreterBytecodeArrayRegister;
646 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset));
647 __ mov(kInterpreterBytecodeArrayRegister,
648 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex));
649 __ jmp(&bytecode_array_loaded);
636 } 650 }
637 651
638 652
639 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { 653 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
640 // TODO(rmcilroy): List of things not currently dealt with here but done in 654 // TODO(rmcilroy): List of things not currently dealt with here but done in
641 // fullcodegen's EmitReturnSequence. 655 // fullcodegen's EmitReturnSequence.
642 // - Supporting FLAG_trace for Runtime::TraceExit. 656 // - Supporting FLAG_trace for Runtime::TraceExit.
643 // - Support profiler (specifically decrementing profiling_counter 657 // - Support profiler (specifically decrementing profiling_counter
644 // appropriately and calling out to HandleInterrupts if necessary). 658 // appropriately and calling out to HandleInterrupts if necessary).
645 659
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { 762 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) {
749 // Initialize register file register. 763 // Initialize register file register.
750 __ mov(kInterpreterRegisterFileRegister, ebp); 764 __ mov(kInterpreterRegisterFileRegister, ebp);
751 __ add(kInterpreterRegisterFileRegister, 765 __ add(kInterpreterRegisterFileRegister,
752 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); 766 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp));
753 767
754 // Get the bytecode array pointer from the frame. 768 // Get the bytecode array pointer from the frame.
755 __ mov(ebx, Operand(kInterpreterRegisterFileRegister, 769 __ mov(ebx, Operand(kInterpreterRegisterFileRegister,
756 InterpreterFrameConstants::kFunctionFromRegisterPointer)); 770 InterpreterFrameConstants::kFunctionFromRegisterPointer));
757 __ mov(ebx, FieldOperand(ebx, JSFunction::kSharedFunctionInfoOffset)); 771 __ mov(ebx, FieldOperand(ebx, JSFunction::kSharedFunctionInfoOffset));
772
773 Label load_debug_bytecode_array, bytecode_array_loaded;
774 __ cmp(FieldOperand(ebx, SharedFunctionInfo::kDebugInfoOffset),
775 Immediate(DebugInfo::uninitialized()));
776 __ j(not_equal, &load_debug_bytecode_array);
758 __ mov(kInterpreterBytecodeArrayRegister, 777 __ mov(kInterpreterBytecodeArrayRegister,
759 FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset)); 778 FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset));
779 __ bind(&bytecode_array_loaded);
760 780
761 if (FLAG_debug_code) { 781 if (FLAG_debug_code) {
762 // Check function data field is actually a BytecodeArray object. 782 // Check function data field is actually a BytecodeArray object.
763 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); 783 __ AssertNotSmi(kInterpreterBytecodeArrayRegister);
764 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, 784 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE,
765 ebx); 785 ebx);
766 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); 786 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
767 } 787 }
768 788
769 // Get the target bytecode offset from the frame. 789 // Get the target bytecode offset from the frame.
(...skipping 18 matching lines...) Expand all
788 808
789 // Get the context from the frame. 809 // Get the context from the frame.
790 __ mov(kContextRegister, 810 __ mov(kContextRegister,
791 Operand(kInterpreterRegisterFileRegister, 811 Operand(kInterpreterRegisterFileRegister,
792 InterpreterFrameConstants::kContextFromRegisterPointer)); 812 InterpreterFrameConstants::kContextFromRegisterPointer));
793 813
794 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging 814 // TODO(rmcilroy): Make dispatch table point to code entrys to avoid untagging
795 // and header removal. 815 // and header removal.
796 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag)); 816 __ add(ebx, Immediate(Code::kHeaderSize - kHeapObjectTag));
797 __ jmp(ebx); 817 __ jmp(ebx);
818
819 // Load debug copy of the bytecode array.
820 __ bind(&load_debug_bytecode_array);
821 Register debug_info = kInterpreterBytecodeArrayRegister;
822 __ mov(debug_info, FieldOperand(ebx, SharedFunctionInfo::kDebugInfoOffset));
823 __ mov(kInterpreterBytecodeArrayRegister,
824 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex));
825 __ jmp(&bytecode_array_loaded);
798 } 826 }
799 827
800 828
801 static void Generate_InterpreterNotifyDeoptimizedHelper( 829 static void Generate_InterpreterNotifyDeoptimizedHelper(
802 MacroAssembler* masm, Deoptimizer::BailoutType type) { 830 MacroAssembler* masm, Deoptimizer::BailoutType type) {
803 // Enter an internal frame. 831 // Enter an internal frame.
804 { 832 {
805 FrameScope scope(masm, StackFrame::INTERNAL); 833 FrameScope scope(masm, StackFrame::INTERNAL);
806 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register. 834 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register.
807 835
(...skipping 1964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2772 2800
2773 __ bind(&ok); 2801 __ bind(&ok);
2774 __ ret(0); 2802 __ ret(0);
2775 } 2803 }
2776 2804
2777 #undef __ 2805 #undef __
2778 } // namespace internal 2806 } // namespace internal
2779 } // namespace v8 2807 } // namespace v8
2780 2808
2781 #endif // V8_TARGET_ARCH_IA32 2809 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698