static void UpdateTraceHintSingle(Repatcher &repatcher, JSC::CodeLocationJump jump, JSC::CodeLocationLabel target) { /* * Hack: The value that will be patched is before the executable address, * so to get protection right, just unprotect the general region around * the jump. */ repatcher.relink(jump, target); JaegerSpew(JSpew_PICs, "relinking trace hint %p to %p\n", jump.executableAddress(), target.executableAddress()); }
static LookupStatus AttachSetGlobalNameStub(VMFrame &f, ic::SetGlobalNameIC *ic, JSObject *obj, const Shape *shape) { Assembler masm; Label start = masm.label(); DataLabel32 shapeLabel; Jump guard = masm.branch32WithPatch(Assembler::NotEqual, ic->shapeReg, Imm32(obj->shape()), shapeLabel); /* A constant object needs rematerialization. */ if (ic->objConst) masm.move(ImmPtr(obj), ic->objReg); JS_ASSERT(obj->branded()); /* * Load obj->slots. If ic->objConst, then this clobbers objReg, because * ic->objReg == ic->shapeReg. */ JS_ASSERT(!obj->isFixedSlot(shape->slot)); masm.loadPtr(Address(ic->objReg, JSObject::offsetOfSlots()), ic->shapeReg); /* Test if overwriting a function-tagged slot. */ Address slot(ic->shapeReg, sizeof(Value) * obj->dynamicSlotIndex(shape->slot)); Jump isNotObject = masm.testObject(Assembler::NotEqual, slot); /* Now, test if the object is a function object. */ masm.loadPayload(slot, ic->shapeReg); Jump isFun = masm.testFunction(Assembler::Equal, ic->shapeReg); /* Restore shapeReg to obj->slots, since we clobbered it. */ if (ic->objConst) masm.move(ImmPtr(obj), ic->objReg); masm.loadPtr(Address(ic->objReg, JSObject::offsetOfSlots()), ic->shapeReg); /* If the object test fails, shapeReg is still obj->slots. */ isNotObject.linkTo(masm.label(), &masm); DataLabel32 store = masm.storeValueWithAddressOffsetPatch(ic->vr, slot); Jump done = masm.jump(); JITScript *jit = f.jit(); LinkerHelper linker(masm, JSC::METHOD_CODE); JSC::ExecutablePool *ep = linker.init(f.cx); if (!ep) return Lookup_Error; if (!jit->execPools.append(ep)) { ep->release(); js_ReportOutOfMemory(f.cx); return Lookup_Error; } if (!linker.verifyRange(jit)) return Lookup_Uncacheable; linker.link(done, ic->fastPathStart.labelAtOffset(ic->fastRejoinOffset)); linker.link(guard, ic->slowPathStart); linker.link(isFun, ic->slowPathStart); JSC::CodeLocationLabel cs = linker.finalize(f); JaegerSpew(JSpew_PICs, "generated setgname stub at %p\n", cs.executableAddress()); Repatcher repatcher(f.jit()); repatcher.relink(ic->fastPathStart.jumpAtOffset(ic->inlineShapeJump), cs); int offset = linker.locationOf(shapeLabel) - linker.locationOf(start); ic->extraShapeGuard = offset; JS_ASSERT(ic->extraShapeGuard == offset); ic->extraStub = JSC::JITCode(cs.executableAddress(), linker.size()); offset = linker.locationOf(store) - linker.locationOf(start); ic->extraStoreOffset = offset; JS_ASSERT(ic->extraStoreOffset == offset); ic->hasExtraStub = true; return Lookup_Cacheable; }