call underrunProtect more aggressively, and remove some LD32_nochks that weren't being protected

This commit is contained in:
Vladimir Vukicevic 2009-03-20 15:53:38 -07:00
parent c19ad6c10e
commit 93a0adea14

View File

@ -541,6 +541,8 @@ Assembler::asm_store64(LInsp value, int dr, LInsp base)
if (value->isconstq()) {
const int32_t* p = (const int32_t*) (value-2);
underrunProtect(LD32_size*2 + 8);
// XXX use another reg, get rid of dependency
STR(IP, rb, dr);
LD32_nochk(IP, p[0]);
@ -574,8 +576,7 @@ Assembler::asm_store64(LInsp value, int dr, LInsp base)
if (value->isconstq()) {
const int32_t* p = (const int32_t*) (value-2);
underrunProtect(12);
underrunProtect(4*4);
asm_quad_nochk(rv, p);
}
} else {
@ -626,34 +627,19 @@ Assembler::asm_quad(LInsp ins)
freeRsrcOf(ins, false);
if (AvmCore::config.vfp) {
if (rr == UnknownReg) {
underrunProtect(LD32_size * 2 + 8);
if (AvmCore::config.vfp &&
rr != UnknownReg)
{
if (d)
FSTD(rr, FP, d);
// asm_mmq might spill a reg, so don't call it;
// instead do the equivalent directly.
//asm_mmq(FP, d, PC, -16);
// XXX use another reg, get rid of dependency
STR(IP, FP, d);
LD32_nochk(IP, p[0]);
STR(IP, FP, d+4);
LD32_nochk(IP, p[1]);
} else {
if (d)
FSTD(rr, FP, d);
underrunProtect(16);
asm_quad_nochk(rr, p);
}
underrunProtect(4*4);
asm_quad_nochk(rr, p);
} else {
if (d) {
underrunProtect(LD32_size * 2 + 8);
STR(IP, FP, d+4);
LD32_nochk(IP, p[1]);
STR(IP, FP, d);
LD32_nochk(IP, p[0]);
}
STR(IP, FP, d+4);
asm_ld_imm(IP, p[1]);
STR(IP, FP, d);
asm_ld_imm(IP, p[0]);
}
//asm_output("<<< asm_quad");
@ -763,6 +749,9 @@ Assembler::nativePageSetup()
}
}
// Note: underrunProtect should not touch any registers, even IP; it
// might need to allocate a new page in the middle of an IP-using
// sequence.
void
Assembler::underrunProtect(int bytes)
{
@ -944,12 +933,17 @@ Assembler::B_cond_chk(ConditionCode _c, NIns* _t, bool _chk)
{
int32_t offs = PC_OFFSET_FROM(_t,_nIns-1);
//fprintf(stderr, "B_cond_chk target: 0x%08x offset: %d @0x%08x\n", _t, offs, _nIns-1);
// optimistically check if this will fit in 24 bits
if (isS24(offs>>2)) {
if (_chk) underrunProtect(4);
// recalculate the offset, because underrunProtect may have
// moved _nIns to a new page
offs = PC_OFFSET_FROM(_t,_nIns-1);
}
if (isS24(offs>>2)) {
// the underrunProtect for this was done above
*(--_nIns) = (NIns)( ((_c)<<28) | (0xA<<24) | (((offs)>>2) & 0xFFFFFF) );
} else if (_c == AL) {
if(_chk) underrunProtect(8);
@ -1004,7 +998,7 @@ Assembler::asm_add_imm(Register rd, Register rn, int32_t imm, int stat)
// make sure someone isn't trying to use IP as an operand
NanoAssert(rn != IP);
ALUr(AL, add, stat, rd, rn, IP);
LD32_nochk(IP, imm);
asm_ld_imm(IP, imm);
}
}
@ -1027,7 +1021,7 @@ Assembler::asm_sub_imm(Register rd, Register rn, int32_t imm, int stat)
/* more than 510 */
NanoAssert(rn != IP);
ALUr(AL, sub, stat, rd, rn, IP);
LD32_nochk(IP, imm);
asm_ld_imm(IP, imm);
}
} else {
if (imm >= -510) {
@ -1039,7 +1033,7 @@ Assembler::asm_sub_imm(Register rd, Register rn, int32_t imm, int stat)
/* less than -510 */
NanoAssert(rn != IP);
ALUr(AL, add, stat, rd, rn, IP);
LD32_nochk(IP, -imm);
asm_ld_imm(IP, -imm);
}
}
}
@ -1283,17 +1277,15 @@ Assembler::asm_cmpi(Register r, int32_t imm)
if (imm > -256) {
ALUi(AL, cmn, 1, 0, r, -imm);
} else {
underrunProtect(4 + LD32_size);
CMP(r, IP);
LD32_nochk(IP, imm);
asm_ld_imm(IP, imm);
}
} else {
if (imm < 256) {
ALUi(AL, cmp, 1, 0, r, imm);
} else {
underrunProtect(4 + LD32_size);
CMP(r, IP);
LD32_nochk(IP, imm);
asm_ld_imm(IP, imm);
}
}
}
@ -1705,9 +1697,8 @@ Assembler::asm_arm_farg(LInsp arg, Register rlo, Register rhi)
// LIR_quad
const int32_t* p = (const int32_t*) (arg-2);
underrunProtect(LD32_size * 2 + 8);
LD32_nochk(rhi, p[1]);
LD32_nochk(rlo, p[0]);
asm_ld_imm(rhi, p[1]);
asm_ld_imm(rlo, p[0]);
}
} else if (rlo != UnknownReg && rhi == UnknownReg) {
if (arg->opcode() == LIR_qjoin) {
@ -1724,10 +1715,9 @@ Assembler::asm_arm_farg(LInsp arg, Register rlo, Register rhi)
// LIR_quad
const int32_t* p = (const int32_t*) (arg-2);
underrunProtect(LD32_size * 2 + 8);
STR_preindex(IP, SP, -4);
LD32_nochk(IP, p[1]);
LD32_nochk(rlo, p[0]);
asm_ld_imm(IP, p[1]);
asm_ld_imm(rlo, p[0]);
}
} else {
asm_pusharg(arg);