Mercurial > hg > truffle
comparison src/cpu/sparc/vm/assembler_sparc.cpp @ 2076:7737fa7ec2b5
7006044: materialize cheap non-oop pointers on 64-bit SPARC
Summary: After 6961690 we load non-oop pointers for the constant table which could easily be materialized in a few instructions.
Reviewed-by: never, kvn
author | twisti |
---|---|
date | Tue, 14 Dec 2010 12:44:30 -0800 |
parents | 2f644f85485d |
children | 84f36150fcc3 |
comparison
equal
deleted
inserted
replaced
2016:361783318e7e | 2076:7737fa7ec2b5 |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | |
26 #include "assembler_sparc.inline.hpp" | 27 #include "assembler_sparc.inline.hpp" |
27 #include "gc_interface/collectedHeap.inline.hpp" | 28 #include "gc_interface/collectedHeap.inline.hpp" |
28 #include "interpreter/interpreter.hpp" | 29 #include "interpreter/interpreter.hpp" |
29 #include "memory/cardTableModRefBS.hpp" | 30 #include "memory/cardTableModRefBS.hpp" |
30 #include "memory/resourceArea.hpp" | 31 #include "memory/resourceArea.hpp" |
1325 void MacroAssembler::patchable_sethi(const AddressLiteral& addrlit, Register d) { | 1326 void MacroAssembler::patchable_sethi(const AddressLiteral& addrlit, Register d) { |
1326 internal_sethi(addrlit, d, true); | 1327 internal_sethi(addrlit, d, true); |
1327 } | 1328 } |
1328 | 1329 |
1329 | 1330 |
1330 int MacroAssembler::size_of_sethi(address a, bool worst_case) { | 1331 int MacroAssembler::insts_for_sethi(address a, bool worst_case) { |
1331 #ifdef _LP64 | 1332 #ifdef _LP64 |
1332 if (worst_case) return 7; | 1333 if (worst_case) return 7; |
1333 intptr_t iaddr = (intptr_t)a; | 1334 intptr_t iaddr = (intptr_t) a; |
1334 int hi32 = (int)(iaddr >> 32); | 1335 int msb32 = (int) (iaddr >> 32); |
1335 int lo32 = (int)(iaddr); | 1336 int lsb32 = (int) (iaddr); |
1336 int inst_count; | 1337 int count; |
1337 if (hi32 == 0 && lo32 >= 0) | 1338 if (msb32 == 0 && lsb32 >= 0) |
1338 inst_count = 1; | 1339 count = 1; |
1339 else if (hi32 == -1) | 1340 else if (msb32 == -1) |
1340 inst_count = 2; | 1341 count = 2; |
1341 else { | 1342 else { |
1342 inst_count = 2; | 1343 count = 2; |
1343 if ( hi32 & 0x3ff ) | 1344 if (msb32 & 0x3ff) |
1344 inst_count++; | 1345 count++; |
1345 if ( lo32 & 0xFFFFFC00 ) { | 1346 if (lsb32 & 0xFFFFFC00 ) { |
1346 if( (lo32 >> 20) & 0xfff ) inst_count += 2; | 1347 if ((lsb32 >> 20) & 0xfff) count += 2; |
1347 if( (lo32 >> 10) & 0x3ff ) inst_count += 2; | 1348 if ((lsb32 >> 10) & 0x3ff) count += 2; |
1348 } | 1349 } |
1349 } | 1350 } |
1350 return BytesPerInstWord * inst_count; | 1351 return count; |
1351 #else | 1352 #else |
1352 return BytesPerInstWord; | 1353 return 1; |
1353 #endif | 1354 #endif |
1354 } | 1355 } |
1355 | 1356 |
1356 int MacroAssembler::worst_case_size_of_set() { | 1357 int MacroAssembler::worst_case_insts_for_set() { |
1357 return size_of_sethi(NULL, true) + 1; | 1358 return insts_for_sethi(NULL, true) + 1; |
1358 } | 1359 } |
1359 | 1360 |
1360 | 1361 |
1362 // Keep in sync with MacroAssembler::insts_for_internal_set | |
1361 void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) { | 1363 void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) { |
1362 intptr_t value = addrlit.value(); | 1364 intptr_t value = addrlit.value(); |
1363 | 1365 |
1364 if (!ForceRelocatable && addrlit.rspec().type() == relocInfo::none) { | 1366 if (!ForceRelocatable && addrlit.rspec().type() == relocInfo::none) { |
1365 // can optimize | 1367 // can optimize |
1377 if (ForceRelocatable || addrlit.rspec().type() != relocInfo::none || addrlit.low10() != 0) { | 1379 if (ForceRelocatable || addrlit.rspec().type() != relocInfo::none || addrlit.low10() != 0) { |
1378 add(d, addrlit.low10(), d, addrlit.rspec()); | 1380 add(d, addrlit.low10(), d, addrlit.rspec()); |
1379 } | 1381 } |
1380 } | 1382 } |
1381 | 1383 |
1384 // Keep in sync with MacroAssembler::internal_set | |
1385 int MacroAssembler::insts_for_internal_set(intptr_t value) { | |
1386 // can optimize | |
1387 if (-4096 <= value && value <= 4095) { | |
1388 return 1; | |
1389 } | |
1390 if (inv_hi22(hi22(value)) == value) { | |
1391 return insts_for_sethi((address) value); | |
1392 } | |
1393 int count = insts_for_sethi((address) value); | |
1394 AddressLiteral al(value); | |
1395 if (al.low10() != 0) { | |
1396 count++; | |
1397 } | |
1398 return count; | |
1399 } | |
1400 | |
1382 void MacroAssembler::set(const AddressLiteral& al, Register d) { | 1401 void MacroAssembler::set(const AddressLiteral& al, Register d) { |
1383 internal_set(al, d, false); | 1402 internal_set(al, d, false); |
1384 } | 1403 } |
1385 | 1404 |
1386 void MacroAssembler::set(intptr_t value, Register d) { | 1405 void MacroAssembler::set(intptr_t value, Register d) { |
1441 sllx(tmp, 32, tmp); | 1460 sllx(tmp, 32, tmp); |
1442 or3 (d, tmp, d); | 1461 or3 (d, tmp, d); |
1443 } | 1462 } |
1444 } | 1463 } |
1445 | 1464 |
1446 int MacroAssembler::size_of_set64(jlong value) { | 1465 int MacroAssembler::insts_for_set64(jlong value) { |
1447 v9_dep(); | 1466 v9_dep(); |
1448 | 1467 |
1449 int hi = (int)(value >> 32); | 1468 int hi = (int) (value >> 32); |
1450 int lo = (int)(value & ~0); | 1469 int lo = (int) (value & ~0); |
1451 int count = 0; | 1470 int count = 0; |
1452 | 1471 |
1453 // (Matcher::isSimpleConstant64 knows about the following optimizations.) | 1472 // (Matcher::isSimpleConstant64 knows about the following optimizations.) |
1454 if (Assembler::is_simm13(lo) && value == lo) { | 1473 if (Assembler::is_simm13(lo) && value == lo) { |
1455 count++; | 1474 count++; |