| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 | 975 |
| 976 void Assembler::andq(Register dst, const Address& address) { | 976 void Assembler::andq(Register dst, const Address& address) { |
| 977 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 977 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 978 EmitOperandREX(dst, address, REX_W); | 978 EmitOperandREX(dst, address, REX_W); |
| 979 EmitUint8(0x23); | 979 EmitUint8(0x23); |
| 980 EmitOperand(dst & 7, address); | 980 EmitOperand(dst & 7, address); |
| 981 } | 981 } |
| 982 | 982 |
| 983 | 983 |
| 984 void Assembler::andq(Register dst, const Immediate& imm) { | 984 void Assembler::andq(Register dst, const Immediate& imm) { |
| 985 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 985 if (imm.is_int32()) { |
| 986 EmitRegisterREX(dst, REX_W); | 986 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 987 EmitComplex(4, Operand(dst), imm); | 987 EmitRegisterREX(dst, REX_W); |
| 988 EmitComplex(4, Operand(dst), imm); |
| 989 } else { |
| 990 movq(TMP, imm); |
| 991 andq(dst, TMP); |
| 992 } |
| 988 } | 993 } |
| 989 | 994 |
| 990 | 995 |
| 991 void Assembler::orq(Register dst, Register src) { | 996 void Assembler::orq(Register dst, Register src) { |
| 992 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 997 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 993 Operand operand(src); | 998 Operand operand(src); |
| 994 EmitOperandREX(dst, operand, REX_W); | 999 EmitOperandREX(dst, operand, REX_W); |
| 995 EmitUint8(0x0B); | 1000 EmitUint8(0x0B); |
| 996 EmitOperand(dst & 7, operand); | 1001 EmitOperand(dst & 7, operand); |
| 997 } | 1002 } |
| 998 | 1003 |
| 999 | 1004 |
| 1000 void Assembler::orq(Register dst, const Address& address) { | 1005 void Assembler::orq(Register dst, const Address& address) { |
| 1001 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1006 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1002 EmitOperandREX(dst, address, REX_W); | 1007 EmitOperandREX(dst, address, REX_W); |
| 1003 EmitUint8(0x0B); | 1008 EmitUint8(0x0B); |
| 1004 EmitOperand(dst & 7, address); | 1009 EmitOperand(dst & 7, address); |
| 1005 } | 1010 } |
| 1006 | 1011 |
| 1007 | 1012 |
| 1008 void Assembler::orq(Register dst, const Immediate& imm) { | 1013 void Assembler::orq(Register dst, const Immediate& imm) { |
| 1009 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1014 if (imm.is_int32()) { |
| 1010 EmitRegisterREX(dst, REX_W); | 1015 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1011 EmitComplex(1, Operand(dst), imm); | 1016 EmitRegisterREX(dst, REX_W); |
| 1017 EmitComplex(1, Operand(dst), imm); |
| 1018 } else { |
| 1019 movq(TMP, imm); |
| 1020 orq(dst, TMP); |
| 1021 } |
| 1012 } | 1022 } |
| 1013 | 1023 |
| 1014 | 1024 |
| 1015 void Assembler::xorq(Register dst, Register src) { | 1025 void Assembler::xorq(Register dst, Register src) { |
| 1016 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1026 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1017 Operand operand(src); | 1027 Operand operand(src); |
| 1018 EmitOperandREX(dst, operand, REX_W); | 1028 EmitOperandREX(dst, operand, REX_W); |
| 1019 EmitUint8(0x33); | 1029 EmitUint8(0x33); |
| 1020 EmitOperand(dst & 7, operand); | 1030 EmitOperand(dst & 7, operand); |
| 1021 } | 1031 } |
| 1022 | 1032 |
| 1023 | 1033 |
| 1024 void Assembler::xorq(Register dst, const Address& address) { | 1034 void Assembler::xorq(Register dst, const Address& address) { |
| 1025 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1035 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1026 EmitOperandREX(dst, address, REX_W); | 1036 EmitOperandREX(dst, address, REX_W); |
| 1027 EmitUint8(0x33); | 1037 EmitUint8(0x33); |
| 1028 EmitOperand(dst & 7, address); | 1038 EmitOperand(dst & 7, address); |
| 1029 } | 1039 } |
| 1030 | 1040 |
| 1031 | 1041 |
| 1032 void Assembler::xorq(const Address& dst, Register src) { | 1042 void Assembler::xorq(const Address& dst, Register src) { |
| 1033 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1043 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1034 EmitOperandREX(src, dst, REX_W); | 1044 EmitOperandREX(src, dst, REX_W); |
| 1035 EmitUint8(0x31); | 1045 EmitUint8(0x31); |
| 1036 EmitOperand(src & 7, dst); | 1046 EmitOperand(src & 7, dst); |
| 1037 } | 1047 } |
| 1038 | 1048 |
| 1039 | 1049 |
| 1040 void Assembler::xorq(Register dst, const Immediate& imm) { | 1050 void Assembler::xorq(Register dst, const Immediate& imm) { |
| 1041 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1051 if (imm.is_int32()) { |
| 1042 EmitRegisterREX(dst, REX_W); | 1052 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1043 EmitComplex(6, Operand(dst), imm); | 1053 EmitRegisterREX(dst, REX_W); |
| 1054 EmitComplex(6, Operand(dst), imm); |
| 1055 } else { |
| 1056 movq(TMP, imm); |
| 1057 xorq(dst, TMP); |
| 1058 } |
| 1044 } | 1059 } |
| 1045 | 1060 |
| 1046 | 1061 |
| 1047 void Assembler::addl(Register dst, Register src) { | 1062 void Assembler::addl(Register dst, Register src) { |
| 1048 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1063 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1049 Operand operand(src); | 1064 Operand operand(src); |
| 1050 EmitOperandREX(dst, operand, REX_NONE); | 1065 EmitOperandREX(dst, operand, REX_NONE); |
| 1051 EmitUint8(0x03); | 1066 EmitUint8(0x03); |
| 1052 EmitOperand(dst & 7, operand); | 1067 EmitOperand(dst & 7, operand); |
| 1053 } | 1068 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1069 EmitOperand(dst & 7, address); | 1084 EmitOperand(dst & 7, address); |
| 1070 } | 1085 } |
| 1071 | 1086 |
| 1072 | 1087 |
| 1073 void Assembler::addl(const Address& address, const Immediate& imm) { | 1088 void Assembler::addl(const Address& address, const Immediate& imm) { |
| 1074 UNIMPLEMENTED(); | 1089 UNIMPLEMENTED(); |
| 1075 } | 1090 } |
| 1076 | 1091 |
| 1077 | 1092 |
| 1078 void Assembler::addq(Register reg, const Immediate& imm) { | 1093 void Assembler::addq(Register reg, const Immediate& imm) { |
| 1079 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1094 if (imm.is_int32()) { |
| 1080 EmitRegisterREX(reg, REX_W); | 1095 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1081 EmitComplex(0, Operand(reg), imm); | 1096 EmitRegisterREX(reg, REX_W); |
| 1097 EmitComplex(0, Operand(reg), imm); |
| 1098 } else { |
| 1099 movq(TMP, imm); |
| 1100 addq(reg, TMP); |
| 1101 } |
| 1082 } | 1102 } |
| 1083 | 1103 |
| 1084 | 1104 |
| 1085 void Assembler::addq(const Address& address, const Immediate& imm) { | 1105 void Assembler::addq(const Address& address, const Immediate& imm) { |
| 1086 // TODO(srdjan): Implement shorter version for imm32. | 1106 // TODO(srdjan): Implement shorter version for imm32. |
| 1087 movq(TMP, imm); | 1107 movq(TMP, imm); |
| 1088 addq(address, TMP); | 1108 addq(address, TMP); |
| 1089 } | 1109 } |
| 1090 | 1110 |
| 1091 | 1111 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1149 Operand operand(src); | 1169 Operand operand(src); |
| 1150 EmitOperandREX(dst, operand, REX_NONE); | 1170 EmitOperandREX(dst, operand, REX_NONE); |
| 1151 EmitUint8(0x0F); | 1171 EmitUint8(0x0F); |
| 1152 EmitUint8(0xAF); | 1172 EmitUint8(0xAF); |
| 1153 EmitOperand(dst & 7, Operand(src)); | 1173 EmitOperand(dst & 7, Operand(src)); |
| 1154 } | 1174 } |
| 1155 | 1175 |
| 1156 | 1176 |
| 1157 void Assembler::imull(Register reg, const Immediate& imm) { | 1177 void Assembler::imull(Register reg, const Immediate& imm) { |
| 1158 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1178 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1159 EmitRegisterREX(reg, REX_NONE); | 1179 Operand operand(reg); |
| 1180 EmitOperandREX(reg, operand, REX_NONE); |
| 1160 EmitUint8(0x69); | 1181 EmitUint8(0x69); |
| 1161 EmitOperand(reg & 7, Operand(reg)); | 1182 EmitOperand(reg & 7, Operand(reg)); |
| 1162 EmitImmediate(imm); | 1183 EmitImmediate(imm); |
| 1163 } | 1184 } |
| 1164 | 1185 |
| 1165 | 1186 |
| 1166 void Assembler::imulq(Register dst, Register src) { | 1187 void Assembler::imulq(Register dst, Register src) { |
| 1167 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1188 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1168 Operand operand(src); | 1189 Operand operand(src); |
| 1169 EmitOperandREX(dst, operand, REX_W); | 1190 EmitOperandREX(dst, operand, REX_W); |
| 1170 EmitUint8(0x0F); | 1191 EmitUint8(0x0F); |
| 1171 EmitUint8(0xAF); | 1192 EmitUint8(0xAF); |
| 1172 EmitOperand(dst & 7, operand); | 1193 EmitOperand(dst & 7, operand); |
| 1173 } | 1194 } |
| 1174 | 1195 |
| 1175 | 1196 |
| 1197 void Assembler::imulq(Register reg, const Immediate& imm) { |
| 1198 if (imm.is_int32()) { |
| 1199 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1200 Operand operand(reg); |
| 1201 EmitOperandREX(reg, operand, REX_W); |
| 1202 EmitUint8(0x69); |
| 1203 EmitOperand(reg & 7, Operand(reg)); |
| 1204 EmitImmediate(imm); |
| 1205 } else { |
| 1206 movq(TMP, imm); |
| 1207 imulq(reg, TMP); |
| 1208 } |
| 1209 } |
| 1210 |
| 1211 |
| 1176 void Assembler::imulq(Register dst, const Address& address) { | 1212 void Assembler::imulq(Register dst, const Address& address) { |
| 1177 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1213 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1178 EmitOperandREX(dst, address, REX_W); | 1214 EmitOperandREX(dst, address, REX_W); |
| 1179 EmitUint8(0x0F); | 1215 EmitUint8(0x0F); |
| 1180 EmitUint8(0xAF); | 1216 EmitUint8(0xAF); |
| 1181 EmitOperand(dst & 7, address); | 1217 EmitOperand(dst & 7, address); |
| 1182 } | 1218 } |
| 1183 | 1219 |
| 1184 | 1220 |
| 1185 void Assembler::subq(Register dst, Register src) { | 1221 void Assembler::subq(Register dst, Register src) { |
| 1186 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1222 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1187 Operand operand(src); | 1223 Operand operand(src); |
| 1188 EmitOperandREX(dst, operand, REX_W); | 1224 EmitOperandREX(dst, operand, REX_W); |
| 1189 EmitUint8(0x2B); | 1225 EmitUint8(0x2B); |
| 1190 EmitOperand(dst & 7, operand); | 1226 EmitOperand(dst & 7, operand); |
| 1191 } | 1227 } |
| 1192 | 1228 |
| 1193 | 1229 |
| 1194 void Assembler::subq(Register reg, const Immediate& imm) { | 1230 void Assembler::subq(Register reg, const Immediate& imm) { |
| 1195 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1231 if (imm.is_int32()) { |
| 1196 EmitRegisterREX(reg, REX_W); | 1232 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1197 EmitComplex(5, Operand(reg), imm); | 1233 EmitRegisterREX(reg, REX_W); |
| 1234 EmitComplex(5, Operand(reg), imm); |
| 1235 } else { |
| 1236 movq(TMP, imm); |
| 1237 subq(reg, TMP); |
| 1238 } |
| 1198 } | 1239 } |
| 1199 | 1240 |
| 1200 | 1241 |
| 1201 void Assembler::subq(Register reg, const Address& address) { | 1242 void Assembler::subq(Register reg, const Address& address) { |
| 1202 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1243 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1203 EmitOperandREX(reg, address, REX_W); | 1244 EmitOperandREX(reg, address, REX_W); |
| 1204 EmitUint8(0x2B); | 1245 EmitUint8(0x2B); |
| 1205 EmitOperand(reg & 7, address); | 1246 EmitOperand(reg & 7, address); |
| 1206 } | 1247 } |
| 1207 | 1248 |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2072 | 2113 |
| 2073 const char* Assembler::XmmRegisterName(XmmRegister reg) { | 2114 const char* Assembler::XmmRegisterName(XmmRegister reg) { |
| 2074 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2115 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 2075 return xmm_reg_names[reg]; | 2116 return xmm_reg_names[reg]; |
| 2076 } | 2117 } |
| 2077 | 2118 |
| 2078 | 2119 |
| 2079 } // namespace dart | 2120 } // namespace dart |
| 2080 | 2121 |
| 2081 #endif // defined TARGET_ARCH_X64 | 2122 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |