Created
March 9, 2013 00:00
-
-
Save syg/5121497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReadSlotStubImpl | |
{ | |
protected: | |
virtual void branchExit(MacroAssembler &masm, Assembler::Condition cond, Address addr, | |
ImmGCPtr ptr) = 0; | |
virtual void jumpRejoin(MacroAssembler &masm) = 0; | |
virtual void jumpExit(MacroAssembler &masm) = 0; | |
virtual void bindFailures(MacroAssembler &masm) = 0; | |
public: | |
void generateReadSlot(JSContext *cx, MacroAssembler &masm, JSObject *obj, PropertyName *propName, | |
JSObject *holder, HandleShape shape, Register object, TypedOrValueRegister output, | |
Label *nonRepatchFailures = NULL) | |
{ | |
// If there's a single jump to |failures|, we can patch the shape guard | |
// jump directly. Otherwise, jump to the end of the stub, so there's a | |
// common point to patch. | |
bool multipleFailureJumps = (nonRepatchFailures != NULL) && nonRepatchFailures->used(); | |
branchExit(masm, Assembler::NotEqual, | |
Address(object, JSObject::offsetOfShape()), | |
ImmGCPtr(obj->lastProperty())); | |
... | |
} | |
}; | |
class GetNativePropertyStub : public ReadSlotStubImpl | |
{ | |
RepatchLabel *failures_; | |
protected: | |
void branchExit(MacroAssembler &masm, Assembler::Condition cond, Address addr, ImmGCPtr ptr) { | |
exitOffset = masm.branchPtrWithPatch(cond, addr, ptr, failures_); | |
} | |
void jumpRejoin(MacroAssembler &masm) { | |
RepatchLabel rejoin_; | |
rejoinOffset = masm.jumpWithPatch(&rejoin_); | |
masm.bind(&rejoin_); | |
} | |
void jumpExit(MacroAssembler &masm) { | |
RepatchLabel exit_; | |
exitOffset = masm.jumpWithPatch(&exit_); | |
masm.bind(&exit_); | |
} | |
void bindFailures(MacroAssembler &masm) { | |
masm.bind(failures_); | |
} | |
public: | |
CodeOffsetJump exitOffset; | |
CodeOffsetJump rejoinOffset; | |
CodeOffsetLabel stubCodePatchOffset; | |
void generateReadSlot(JSContext *cx, MacroAssembler &masm, JSObject *obj, PropertyName *propName, | |
JSObject *holder, HandleShape shape, Register object, TypedOrValueRegister output, | |
RepatchLabel *failures, Label *nonRepatchFailures = NULL) | |
{ | |
this->failures_ = failures; | |
ReadSlotStubImpl::generateReadSlot(cx, masm, obj, propName, holder, shape, object, | |
output, nonRepatchFailures); | |
} | |
}; | |
class ParallelReadSlotStub : public ReadSlotStubImpl | |
{ | |
Label failures_; | |
Label *rejoin_; | |
Label *exit_; | |
protected: | |
void branchExit(MacroAssembler &masm, Assembler::Condition cond, Address addr, ImmGCPtr ptr) { | |
masm.branchPtr(cond, addr, ptr, &failures_); | |
} | |
void jumpRejoin(MacroAssembler &masm) { | |
masm.jump(rejoin_); | |
} | |
void jumpExit(MacroAssembler &masm) { | |
masm.jump(exit_); | |
} | |
void bindFailures(MacroAssembler &masm) { | |
masm.bind(&failures_); | |
} | |
public: | |
void generateReadSlot(JSContext *cx, MacroAssembler &masm, JSObject *obj, PropertyName *propName, | |
JSObject *holder, HandleShape shape, Register object, TypedOrValueRegister output, | |
Label *rejoin, Label *exit, Label *nonRepatchFailures = NULL) | |
{ | |
this->rejoin_ = rejoin; | |
this->exit_ = exit; | |
ReadSlotStubImpl::generateReadSlot(cx, masm, obj, propName, holder, shape, object, | |
output, nonRepatchFailures); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment