OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/compilation-info.h" | 7 #include "src/compilation-info.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 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 753 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
754 2); \ | 754 2); \ |
755 /* Return value is in st(0) on ia32. */ \ | 755 /* Return value is in st(0) on ia32. */ \ |
756 /* Store it into the result register. */ \ | 756 /* Store it into the result register. */ \ |
757 __ sub(esp, Immediate(kDoubleSize)); \ | 757 __ sub(esp, Immediate(kDoubleSize)); \ |
758 __ fstp_d(Operand(esp, 0)); \ | 758 __ fstp_d(Operand(esp, 0)); \ |
759 __ movsd(i.OutputDoubleRegister(), Operand(esp, 0)); \ | 759 __ movsd(i.OutputDoubleRegister(), Operand(esp, 0)); \ |
760 __ add(esp, Immediate(kDoubleSize)); \ | 760 __ add(esp, Immediate(kDoubleSize)); \ |
761 } while (false) | 761 } while (false) |
762 | 762 |
763 #define ASSEMBLE_BINOP(asm_instr) \ | |
ahaas
2017/03/09 07:10:58
Is it worth to implement ASSEMBLE_BINOP as a macro
shiyu.zhang
2017/03/09 09:53:16
I use a macro here in order to be consistent with
ahaas
2017/03/10 12:02:50
I think it's fine like this for this CL, since it
| |
764 do { \ | |
765 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { \ | |
ahaas
2017/03/09 07:10:58
Can you pass in {instr} as a parameter to the macr
shiyu.zhang
2017/03/09 09:53:17
The usage of ASSEMBLE_BINOP is similar to ASSEMBLE
ahaas
2017/03/10 12:02:50
I think it's a bad style to assume implicitly in t
shiyu.zhang
2017/03/13 02:39:35
Sure. And I think {i} should also be passed in as
ahaas
2017/03/13 08:10:57
Oh, I was not aware that this code style is all ov
| |
766 size_t index = 1; \ | |
767 Operand right = i.MemoryOperand(&index); \ | |
768 __ asm_instr(i.InputRegister(0), right); \ | |
769 } else { \ | |
770 if (HasImmediateInput(instr, 1)) { \ | |
771 __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ | |
772 } else { \ | |
773 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ | |
774 } \ | |
775 } \ | |
776 } while (0) | |
777 | |
763 void CodeGenerator::AssembleDeconstructFrame() { | 778 void CodeGenerator::AssembleDeconstructFrame() { |
764 __ mov(esp, ebp); | 779 __ mov(esp, ebp); |
765 __ pop(ebp); | 780 __ pop(ebp); |
766 } | 781 } |
767 | 782 |
768 void CodeGenerator::AssemblePrepareTailCall() { | 783 void CodeGenerator::AssemblePrepareTailCall() { |
769 if (frame_access_state()->has_frame()) { | 784 if (frame_access_state()->has_frame()) { |
770 __ mov(ebp, MemOperand(ebp, 0)); | 785 __ mov(ebp, MemOperand(ebp, 0)); |
771 } | 786 } |
772 frame_access_state()->SetFrameAccessToSP(); | 787 frame_access_state()->SetFrameAccessToSP(); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1123 case kIeee754Float64Sinh: | 1138 case kIeee754Float64Sinh: |
1124 ASSEMBLE_IEEE754_UNOP(sinh); | 1139 ASSEMBLE_IEEE754_UNOP(sinh); |
1125 break; | 1140 break; |
1126 case kIeee754Float64Tan: | 1141 case kIeee754Float64Tan: |
1127 ASSEMBLE_IEEE754_UNOP(tan); | 1142 ASSEMBLE_IEEE754_UNOP(tan); |
1128 break; | 1143 break; |
1129 case kIeee754Float64Tanh: | 1144 case kIeee754Float64Tanh: |
1130 ASSEMBLE_IEEE754_UNOP(tanh); | 1145 ASSEMBLE_IEEE754_UNOP(tanh); |
1131 break; | 1146 break; |
1132 case kIA32Add: | 1147 case kIA32Add: |
1133 if (HasImmediateInput(instr, 1)) { | 1148 ASSEMBLE_BINOP(add); |
1134 __ add(i.InputOperand(0), i.InputImmediate(1)); | |
1135 } else { | |
1136 __ add(i.InputRegister(0), i.InputOperand(1)); | |
1137 } | |
1138 break; | 1149 break; |
1139 case kIA32And: | 1150 case kIA32And: |
1140 if (HasImmediateInput(instr, 1)) { | 1151 ASSEMBLE_BINOP(and_); |
1141 __ and_(i.InputOperand(0), i.InputImmediate(1)); | |
1142 } else { | |
1143 __ and_(i.InputRegister(0), i.InputOperand(1)); | |
1144 } | |
1145 break; | 1152 break; |
1146 case kIA32Cmp: | 1153 case kIA32Cmp: |
1147 ASSEMBLE_COMPARE(cmp); | 1154 ASSEMBLE_COMPARE(cmp); |
1148 break; | 1155 break; |
1149 case kIA32Cmp16: | 1156 case kIA32Cmp16: |
1150 ASSEMBLE_COMPARE(cmpw); | 1157 ASSEMBLE_COMPARE(cmpw); |
1151 break; | 1158 break; |
1152 case kIA32Cmp8: | 1159 case kIA32Cmp8: |
1153 ASSEMBLE_COMPARE(cmpb); | 1160 ASSEMBLE_COMPARE(cmpb); |
1154 break; | 1161 break; |
(...skipping 27 matching lines...) Expand all Loading... | |
1182 __ Move(edx, Immediate(0)); | 1189 __ Move(edx, Immediate(0)); |
1183 __ div(i.InputOperand(1)); | 1190 __ div(i.InputOperand(1)); |
1184 break; | 1191 break; |
1185 case kIA32Not: | 1192 case kIA32Not: |
1186 __ not_(i.OutputOperand()); | 1193 __ not_(i.OutputOperand()); |
1187 break; | 1194 break; |
1188 case kIA32Neg: | 1195 case kIA32Neg: |
1189 __ neg(i.OutputOperand()); | 1196 __ neg(i.OutputOperand()); |
1190 break; | 1197 break; |
1191 case kIA32Or: | 1198 case kIA32Or: |
1192 if (HasImmediateInput(instr, 1)) { | 1199 ASSEMBLE_BINOP(or_); |
1193 __ or_(i.InputOperand(0), i.InputImmediate(1)); | |
1194 } else { | |
1195 __ or_(i.InputRegister(0), i.InputOperand(1)); | |
1196 } | |
1197 break; | 1200 break; |
1198 case kIA32Xor: | 1201 case kIA32Xor: |
1199 if (HasImmediateInput(instr, 1)) { | 1202 ASSEMBLE_BINOP(xor_); |
1200 __ xor_(i.InputOperand(0), i.InputImmediate(1)); | |
1201 } else { | |
1202 __ xor_(i.InputRegister(0), i.InputOperand(1)); | |
1203 } | |
1204 break; | 1203 break; |
1205 case kIA32Sub: | 1204 case kIA32Sub: |
1206 if (HasImmediateInput(instr, 1)) { | 1205 ASSEMBLE_BINOP(sub); |
1207 __ sub(i.InputOperand(0), i.InputImmediate(1)); | |
1208 } else { | |
1209 __ sub(i.InputRegister(0), i.InputOperand(1)); | |
1210 } | |
1211 break; | 1206 break; |
1212 case kIA32Shl: | 1207 case kIA32Shl: |
1213 if (HasImmediateInput(instr, 1)) { | 1208 if (HasImmediateInput(instr, 1)) { |
1214 __ shl(i.OutputOperand(), i.InputInt5(1)); | 1209 __ shl(i.OutputOperand(), i.InputInt5(1)); |
1215 } else { | 1210 } else { |
1216 __ shl_cl(i.OutputOperand()); | 1211 __ shl_cl(i.OutputOperand()); |
1217 } | 1212 } |
1218 break; | 1213 break; |
1219 case kIA32Shr: | 1214 case kIA32Shr: |
1220 if (HasImmediateInput(instr, 1)) { | 1215 if (HasImmediateInput(instr, 1)) { |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2672 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2667 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2673 __ Nop(padding_size); | 2668 __ Nop(padding_size); |
2674 } | 2669 } |
2675 } | 2670 } |
2676 | 2671 |
2677 #undef __ | 2672 #undef __ |
2678 | 2673 |
2679 } // namespace compiler | 2674 } // namespace compiler |
2680 } // namespace internal | 2675 } // namespace internal |
2681 } // namespace v8 | 2676 } // namespace v8 |
OLD | NEW |