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

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

Issue 1950913004: [Interpreter] Fix bytecode offset for stack overflows. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Also fixes error-to-sttring-stack-overflow.html Created 4 years, 7 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
« no previous file with comments | « src/s390/macro-assembler-s390.h ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X64 5 #if V8_TARGET_ARCH_X64
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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 __ CompareRoot(kInterpreterBytecodeArrayRegister, 642 __ CompareRoot(kInterpreterBytecodeArrayRegister,
643 Heap::kUndefinedValueRootIndex); 643 Heap::kUndefinedValueRootIndex);
644 __ j(equal, &bytecode_array_not_present); 644 __ j(equal, &bytecode_array_not_present);
645 if (FLAG_debug_code) { 645 if (FLAG_debug_code) {
646 __ AssertNotSmi(kInterpreterBytecodeArrayRegister); 646 __ AssertNotSmi(kInterpreterBytecodeArrayRegister);
647 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE, 647 __ CmpObjectType(kInterpreterBytecodeArrayRegister, BYTECODE_ARRAY_TYPE,
648 rax); 648 rax);
649 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); 649 __ Assert(equal, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry);
650 } 650 }
651 651
652 // Push bytecode array. 652 // Load initial bytecode offset.
653 __ movp(kInterpreterBytecodeOffsetRegister,
654 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
655
656 // Push bytecode array and Smi tagged bytecode offset.
653 __ Push(kInterpreterBytecodeArrayRegister); 657 __ Push(kInterpreterBytecodeArrayRegister);
654 // Push zero for bytecode array offset. 658 __ Integer32ToSmi(rcx, kInterpreterBytecodeOffsetRegister);
655 __ Push(Immediate(0)); 659 __ Push(rcx);
656 660
657 // Allocate the local and temporary register file on the stack. 661 // Allocate the local and temporary register file on the stack.
658 { 662 {
659 // Load frame size from the BytecodeArray object. 663 // Load frame size from the BytecodeArray object.
660 __ movl(rcx, FieldOperand(kInterpreterBytecodeArrayRegister, 664 __ movl(rcx, FieldOperand(kInterpreterBytecodeArrayRegister,
661 BytecodeArray::kFrameSizeOffset)); 665 BytecodeArray::kFrameSizeOffset));
662 666
663 // Do a stack check to ensure we don't go over the limit. 667 // Do a stack check to ensure we don't go over the limit.
664 Label ok; 668 Label ok;
665 __ movp(rdx, rsp); 669 __ movp(rdx, rsp);
(...skipping 10 matching lines...) Expand all
676 __ j(always, &loop_check); 680 __ j(always, &loop_check);
677 __ bind(&loop_header); 681 __ bind(&loop_header);
678 // TODO(rmcilroy): Consider doing more than one push per loop iteration. 682 // TODO(rmcilroy): Consider doing more than one push per loop iteration.
679 __ Push(rdx); 683 __ Push(rdx);
680 // Continue loop if not done. 684 // Continue loop if not done.
681 __ bind(&loop_check); 685 __ bind(&loop_check);
682 __ subp(rcx, Immediate(kPointerSize)); 686 __ subp(rcx, Immediate(kPointerSize));
683 __ j(greater_equal, &loop_header, Label::kNear); 687 __ j(greater_equal, &loop_header, Label::kNear);
684 } 688 }
685 689
686 // Load accumulator, register file, bytecode offset, dispatch table into 690 // Load accumulator and dispatch table into registers.
687 // registers.
688 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); 691 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex);
689 __ movp(r11, rbp);
690 __ addp(r11, Immediate(InterpreterFrameConstants::kRegisterFileFromFp));
691 __ movp(kInterpreterBytecodeOffsetRegister,
692 Immediate(BytecodeArray::kHeaderSize - kHeapObjectTag));
693 __ Move( 692 __ Move(
694 kInterpreterDispatchTableRegister, 693 kInterpreterDispatchTableRegister,
695 ExternalReference::interpreter_dispatch_table_address(masm->isolate())); 694 ExternalReference::interpreter_dispatch_table_address(masm->isolate()));
696 695
697 // Dispatch to the first bytecode handler for the function. 696 // Dispatch to the first bytecode handler for the function.
698 __ movzxbp(rbx, Operand(kInterpreterBytecodeArrayRegister, 697 __ movzxbp(rbx, Operand(kInterpreterBytecodeArrayRegister,
699 kInterpreterBytecodeOffsetRegister, times_1, 0)); 698 kInterpreterBytecodeOffsetRegister, times_1, 0));
700 __ movp(rbx, Operand(kInterpreterDispatchTableRegister, rbx, 699 __ movp(rbx, Operand(kInterpreterDispatchTableRegister, rbx,
701 times_pointer_size, 0)); 700 times_pointer_size, 0));
702 __ call(rbx); 701 __ call(rbx);
(...skipping 2263 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 __ ret(0); 2965 __ ret(0);
2967 } 2966 }
2968 2967
2969 2968
2970 #undef __ 2969 #undef __
2971 2970
2972 } // namespace internal 2971 } // namespace internal
2973 } // namespace v8 2972 } // namespace v8
2974 2973
2975 #endif // V8_TARGET_ARCH_X64 2974 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/s390/macro-assembler-s390.h ('k') | src/x87/builtins-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698