OLD | NEW |
1 | 1 |
2 // Copyright 2012 the V8 project authors. All rights reserved. | 2 // Copyright 2012 the V8 project authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 #include <limits.h> // For LONG_MIN, LONG_MAX. | 6 #include <limits.h> // For LONG_MIN, LONG_MAX. |
7 | 7 |
8 #if V8_TARGET_ARCH_MIPS | 8 #if V8_TARGET_ARCH_MIPS |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 93 |
94 void MacroAssembler::StoreRoot(Register source, | 94 void MacroAssembler::StoreRoot(Register source, |
95 Heap::RootListIndex index, | 95 Heap::RootListIndex index, |
96 Condition cond, | 96 Condition cond, |
97 Register src1, const Operand& src2) { | 97 Register src1, const Operand& src2) { |
98 DCHECK(Heap::RootCanBeWrittenAfterInitialization(index)); | 98 DCHECK(Heap::RootCanBeWrittenAfterInitialization(index)); |
99 Branch(2, NegateCondition(cond), src1, src2); | 99 Branch(2, NegateCondition(cond), src1, src2); |
100 sw(source, MemOperand(s6, index << kPointerSizeLog2)); | 100 sw(source, MemOperand(s6, index << kPointerSizeLog2)); |
101 } | 101 } |
102 | 102 |
| 103 void MacroAssembler::PushCommonFrame(Register marker_reg) { |
| 104 if (marker_reg.is_valid()) { |
| 105 Push(ra, fp, marker_reg); |
| 106 Addu(fp, sp, Operand(kPointerSize)); |
| 107 } else { |
| 108 Push(ra, fp); |
| 109 mov(fp, sp); |
| 110 } |
| 111 } |
| 112 |
| 113 void MacroAssembler::PopCommonFrame(Register marker_reg) { |
| 114 if (marker_reg.is_valid()) { |
| 115 Pop(ra, fp, marker_reg); |
| 116 } else { |
| 117 Pop(ra, fp); |
| 118 } |
| 119 } |
| 120 |
| 121 void MacroAssembler::PushStandardFrame(Register function_reg) { |
| 122 int offset = -StandardFrameConstants::kContextOffset; |
| 123 if (function_reg.is_valid()) { |
| 124 Push(ra, fp, cp, function_reg); |
| 125 offset += kPointerSize; |
| 126 } else { |
| 127 Push(ra, fp, cp); |
| 128 } |
| 129 Addu(fp, sp, Operand(offset)); |
| 130 } |
103 | 131 |
104 // Push and pop all registers that can hold pointers. | 132 // Push and pop all registers that can hold pointers. |
105 void MacroAssembler::PushSafepointRegisters() { | 133 void MacroAssembler::PushSafepointRegisters() { |
106 // Safepoints expect a block of kNumSafepointRegisters values on the | 134 // Safepoints expect a block of kNumSafepointRegisters values on the |
107 // stack, so adjust the stack for unsaved registers. | 135 // stack, so adjust the stack for unsaved registers. |
108 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters; | 136 const int num_unsaved = kNumSafepointRegisters - kNumSafepointSavedRegisters; |
109 DCHECK(num_unsaved >= 0); | 137 DCHECK(num_unsaved >= 0); |
110 if (num_unsaved > 0) { | 138 if (num_unsaved > 0) { |
111 Subu(sp, sp, Operand(num_unsaved * kPointerSize)); | 139 Subu(sp, sp, Operand(num_unsaved * kPointerSize)); |
112 } | 140 } |
(...skipping 4761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4874 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); | 4902 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); |
4875 Branch(&ok); | 4903 Branch(&ok); |
4876 bind(&fail); | 4904 bind(&fail); |
4877 Abort(kGlobalFunctionsMustHaveInitialMap); | 4905 Abort(kGlobalFunctionsMustHaveInitialMap); |
4878 bind(&ok); | 4906 bind(&ok); |
4879 } | 4907 } |
4880 } | 4908 } |
4881 | 4909 |
4882 | 4910 |
4883 void MacroAssembler::StubPrologue() { | 4911 void MacroAssembler::StubPrologue() { |
4884 Push(ra, fp, cp); | 4912 li(at, Operand(Smi::FromInt(StackFrame::STUB))); |
4885 Push(Smi::FromInt(StackFrame::STUB)); | 4913 PushCommonFrame(at); |
4886 // Adjust FP to point to saved FP. | |
4887 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | |
4888 } | 4914 } |
4889 | 4915 |
4890 | 4916 |
4891 void MacroAssembler::Prologue(bool code_pre_aging) { | 4917 void MacroAssembler::Prologue(bool code_pre_aging) { |
4892 PredictableCodeSizeScope predictible_code_size_scope( | 4918 PredictableCodeSizeScope predictible_code_size_scope( |
4893 this, kNoCodeAgeSequenceLength); | 4919 this, kNoCodeAgeSequenceLength); |
4894 // The following three instructions must remain together and unmodified | 4920 // The following three instructions must remain together and unmodified |
4895 // for code aging to work properly. | 4921 // for code aging to work properly. |
4896 if (code_pre_aging) { | 4922 if (code_pre_aging) { |
4897 // Pre-age the code. | 4923 // Pre-age the code. |
4898 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); | 4924 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); |
4899 nop(Assembler::CODE_AGE_MARKER_NOP); | 4925 nop(Assembler::CODE_AGE_MARKER_NOP); |
4900 // Load the stub address to t9 and call it, | 4926 // Load the stub address to t9 and call it, |
4901 // GetCodeAgeAndParity() extracts the stub address from this instruction. | 4927 // GetCodeAgeAndParity() extracts the stub address from this instruction. |
4902 li(t9, | 4928 li(t9, |
4903 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), | 4929 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), |
4904 CONSTANT_SIZE); | 4930 CONSTANT_SIZE); |
4905 nop(); // Prevent jalr to jal optimization. | 4931 nop(); // Prevent jalr to jal optimization. |
4906 jalr(t9, a0); | 4932 jalr(t9, a0); |
4907 nop(); // Branch delay slot nop. | 4933 nop(); // Branch delay slot nop. |
4908 nop(); // Pad the empty space. | 4934 nop(); // Pad the empty space. |
4909 } else { | 4935 } else { |
4910 Push(ra, fp, cp, a1); | 4936 PushStandardFrame(a1); |
4911 nop(Assembler::CODE_AGE_SEQUENCE_NOP); | 4937 nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
4912 // Adjust fp to point to caller's fp. | |
4913 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | |
4914 } | 4938 } |
4915 } | 4939 } |
4916 | 4940 |
4917 | 4941 |
4918 void MacroAssembler::EmitLoadTypeFeedbackVector(Register vector) { | 4942 void MacroAssembler::EmitLoadTypeFeedbackVector(Register vector) { |
4919 lw(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 4943 lw(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
4920 lw(vector, FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset)); | 4944 lw(vector, FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset)); |
4921 lw(vector, | 4945 lw(vector, |
4922 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset)); | 4946 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset)); |
4923 } | 4947 } |
4924 | 4948 |
4925 | 4949 |
4926 void MacroAssembler::EnterFrame(StackFrame::Type type, | 4950 void MacroAssembler::EnterFrame(StackFrame::Type type, |
4927 bool load_constant_pool_pointer_reg) { | 4951 bool load_constant_pool_pointer_reg) { |
4928 // Out-of-line constant pool not implemented on mips. | 4952 // Out-of-line constant pool not implemented on mips. |
4929 UNREACHABLE(); | 4953 UNREACHABLE(); |
4930 } | 4954 } |
4931 | 4955 |
4932 | 4956 |
4933 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 4957 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
4934 addiu(sp, sp, -5 * kPointerSize); | 4958 int stack_offset, fp_offset; |
4935 li(t8, Operand(Smi::FromInt(type))); | 4959 if (type == StackFrame::INTERNAL) { |
4936 li(t9, Operand(CodeObject()), CONSTANT_SIZE); | 4960 stack_offset = -4 * kPointerSize; |
4937 sw(ra, MemOperand(sp, 4 * kPointerSize)); | 4961 fp_offset = 2 * kPointerSize; |
4938 sw(fp, MemOperand(sp, 3 * kPointerSize)); | 4962 } else { |
4939 sw(cp, MemOperand(sp, 2 * kPointerSize)); | 4963 stack_offset = -3 * kPointerSize; |
4940 sw(t8, MemOperand(sp, 1 * kPointerSize)); | 4964 fp_offset = 1 * kPointerSize; |
4941 sw(t9, MemOperand(sp, 0 * kPointerSize)); | 4965 } |
| 4966 addiu(sp, sp, stack_offset); |
| 4967 stack_offset = -stack_offset - kPointerSize; |
| 4968 sw(ra, MemOperand(sp, stack_offset)); |
| 4969 stack_offset -= kPointerSize; |
| 4970 sw(fp, MemOperand(sp, stack_offset)); |
| 4971 stack_offset -= kPointerSize; |
| 4972 li(t9, Operand(Smi::FromInt(type))); |
| 4973 sw(t9, MemOperand(sp, stack_offset)); |
| 4974 if (type == StackFrame::INTERNAL) { |
| 4975 DCHECK_EQ(stack_offset, kPointerSize); |
| 4976 li(t9, Operand(CodeObject())); |
| 4977 sw(t9, MemOperand(sp, 0)); |
| 4978 } else { |
| 4979 DCHECK_EQ(stack_offset, 0); |
| 4980 } |
4942 // Adjust FP to point to saved FP. | 4981 // Adjust FP to point to saved FP. |
4943 Addu(fp, sp, | 4982 Addu(fp, sp, Operand(fp_offset)); |
4944 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); | |
4945 } | 4983 } |
4946 | 4984 |
4947 | 4985 |
4948 void MacroAssembler::LeaveFrame(StackFrame::Type type) { | 4986 void MacroAssembler::LeaveFrame(StackFrame::Type type) { |
4949 mov(sp, fp); | 4987 addiu(sp, fp, 2 * kPointerSize); |
4950 lw(fp, MemOperand(sp, 0 * kPointerSize)); | 4988 lw(ra, MemOperand(fp, 1 * kPointerSize)); |
4951 lw(ra, MemOperand(sp, 1 * kPointerSize)); | 4989 lw(fp, MemOperand(fp, 0 * kPointerSize)); |
4952 addiu(sp, sp, 2 * kPointerSize); | |
4953 } | 4990 } |
4954 | 4991 |
4955 | 4992 void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) { |
4956 void MacroAssembler::EnterExitFrame(bool save_doubles, | |
4957 int stack_space) { | |
4958 // Set up the frame structure on the stack. | 4993 // Set up the frame structure on the stack. |
4959 STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); | 4994 STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); |
4960 STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); | 4995 STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); |
4961 STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); | 4996 STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); |
4962 | 4997 |
4963 // This is how the stack will look: | 4998 // This is how the stack will look: |
4964 // fp + 2 (==kCallerSPDisplacement) - old stack's end | 4999 // fp + 2 (==kCallerSPDisplacement) - old stack's end |
4965 // [fp + 1 (==kCallerPCOffset)] - saved old ra | 5000 // [fp + 1 (==kCallerPCOffset)] - saved old ra |
4966 // [fp + 0 (==kCallerFPOffset)] - saved old fp | 5001 // [fp + 0 (==kCallerFPOffset)] - saved old fp |
4967 // [fp - 1 (==kSPOffset)] - sp of the called function | 5002 // [fp - 1 StackFrame::EXIT Smi |
4968 // [fp - 2 (==kCodeOffset)] - CodeObject | 5003 // [fp - 2 (==kSPOffset)] - sp of the called function |
| 5004 // [fp - 3 (==kCodeOffset)] - CodeObject |
4969 // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the | 5005 // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the |
4970 // new stack (will contain saved ra) | 5006 // new stack (will contain saved ra) |
4971 | 5007 |
4972 // Save registers. | 5008 // Save registers and reserve room for saved entry sp and code object. |
4973 addiu(sp, sp, -4 * kPointerSize); | 5009 addiu(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp); |
4974 sw(ra, MemOperand(sp, 3 * kPointerSize)); | 5010 sw(ra, MemOperand(sp, 4 * kPointerSize)); |
4975 sw(fp, MemOperand(sp, 2 * kPointerSize)); | 5011 sw(fp, MemOperand(sp, 3 * kPointerSize)); |
4976 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer. | 5012 li(at, Operand(Smi::FromInt(StackFrame::EXIT))); |
| 5013 sw(at, MemOperand(sp, 2 * kPointerSize)); |
| 5014 // Set up new frame pointer. |
| 5015 addiu(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp); |
4977 | 5016 |
4978 if (emit_debug_code()) { | 5017 if (emit_debug_code()) { |
4979 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 5018 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
4980 } | 5019 } |
4981 | 5020 |
4982 // Accessed from ExitFrame::code_slot. | 5021 // Accessed from ExitFrame::code_slot. |
4983 li(t8, Operand(CodeObject()), CONSTANT_SIZE); | 5022 li(t8, Operand(CodeObject()), CONSTANT_SIZE); |
4984 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); | 5023 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); |
4985 | 5024 |
4986 // Save the frame pointer and the context in top. | 5025 // Save the frame pointer and the context in top. |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5913 if (mag.shift > 0) sra(result, result, mag.shift); | 5952 if (mag.shift > 0) sra(result, result, mag.shift); |
5914 srl(at, dividend, 31); | 5953 srl(at, dividend, 31); |
5915 Addu(result, result, Operand(at)); | 5954 Addu(result, result, Operand(at)); |
5916 } | 5955 } |
5917 | 5956 |
5918 | 5957 |
5919 } // namespace internal | 5958 } // namespace internal |
5920 } // namespace v8 | 5959 } // namespace v8 |
5921 | 5960 |
5922 #endif // V8_TARGET_ARCH_MIPS | 5961 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |