OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 #include "src/compiler/code-generator-impl.h" | 6 #include "src/compiler/code-generator-impl.h" |
7 #include "src/compiler/gap-resolver.h" | 7 #include "src/compiler/gap-resolver.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/mips/macro-assembler-mips.h" | 9 #include "src/mips/macro-assembler-mips.h" |
10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 UNREACHABLE(); | 99 UNREACHABLE(); |
100 } | 100 } |
101 UNREACHABLE(); | 101 UNREACHABLE(); |
102 return MemOperand(no_reg); | 102 return MemOperand(no_reg); |
103 } | 103 } |
104 | 104 |
105 MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } | 105 MemOperand MemoryOperand(size_t index = 0) { return MemoryOperand(&index); } |
106 | 106 |
107 MemOperand ToMemOperand(InstructionOperand* op) const { | 107 MemOperand ToMemOperand(InstructionOperand* op) const { |
108 DCHECK(op != NULL); | 108 DCHECK(op != NULL); |
109 DCHECK(!op->IsRegister()); | |
110 DCHECK(!op->IsDoubleRegister()); | |
111 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 109 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
112 // The linkage computes where all spill slots are located. | 110 FrameOffset offset = |
113 FrameOffset offset = linkage()->GetFrameOffset( | 111 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); |
114 AllocatedOperand::cast(op)->index(), frame(), 0); | |
115 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 112 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
116 } | 113 } |
117 }; | 114 }; |
118 | 115 |
119 | 116 |
120 static inline bool HasRegisterInput(Instruction* instr, size_t index) { | 117 static inline bool HasRegisterInput(Instruction* instr, size_t index) { |
121 return instr->InputAt(index)->IsRegister(); | 118 return instr->InputAt(index)->IsRegister(); |
122 } | 119 } |
123 | 120 |
124 | 121 |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1090 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1094 } else if (descriptor->IsJSFunctionCall()) { | 1091 } else if (descriptor->IsJSFunctionCall()) { |
1095 CompilationInfo* info = this->info(); | 1092 CompilationInfo* info = this->info(); |
1096 __ Prologue(info->IsCodePreAgingActive()); | 1093 __ Prologue(info->IsCodePreAgingActive()); |
1097 frame()->SetRegisterSaveAreaSize( | 1094 frame()->SetRegisterSaveAreaSize( |
1098 StandardFrameConstants::kFixedFrameSizeFromFp); | 1095 StandardFrameConstants::kFixedFrameSizeFromFp); |
1099 } else if (needs_frame_) { | 1096 } else if (needs_frame_) { |
1100 __ StubPrologue(); | 1097 __ StubPrologue(); |
1101 frame()->SetRegisterSaveAreaSize( | 1098 frame()->SetRegisterSaveAreaSize( |
1102 StandardFrameConstants::kFixedFrameSizeFromFp); | 1099 StandardFrameConstants::kFixedFrameSizeFromFp); |
| 1100 } else { |
| 1101 frame()->SetPCOnStack(false); |
1103 } | 1102 } |
1104 | 1103 |
1105 if (info()->is_osr()) { | 1104 if (info()->is_osr()) { |
1106 // TurboFan OSR-compiled functions cannot be entered directly. | 1105 // TurboFan OSR-compiled functions cannot be entered directly. |
1107 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1106 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1108 | 1107 |
1109 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1108 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1110 // frame is still on the stack. Optimized code uses OSR values directly from | 1109 // frame is still on the stack. Optimized code uses OSR values directly from |
1111 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1110 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1112 // remaining stack slots. | 1111 // remaining stack slots. |
1113 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1112 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1114 osr_pc_offset_ = __ pc_offset(); | 1113 osr_pc_offset_ = __ pc_offset(); |
1115 // TODO(titzer): cannot address target function == local #-1 | 1114 // TODO(titzer): cannot address target function == local #-1 |
1116 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1115 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1117 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); | 1116 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); |
1118 stack_slots -= frame()->GetOsrStackSlotCount(); | 1117 stack_slots -= frame()->GetOsrStackSlotCount(); |
1119 } | 1118 } |
1120 | 1119 |
1121 if (stack_slots > 0) { | 1120 if (stack_slots > 0) { |
1122 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); | 1121 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); |
1123 } | 1122 } |
1124 } | 1123 } |
1125 | 1124 |
1126 | 1125 |
1127 void CodeGenerator::AssembleReturn() { | 1126 void CodeGenerator::AssembleReturn() { |
1128 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1127 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1129 int stack_slots = frame()->GetSpillSlotCount(); | 1128 int stack_slots = frame()->GetSpillSlotCount(); |
| 1129 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
1130 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1130 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1131 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1131 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1132 // Remove this frame's spill slots first. | 1132 // Remove this frame's spill slots first. |
1133 if (stack_slots > 0) { | 1133 if (stack_slots > 0) { |
1134 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); | 1134 __ Addu(sp, sp, Operand(stack_slots * kPointerSize)); |
1135 } | 1135 } |
1136 // Restore FPU registers. | 1136 // Restore FPU registers. |
1137 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); | 1137 const RegList saves_fpu = descriptor->CalleeSavedFPRegisters(); |
1138 __ MultiPopFPU(saves_fpu); | 1138 __ MultiPopFPU(saves_fpu); |
1139 | 1139 |
1140 // Restore GP registers. | 1140 // Restore GP registers. |
1141 const RegList saves = descriptor->CalleeSavedRegisters(); | 1141 const RegList saves = descriptor->CalleeSavedRegisters(); |
1142 __ MultiPop(saves); | 1142 __ MultiPop(saves); |
1143 } | 1143 } |
1144 __ mov(sp, fp); | 1144 __ mov(sp, fp); |
1145 __ Pop(ra, fp); | 1145 __ Pop(ra, fp); |
1146 __ Ret(); | |
1147 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1146 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1148 // Canonicalize JSFunction return sites for now. | 1147 // Canonicalize JSFunction return sites for now. |
1149 if (return_label_.is_bound()) { | 1148 if (return_label_.is_bound()) { |
1150 __ Branch(&return_label_); | 1149 __ Branch(&return_label_); |
| 1150 return; |
1151 } else { | 1151 } else { |
1152 __ bind(&return_label_); | 1152 __ bind(&return_label_); |
1153 __ mov(sp, fp); | 1153 __ mov(sp, fp); |
1154 __ Pop(ra, fp); | 1154 __ Pop(ra, fp); |
1155 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | |
1156 if (pop_count != 0) { | |
1157 __ DropAndRet(pop_count); | |
1158 } else { | |
1159 __ Ret(); | |
1160 } | |
1161 } | 1155 } |
| 1156 } |
| 1157 if (pop_count != 0) { |
| 1158 __ DropAndRet(pop_count); |
1162 } else { | 1159 } else { |
1163 __ Ret(); | 1160 __ Ret(); |
1164 } | 1161 } |
1165 } | 1162 } |
1166 | 1163 |
1167 | 1164 |
1168 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1165 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1169 InstructionOperand* destination) { | 1166 InstructionOperand* destination) { |
1170 MipsOperandConverter g(this, NULL); | 1167 MipsOperandConverter g(this, NULL); |
1171 // Dispatch on the source and destination operand kinds. Not all | 1168 // Dispatch on the source and destination operand kinds. Not all |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 } | 1366 } |
1370 } | 1367 } |
1371 } | 1368 } |
1372 } | 1369 } |
1373 | 1370 |
1374 #undef __ | 1371 #undef __ |
1375 | 1372 |
1376 } // namespace compiler | 1373 } // namespace compiler |
1377 } // namespace internal | 1374 } // namespace internal |
1378 } // namespace v8 | 1375 } // namespace v8 |
OLD | NEW |