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 | 6 |
7 #include "src/arm/macro-assembler-arm.h" | 7 #include "src/arm/macro-assembler-arm.h" |
8 #include "src/compiler/code-generator-impl.h" | 8 #include "src/compiler/code-generator-impl.h" |
9 #include "src/compiler/gap-resolver.h" | 9 #include "src/compiler/gap-resolver.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 UNREACHABLE(); | 140 UNREACHABLE(); |
141 return MemOperand(r0); | 141 return MemOperand(r0); |
142 } | 142 } |
143 | 143 |
144 MemOperand InputOffset(size_t first_index = 0) { | 144 MemOperand InputOffset(size_t first_index = 0) { |
145 return InputOffset(&first_index); | 145 return InputOffset(&first_index); |
146 } | 146 } |
147 | 147 |
148 MemOperand ToMemOperand(InstructionOperand* op) const { | 148 MemOperand ToMemOperand(InstructionOperand* op) const { |
149 DCHECK(op != NULL); | 149 DCHECK(op != NULL); |
| 150 DCHECK(!op->IsRegister()); |
| 151 DCHECK(!op->IsDoubleRegister()); |
150 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); | 152 DCHECK(op->IsStackSlot() || op->IsDoubleStackSlot()); |
151 FrameOffset offset = | 153 // The linkage computes where all spill slots are located. |
152 linkage()->GetFrameOffset(AllocatedOperand::cast(op)->index(), frame()); | 154 FrameOffset offset = linkage()->GetFrameOffset( |
| 155 AllocatedOperand::cast(op)->index(), frame(), 0); |
153 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); | 156 return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset()); |
154 } | 157 } |
155 }; | 158 }; |
156 | 159 |
157 | 160 |
158 namespace { | 161 namespace { |
159 | 162 |
160 class OutOfLineLoadFloat32 final : public OutOfLineCode { | 163 class OutOfLineLoadFloat32 final : public OutOfLineCode { |
161 public: | 164 public: |
162 OutOfLineLoadFloat32(CodeGenerator* gen, SwVfpRegister result) | 165 OutOfLineLoadFloat32(CodeGenerator* gen, SwVfpRegister result) |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 985 } |
983 } else if (descriptor->IsJSFunctionCall()) { | 986 } else if (descriptor->IsJSFunctionCall()) { |
984 CompilationInfo* info = this->info(); | 987 CompilationInfo* info = this->info(); |
985 __ Prologue(info->IsCodePreAgingActive()); | 988 __ Prologue(info->IsCodePreAgingActive()); |
986 frame()->SetRegisterSaveAreaSize( | 989 frame()->SetRegisterSaveAreaSize( |
987 StandardFrameConstants::kFixedFrameSizeFromFp); | 990 StandardFrameConstants::kFixedFrameSizeFromFp); |
988 } else if (needs_frame_) { | 991 } else if (needs_frame_) { |
989 __ StubPrologue(); | 992 __ StubPrologue(); |
990 frame()->SetRegisterSaveAreaSize( | 993 frame()->SetRegisterSaveAreaSize( |
991 StandardFrameConstants::kFixedFrameSizeFromFp); | 994 StandardFrameConstants::kFixedFrameSizeFromFp); |
992 } else { | |
993 frame()->SetPCOnStack(false); | |
994 } | 995 } |
995 | 996 |
996 if (info()->is_osr()) { | 997 if (info()->is_osr()) { |
997 // TurboFan OSR-compiled functions cannot be entered directly. | 998 // TurboFan OSR-compiled functions cannot be entered directly. |
998 __ Abort(kShouldNotDirectlyEnterOsrFunction); | 999 __ Abort(kShouldNotDirectlyEnterOsrFunction); |
999 | 1000 |
1000 // Unoptimized code jumps directly to this entrypoint while the unoptimized | 1001 // Unoptimized code jumps directly to this entrypoint while the unoptimized |
1001 // frame is still on the stack. Optimized code uses OSR values directly from | 1002 // frame is still on the stack. Optimized code uses OSR values directly from |
1002 // the unoptimized frame. Thus, all that needs to be done is to allocate the | 1003 // the unoptimized frame. Thus, all that needs to be done is to allocate the |
1003 // remaining stack slots. | 1004 // remaining stack slots. |
1004 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); | 1005 if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); |
1005 osr_pc_offset_ = __ pc_offset(); | 1006 osr_pc_offset_ = __ pc_offset(); |
1006 // TODO(titzer): cannot address target function == local #-1 | 1007 // TODO(titzer): cannot address target function == local #-1 |
1007 __ ldr(r1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1008 __ ldr(r1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1008 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); | 1009 DCHECK(stack_slots >= frame()->GetOsrStackSlotCount()); |
1009 stack_slots -= frame()->GetOsrStackSlotCount(); | 1010 stack_slots -= frame()->GetOsrStackSlotCount(); |
1010 } | 1011 } |
1011 | 1012 |
1012 if (stack_slots > 0) { | 1013 if (stack_slots > 0) { |
1013 __ sub(sp, sp, Operand(stack_slots * kPointerSize)); | 1014 __ sub(sp, sp, Operand(stack_slots * kPointerSize)); |
1014 } | 1015 } |
1015 } | 1016 } |
1016 | 1017 |
1017 | 1018 |
1018 void CodeGenerator::AssembleReturn() { | 1019 void CodeGenerator::AssembleReturn() { |
1019 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); | 1020 CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); |
1020 int stack_slots = frame()->GetSpillSlotCount(); | 1021 int stack_slots = frame()->GetSpillSlotCount(); |
1021 int pop_count = static_cast<int>(descriptor->StackParameterCount()); | |
1022 if (descriptor->kind() == CallDescriptor::kCallAddress) { | 1022 if (descriptor->kind() == CallDescriptor::kCallAddress) { |
1023 if (frame()->GetRegisterSaveAreaSize() > 0) { | 1023 if (frame()->GetRegisterSaveAreaSize() > 0) { |
1024 // Remove this frame's spill slots first. | 1024 // Remove this frame's spill slots first. |
1025 if (stack_slots > 0) { | 1025 if (stack_slots > 0) { |
1026 __ add(sp, sp, Operand(stack_slots * kPointerSize)); | 1026 __ add(sp, sp, Operand(stack_slots * kPointerSize)); |
1027 } | 1027 } |
1028 // Restore FP registers. | 1028 // Restore FP registers. |
1029 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); | 1029 const RegList saves_fp = descriptor->CalleeSavedFPRegisters(); |
1030 if (saves_fp != 0) { | 1030 if (saves_fp != 0) { |
1031 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); | 1031 STATIC_ASSERT(DwVfpRegister::kMaxNumRegisters == 32); |
1032 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; | 1032 uint32_t last = base::bits::CountLeadingZeros32(saves_fp) - 1; |
1033 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); | 1033 uint32_t first = base::bits::CountTrailingZeros32(saves_fp); |
1034 __ vldm(ia_w, sp, DwVfpRegister::from_code(first), | 1034 __ vldm(ia_w, sp, DwVfpRegister::from_code(first), |
1035 DwVfpRegister::from_code(last)); | 1035 DwVfpRegister::from_code(last)); |
1036 } | 1036 } |
1037 // Restore registers. | 1037 // Restore registers. |
1038 const RegList saves = descriptor->CalleeSavedRegisters(); | 1038 const RegList saves = descriptor->CalleeSavedRegisters(); |
1039 if (saves != 0) { | 1039 if (saves != 0) { |
1040 __ ldm(ia_w, sp, saves); | 1040 __ ldm(ia_w, sp, saves); |
1041 } | 1041 } |
1042 } | 1042 } |
1043 __ LeaveFrame(StackFrame::MANUAL); | 1043 __ LeaveFrame(StackFrame::MANUAL); |
| 1044 __ Ret(); |
1044 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { | 1045 } else if (descriptor->IsJSFunctionCall() || needs_frame_) { |
1045 // Canonicalize JSFunction return sites for now. | 1046 // Canonicalize JSFunction return sites for now. |
1046 if (return_label_.is_bound()) { | 1047 if (return_label_.is_bound()) { |
1047 __ b(&return_label_); | 1048 __ b(&return_label_); |
1048 return; | |
1049 } else { | 1049 } else { |
1050 __ bind(&return_label_); | 1050 __ bind(&return_label_); |
1051 __ LeaveFrame(StackFrame::MANUAL); | 1051 __ LeaveFrame(StackFrame::MANUAL); |
| 1052 int pop_count = static_cast<int>(descriptor->StackParameterCount()); |
| 1053 if (pop_count != 0) { |
| 1054 __ Drop(pop_count); |
| 1055 } |
| 1056 __ Ret(); |
1052 } | 1057 } |
| 1058 } else { |
| 1059 __ Ret(); |
1053 } | 1060 } |
1054 __ Ret(pop_count); | |
1055 } | 1061 } |
1056 | 1062 |
1057 | 1063 |
1058 void CodeGenerator::AssembleMove(InstructionOperand* source, | 1064 void CodeGenerator::AssembleMove(InstructionOperand* source, |
1059 InstructionOperand* destination) { | 1065 InstructionOperand* destination) { |
1060 ArmOperandConverter g(this, NULL); | 1066 ArmOperandConverter g(this, NULL); |
1061 // Dispatch on the source and destination operand kinds. Not all | 1067 // Dispatch on the source and destination operand kinds. Not all |
1062 // combinations are possible. | 1068 // combinations are possible. |
1063 if (source->IsRegister()) { | 1069 if (source->IsRegister()) { |
1064 DCHECK(destination->IsRegister() || destination->IsStackSlot()); | 1070 DCHECK(destination->IsRegister() || destination->IsStackSlot()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1258 } | 1264 } |
1259 } | 1265 } |
1260 } | 1266 } |
1261 } | 1267 } |
1262 | 1268 |
1263 #undef __ | 1269 #undef __ |
1264 | 1270 |
1265 } // namespace compiler | 1271 } // namespace compiler |
1266 } // namespace internal | 1272 } // namespace internal |
1267 } // namespace v8 | 1273 } // namespace v8 |
OLD | NEW |