Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/assembler_x86.cpp @ 3851:95134e034042
7063629: use cbcond in C2 generated code on T4
Summary: Use new short branch instruction in C2 generated code.
Reviewed-by: never
author | kvn |
---|---|
date | Thu, 11 Aug 2011 12:08:11 -0700 |
parents | de6a837d75cf |
children | 1af104d6cf99 |
comparison
equal
deleted
inserted
replaced
3850:6987871cfb9b | 3851:95134e034042 |
---|---|
1337 prefix(dst); | 1337 prefix(dst); |
1338 emit_byte(0xFF); | 1338 emit_byte(0xFF); |
1339 emit_operand(rax, dst); | 1339 emit_operand(rax, dst); |
1340 } | 1340 } |
1341 | 1341 |
1342 void Assembler::jcc(Condition cc, Label& L, relocInfo::relocType rtype) { | 1342 void Assembler::jcc(Condition cc, Label& L, bool maybe_short) { |
1343 InstructionMark im(this); | 1343 InstructionMark im(this); |
1344 relocate(rtype); | |
1345 assert((0 <= cc) && (cc < 16), "illegal cc"); | 1344 assert((0 <= cc) && (cc < 16), "illegal cc"); |
1346 if (L.is_bound()) { | 1345 if (L.is_bound()) { |
1347 address dst = target(L); | 1346 address dst = target(L); |
1348 assert(dst != NULL, "jcc most probably wrong"); | 1347 assert(dst != NULL, "jcc most probably wrong"); |
1349 | 1348 |
1350 const int short_size = 2; | 1349 const int short_size = 2; |
1351 const int long_size = 6; | 1350 const int long_size = 6; |
1352 intptr_t offs = (intptr_t)dst - (intptr_t)_code_pos; | 1351 intptr_t offs = (intptr_t)dst - (intptr_t)_code_pos; |
1353 if (rtype == relocInfo::none && is8bit(offs - short_size)) { | 1352 if (maybe_short && is8bit(offs - short_size)) { |
1354 // 0111 tttn #8-bit disp | 1353 // 0111 tttn #8-bit disp |
1355 emit_byte(0x70 | cc); | 1354 emit_byte(0x70 | cc); |
1356 emit_byte((offs - short_size) & 0xFF); | 1355 emit_byte((offs - short_size) & 0xFF); |
1357 } else { | 1356 } else { |
1358 // 0000 1111 1000 tttn #32-bit disp | 1357 // 0000 1111 1000 tttn #32-bit disp |
1397 prefix(adr); | 1396 prefix(adr); |
1398 emit_byte(0xFF); | 1397 emit_byte(0xFF); |
1399 emit_operand(rsp, adr); | 1398 emit_operand(rsp, adr); |
1400 } | 1399 } |
1401 | 1400 |
1402 void Assembler::jmp(Label& L, relocInfo::relocType rtype) { | 1401 void Assembler::jmp(Label& L, bool maybe_short) { |
1403 if (L.is_bound()) { | 1402 if (L.is_bound()) { |
1404 address entry = target(L); | 1403 address entry = target(L); |
1405 assert(entry != NULL, "jmp most probably wrong"); | 1404 assert(entry != NULL, "jmp most probably wrong"); |
1406 InstructionMark im(this); | 1405 InstructionMark im(this); |
1407 const int short_size = 2; | 1406 const int short_size = 2; |
1408 const int long_size = 5; | 1407 const int long_size = 5; |
1409 intptr_t offs = entry - _code_pos; | 1408 intptr_t offs = entry - _code_pos; |
1410 if (rtype == relocInfo::none && is8bit(offs - short_size)) { | 1409 if (maybe_short && is8bit(offs - short_size)) { |
1411 emit_byte(0xEB); | 1410 emit_byte(0xEB); |
1412 emit_byte((offs - short_size) & 0xFF); | 1411 emit_byte((offs - short_size) & 0xFF); |
1413 } else { | 1412 } else { |
1414 emit_byte(0xE9); | 1413 emit_byte(0xE9); |
1415 emit_long(offs - long_size); | 1414 emit_long(offs - long_size); |
1418 // By default, forward jumps are always 32-bit displacements, since | 1417 // By default, forward jumps are always 32-bit displacements, since |
1419 // we can't yet know where the label will be bound. If you're sure that | 1418 // we can't yet know where the label will be bound. If you're sure that |
1420 // the forward jump will not run beyond 256 bytes, use jmpb to | 1419 // the forward jump will not run beyond 256 bytes, use jmpb to |
1421 // force an 8-bit displacement. | 1420 // force an 8-bit displacement. |
1422 InstructionMark im(this); | 1421 InstructionMark im(this); |
1423 relocate(rtype); | |
1424 L.add_patch_at(code(), locator()); | 1422 L.add_patch_at(code(), locator()); |
1425 emit_byte(0xE9); | 1423 emit_byte(0xE9); |
1426 emit_long(0); | 1424 emit_long(0); |
1427 } | 1425 } |
1428 } | 1426 } |