| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions | 5 // modification, are permitted provided that the following conditions |
| 6 // are met: | 6 // are met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 | 412 |
| 413 | 413 |
| 414 void Assembler::push(const Operand& src) { | 414 void Assembler::push(const Operand& src) { |
| 415 EnsureSpace ensure_space(this); | 415 EnsureSpace ensure_space(this); |
| 416 last_pc_ = pc_; | 416 last_pc_ = pc_; |
| 417 EMIT(0xFF); | 417 EMIT(0xFF); |
| 418 emit_operand(esi, src); | 418 emit_operand(esi, src); |
| 419 } | 419 } |
| 420 | 420 |
| 421 | 421 |
| 422 void Assembler::push(Label* label, RelocInfo::Mode reloc_mode) { |
| 423 EnsureSpace ensure_space(this); |
| 424 last_pc_ = pc_; |
| 425 // If reloc_mode == NONE, the label is stored as buffer relative. |
| 426 ASSERT(reloc_mode == RelocInfo::NONE); |
| 427 if (label->is_bound()) { |
| 428 // Index of position in Code object: |
| 429 int pos = label->pos() + Code::kHeaderSize; |
| 430 if (pos >= 0 && pos < 256) { |
| 431 EMIT(0x6a); |
| 432 EMIT(pos); |
| 433 } else { |
| 434 EMIT(0x68); |
| 435 emit(pos); |
| 436 } |
| 437 } else { |
| 438 EMIT(0x68); |
| 439 emit_disp(label, Displacement::CODE_RELATIVE); |
| 440 } |
| 441 } |
| 442 |
| 443 |
| 422 void Assembler::pop(Register dst) { | 444 void Assembler::pop(Register dst) { |
| 423 ASSERT(reloc_info_writer.last_pc() != NULL); | 445 ASSERT(reloc_info_writer.last_pc() != NULL); |
| 424 if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) { | 446 if (FLAG_push_pop_elimination && (reloc_info_writer.last_pc() <= last_pc_)) { |
| 425 // (last_pc_ != NULL) is rolled into the above check | 447 // (last_pc_ != NULL) is rolled into the above check |
| 426 // If a last_pc_ is set, we need to make sure that there has not been any | 448 // If a last_pc_ is set, we need to make sure that there has not been any |
| 427 // relocation information generated between the last instruction and this | 449 // relocation information generated between the last instruction and this |
| 428 // pop instruction. | 450 // pop instruction. |
| 429 byte instr = last_pc_[0]; | 451 byte instr = last_pc_[0]; |
| 430 if ((instr & ~0x7) == 0x50) { | 452 if ((instr & ~0x7) == 0x50) { |
| 431 int push_reg_code = instr & 0x7; | 453 int push_reg_code = instr & 0x7; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 | 1121 |
| 1100 | 1122 |
| 1101 void Assembler::shr(Register dst) { | 1123 void Assembler::shr(Register dst) { |
| 1102 EnsureSpace ensure_space(this); | 1124 EnsureSpace ensure_space(this); |
| 1103 last_pc_ = pc_; | 1125 last_pc_ = pc_; |
| 1104 EMIT(0xD3); | 1126 EMIT(0xD3); |
| 1105 EMIT(0xE8 | dst.code()); | 1127 EMIT(0xE8 | dst.code()); |
| 1106 } | 1128 } |
| 1107 | 1129 |
| 1108 | 1130 |
| 1131 void Assembler::shr_cl(Register dst) { |
| 1132 EnsureSpace ensure_space(this); |
| 1133 last_pc_ = pc_; |
| 1134 EMIT(0xD1); |
| 1135 EMIT(0xE8 | dst.code()); |
| 1136 } |
| 1137 |
| 1138 |
| 1109 void Assembler::sub(const Operand& dst, const Immediate& x) { | 1139 void Assembler::sub(const Operand& dst, const Immediate& x) { |
| 1110 EnsureSpace ensure_space(this); | 1140 EnsureSpace ensure_space(this); |
| 1111 last_pc_ = pc_; | 1141 last_pc_ = pc_; |
| 1112 emit_arith(5, dst, x); | 1142 emit_arith(5, dst, x); |
| 1113 } | 1143 } |
| 1114 | 1144 |
| 1115 | 1145 |
| 1116 void Assembler::sub(Register dst, const Operand& src) { | 1146 void Assembler::sub(Register dst, const Operand& src) { |
| 1117 EnsureSpace ensure_space(this); | 1147 EnsureSpace ensure_space(this); |
| 1118 last_pc_ = pc_; | 1148 last_pc_ = pc_; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 } | 1327 } |
| 1298 | 1328 |
| 1299 | 1329 |
| 1300 void Assembler::bind_to(Label* L, int pos) { | 1330 void Assembler::bind_to(Label* L, int pos) { |
| 1301 EnsureSpace ensure_space(this); | 1331 EnsureSpace ensure_space(this); |
| 1302 last_pc_ = NULL; | 1332 last_pc_ = NULL; |
| 1303 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position | 1333 ASSERT(0 <= pos && pos <= pc_offset()); // must have a valid binding position |
| 1304 while (L->is_linked()) { | 1334 while (L->is_linked()) { |
| 1305 Displacement disp = disp_at(L); | 1335 Displacement disp = disp_at(L); |
| 1306 int fixup_pos = L->pos(); | 1336 int fixup_pos = L->pos(); |
| 1307 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { | 1337 if (disp.type() == Displacement::CODE_RELATIVE) { |
| 1308 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected | 1338 long_at_put(fixup_pos, pos + Code::kHeaderSize); |
| 1339 } else { |
| 1340 if (disp.type() == Displacement::UNCONDITIONAL_JUMP) { |
| 1341 ASSERT(byte_at(fixup_pos - 1) == 0xE9); // jmp expected |
| 1342 } |
| 1343 // relative address, relative to point after address |
| 1344 int imm32 = pos - (fixup_pos + sizeof(int32_t)); |
| 1345 long_at_put(fixup_pos, imm32); |
| 1309 } | 1346 } |
| 1310 // relative address, relative to point after address | |
| 1311 int imm32 = pos - (fixup_pos + sizeof(int32_t)); | |
| 1312 long_at_put(fixup_pos, imm32); | |
| 1313 disp.next(L); | 1347 disp.next(L); |
| 1314 } | 1348 } |
| 1315 L->bind_to(pos); | 1349 L->bind_to(pos); |
| 1316 } | 1350 } |
| 1317 | 1351 |
| 1318 | 1352 |
| 1319 void Assembler::link_to(Label* L, Label* appendix) { | 1353 void Assembler::link_to(Label* L, Label* appendix) { |
| 1320 EnsureSpace ensure_space(this); | 1354 EnsureSpace ensure_space(this); |
| 1321 last_pc_ = NULL; | 1355 last_pc_ = NULL; |
| 1322 if (appendix->is_linked()) { | 1356 if (appendix->is_linked()) { |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 ASSERT(bound_label.is_bound()); | 2132 ASSERT(bound_label.is_bound()); |
| 2099 ASSERT(0 <= position); | 2133 ASSERT(0 <= position); |
| 2100 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); | 2134 ASSERT(position + static_cast<int>(sizeof(uint32_t)) <= pc_offset()); |
| 2101 ASSERT(long_at(position) == 0); // only initialize once! | 2135 ASSERT(long_at(position) == 0); // only initialize once! |
| 2102 | 2136 |
| 2103 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); | 2137 uint32_t label_loc = reinterpret_cast<uint32_t>(addr_at(bound_label.pos())); |
| 2104 long_at_put(position, label_loc); | 2138 long_at_put(position, label_loc); |
| 2105 } | 2139 } |
| 2106 | 2140 |
| 2107 } } // namespace v8::internal | 2141 } } // namespace v8::internal |
| OLD | NEW |