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()); |
109 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 111 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
110 FrameOffset offset = | 112 // The linkage computes where all spill slots are located. |
111 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); | 113 FrameOffset offset = linkage()->GetFrameOffset( |
| 114 AllocatedOperand::cast(op)->index(), frame(), 0); |
112 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 115 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
113 } | 116 } |
114 }; | 117 }; |
115 | 118 |
116 | 119 |
117 static inline bool HasRegisterInput(Instruction* instr, size_t index) { | 120 static inline bool HasRegisterInput(Instruction* instr, size_t index) { |
118 return instr->InputAt(index)->IsRegister(); | 121 return instr->InputAt(index)->IsRegister(); |
119 } | 122 } |
120 | 123 |
121 | 124 |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 frame()->SetRegisterSaveAreaSize(register_save_area_size); | 1093 frame()->SetRegisterSaveAreaSize(register_save_area_size); |
1091 } else if (descriptor->IsJSFunctionCall()) { | 1094 } else if (descriptor->IsJSFunctionCall()) { |
1092 CompilationInfo* info = this->info(); | 1095 CompilationInfo* info = this->info(); |
1093 __ Prologue(info->IsCodePreAgingActive()); | 1096 __ Prologue(info->IsCodePreAgingActive()); |
1094 frame()->SetRegisterSaveAreaSize( | 1097 frame()->SetRegisterSaveAreaSize( |
1095 StandardFrameConstants::kFixedFrameSizeFromFp); | 1098 StandardFrameConstants::kFixedFrameSizeFromFp); |
1096 } else if (needs_frame_) { | 1099 } else if (needs_frame_) { |
1097 __ StubPrologue(); | 1100 __ StubPrologue(); |
1098 frame()->SetRegisterSaveAreaSize( | 1101 frame()->SetRegisterSaveAreaSize( |
1099 StandardFrameConstants::kFixedFrameSizeFromFp); | 1102 StandardFrameConstants::kFixedFrameSizeFromFp); |
1100 } else { | |
1101 frame()->SetPCOnStack(false); | |
1102 } | 1103 } |
1103 | 1104 |
1104 if (info()->is_osr()) { | 1105 if (info()->is_osr()) { |
1105 // TurboFan OSR-compiled functions cannot be entered directly. | 1106 // TurboFan OSR-compiled functions cannot be entered directly. |
1106 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 1107 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
1107 | 1108 |
1108 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1109 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1109 // frame is still on the stack. Optimized code uses OSR values directly from | 1110 // frame is still on the stack. Optimized code uses OSR values directly from |
1110 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1111 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1111 // remaining stack slots. | 1112 // remaining stack slots. |
1112 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1113 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1113 osr_pc_offset_ = __ pc_offset(); | 1114 osr_pc_offset_ = __ pc_offset(); |
1114 // TODO(titzer): cannot address target function == local #-1 | 1115 // TODO(titzer): cannot address target function == local #-1 |
1115 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1116 __ lw(a1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1116 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); | 1117 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); |
1117 stack_slots -= frame()->GetOsrStackSlotCount(); | 1118 stack_slots -= frame()->GetOsrStackSlotCount(); |
1118 } | 1119 } |
1119 | 1120 |
1120 if (stack_slots > 0) { | 1121 if (stack_slots > 0) { |
1121 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); | 1122 __ Subu(sp, sp, Operand(stack_slots * kPointerSize)); |
1122 } | 1123 } |
1123 } | 1124 } |
1124 | 1125 |
1125 | 1126 |
1126 void CodeGenerator::AssembleReturn() { | 1127 void CodeGenerator::AssembleReturn() { |
1127 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1128 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1128 int stack_slots = frame()->GetSpillSlotCount(); | 1129 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(); |
1146 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1147 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1147 // Canonicalize JSFunction return sites for now. | 1148 // Canonicalize JSFunction return sites for now. |
1148 if (return_label_.is_bound()) { | 1149 if (return_label_.is_bound()) { |
1149 __ Branch(&return_label_); | 1150 __ 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 } |
1155 } | 1161 } |
1156 } | |
1157 if (pop_count != 0) { | |
1158 __ DropAndRet(pop_count); | |
1159 } else { | 1162 } else { |
1160 __ Ret(); | 1163 __ Ret(); |
1161 } | 1164 } |
1162 } | 1165 } |
1163 | 1166 |
1164 | 1167 |
1165 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1168 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1166 InstructionOperand* destination) { | 1169 InstructionOperand* destination) { |
1167 MipsOperandConverter g(this, NULL); | 1170 MipsOperandConverter g(this, NULL); |
1168 // Dispatch on the source and destination operand kinds. Not all | 1171 // Dispatch on the source and destination operand kinds. Not all |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 } | 1369 } |
1367 } | 1370 } |
1368 } | 1371 } |
1369 } | 1372 } |
1370 | 1373 |
1371 #undef __ | 1374 #undef __ |
1372 | 1375 |
1373 } // namespace compiler | 1376 } // namespace compiler |
1374 } // namespace internal | 1377 } // namespace internal |
1375 } // namespace v8 | 1378 } // namespace v8 |
OLD | NEW |