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

Side by Side Diff: src/mips/macro-assembler-mips.cc

Issue 1696043002: [runtime] Unify and simplify how frames are marked (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix merge problems Created 4 years, 9 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 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
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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 507
480 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, 508 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
481 Register scratch, 509 Register scratch,
482 Label* miss) { 510 Label* miss) {
483 Label same_contexts; 511 Label same_contexts;
484 512
485 DCHECK(!holder_reg.is(scratch)); 513 DCHECK(!holder_reg.is(scratch));
486 DCHECK(!holder_reg.is(at)); 514 DCHECK(!holder_reg.is(at));
487 DCHECK(!scratch.is(at)); 515 DCHECK(!scratch.is(at));
488 516
489 // Load current lexical context from the stack frame. 517 // Load current lexical context from the active StandardFrame, which
490 lw(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); 518 // may require crawling past STUB frames.
519 Label load_context;
520 Label has_context;
521 mov(at, fp);
522 bind(&load_context);
523 lw(scratch, MemOperand(at, CommonFrameConstants::kContextOrFrameTypeOffset));
524 JumpIfNotSmi(scratch, &has_context);
525 lw(at, MemOperand(at, CommonFrameConstants::kCallerFPOffset));
526 b(&load_context);
527 bind(&has_context);
528
491 // In debug mode, make sure the lexical context is set. 529 // In debug mode, make sure the lexical context is set.
492 #ifdef DEBUG 530 #ifdef DEBUG
493 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext, 531 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext,
494 scratch, Operand(zero_reg)); 532 scratch, Operand(zero_reg));
495 #endif 533 #endif
496 534
497 // Load the native context of the current context. 535 // Load the native context of the current context.
498 lw(scratch, ContextMemOperand(scratch, Context::NATIVE_CONTEXT_INDEX)); 536 lw(scratch, ContextMemOperand(scratch, Context::NATIVE_CONTEXT_INDEX));
499 537
500 // Check the context is a native context. 538 // Check the context is a native context.
(...skipping 4430 matching lines...) Expand 10 before | Expand all | Expand 10 after
4931 if (emit_debug_code()) { 4969 if (emit_debug_code()) {
4932 Label ok, fail; 4970 Label ok, fail;
4933 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK); 4971 CheckMap(map, scratch, Heap::kMetaMapRootIndex, &fail, DO_SMI_CHECK);
4934 Branch(&ok); 4972 Branch(&ok);
4935 bind(&fail); 4973 bind(&fail);
4936 Abort(kGlobalFunctionsMustHaveInitialMap); 4974 Abort(kGlobalFunctionsMustHaveInitialMap);
4937 bind(&ok); 4975 bind(&ok);
4938 } 4976 }
4939 } 4977 }
4940 4978
4941 4979 void MacroAssembler::StubPrologue(StackFrame::Type type) {
4942 void MacroAssembler::StubPrologue() { 4980 li(at, Operand(Smi::FromInt(type)));
4943 Push(ra, fp, cp); 4981 PushCommonFrame(at);
4944 Push(Smi::FromInt(StackFrame::STUB));
4945 // Adjust FP to point to saved FP.
4946 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
4947 } 4982 }
4948 4983
4949 4984
4950 void MacroAssembler::Prologue(bool code_pre_aging) { 4985 void MacroAssembler::Prologue(bool code_pre_aging) {
4951 PredictableCodeSizeScope predictible_code_size_scope( 4986 PredictableCodeSizeScope predictible_code_size_scope(
4952 this, kNoCodeAgeSequenceLength); 4987 this, kNoCodeAgeSequenceLength);
4953 // The following three instructions must remain together and unmodified 4988 // The following three instructions must remain together and unmodified
4954 // for code aging to work properly. 4989 // for code aging to work properly.
4955 if (code_pre_aging) { 4990 if (code_pre_aging) {
4956 // Pre-age the code. 4991 // Pre-age the code.
4957 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); 4992 Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
4958 nop(Assembler::CODE_AGE_MARKER_NOP); 4993 nop(Assembler::CODE_AGE_MARKER_NOP);
4959 // Load the stub address to t9 and call it, 4994 // Load the stub address to t9 and call it,
4960 // GetCodeAgeAndParity() extracts the stub address from this instruction. 4995 // GetCodeAgeAndParity() extracts the stub address from this instruction.
4961 li(t9, 4996 li(t9,
4962 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())), 4997 Operand(reinterpret_cast<uint32_t>(stub->instruction_start())),
4963 CONSTANT_SIZE); 4998 CONSTANT_SIZE);
4964 nop(); // Prevent jalr to jal optimization. 4999 nop(); // Prevent jalr to jal optimization.
4965 jalr(t9, a0); 5000 jalr(t9, a0);
4966 nop(); // Branch delay slot nop. 5001 nop(); // Branch delay slot nop.
4967 nop(); // Pad the empty space. 5002 nop(); // Pad the empty space.
4968 } else { 5003 } else {
4969 Push(ra, fp, cp, a1); 5004 PushStandardFrame(a1);
4970 nop(Assembler::CODE_AGE_SEQUENCE_NOP); 5005 nop(Assembler::CODE_AGE_SEQUENCE_NOP);
4971 // Adjust fp to point to caller's fp.
4972 Addu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp));
4973 } 5006 }
4974 } 5007 }
4975 5008
4976 5009
4977 void MacroAssembler::EmitLoadTypeFeedbackVector(Register vector) { 5010 void MacroAssembler::EmitLoadTypeFeedbackVector(Register vector) {
4978 lw(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); 5011 lw(vector, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
4979 lw(vector, FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 5012 lw(vector, FieldMemOperand(vector, JSFunction::kSharedFunctionInfoOffset));
4980 lw(vector, 5013 lw(vector,
4981 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset)); 5014 FieldMemOperand(vector, SharedFunctionInfo::kFeedbackVectorOffset));
4982 } 5015 }
4983 5016
4984 5017
4985 void MacroAssembler::EnterFrame(StackFrame::Type type, 5018 void MacroAssembler::EnterFrame(StackFrame::Type type,
4986 bool load_constant_pool_pointer_reg) { 5019 bool load_constant_pool_pointer_reg) {
4987 // Out-of-line constant pool not implemented on mips. 5020 // Out-of-line constant pool not implemented on mips.
4988 UNREACHABLE(); 5021 UNREACHABLE();
4989 } 5022 }
4990 5023
4991 5024
4992 void MacroAssembler::EnterFrame(StackFrame::Type type) { 5025 void MacroAssembler::EnterFrame(StackFrame::Type type) {
4993 addiu(sp, sp, -5 * kPointerSize); 5026 int stack_offset, fp_offset;
4994 li(t8, Operand(Smi::FromInt(type))); 5027 if (type == StackFrame::INTERNAL) {
4995 li(t9, Operand(CodeObject()), CONSTANT_SIZE); 5028 stack_offset = -4 * kPointerSize;
4996 sw(ra, MemOperand(sp, 4 * kPointerSize)); 5029 fp_offset = 2 * kPointerSize;
4997 sw(fp, MemOperand(sp, 3 * kPointerSize)); 5030 } else {
4998 sw(cp, MemOperand(sp, 2 * kPointerSize)); 5031 stack_offset = -3 * kPointerSize;
4999 sw(t8, MemOperand(sp, 1 * kPointerSize)); 5032 fp_offset = 1 * kPointerSize;
5000 sw(t9, MemOperand(sp, 0 * kPointerSize)); 5033 }
5034 addiu(sp, sp, stack_offset);
5035 stack_offset = -stack_offset - kPointerSize;
5036 sw(ra, MemOperand(sp, stack_offset));
5037 stack_offset -= kPointerSize;
5038 sw(fp, MemOperand(sp, stack_offset));
5039 stack_offset -= kPointerSize;
5040 li(t9, Operand(Smi::FromInt(type)));
5041 sw(t9, MemOperand(sp, stack_offset));
5042 if (type == StackFrame::INTERNAL) {
5043 DCHECK_EQ(stack_offset, kPointerSize);
5044 li(t9, Operand(CodeObject()));
5045 sw(t9, MemOperand(sp, 0));
5046 } else {
5047 DCHECK_EQ(stack_offset, 0);
5048 }
5001 // Adjust FP to point to saved FP. 5049 // Adjust FP to point to saved FP.
5002 Addu(fp, sp, 5050 Addu(fp, sp, Operand(fp_offset));
5003 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize));
5004 } 5051 }
5005 5052
5006 5053
5007 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 5054 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
5008 mov(sp, fp); 5055 addiu(sp, fp, 2 * kPointerSize);
5009 lw(fp, MemOperand(sp, 0 * kPointerSize)); 5056 lw(ra, MemOperand(fp, 1 * kPointerSize));
5010 lw(ra, MemOperand(sp, 1 * kPointerSize)); 5057 lw(fp, MemOperand(fp, 0 * kPointerSize));
5011 addiu(sp, sp, 2 * kPointerSize);
5012 } 5058 }
5013 5059
5014 5060 void MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space) {
5015 void MacroAssembler::EnterExitFrame(bool save_doubles,
5016 int stack_space) {
5017 // Set up the frame structure on the stack. 5061 // Set up the frame structure on the stack.
5018 STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement); 5062 STATIC_ASSERT(2 * kPointerSize == ExitFrameConstants::kCallerSPDisplacement);
5019 STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset); 5063 STATIC_ASSERT(1 * kPointerSize == ExitFrameConstants::kCallerPCOffset);
5020 STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset); 5064 STATIC_ASSERT(0 * kPointerSize == ExitFrameConstants::kCallerFPOffset);
5021 5065
5022 // This is how the stack will look: 5066 // This is how the stack will look:
5023 // fp + 2 (==kCallerSPDisplacement) - old stack's end 5067 // fp + 2 (==kCallerSPDisplacement) - old stack's end
5024 // [fp + 1 (==kCallerPCOffset)] - saved old ra 5068 // [fp + 1 (==kCallerPCOffset)] - saved old ra
5025 // [fp + 0 (==kCallerFPOffset)] - saved old fp 5069 // [fp + 0 (==kCallerFPOffset)] - saved old fp
5026 // [fp - 1 (==kSPOffset)] - sp of the called function 5070 // [fp - 1 StackFrame::EXIT Smi
5027 // [fp - 2 (==kCodeOffset)] - CodeObject 5071 // [fp - 2 (==kSPOffset)] - sp of the called function
5072 // [fp - 3 (==kCodeOffset)] - CodeObject
5028 // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the 5073 // fp - (2 + stack_space + alignment) == sp == [fp - kSPOffset] - top of the
5029 // new stack (will contain saved ra) 5074 // new stack (will contain saved ra)
5030 5075
5031 // Save registers. 5076 // Save registers and reserve room for saved entry sp and code object.
5032 addiu(sp, sp, -4 * kPointerSize); 5077 addiu(sp, sp, -2 * kPointerSize - ExitFrameConstants::kFixedFrameSizeFromFp);
5033 sw(ra, MemOperand(sp, 3 * kPointerSize)); 5078 sw(ra, MemOperand(sp, 4 * kPointerSize));
5034 sw(fp, MemOperand(sp, 2 * kPointerSize)); 5079 sw(fp, MemOperand(sp, 3 * kPointerSize));
5035 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer. 5080 li(at, Operand(Smi::FromInt(StackFrame::EXIT)));
5081 sw(at, MemOperand(sp, 2 * kPointerSize));
5082 // Set up new frame pointer.
5083 addiu(fp, sp, ExitFrameConstants::kFixedFrameSizeFromFp);
5036 5084
5037 if (emit_debug_code()) { 5085 if (emit_debug_code()) {
5038 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); 5086 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset));
5039 } 5087 }
5040 5088
5041 // Accessed from ExitFrame::code_slot. 5089 // Accessed from ExitFrame::code_slot.
5042 li(t8, Operand(CodeObject()), CONSTANT_SIZE); 5090 li(t8, Operand(CodeObject()), CONSTANT_SIZE);
5043 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); 5091 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset));
5044 5092
5045 // Save the frame pointer and the context in top. 5093 // Save the frame pointer and the context in top.
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
5972 if (mag.shift > 0) sra(result, result, mag.shift); 6020 if (mag.shift > 0) sra(result, result, mag.shift);
5973 srl(at, dividend, 31); 6021 srl(at, dividend, 31);
5974 Addu(result, result, Operand(at)); 6022 Addu(result, result, Operand(at));
5975 } 6023 }
5976 6024
5977 6025
5978 } // namespace internal 6026 } // namespace internal
5979 } // namespace v8 6027 } // namespace v8
5980 6028
5981 #endif // V8_TARGET_ARCH_MIPS 6029 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698