Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #include <string.h> |
| 4 | #include "src/assembler.h" |
| 5 | #include "src/casts.h" |
| 6 | #include "src/globals.h" |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 7 | #include "src/memory_region.h" |
| 8 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 9 | namespace art { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 10 | |
| 11 | class DirectCallRelocation : public AssemblerFixup { |
| 12 | public: |
| 13 | void Process(const MemoryRegion& region, int position) { |
| 14 | // Direct calls are relative to the following instruction on x86. |
| 15 | int32_t pointer = region.Load<int32_t>(position); |
| 16 | int32_t start = reinterpret_cast<int32_t>(region.start()); |
| 17 | int32_t delta = start + position + sizeof(int32_t); |
| 18 | region.Store<int32_t>(position, pointer - delta); |
| 19 | } |
| 20 | }; |
| 21 | |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 22 | static const char* kRegisterNames[] = { |
| 23 | "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", |
| 24 | }; |
| 25 | std::ostream& operator<<(std::ostream& os, const Register& rhs) { |
| 26 | if (rhs >= EAX && rhs <= EDI) { |
| 27 | os << kRegisterNames[rhs]; |
| 28 | } else { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 29 | os << "Register[" << static_cast<int>(rhs) << "]"; |
Elliott Hughes | 1f359b0 | 2011-07-17 14:27:17 -0700 | [diff] [blame] | 30 | } |
| 31 | return os; |
| 32 | } |
| 33 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 34 | std::ostream& operator<<(std::ostream& os, const XmmRegister& reg) { |
| 35 | return os << "XMM" << static_cast<int>(reg); |
| 36 | } |
| 37 | |
| 38 | std::ostream& operator<<(std::ostream& os, const X87Register& reg) { |
| 39 | return os << "ST" << static_cast<int>(reg); |
| 40 | } |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 41 | |
| 42 | void Assembler::InitializeMemoryWithBreakpoints(byte* data, size_t length) { |
| 43 | memset(reinterpret_cast<void*>(data), Instr::kBreakPointInstruction, length); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | void Assembler::call(Register reg) { |
| 48 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 49 | EmitUint8(0xFF); |
| 50 | EmitRegisterOperand(2, reg); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | void Assembler::call(const Address& address) { |
| 55 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 56 | EmitUint8(0xFF); |
| 57 | EmitOperand(2, address); |
| 58 | } |
| 59 | |
| 60 | |
| 61 | void Assembler::call(Label* label) { |
| 62 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 63 | EmitUint8(0xE8); |
| 64 | static const int kSize = 5; |
| 65 | EmitLabel(label, kSize); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | void Assembler::pushl(Register reg) { |
| 70 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 71 | EmitUint8(0x50 + reg); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | void Assembler::pushl(const Address& address) { |
| 76 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 77 | EmitUint8(0xFF); |
| 78 | EmitOperand(6, address); |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void Assembler::pushl(const Immediate& imm) { |
| 83 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 84 | EmitUint8(0x68); |
| 85 | EmitImmediate(imm); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | void Assembler::popl(Register reg) { |
| 90 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 91 | EmitUint8(0x58 + reg); |
| 92 | } |
| 93 | |
| 94 | |
| 95 | void Assembler::popl(const Address& address) { |
| 96 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 97 | EmitUint8(0x8F); |
| 98 | EmitOperand(0, address); |
| 99 | } |
| 100 | |
| 101 | |
| 102 | void Assembler::movl(Register dst, const Immediate& imm) { |
| 103 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 104 | EmitUint8(0xB8 + dst); |
| 105 | EmitImmediate(imm); |
| 106 | } |
| 107 | |
| 108 | |
| 109 | void Assembler::movl(Register dst, Register src) { |
| 110 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 111 | EmitUint8(0x89); |
| 112 | EmitRegisterOperand(src, dst); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | void Assembler::movl(Register dst, const Address& src) { |
| 117 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 118 | EmitUint8(0x8B); |
| 119 | EmitOperand(dst, src); |
| 120 | } |
| 121 | |
| 122 | |
| 123 | void Assembler::movl(const Address& dst, Register src) { |
| 124 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 125 | EmitUint8(0x89); |
| 126 | EmitOperand(src, dst); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | void Assembler::movl(const Address& dst, const Immediate& imm) { |
| 131 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 132 | EmitUint8(0xC7); |
| 133 | EmitOperand(0, dst); |
| 134 | EmitImmediate(imm); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | void Assembler::movzxb(Register dst, ByteRegister src) { |
| 139 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 140 | EmitUint8(0x0F); |
| 141 | EmitUint8(0xB6); |
| 142 | EmitRegisterOperand(dst, src); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | void Assembler::movzxb(Register dst, const Address& src) { |
| 147 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 148 | EmitUint8(0x0F); |
| 149 | EmitUint8(0xB6); |
| 150 | EmitOperand(dst, src); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | void Assembler::movsxb(Register dst, ByteRegister src) { |
| 155 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 156 | EmitUint8(0x0F); |
| 157 | EmitUint8(0xBE); |
| 158 | EmitRegisterOperand(dst, src); |
| 159 | } |
| 160 | |
| 161 | |
| 162 | void Assembler::movsxb(Register dst, const Address& src) { |
| 163 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 164 | EmitUint8(0x0F); |
| 165 | EmitUint8(0xBE); |
| 166 | EmitOperand(dst, src); |
| 167 | } |
| 168 | |
| 169 | |
| 170 | void Assembler::movb(Register dst, const Address& src) { |
| 171 | LOG(FATAL) << "Use movzxb or movsxb instead."; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | void Assembler::movb(const Address& dst, ByteRegister src) { |
| 176 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 177 | EmitUint8(0x88); |
| 178 | EmitOperand(src, dst); |
| 179 | } |
| 180 | |
| 181 | |
| 182 | void Assembler::movb(const Address& dst, const Immediate& imm) { |
| 183 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 184 | EmitUint8(0xC6); |
| 185 | EmitOperand(EAX, dst); |
| 186 | CHECK(imm.is_int8()); |
| 187 | EmitUint8(imm.value() & 0xFF); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | void Assembler::movzxw(Register dst, Register src) { |
| 192 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 193 | EmitUint8(0x0F); |
| 194 | EmitUint8(0xB7); |
| 195 | EmitRegisterOperand(dst, src); |
| 196 | } |
| 197 | |
| 198 | |
| 199 | void Assembler::movzxw(Register dst, const Address& src) { |
| 200 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 201 | EmitUint8(0x0F); |
| 202 | EmitUint8(0xB7); |
| 203 | EmitOperand(dst, src); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | void Assembler::movsxw(Register dst, Register src) { |
| 208 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 209 | EmitUint8(0x0F); |
| 210 | EmitUint8(0xBF); |
| 211 | EmitRegisterOperand(dst, src); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | void Assembler::movsxw(Register dst, const Address& src) { |
| 216 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 217 | EmitUint8(0x0F); |
| 218 | EmitUint8(0xBF); |
| 219 | EmitOperand(dst, src); |
| 220 | } |
| 221 | |
| 222 | |
| 223 | void Assembler::movw(Register dst, const Address& src) { |
| 224 | LOG(FATAL) << "Use movzxw or movsxw instead."; |
| 225 | } |
| 226 | |
| 227 | |
| 228 | void Assembler::movw(const Address& dst, Register src) { |
| 229 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 230 | EmitOperandSizeOverride(); |
| 231 | EmitUint8(0x89); |
| 232 | EmitOperand(src, dst); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | void Assembler::leal(Register dst, const Address& src) { |
| 237 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 238 | EmitUint8(0x8D); |
| 239 | EmitOperand(dst, src); |
| 240 | } |
| 241 | |
| 242 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 243 | void Assembler::cmovl(Condition condition, Register dst, Register src) { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 244 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 245 | EmitUint8(0x0F); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 246 | EmitUint8(0x40 + condition); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 247 | EmitRegisterOperand(dst, src); |
| 248 | } |
| 249 | |
| 250 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 251 | void Assembler::setb(Condition condition, Register dst) { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 252 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 253 | EmitUint8(0x0F); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 254 | EmitUint8(0x90 + condition); |
| 255 | EmitOperand(0, Operand(dst)); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | |
| 259 | void Assembler::movss(XmmRegister dst, const Address& src) { |
| 260 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 261 | EmitUint8(0xF3); |
| 262 | EmitUint8(0x0F); |
| 263 | EmitUint8(0x10); |
| 264 | EmitOperand(dst, src); |
| 265 | } |
| 266 | |
| 267 | |
| 268 | void Assembler::movss(const Address& dst, XmmRegister src) { |
| 269 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 270 | EmitUint8(0xF3); |
| 271 | EmitUint8(0x0F); |
| 272 | EmitUint8(0x11); |
| 273 | EmitOperand(src, dst); |
| 274 | } |
| 275 | |
| 276 | |
| 277 | void Assembler::movss(XmmRegister dst, XmmRegister src) { |
| 278 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 279 | EmitUint8(0xF3); |
| 280 | EmitUint8(0x0F); |
| 281 | EmitUint8(0x11); |
| 282 | EmitXmmRegisterOperand(src, dst); |
| 283 | } |
| 284 | |
| 285 | |
| 286 | void Assembler::movd(XmmRegister dst, Register src) { |
| 287 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 288 | EmitUint8(0x66); |
| 289 | EmitUint8(0x0F); |
| 290 | EmitUint8(0x6E); |
| 291 | EmitOperand(dst, Operand(src)); |
| 292 | } |
| 293 | |
| 294 | |
| 295 | void Assembler::movd(Register dst, XmmRegister src) { |
| 296 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 297 | EmitUint8(0x66); |
| 298 | EmitUint8(0x0F); |
| 299 | EmitUint8(0x7E); |
| 300 | EmitOperand(src, Operand(dst)); |
| 301 | } |
| 302 | |
| 303 | |
| 304 | void Assembler::addss(XmmRegister dst, XmmRegister src) { |
| 305 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 306 | EmitUint8(0xF3); |
| 307 | EmitUint8(0x0F); |
| 308 | EmitUint8(0x58); |
| 309 | EmitXmmRegisterOperand(dst, src); |
| 310 | } |
| 311 | |
| 312 | |
| 313 | void Assembler::addss(XmmRegister dst, const Address& src) { |
| 314 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 315 | EmitUint8(0xF3); |
| 316 | EmitUint8(0x0F); |
| 317 | EmitUint8(0x58); |
| 318 | EmitOperand(dst, src); |
| 319 | } |
| 320 | |
| 321 | |
| 322 | void Assembler::subss(XmmRegister dst, XmmRegister src) { |
| 323 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 324 | EmitUint8(0xF3); |
| 325 | EmitUint8(0x0F); |
| 326 | EmitUint8(0x5C); |
| 327 | EmitXmmRegisterOperand(dst, src); |
| 328 | } |
| 329 | |
| 330 | |
| 331 | void Assembler::subss(XmmRegister dst, const Address& src) { |
| 332 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 333 | EmitUint8(0xF3); |
| 334 | EmitUint8(0x0F); |
| 335 | EmitUint8(0x5C); |
| 336 | EmitOperand(dst, src); |
| 337 | } |
| 338 | |
| 339 | |
| 340 | void Assembler::mulss(XmmRegister dst, XmmRegister src) { |
| 341 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 342 | EmitUint8(0xF3); |
| 343 | EmitUint8(0x0F); |
| 344 | EmitUint8(0x59); |
| 345 | EmitXmmRegisterOperand(dst, src); |
| 346 | } |
| 347 | |
| 348 | |
| 349 | void Assembler::mulss(XmmRegister dst, const Address& src) { |
| 350 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 351 | EmitUint8(0xF3); |
| 352 | EmitUint8(0x0F); |
| 353 | EmitUint8(0x59); |
| 354 | EmitOperand(dst, src); |
| 355 | } |
| 356 | |
| 357 | |
| 358 | void Assembler::divss(XmmRegister dst, XmmRegister src) { |
| 359 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 360 | EmitUint8(0xF3); |
| 361 | EmitUint8(0x0F); |
| 362 | EmitUint8(0x5E); |
| 363 | EmitXmmRegisterOperand(dst, src); |
| 364 | } |
| 365 | |
| 366 | |
| 367 | void Assembler::divss(XmmRegister dst, const Address& src) { |
| 368 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 369 | EmitUint8(0xF3); |
| 370 | EmitUint8(0x0F); |
| 371 | EmitUint8(0x5E); |
| 372 | EmitOperand(dst, src); |
| 373 | } |
| 374 | |
| 375 | |
| 376 | void Assembler::flds(const Address& src) { |
| 377 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 378 | EmitUint8(0xD9); |
| 379 | EmitOperand(0, src); |
| 380 | } |
| 381 | |
| 382 | |
| 383 | void Assembler::fstps(const Address& dst) { |
| 384 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 385 | EmitUint8(0xD9); |
| 386 | EmitOperand(3, dst); |
| 387 | } |
| 388 | |
| 389 | |
| 390 | void Assembler::movsd(XmmRegister dst, const Address& src) { |
| 391 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 392 | EmitUint8(0xF2); |
| 393 | EmitUint8(0x0F); |
| 394 | EmitUint8(0x10); |
| 395 | EmitOperand(dst, src); |
| 396 | } |
| 397 | |
| 398 | |
| 399 | void Assembler::movsd(const Address& dst, XmmRegister src) { |
| 400 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 401 | EmitUint8(0xF2); |
| 402 | EmitUint8(0x0F); |
| 403 | EmitUint8(0x11); |
| 404 | EmitOperand(src, dst); |
| 405 | } |
| 406 | |
| 407 | |
| 408 | void Assembler::movsd(XmmRegister dst, XmmRegister src) { |
| 409 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 410 | EmitUint8(0xF2); |
| 411 | EmitUint8(0x0F); |
| 412 | EmitUint8(0x11); |
| 413 | EmitXmmRegisterOperand(src, dst); |
| 414 | } |
| 415 | |
| 416 | |
| 417 | void Assembler::addsd(XmmRegister dst, XmmRegister src) { |
| 418 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 419 | EmitUint8(0xF2); |
| 420 | EmitUint8(0x0F); |
| 421 | EmitUint8(0x58); |
| 422 | EmitXmmRegisterOperand(dst, src); |
| 423 | } |
| 424 | |
| 425 | |
| 426 | void Assembler::addsd(XmmRegister dst, const Address& src) { |
| 427 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 428 | EmitUint8(0xF2); |
| 429 | EmitUint8(0x0F); |
| 430 | EmitUint8(0x58); |
| 431 | EmitOperand(dst, src); |
| 432 | } |
| 433 | |
| 434 | |
| 435 | void Assembler::subsd(XmmRegister dst, XmmRegister src) { |
| 436 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 437 | EmitUint8(0xF2); |
| 438 | EmitUint8(0x0F); |
| 439 | EmitUint8(0x5C); |
| 440 | EmitXmmRegisterOperand(dst, src); |
| 441 | } |
| 442 | |
| 443 | |
| 444 | void Assembler::subsd(XmmRegister dst, const Address& src) { |
| 445 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 446 | EmitUint8(0xF2); |
| 447 | EmitUint8(0x0F); |
| 448 | EmitUint8(0x5C); |
| 449 | EmitOperand(dst, src); |
| 450 | } |
| 451 | |
| 452 | |
| 453 | void Assembler::mulsd(XmmRegister dst, XmmRegister src) { |
| 454 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 455 | EmitUint8(0xF2); |
| 456 | EmitUint8(0x0F); |
| 457 | EmitUint8(0x59); |
| 458 | EmitXmmRegisterOperand(dst, src); |
| 459 | } |
| 460 | |
| 461 | |
| 462 | void Assembler::mulsd(XmmRegister dst, const Address& src) { |
| 463 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 464 | EmitUint8(0xF2); |
| 465 | EmitUint8(0x0F); |
| 466 | EmitUint8(0x59); |
| 467 | EmitOperand(dst, src); |
| 468 | } |
| 469 | |
| 470 | |
| 471 | void Assembler::divsd(XmmRegister dst, XmmRegister src) { |
| 472 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 473 | EmitUint8(0xF2); |
| 474 | EmitUint8(0x0F); |
| 475 | EmitUint8(0x5E); |
| 476 | EmitXmmRegisterOperand(dst, src); |
| 477 | } |
| 478 | |
| 479 | |
| 480 | void Assembler::divsd(XmmRegister dst, const Address& src) { |
| 481 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 482 | EmitUint8(0xF2); |
| 483 | EmitUint8(0x0F); |
| 484 | EmitUint8(0x5E); |
| 485 | EmitOperand(dst, src); |
| 486 | } |
| 487 | |
| 488 | |
| 489 | void Assembler::cvtsi2ss(XmmRegister dst, Register src) { |
| 490 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 491 | EmitUint8(0xF3); |
| 492 | EmitUint8(0x0F); |
| 493 | EmitUint8(0x2A); |
| 494 | EmitOperand(dst, Operand(src)); |
| 495 | } |
| 496 | |
| 497 | |
| 498 | void Assembler::cvtsi2sd(XmmRegister dst, Register src) { |
| 499 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 500 | EmitUint8(0xF2); |
| 501 | EmitUint8(0x0F); |
| 502 | EmitUint8(0x2A); |
| 503 | EmitOperand(dst, Operand(src)); |
| 504 | } |
| 505 | |
| 506 | |
| 507 | void Assembler::cvtss2si(Register dst, XmmRegister src) { |
| 508 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 509 | EmitUint8(0xF3); |
| 510 | EmitUint8(0x0F); |
| 511 | EmitUint8(0x2D); |
| 512 | EmitXmmRegisterOperand(dst, src); |
| 513 | } |
| 514 | |
| 515 | |
| 516 | void Assembler::cvtss2sd(XmmRegister dst, XmmRegister src) { |
| 517 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 518 | EmitUint8(0xF3); |
| 519 | EmitUint8(0x0F); |
| 520 | EmitUint8(0x5A); |
| 521 | EmitXmmRegisterOperand(dst, src); |
| 522 | } |
| 523 | |
| 524 | |
| 525 | void Assembler::cvtsd2si(Register dst, XmmRegister src) { |
| 526 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 527 | EmitUint8(0xF2); |
| 528 | EmitUint8(0x0F); |
| 529 | EmitUint8(0x2D); |
| 530 | EmitXmmRegisterOperand(dst, src); |
| 531 | } |
| 532 | |
| 533 | |
| 534 | void Assembler::cvttss2si(Register dst, XmmRegister src) { |
| 535 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 536 | EmitUint8(0xF3); |
| 537 | EmitUint8(0x0F); |
| 538 | EmitUint8(0x2C); |
| 539 | EmitXmmRegisterOperand(dst, src); |
| 540 | } |
| 541 | |
| 542 | |
| 543 | void Assembler::cvttsd2si(Register dst, XmmRegister src) { |
| 544 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 545 | EmitUint8(0xF2); |
| 546 | EmitUint8(0x0F); |
| 547 | EmitUint8(0x2C); |
| 548 | EmitXmmRegisterOperand(dst, src); |
| 549 | } |
| 550 | |
| 551 | |
| 552 | void Assembler::cvtsd2ss(XmmRegister dst, XmmRegister src) { |
| 553 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 554 | EmitUint8(0xF2); |
| 555 | EmitUint8(0x0F); |
| 556 | EmitUint8(0x5A); |
| 557 | EmitXmmRegisterOperand(dst, src); |
| 558 | } |
| 559 | |
| 560 | |
| 561 | void Assembler::cvtdq2pd(XmmRegister dst, XmmRegister src) { |
| 562 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 563 | EmitUint8(0xF3); |
| 564 | EmitUint8(0x0F); |
| 565 | EmitUint8(0xE6); |
| 566 | EmitXmmRegisterOperand(dst, src); |
| 567 | } |
| 568 | |
| 569 | |
| 570 | void Assembler::comiss(XmmRegister a, XmmRegister b) { |
| 571 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 572 | EmitUint8(0x0F); |
| 573 | EmitUint8(0x2F); |
| 574 | EmitXmmRegisterOperand(a, b); |
| 575 | } |
| 576 | |
| 577 | |
| 578 | void Assembler::comisd(XmmRegister a, XmmRegister b) { |
| 579 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 580 | EmitUint8(0x66); |
| 581 | EmitUint8(0x0F); |
| 582 | EmitUint8(0x2F); |
| 583 | EmitXmmRegisterOperand(a, b); |
| 584 | } |
| 585 | |
| 586 | |
| 587 | void Assembler::sqrtsd(XmmRegister dst, XmmRegister src) { |
| 588 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 589 | EmitUint8(0xF2); |
| 590 | EmitUint8(0x0F); |
| 591 | EmitUint8(0x51); |
| 592 | EmitXmmRegisterOperand(dst, src); |
| 593 | } |
| 594 | |
| 595 | |
| 596 | void Assembler::sqrtss(XmmRegister dst, XmmRegister src) { |
| 597 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 598 | EmitUint8(0xF3); |
| 599 | EmitUint8(0x0F); |
| 600 | EmitUint8(0x51); |
| 601 | EmitXmmRegisterOperand(dst, src); |
| 602 | } |
| 603 | |
| 604 | |
| 605 | void Assembler::xorpd(XmmRegister dst, const Address& src) { |
| 606 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 607 | EmitUint8(0x66); |
| 608 | EmitUint8(0x0F); |
| 609 | EmitUint8(0x57); |
| 610 | EmitOperand(dst, src); |
| 611 | } |
| 612 | |
| 613 | |
| 614 | void Assembler::xorpd(XmmRegister dst, XmmRegister src) { |
| 615 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 616 | EmitUint8(0x66); |
| 617 | EmitUint8(0x0F); |
| 618 | EmitUint8(0x57); |
| 619 | EmitXmmRegisterOperand(dst, src); |
| 620 | } |
| 621 | |
| 622 | |
| 623 | void Assembler::xorps(XmmRegister dst, const Address& src) { |
| 624 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 625 | EmitUint8(0x0F); |
| 626 | EmitUint8(0x57); |
| 627 | EmitOperand(dst, src); |
| 628 | } |
| 629 | |
| 630 | |
| 631 | void Assembler::xorps(XmmRegister dst, XmmRegister src) { |
| 632 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 633 | EmitUint8(0x0F); |
| 634 | EmitUint8(0x57); |
| 635 | EmitXmmRegisterOperand(dst, src); |
| 636 | } |
| 637 | |
| 638 | |
| 639 | void Assembler::andpd(XmmRegister dst, const Address& src) { |
| 640 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 641 | EmitUint8(0x66); |
| 642 | EmitUint8(0x0F); |
| 643 | EmitUint8(0x54); |
| 644 | EmitOperand(dst, src); |
| 645 | } |
| 646 | |
| 647 | |
| 648 | void Assembler::fldl(const Address& src) { |
| 649 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 650 | EmitUint8(0xDD); |
| 651 | EmitOperand(0, src); |
| 652 | } |
| 653 | |
| 654 | |
| 655 | void Assembler::fstpl(const Address& dst) { |
| 656 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 657 | EmitUint8(0xDD); |
| 658 | EmitOperand(3, dst); |
| 659 | } |
| 660 | |
| 661 | |
| 662 | void Assembler::fnstcw(const Address& dst) { |
| 663 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 664 | EmitUint8(0xD9); |
| 665 | EmitOperand(7, dst); |
| 666 | } |
| 667 | |
| 668 | |
| 669 | void Assembler::fldcw(const Address& src) { |
| 670 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 671 | EmitUint8(0xD9); |
| 672 | EmitOperand(5, src); |
| 673 | } |
| 674 | |
| 675 | |
| 676 | void Assembler::fistpl(const Address& dst) { |
| 677 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 678 | EmitUint8(0xDF); |
| 679 | EmitOperand(7, dst); |
| 680 | } |
| 681 | |
| 682 | |
| 683 | void Assembler::fistps(const Address& dst) { |
| 684 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 685 | EmitUint8(0xDB); |
| 686 | EmitOperand(3, dst); |
| 687 | } |
| 688 | |
| 689 | |
| 690 | void Assembler::fildl(const Address& src) { |
| 691 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 692 | EmitUint8(0xDF); |
| 693 | EmitOperand(5, src); |
| 694 | } |
| 695 | |
| 696 | |
| 697 | void Assembler::fincstp() { |
| 698 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 699 | EmitUint8(0xD9); |
| 700 | EmitUint8(0xF7); |
| 701 | } |
| 702 | |
| 703 | |
| 704 | void Assembler::ffree(const Immediate& index) { |
| 705 | CHECK_LT(index.value(), 7); |
| 706 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 707 | EmitUint8(0xDD); |
| 708 | EmitUint8(0xC0 + index.value()); |
| 709 | } |
| 710 | |
| 711 | |
| 712 | void Assembler::fsin() { |
| 713 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 714 | EmitUint8(0xD9); |
| 715 | EmitUint8(0xFE); |
| 716 | } |
| 717 | |
| 718 | |
| 719 | void Assembler::fcos() { |
| 720 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 721 | EmitUint8(0xD9); |
| 722 | EmitUint8(0xFF); |
| 723 | } |
| 724 | |
| 725 | |
| 726 | void Assembler::fptan() { |
| 727 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 728 | EmitUint8(0xD9); |
| 729 | EmitUint8(0xF2); |
| 730 | } |
| 731 | |
| 732 | |
| 733 | void Assembler::xchgl(Register dst, Register src) { |
| 734 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 735 | EmitUint8(0x87); |
| 736 | EmitRegisterOperand(dst, src); |
| 737 | } |
| 738 | |
| 739 | |
| 740 | void Assembler::cmpl(Register reg, const Immediate& imm) { |
| 741 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 742 | EmitComplex(7, Operand(reg), imm); |
| 743 | } |
| 744 | |
| 745 | |
| 746 | void Assembler::cmpl(Register reg0, Register reg1) { |
| 747 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 748 | EmitUint8(0x3B); |
| 749 | EmitOperand(reg0, Operand(reg1)); |
| 750 | } |
| 751 | |
| 752 | |
| 753 | void Assembler::cmpl(Register reg, const Address& address) { |
| 754 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 755 | EmitUint8(0x3B); |
| 756 | EmitOperand(reg, address); |
| 757 | } |
| 758 | |
| 759 | |
| 760 | void Assembler::addl(Register dst, Register src) { |
| 761 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 762 | EmitUint8(0x03); |
| 763 | EmitRegisterOperand(dst, src); |
| 764 | } |
| 765 | |
| 766 | |
| 767 | void Assembler::addl(Register reg, const Address& address) { |
| 768 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 769 | EmitUint8(0x03); |
| 770 | EmitOperand(reg, address); |
| 771 | } |
| 772 | |
| 773 | |
| 774 | void Assembler::cmpl(const Address& address, Register reg) { |
| 775 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 776 | EmitUint8(0x39); |
| 777 | EmitOperand(reg, address); |
| 778 | } |
| 779 | |
| 780 | |
| 781 | void Assembler::cmpl(const Address& address, const Immediate& imm) { |
| 782 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 783 | EmitComplex(7, address, imm); |
| 784 | } |
| 785 | |
| 786 | |
| 787 | void Assembler::testl(Register reg1, Register reg2) { |
| 788 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 789 | EmitUint8(0x85); |
| 790 | EmitRegisterOperand(reg1, reg2); |
| 791 | } |
| 792 | |
| 793 | |
| 794 | void Assembler::testl(Register reg, const Immediate& immediate) { |
| 795 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 796 | // For registers that have a byte variant (EAX, EBX, ECX, and EDX) |
| 797 | // we only test the byte register to keep the encoding short. |
| 798 | if (immediate.is_uint8() && reg < 4) { |
| 799 | // Use zero-extended 8-bit immediate. |
| 800 | if (reg == EAX) { |
| 801 | EmitUint8(0xA8); |
| 802 | } else { |
| 803 | EmitUint8(0xF6); |
| 804 | EmitUint8(0xC0 + reg); |
| 805 | } |
| 806 | EmitUint8(immediate.value() & 0xFF); |
| 807 | } else if (reg == EAX) { |
| 808 | // Use short form if the destination is EAX. |
| 809 | EmitUint8(0xA9); |
| 810 | EmitImmediate(immediate); |
| 811 | } else { |
| 812 | EmitUint8(0xF7); |
| 813 | EmitOperand(0, Operand(reg)); |
| 814 | EmitImmediate(immediate); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | |
| 819 | void Assembler::andl(Register dst, Register src) { |
| 820 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 821 | EmitUint8(0x23); |
| 822 | EmitOperand(dst, Operand(src)); |
| 823 | } |
| 824 | |
| 825 | |
| 826 | void Assembler::andl(Register dst, const Immediate& imm) { |
| 827 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 828 | EmitComplex(4, Operand(dst), imm); |
| 829 | } |
| 830 | |
| 831 | |
| 832 | void Assembler::orl(Register dst, Register src) { |
| 833 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 834 | EmitUint8(0x0B); |
| 835 | EmitOperand(dst, Operand(src)); |
| 836 | } |
| 837 | |
| 838 | |
| 839 | void Assembler::orl(Register dst, const Immediate& imm) { |
| 840 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 841 | EmitComplex(1, Operand(dst), imm); |
| 842 | } |
| 843 | |
| 844 | |
| 845 | void Assembler::xorl(Register dst, Register src) { |
| 846 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 847 | EmitUint8(0x33); |
| 848 | EmitOperand(dst, Operand(src)); |
| 849 | } |
| 850 | |
| 851 | |
| 852 | void Assembler::addl(Register reg, const Immediate& imm) { |
| 853 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 854 | EmitComplex(0, Operand(reg), imm); |
| 855 | } |
| 856 | |
| 857 | |
| 858 | void Assembler::addl(const Address& address, Register reg) { |
| 859 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 860 | EmitUint8(0x01); |
| 861 | EmitOperand(reg, address); |
| 862 | } |
| 863 | |
| 864 | |
| 865 | void Assembler::addl(const Address& address, const Immediate& imm) { |
| 866 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 867 | EmitComplex(0, address, imm); |
| 868 | } |
| 869 | |
| 870 | |
| 871 | void Assembler::adcl(Register reg, const Immediate& imm) { |
| 872 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 873 | EmitComplex(2, Operand(reg), imm); |
| 874 | } |
| 875 | |
| 876 | |
| 877 | void Assembler::adcl(Register dst, Register src) { |
| 878 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 879 | EmitUint8(0x13); |
| 880 | EmitOperand(dst, Operand(src)); |
| 881 | } |
| 882 | |
| 883 | |
| 884 | void Assembler::adcl(Register dst, const Address& address) { |
| 885 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 886 | EmitUint8(0x13); |
| 887 | EmitOperand(dst, address); |
| 888 | } |
| 889 | |
| 890 | |
| 891 | void Assembler::subl(Register dst, Register src) { |
| 892 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 893 | EmitUint8(0x2B); |
| 894 | EmitOperand(dst, Operand(src)); |
| 895 | } |
| 896 | |
| 897 | |
| 898 | void Assembler::subl(Register reg, const Immediate& imm) { |
| 899 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 900 | EmitComplex(5, Operand(reg), imm); |
| 901 | } |
| 902 | |
| 903 | |
| 904 | void Assembler::subl(Register reg, const Address& address) { |
| 905 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 906 | EmitUint8(0x2B); |
| 907 | EmitOperand(reg, address); |
| 908 | } |
| 909 | |
| 910 | |
| 911 | void Assembler::cdq() { |
| 912 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 913 | EmitUint8(0x99); |
| 914 | } |
| 915 | |
| 916 | |
| 917 | void Assembler::idivl(Register reg) { |
| 918 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 919 | EmitUint8(0xF7); |
| 920 | EmitUint8(0xF8 | reg); |
| 921 | } |
| 922 | |
| 923 | |
| 924 | void Assembler::imull(Register dst, Register src) { |
| 925 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 926 | EmitUint8(0x0F); |
| 927 | EmitUint8(0xAF); |
| 928 | EmitOperand(dst, Operand(src)); |
| 929 | } |
| 930 | |
| 931 | |
| 932 | void Assembler::imull(Register reg, const Immediate& imm) { |
| 933 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 934 | EmitUint8(0x69); |
| 935 | EmitOperand(reg, Operand(reg)); |
| 936 | EmitImmediate(imm); |
| 937 | } |
| 938 | |
| 939 | |
| 940 | void Assembler::imull(Register reg, const Address& address) { |
| 941 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 942 | EmitUint8(0x0F); |
| 943 | EmitUint8(0xAF); |
| 944 | EmitOperand(reg, address); |
| 945 | } |
| 946 | |
| 947 | |
| 948 | void Assembler::imull(Register reg) { |
| 949 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 950 | EmitUint8(0xF7); |
| 951 | EmitOperand(5, Operand(reg)); |
| 952 | } |
| 953 | |
| 954 | |
| 955 | void Assembler::imull(const Address& address) { |
| 956 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 957 | EmitUint8(0xF7); |
| 958 | EmitOperand(5, address); |
| 959 | } |
| 960 | |
| 961 | |
| 962 | void Assembler::mull(Register reg) { |
| 963 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 964 | EmitUint8(0xF7); |
| 965 | EmitOperand(4, Operand(reg)); |
| 966 | } |
| 967 | |
| 968 | |
| 969 | void Assembler::mull(const Address& address) { |
| 970 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 971 | EmitUint8(0xF7); |
| 972 | EmitOperand(4, address); |
| 973 | } |
| 974 | |
| 975 | |
| 976 | void Assembler::sbbl(Register dst, Register src) { |
| 977 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 978 | EmitUint8(0x1B); |
| 979 | EmitOperand(dst, Operand(src)); |
| 980 | } |
| 981 | |
| 982 | |
| 983 | void Assembler::sbbl(Register reg, const Immediate& imm) { |
| 984 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 985 | EmitComplex(3, Operand(reg), imm); |
| 986 | } |
| 987 | |
| 988 | |
| 989 | void Assembler::sbbl(Register dst, const Address& address) { |
| 990 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 991 | EmitUint8(0x1B); |
| 992 | EmitOperand(dst, address); |
| 993 | } |
| 994 | |
| 995 | |
| 996 | void Assembler::incl(Register reg) { |
| 997 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 998 | EmitUint8(0x40 + reg); |
| 999 | } |
| 1000 | |
| 1001 | |
| 1002 | void Assembler::incl(const Address& address) { |
| 1003 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1004 | EmitUint8(0xFF); |
| 1005 | EmitOperand(0, address); |
| 1006 | } |
| 1007 | |
| 1008 | |
| 1009 | void Assembler::decl(Register reg) { |
| 1010 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1011 | EmitUint8(0x48 + reg); |
| 1012 | } |
| 1013 | |
| 1014 | |
| 1015 | void Assembler::decl(const Address& address) { |
| 1016 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1017 | EmitUint8(0xFF); |
| 1018 | EmitOperand(1, address); |
| 1019 | } |
| 1020 | |
| 1021 | |
| 1022 | void Assembler::shll(Register reg, const Immediate& imm) { |
| 1023 | EmitGenericShift(4, reg, imm); |
| 1024 | } |
| 1025 | |
| 1026 | |
| 1027 | void Assembler::shll(Register operand, Register shifter) { |
| 1028 | EmitGenericShift(4, operand, shifter); |
| 1029 | } |
| 1030 | |
| 1031 | |
| 1032 | void Assembler::shrl(Register reg, const Immediate& imm) { |
| 1033 | EmitGenericShift(5, reg, imm); |
| 1034 | } |
| 1035 | |
| 1036 | |
| 1037 | void Assembler::shrl(Register operand, Register shifter) { |
| 1038 | EmitGenericShift(5, operand, shifter); |
| 1039 | } |
| 1040 | |
| 1041 | |
| 1042 | void Assembler::sarl(Register reg, const Immediate& imm) { |
| 1043 | EmitGenericShift(7, reg, imm); |
| 1044 | } |
| 1045 | |
| 1046 | |
| 1047 | void Assembler::sarl(Register operand, Register shifter) { |
| 1048 | EmitGenericShift(7, operand, shifter); |
| 1049 | } |
| 1050 | |
| 1051 | |
| 1052 | void Assembler::shld(Register dst, Register src) { |
| 1053 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1054 | EmitUint8(0x0F); |
| 1055 | EmitUint8(0xA5); |
| 1056 | EmitRegisterOperand(src, dst); |
| 1057 | } |
| 1058 | |
| 1059 | |
| 1060 | void Assembler::negl(Register reg) { |
| 1061 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1062 | EmitUint8(0xF7); |
| 1063 | EmitOperand(3, Operand(reg)); |
| 1064 | } |
| 1065 | |
| 1066 | |
| 1067 | void Assembler::notl(Register reg) { |
| 1068 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1069 | EmitUint8(0xF7); |
| 1070 | EmitUint8(0xD0 | reg); |
| 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | void Assembler::enter(const Immediate& imm) { |
| 1075 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1076 | EmitUint8(0xC8); |
| 1077 | CHECK(imm.is_uint16()); |
| 1078 | EmitUint8(imm.value() & 0xFF); |
| 1079 | EmitUint8((imm.value() >> 8) & 0xFF); |
| 1080 | EmitUint8(0x00); |
| 1081 | } |
| 1082 | |
| 1083 | |
| 1084 | void Assembler::leave() { |
| 1085 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1086 | EmitUint8(0xC9); |
| 1087 | } |
| 1088 | |
| 1089 | |
| 1090 | void Assembler::ret() { |
| 1091 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1092 | EmitUint8(0xC3); |
| 1093 | } |
| 1094 | |
| 1095 | |
| 1096 | void Assembler::ret(const Immediate& imm) { |
| 1097 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1098 | EmitUint8(0xC2); |
| 1099 | CHECK(imm.is_uint16()); |
| 1100 | EmitUint8(imm.value() & 0xFF); |
| 1101 | EmitUint8((imm.value() >> 8) & 0xFF); |
| 1102 | } |
| 1103 | |
| 1104 | |
| 1105 | |
| 1106 | void Assembler::nop() { |
| 1107 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1108 | EmitUint8(0x90); |
| 1109 | } |
| 1110 | |
| 1111 | |
| 1112 | void Assembler::int3() { |
| 1113 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1114 | EmitUint8(0xCC); |
| 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | void Assembler::hlt() { |
| 1119 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1120 | EmitUint8(0xF4); |
| 1121 | } |
| 1122 | |
| 1123 | |
| 1124 | void Assembler::j(Condition condition, Label* label) { |
| 1125 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1126 | if (label->IsBound()) { |
| 1127 | static const int kShortSize = 2; |
| 1128 | static const int kLongSize = 6; |
| 1129 | int offset = label->Position() - buffer_.Size(); |
| 1130 | CHECK_LE(offset, 0); |
| 1131 | if (IsInt(8, offset - kShortSize)) { |
| 1132 | EmitUint8(0x70 + condition); |
| 1133 | EmitUint8((offset - kShortSize) & 0xFF); |
| 1134 | } else { |
| 1135 | EmitUint8(0x0F); |
| 1136 | EmitUint8(0x80 + condition); |
| 1137 | EmitInt32(offset - kLongSize); |
| 1138 | } |
| 1139 | } else { |
| 1140 | EmitUint8(0x0F); |
| 1141 | EmitUint8(0x80 + condition); |
| 1142 | EmitLabelLink(label); |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | |
| 1147 | void Assembler::jmp(Register reg) { |
| 1148 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1149 | EmitUint8(0xFF); |
| 1150 | EmitRegisterOperand(4, reg); |
| 1151 | } |
| 1152 | |
| 1153 | |
| 1154 | void Assembler::jmp(Label* label) { |
| 1155 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1156 | if (label->IsBound()) { |
| 1157 | static const int kShortSize = 2; |
| 1158 | static const int kLongSize = 5; |
| 1159 | int offset = label->Position() - buffer_.Size(); |
| 1160 | CHECK_LE(offset, 0); |
| 1161 | if (IsInt(8, offset - kShortSize)) { |
| 1162 | EmitUint8(0xEB); |
| 1163 | EmitUint8((offset - kShortSize) & 0xFF); |
| 1164 | } else { |
| 1165 | EmitUint8(0xE9); |
| 1166 | EmitInt32(offset - kLongSize); |
| 1167 | } |
| 1168 | } else { |
| 1169 | EmitUint8(0xE9); |
| 1170 | EmitLabelLink(label); |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | |
| 1175 | void Assembler::lock() { |
| 1176 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1177 | EmitUint8(0xF0); |
| 1178 | } |
| 1179 | |
| 1180 | |
| 1181 | void Assembler::cmpxchgl(const Address& address, Register reg) { |
| 1182 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1183 | EmitUint8(0x0F); |
| 1184 | EmitUint8(0xB1); |
| 1185 | EmitOperand(reg, address); |
| 1186 | } |
| 1187 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1188 | void Assembler::fs() { |
| 1189 | // TODO: fs is a prefix and not an instruction |
| 1190 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1191 | EmitUint8(0x64); |
| 1192 | } |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 1193 | |
| 1194 | void Assembler::AddImmediate(Register reg, const Immediate& imm) { |
| 1195 | int value = imm.value(); |
| 1196 | if (value > 0) { |
| 1197 | if (value == 1) { |
| 1198 | incl(reg); |
| 1199 | } else if (value != 0) { |
| 1200 | addl(reg, imm); |
| 1201 | } |
| 1202 | } else if (value < 0) { |
| 1203 | value = -value; |
| 1204 | if (value == 1) { |
| 1205 | decl(reg); |
| 1206 | } else if (value != 0) { |
| 1207 | subl(reg, Immediate(value)); |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | |
| 1213 | void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { |
| 1214 | // TODO: Need to have a code constants table. |
| 1215 | int64_t constant = bit_cast<int64_t, double>(value); |
| 1216 | pushl(Immediate(High32Bits(constant))); |
| 1217 | pushl(Immediate(Low32Bits(constant))); |
| 1218 | movsd(dst, Address(ESP, 0)); |
| 1219 | addl(ESP, Immediate(2 * kWordSize)); |
| 1220 | } |
| 1221 | |
| 1222 | |
| 1223 | void Assembler::FloatNegate(XmmRegister f) { |
| 1224 | static const struct { |
| 1225 | uint32_t a; |
| 1226 | uint32_t b; |
| 1227 | uint32_t c; |
| 1228 | uint32_t d; |
| 1229 | } float_negate_constant __attribute__((aligned(16))) = |
| 1230 | { 0x80000000, 0x00000000, 0x80000000, 0x00000000 }; |
| 1231 | xorps(f, Address::Absolute(reinterpret_cast<uword>(&float_negate_constant))); |
| 1232 | } |
| 1233 | |
| 1234 | |
| 1235 | void Assembler::DoubleNegate(XmmRegister d) { |
| 1236 | static const struct { |
| 1237 | uint64_t a; |
| 1238 | uint64_t b; |
| 1239 | } double_negate_constant __attribute__((aligned(16))) = |
| 1240 | {0x8000000000000000LL, 0x8000000000000000LL}; |
| 1241 | xorpd(d, Address::Absolute(reinterpret_cast<uword>(&double_negate_constant))); |
| 1242 | } |
| 1243 | |
| 1244 | |
| 1245 | void Assembler::DoubleAbs(XmmRegister reg) { |
| 1246 | static const struct { |
| 1247 | uint64_t a; |
| 1248 | uint64_t b; |
| 1249 | } double_abs_constant __attribute__((aligned(16))) = |
| 1250 | {0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFFLL}; |
| 1251 | andpd(reg, Address::Absolute(reinterpret_cast<uword>(&double_abs_constant))); |
| 1252 | } |
| 1253 | |
| 1254 | |
| 1255 | void Assembler::Align(int alignment, int offset) { |
| 1256 | CHECK(IsPowerOfTwo(alignment)); |
| 1257 | // Emit nop instruction until the real position is aligned. |
| 1258 | while (((offset + buffer_.GetPosition()) & (alignment-1)) != 0) { |
| 1259 | nop(); |
| 1260 | } |
| 1261 | } |
| 1262 | |
| 1263 | |
| 1264 | void Assembler::Bind(Label* label) { |
| 1265 | int bound = buffer_.Size(); |
| 1266 | CHECK(!label->IsBound()); // Labels can only be bound once. |
| 1267 | while (label->IsLinked()) { |
| 1268 | int position = label->LinkPosition(); |
| 1269 | int next = buffer_.Load<int32_t>(position); |
| 1270 | buffer_.Store<int32_t>(position, bound - (position + 4)); |
| 1271 | label->position_ = next; |
| 1272 | } |
| 1273 | label->BindTo(bound); |
| 1274 | } |
| 1275 | |
| 1276 | |
| 1277 | void Assembler::Stop(const char* message) { |
| 1278 | // Emit the message address as immediate operand in the test rax instruction, |
| 1279 | // followed by the int3 instruction. |
| 1280 | // Execution can be resumed with the 'cont' command in gdb. |
| 1281 | testl(EAX, Immediate(reinterpret_cast<int32_t>(message))); |
| 1282 | int3(); |
| 1283 | } |
| 1284 | |
| 1285 | |
| 1286 | void Assembler::EmitOperand(int rm, const Operand& operand) { |
| 1287 | CHECK_GE(rm, 0); |
| 1288 | CHECK_LT(rm, 8); |
| 1289 | const int length = operand.length_; |
| 1290 | CHECK_GT(length, 0); |
| 1291 | // Emit the ModRM byte updated with the given RM value. |
| 1292 | CHECK_EQ(operand.encoding_[0] & 0x38, 0); |
| 1293 | EmitUint8(operand.encoding_[0] + (rm << 3)); |
| 1294 | // Emit the rest of the encoded operand. |
| 1295 | for (int i = 1; i < length; i++) { |
| 1296 | EmitUint8(operand.encoding_[i]); |
| 1297 | } |
| 1298 | } |
| 1299 | |
| 1300 | |
| 1301 | void Assembler::EmitImmediate(const Immediate& imm) { |
| 1302 | EmitInt32(imm.value()); |
| 1303 | } |
| 1304 | |
| 1305 | |
| 1306 | void Assembler::EmitComplex(int rm, |
| 1307 | const Operand& operand, |
| 1308 | const Immediate& immediate) { |
| 1309 | CHECK_GE(rm, 0); |
| 1310 | CHECK_LT(rm, 8); |
| 1311 | if (immediate.is_int8()) { |
| 1312 | // Use sign-extended 8-bit immediate. |
| 1313 | EmitUint8(0x83); |
| 1314 | EmitOperand(rm, operand); |
| 1315 | EmitUint8(immediate.value() & 0xFF); |
| 1316 | } else if (operand.IsRegister(EAX)) { |
| 1317 | // Use short form if the destination is eax. |
| 1318 | EmitUint8(0x05 + (rm << 3)); |
| 1319 | EmitImmediate(immediate); |
| 1320 | } else { |
| 1321 | EmitUint8(0x81); |
| 1322 | EmitOperand(rm, operand); |
| 1323 | EmitImmediate(immediate); |
| 1324 | } |
| 1325 | } |
| 1326 | |
| 1327 | |
| 1328 | void Assembler::EmitLabel(Label* label, int instruction_size) { |
| 1329 | if (label->IsBound()) { |
| 1330 | int offset = label->Position() - buffer_.Size(); |
| 1331 | CHECK_LE(offset, 0); |
| 1332 | EmitInt32(offset - instruction_size); |
| 1333 | } else { |
| 1334 | EmitLabelLink(label); |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | |
| 1339 | void Assembler::EmitLabelLink(Label* label) { |
| 1340 | CHECK(!label->IsBound()); |
| 1341 | int position = buffer_.Size(); |
| 1342 | EmitInt32(label->position_); |
| 1343 | label->LinkTo(position); |
| 1344 | } |
| 1345 | |
| 1346 | |
| 1347 | void Assembler::EmitGenericShift(int rm, |
| 1348 | Register reg, |
| 1349 | const Immediate& imm) { |
| 1350 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1351 | CHECK(imm.is_int8()); |
| 1352 | if (imm.value() == 1) { |
| 1353 | EmitUint8(0xD1); |
| 1354 | EmitOperand(rm, Operand(reg)); |
| 1355 | } else { |
| 1356 | EmitUint8(0xC1); |
| 1357 | EmitOperand(rm, Operand(reg)); |
| 1358 | EmitUint8(imm.value() & 0xFF); |
| 1359 | } |
| 1360 | } |
| 1361 | |
| 1362 | |
| 1363 | void Assembler::EmitGenericShift(int rm, |
| 1364 | Register operand, |
| 1365 | Register shifter) { |
| 1366 | AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1367 | CHECK_EQ(shifter, ECX); |
| 1368 | EmitUint8(0xD3); |
| 1369 | EmitOperand(rm, Operand(operand)); |
| 1370 | } |
| 1371 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1372 | // Emit code that will create an activation on the stack |
| 1373 | void Assembler::BuildFrame(size_t frame_size, ManagedRegister method_reg) { |
| 1374 | CHECK(IsAligned(frame_size, 16)); |
| 1375 | // return address then method on stack |
| 1376 | addl(ESP, Immediate(-frame_size + 4 /*method*/ + 4 /*return address*/)); |
| 1377 | pushl(method_reg.AsCpuRegister()); |
| 1378 | } |
| 1379 | |
| 1380 | // Emit code that will remove an activation from the stack |
| 1381 | void Assembler::RemoveFrame(size_t frame_size) { |
| 1382 | CHECK(IsAligned(frame_size, 16)); |
| 1383 | addl(ESP, Immediate(frame_size - 4)); |
| 1384 | ret(); |
| 1385 | } |
| 1386 | |
| 1387 | void Assembler::IncreaseFrameSize(size_t adjust) { |
| 1388 | CHECK(IsAligned(adjust, 16)); |
| 1389 | addl(ESP, Immediate(-adjust)); |
| 1390 | } |
| 1391 | |
| 1392 | void Assembler::DecreaseFrameSize(size_t adjust) { |
| 1393 | CHECK(IsAligned(adjust, 16)); |
| 1394 | addl(ESP, Immediate(adjust)); |
| 1395 | } |
| 1396 | |
| 1397 | // Store bytes from the given register onto the stack |
| 1398 | void Assembler::Store(FrameOffset offs, ManagedRegister src, size_t size) { |
| 1399 | if (src.IsCpuRegister()) { |
| 1400 | CHECK_EQ(4u, size); |
| 1401 | movl(Address(ESP, offs), src.AsCpuRegister()); |
| 1402 | } else if (src.IsXmmRegister()) { |
| 1403 | if (size == 4) { |
| 1404 | movss(Address(ESP, offs), src.AsXmmRegister()); |
| 1405 | } else { |
| 1406 | movsd(Address(ESP, offs), src.AsXmmRegister()); |
| 1407 | } |
| 1408 | } |
| 1409 | } |
| 1410 | |
| 1411 | void Assembler::StoreRef(FrameOffset dest, ManagedRegister src) { |
| 1412 | CHECK(src.IsCpuRegister()); |
| 1413 | movl(Address(ESP, dest), src.AsCpuRegister()); |
| 1414 | } |
| 1415 | |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame^] | 1416 | void Assembler::StoreRawPtr(FrameOffset dest, ManagedRegister src) { |
| 1417 | CHECK(src.IsCpuRegister()); |
| 1418 | movl(Address(ESP, dest), src.AsCpuRegister()); |
| 1419 | } |
| 1420 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1421 | void Assembler::CopyRef(FrameOffset dest, FrameOffset src, |
| 1422 | ManagedRegister scratch) { |
| 1423 | CHECK(scratch.IsCpuRegister()); |
| 1424 | movl(scratch.AsCpuRegister(), Address(ESP, src)); |
| 1425 | movl(Address(ESP, dest), scratch.AsCpuRegister()); |
| 1426 | } |
| 1427 | |
| 1428 | void Assembler::StoreImmediateToFrame(FrameOffset dest, uint32_t imm, |
| 1429 | ManagedRegister) { |
| 1430 | movl(Address(ESP, dest), Immediate(imm)); |
| 1431 | } |
| 1432 | |
| 1433 | void Assembler::StoreImmediateToThread(ThreadOffset dest, uint32_t imm, |
| 1434 | ManagedRegister) { |
| 1435 | fs(); |
| 1436 | movl(Address::Absolute(dest), Immediate(imm)); |
| 1437 | } |
| 1438 | |
| 1439 | void Assembler::Load(ManagedRegister dest, FrameOffset src, size_t size) { |
| 1440 | if (dest.IsCpuRegister()) { |
| 1441 | CHECK_EQ(4u, size); |
| 1442 | movl(dest.AsCpuRegister(), Address(ESP, src)); |
| 1443 | } else { |
| 1444 | // TODO: x87, SSE |
| 1445 | LOG(FATAL) << "Unimplemented"; |
| 1446 | } |
| 1447 | } |
| 1448 | |
| 1449 | void Assembler::LoadRef(ManagedRegister dest, FrameOffset src) { |
| 1450 | CHECK(dest.IsCpuRegister()); |
| 1451 | movl(dest.AsCpuRegister(), Address(ESP, src)); |
| 1452 | } |
| 1453 | |
| 1454 | void Assembler::LoadRef(ManagedRegister dest, ManagedRegister base, |
| 1455 | MemberOffset offs) { |
| 1456 | CHECK(dest.IsCpuRegister() && dest.IsCpuRegister()); |
| 1457 | movl(dest.AsCpuRegister(), Address(base.AsCpuRegister(), offs)); |
| 1458 | } |
| 1459 | |
| 1460 | void Assembler::LoadRawPtrFromThread(ManagedRegister dest, ThreadOffset offs) { |
| 1461 | CHECK(dest.IsCpuRegister()); |
| 1462 | fs(); |
| 1463 | movl(dest.AsCpuRegister(), Address::Absolute(offs)); |
| 1464 | } |
| 1465 | |
| 1466 | void Assembler::CopyRawPtrFromThread(FrameOffset fr_offs, ThreadOffset thr_offs, |
| 1467 | ManagedRegister scratch) { |
| 1468 | CHECK(scratch.IsCpuRegister()); |
| 1469 | fs(); |
| 1470 | movl(scratch.AsCpuRegister(), Address::Absolute(thr_offs)); |
| 1471 | Store(fr_offs, scratch, 4); |
| 1472 | } |
| 1473 | |
| 1474 | void Assembler::CopyRawPtrToThread(ThreadOffset thr_offs, FrameOffset fr_offs, |
| 1475 | ManagedRegister scratch) { |
| 1476 | CHECK(scratch.IsCpuRegister()); |
| 1477 | Load(scratch, fr_offs, 4); |
| 1478 | fs(); |
| 1479 | movl(Address::Absolute(thr_offs), scratch.AsCpuRegister()); |
| 1480 | } |
| 1481 | |
| 1482 | void Assembler::StoreStackOffsetToThread(ThreadOffset thr_offs, |
| 1483 | FrameOffset fr_offs, |
| 1484 | ManagedRegister scratch) { |
| 1485 | CHECK(scratch.IsCpuRegister()); |
| 1486 | leal(scratch.AsCpuRegister(), Address(ESP, fr_offs)); |
| 1487 | fs(); |
| 1488 | movl(Address::Absolute(thr_offs), scratch.AsCpuRegister()); |
| 1489 | } |
| 1490 | |
| 1491 | void Assembler::Move(ManagedRegister dest, ManagedRegister src) { |
| 1492 | if (!dest.Equals(src)) { |
| 1493 | if (dest.IsCpuRegister() && src.IsCpuRegister()) { |
| 1494 | movl(dest.AsCpuRegister(), src.AsCpuRegister()); |
| 1495 | } else { |
| 1496 | // TODO: x87, SSE |
| 1497 | LOG(FATAL) << "Unimplemented"; |
| 1498 | } |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | void Assembler::Copy(FrameOffset dest, FrameOffset src, ManagedRegister scratch, |
| 1503 | size_t size) { |
| 1504 | if (scratch.IsCpuRegister() && size == 8) { |
| 1505 | Load(scratch, src, 4); |
| 1506 | Store(dest, scratch, 4); |
| 1507 | Load(scratch, FrameOffset(src.Int32Value() + 4), 4); |
| 1508 | Store(FrameOffset(dest.Int32Value() + 4), scratch, 4); |
| 1509 | } else { |
| 1510 | Load(scratch, src, size); |
| 1511 | Store(dest, scratch, size); |
| 1512 | } |
| 1513 | } |
| 1514 | |
| 1515 | void Assembler::CreateStackHandle(ManagedRegister out_reg, |
| 1516 | FrameOffset handle_offset, |
| 1517 | ManagedRegister in_reg, bool null_allowed) { |
| 1518 | CHECK(in_reg.IsCpuRegister()); |
| 1519 | CHECK(out_reg.IsCpuRegister()); |
| 1520 | ValidateRef(in_reg, null_allowed); |
| 1521 | if (null_allowed) { |
| 1522 | Label null_arg; |
| 1523 | if (!out_reg.Equals(in_reg)) { |
| 1524 | xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister()); |
| 1525 | } |
| 1526 | testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister()); |
| 1527 | j(ZERO, &null_arg); |
| 1528 | leal(out_reg.AsCpuRegister(), Address(ESP, handle_offset)); |
| 1529 | Bind(&null_arg); |
| 1530 | } else { |
| 1531 | leal(out_reg.AsCpuRegister(), Address(ESP, handle_offset)); |
| 1532 | } |
| 1533 | } |
| 1534 | |
| 1535 | void Assembler::CreateStackHandle(FrameOffset out_off, |
| 1536 | FrameOffset handle_offset, |
| 1537 | ManagedRegister scratch, bool null_allowed) { |
| 1538 | CHECK(scratch.IsCpuRegister()); |
| 1539 | if (null_allowed) { |
| 1540 | Label null_arg; |
| 1541 | movl(scratch.AsCpuRegister(), Address(ESP, handle_offset)); |
| 1542 | testl(scratch.AsCpuRegister(), scratch.AsCpuRegister()); |
| 1543 | j(ZERO, &null_arg); |
| 1544 | leal(scratch.AsCpuRegister(), Address(ESP, handle_offset)); |
| 1545 | Bind(&null_arg); |
| 1546 | } else { |
| 1547 | leal(scratch.AsCpuRegister(), Address(ESP, handle_offset)); |
| 1548 | } |
| 1549 | Store(out_off, scratch, 4); |
| 1550 | } |
| 1551 | |
| 1552 | // Given a stack handle, load the associated reference. |
| 1553 | void Assembler::LoadReferenceFromStackHandle(ManagedRegister out_reg, |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame^] | 1554 | ManagedRegister in_reg) { |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1555 | CHECK(out_reg.IsCpuRegister()); |
| 1556 | CHECK(in_reg.IsCpuRegister()); |
| 1557 | Label null_arg; |
| 1558 | if (!out_reg.Equals(in_reg)) { |
| 1559 | xorl(out_reg.AsCpuRegister(), out_reg.AsCpuRegister()); |
| 1560 | } |
| 1561 | testl(in_reg.AsCpuRegister(), in_reg.AsCpuRegister()); |
| 1562 | j(ZERO, &null_arg); |
| 1563 | movl(out_reg.AsCpuRegister(), Address(in_reg.AsCpuRegister(), 0)); |
| 1564 | Bind(&null_arg); |
| 1565 | } |
| 1566 | |
| 1567 | void Assembler::ValidateRef(ManagedRegister src, bool could_be_null) { |
| 1568 | // TODO: not validating references |
| 1569 | } |
| 1570 | |
| 1571 | void Assembler::ValidateRef(FrameOffset src, bool could_be_null) { |
| 1572 | // TODO: not validating references |
| 1573 | } |
| 1574 | |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame^] | 1575 | void Assembler::Call(ManagedRegister base, Offset offset, |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1576 | ManagedRegister) { |
| 1577 | CHECK(base.IsCpuRegister()); |
Ian Rogers | df20fe0 | 2011-07-20 20:34:16 -0700 | [diff] [blame^] | 1578 | call(Address(base.AsCpuRegister(), offset.Int32Value())); |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1579 | // TODO: place reference map on call |
| 1580 | } |
| 1581 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 1582 | } // namespace art |