Bug 701584 - Move various offsetof uses into static offsetOf* methods. r=cdleary

--HG--
extra : rebase_source : 6d453db67d872318160eee60bed3f628c1915c69
This commit is contained in:
Jeff Walden 2011-11-02 12:57:59 -07:00
parent ca6ba5c8ed
commit 2b2646eebe
7 changed files with 31 additions and 15 deletions

View File

@ -110,7 +110,7 @@ struct JSFunction : public JSObject_Slots2
reflected as f.length/f.arity */
uint16 flags; /* flags, see JSFUN_* below and in jsapi.h */
union U {
struct {
struct Native {
js::Native native; /* native method pointer or null */
js::Class *clasp; /* class of objects constructed
by this function */

View File

@ -624,7 +624,7 @@ static const JSC::MacroAssembler::RegisterID JSParamReg_Argc = JSC::SparcRegist
addPtr(Imm32(sizeof(StackFrame) + frameDepth * sizeof(jsval)),
JSFrameReg,
Registers::ClobberInCall);
storePtr(Registers::ClobberInCall, FrameAddress(offsetof(VMFrame, regs.sp)));
storePtr(Registers::ClobberInCall, FrameAddress(VMFrame::offsetOfRegsSp()));
}
}
@ -645,7 +645,7 @@ static const JSC::MacroAssembler::RegisterID JSParamReg_Argc = JSC::SparcRegist
storePtr(JSFrameReg, FrameAddress(VMFrame::offsetOfFp));
/* PC -> regs->pc :( */
storePtr(ImmPtr(pc), FrameAddress(offsetof(VMFrame, regs.pc)));
storePtr(ImmPtr(pc), FrameAddress(VMFrame::offsetOfRegsPc()));
if (inlining) {
/* inlined -> regs->inlined :( */
@ -663,7 +663,7 @@ static const JSC::MacroAssembler::RegisterID JSParamReg_Argc = JSC::SparcRegist
/* Store fp and pc */
storePtr(JSFrameReg, FrameAddress(VMFrame::offsetOfFp));
storePtr(ImmPtr(pc), FrameAddress(offsetof(VMFrame, regs.pc)));
storePtr(ImmPtr(pc), FrameAddress(VMFrame::offsetOfRegsPc()));
if (inlining) {
/* ABI calls cannot be made from inlined frames. */

View File

@ -3592,7 +3592,7 @@ mjit::Compiler::emitUncachedCall(uint32 argc, bool callingNew)
Jump notCompiled = masm.branchTestPtr(Assembler::Zero, r0, r0);
masm.loadPtr(FrameAddress(offsetof(VMFrame, regs.sp)), JSFrameReg);
masm.loadPtr(FrameAddress(VMFrame::offsetOfRegsSp()), JSFrameReg);
callPatch.hasFastNcode = true;
callPatch.fastNcodePatch =
masm.storePtrWithPatch(ImmPtr(NULL),
@ -3699,7 +3699,7 @@ mjit::Compiler::checkCallApplySpeculation(uint32 callImmArgc, uint32 speculatedA
*/
if (*PC == JSOP_FUNAPPLY) {
masm.store32(Imm32(applyTricks == LazyArgsObj),
FrameAddress(offsetof(VMFrame, u.call.lazyArgsObj)));
FrameAddress(VMFrame::offsetOfLazyArgsObj()));
}
}
@ -3978,8 +3978,8 @@ mjit::Compiler::inlineCallHelper(uint32 callImmArgc, bool callingNew, FrameSize
if (callIC.frameSize.isStatic())
stubcc.masm.move(Imm32(callIC.frameSize.staticArgc()), JSParamReg_Argc);
else
stubcc.masm.load32(FrameAddress(offsetof(VMFrame, u.call.dynamicArgc)), JSParamReg_Argc);
stubcc.masm.loadPtr(FrameAddress(offsetof(VMFrame, regs.sp)), JSFrameReg);
stubcc.masm.load32(FrameAddress(VMFrame::offsetOfDynamicArgc()), JSParamReg_Argc);
stubcc.masm.loadPtr(FrameAddress(VMFrame::offsetOfRegsSp()), JSFrameReg);
callPatch.hasSlowNcode = true;
callPatch.slowNcodePatch =
stubcc.masm.storePtrWithPatch(ImmPtr(NULL),

View File

@ -137,7 +137,7 @@ class InlineFrameAssembler {
* here to get the new frame pointer.
*/
RegisterID newfp = tempRegs.takeAnyReg().reg();
masm.loadPtr(FrameAddress(offsetof(VMFrame, regs.sp)), newfp);
masm.loadPtr(FrameAddress(VMFrame::offsetOfRegsSp()), newfp);
Address flagsAddr(newfp, StackFrame::offsetOfFlags());
masm.store32(Imm32(flags), flagsAddr);

View File

@ -110,9 +110,26 @@ struct VMFrame
} call;
} u;
static size_t offsetOfLazyArgsObj() {
return offsetof(VMFrame, u.call.lazyArgsObj);
}
static size_t offsetOfDynamicArgc() {
return offsetof(VMFrame, u.call.dynamicArgc);
}
VMFrame *previous;
void *scratch;
FrameRegs regs;
static size_t offsetOfRegsSp() {
return offsetof(VMFrame, regs.sp);
}
static size_t offsetOfRegsPc() {
return offsetof(VMFrame, regs.pc);
}
JSContext *cx;
Value *stackLimit;
StackFrame *entryfp;

View File

@ -768,14 +768,14 @@ class CallCompiler : public BaseCompiler
masm.fallibleVMCall(cx->typeInferenceEnabled(),
compilePtr, f.regs.pc, &inlined, ic.frameSize.staticLocalSlots());
} else {
masm.load32(FrameAddress(offsetof(VMFrame, u.call.dynamicArgc)), Registers::ArgReg1);
masm.load32(FrameAddress(VMFrame::offsetOfDynamicArgc()), Registers::ArgReg1);
masm.fallibleVMCall(cx->typeInferenceEnabled(),
compilePtr, f.regs.pc, &inlined, -1);
}
Jump notCompiled = masm.branchTestPtr(Assembler::Zero, Registers::ReturnReg,
Registers::ReturnReg);
masm.loadPtr(FrameAddress(offsetof(VMFrame, regs.sp)), JSFrameReg);
masm.loadPtr(FrameAddress(VMFrame::offsetOfRegsSp()), JSFrameReg);
/* Compute the value of ncode to use at this call site. */
ncode = (uint8 *) f.jit()->code.m_code.executableAddress() + ic.call->codeOffset;
@ -789,7 +789,7 @@ class CallCompiler : public BaseCompiler
if (ic.frameSize.isStatic())
masm.move(Imm32(ic.frameSize.staticArgc()), JSParamReg_Argc);
else
masm.load32(FrameAddress(offsetof(VMFrame, u.call.dynamicArgc)), JSParamReg_Argc);
masm.load32(FrameAddress(VMFrame::offsetOfDynamicArgc()), JSParamReg_Argc);
masm.jump(t0);
LinkerHelper linker(masm, JSC::METHOD_CODE);
@ -1023,7 +1023,7 @@ class CallCompiler : public BaseCompiler
MaybeRegisterID argcReg;
if (!ic.frameSize.isStatic()) {
argcReg = tempRegs.takeAnyReg().reg();
masm.load32(FrameAddress(offsetof(VMFrame, u.call.dynamicArgc)), argcReg.reg());
masm.load32(FrameAddress(VMFrame::offsetOfDynamicArgc()), argcReg.reg());
}
/* Mark vp[1] as magic for |new|. */

View File

@ -275,8 +275,7 @@ class JSString : public js::gc::Cell
JS_STATIC_ASSERT(((JSString::MAX_LENGTH << JSString::LENGTH_SHIFT) >>
JSString::LENGTH_SHIFT) == JSString::MAX_LENGTH);
JS_STATIC_ASSERT(sizeof(JSString) ==
offsetof(JSString, d.inlineStorage) +
NUM_INLINE_CHARS * sizeof(jschar));
offsetof(JSString, d.inlineStorage) + NUM_INLINE_CHARS * sizeof(jschar));
}
/* Avoid lame compile errors in JSRope::flatten */