Clean up IonScript privacy (bug 793165 part 1, r=jandem).

This commit is contained in:
David Anderson 2012-10-02 13:43:44 -07:00
parent 496ba30df1
commit d883bf7cae
8 changed files with 25 additions and 21 deletions

View File

@ -780,8 +780,8 @@ CodeGenerator::visitCallGeneric(LCallGeneric *call)
masm.j(Assembler::Above, &thunk);
// No argument fixup needed. Load the start of the target IonCode.
masm.movePtr(Address(objreg, offsetof(IonScript, method_)), objreg);
masm.movePtr(Address(objreg, IonCode::OffsetOfCode()), objreg);
masm.movePtr(Address(objreg, IonScript::offsetOfMethod()), objreg);
masm.movePtr(Address(objreg, IonCode::offsetOfCode()), objreg);
masm.jump(&makeCall);
// Argument fixed needed. Load the ArgumentsRectifier.
@ -789,7 +789,7 @@ CodeGenerator::visitCallGeneric(LCallGeneric *call)
{
JS_ASSERT(ArgumentsRectifierReg != objreg);
masm.movePtr(ImmGCPtr(argumentsRectifier), objreg); // Necessary for GC marking.
masm.movePtr(Address(objreg, IonCode::OffsetOfCode()), objreg);
masm.movePtr(Address(objreg, IonCode::offsetOfCode()), objreg);
masm.move32(Imm32(call->numStackArgs()), ArgumentsRectifierReg);
}
@ -855,8 +855,8 @@ CodeGenerator::visitCallKnown(LCallKnown *call)
masm.branchPtr(Assembler::BelowOrEqual, objreg, ImmWord(ION_COMPILING_SCRIPT), &invoke);
// Load the start of the target IonCode.
masm.movePtr(Address(objreg, offsetof(IonScript, method_)), objreg);
masm.movePtr(Address(objreg, IonCode::OffsetOfCode()), objreg);
masm.movePtr(Address(objreg, IonScript::offsetOfMethod()), objreg);
masm.movePtr(Address(objreg, IonCode::offsetOfCode()), objreg);
// Nestle the StackPointer up to the argument vector.
masm.freeStack(unusedStack);
@ -1098,8 +1098,8 @@ CodeGenerator::visitApplyArgsGeneric(LApplyArgsGeneric *apply)
// No argument fixup needed. Load the start of the target IonCode.
{
masm.movePtr(Address(objreg, offsetof(IonScript, method_)), objreg);
masm.movePtr(Address(objreg, IonCode::OffsetOfCode()), objreg);
masm.movePtr(Address(objreg, IonScript::offsetOfMethod()), objreg);
masm.movePtr(Address(objreg, IonCode::offsetOfCode()), objreg);
// Skip the construction of the rectifier frame because we have no
// underflow.
@ -1118,7 +1118,7 @@ CodeGenerator::visitApplyArgsGeneric(LApplyArgsGeneric *apply)
JS_ASSERT(ArgumentsRectifierReg != objreg);
masm.movePtr(ImmGCPtr(argumentsRectifier), objreg); // Necessary for GC marking.
masm.movePtr(Address(objreg, IonCode::OffsetOfCode()), objreg);
masm.movePtr(Address(objreg, IonCode::offsetOfCode()), objreg);
masm.movePtr(argcreg, ArgumentsRectifierReg);
}

View File

@ -426,11 +426,13 @@ IonScript::IonScript()
scriptList_(0),
scriptEntries_(0),
refcount_(0),
slowCallCount(0),
recompileInfo_()
recompileInfo_(),
slowCallCount(0)
{
}
static const int DataAlignment = 4;
IonScript *
IonScript::New(JSContext *cx, uint32 frameSlots, uint32 frameSize, size_t snapshotsSize,
size_t bailoutEntries, size_t constants, size_t safepointIndices,

View File

@ -105,7 +105,7 @@ class IonCode : public gc::Cell
return code;
}
static size_t OffsetOfCode() {
static size_t offsetOfCode() {
return offsetof(IonCode, code_);
}
@ -133,6 +133,7 @@ class IonCache;
// An IonScript attaches Ion-generated information to a JSScript.
struct IonScript
{
private:
// Code pointer containing the actual method.
HeapPtr<IonCode> method_;
@ -205,11 +206,12 @@ struct IonScript
// Number of references from invalidation records.
size_t refcount_;
types::RecompileInfo recompileInfo_;
public:
// Number of times this function has tried to call a non-IM compileable function
uint32 slowCallCount;
types::RecompileInfo recompileInfo_;
SnapshotOffset *bailoutTable() {
return (SnapshotOffset *)(reinterpret_cast<uint8 *>(this) + bailoutTable_);
}

View File

@ -481,7 +481,7 @@ MacroAssembler::performOsr()
// Get ionScript->method->code, and scoot to the osrEntry.
const Register code = ionScript;
loadPtr(Address(ionScript, IonScript::offsetOfMethod()), code);
loadPtr(Address(code, IonCode::OffsetOfCode()), code);
loadPtr(Address(code, IonCode::offsetOfCode()), code);
addPtr(osrEntry, code);
// To simplify stack handling, we create an intermediate OSR frame, that

View File

@ -324,8 +324,8 @@ IonCompartment::generateArgumentsRectifier(JSContext *cx)
// Note that this code assumes the function is JITted.
masm.ma_ldr(DTRAddr(r1, DtrOffImm(offsetof(JSFunction, u.i.script_))), r3);
masm.ma_ldr(DTRAddr(r3, DtrOffImm(offsetof(JSScript, ion))), r3);
masm.ma_ldr(DTRAddr(r3, DtrOffImm(offsetof(IonScript, method_))), r3);
masm.ma_ldr(DTRAddr(r3, DtrOffImm(IonCode::OffsetOfCode())), r3);
masm.ma_ldr(DTRAddr(r3, DtrOffImm(IonScript::offsetOfMethod())), r3);
masm.ma_ldr(DTRAddr(r3, DtrOffImm(IonCode::offsetOfCode())), r3);
masm.ma_callIonHalfPush(r3);
// arg1

View File

@ -277,8 +277,8 @@ IonCompartment::generateArgumentsRectifier(JSContext *cx)
// Note that this code assumes the function is JITted.
masm.movq(Operand(rax, offsetof(JSFunction, u.i.script_)), rax);
masm.movq(Operand(rax, offsetof(JSScript, ion)), rax);
masm.movq(Operand(rax, offsetof(IonScript, method_)), rax);
masm.movq(Operand(rax, IonCode::OffsetOfCode()), rax);
masm.movq(Operand(rax, IonScript::offsetOfMethod()), rax);
masm.movq(Operand(rax, IonCode::offsetOfCode()), rax);
masm.call(rax);
// Remove the rectifier frame.

View File

@ -283,8 +283,8 @@ IonCompartment::generateArgumentsRectifier(JSContext *cx)
// Note that this assumes the function is JITted.
masm.movl(Operand(eax, offsetof(JSFunction, u.i.script_)), eax);
masm.movl(Operand(eax, offsetof(JSScript, ion)), eax);
masm.movl(Operand(eax, offsetof(IonScript, method_)), eax);
masm.movl(Operand(eax, IonCode::OffsetOfCode()), eax);
masm.movl(Operand(eax, IonScript::offsetOfMethod()), eax);
masm.movl(Operand(eax, IonCode::offsetOfCode()), eax);
masm.call(eax);
// Remove the rectifier frame.

View File

@ -707,7 +707,7 @@ class CallCompiler : public BaseCompiler
/* Call into Ion. */
masm.loadPtr(Address(ionScript, ion::IonScript::offsetOfMethod()), t0);
#if defined(JS_CPU_X86) || defined(JS_CPU_X64)
masm.loadPtr(Address(t0, ion::IonCode::OffsetOfCode()), t0);
masm.loadPtr(Address(t0, ion::IonCode::offsetOfCode()), t0);
masm.call(t0);
#elif defined(JS_CPU_ARM)
masm.loadPtr(Address(t0, ion::IonCode::OffsetOfCode()), JSC::ARMRegisters::ip);