Bug 1890750 - Part 1: Include NATIVE_JIT_ENTRY in FunctionFlags::HasJitEntryFlags() even when constructing. r=iain

Always include `NATIVE_JIT_ENTRY` to keep `MacroAssembler::branchIfFunctionHas{No,}JitEntry()`
consistent with `FunctionFlags::hasJitEntry()`.

Differential Revision: https://phabricator.services.mozilla.com/D207135
This commit is contained in:
André Bargull 2024-04-15 14:40:42 +00:00
Родитель 1928539e57
Коммит 75865bebb2
9 изменённых файлов: 21 добавлений и 37 удалений

Просмотреть файл

@ -10308,7 +10308,7 @@ AttachDecision CallIRGenerator::tryAttachFunCall(HandleFunction callee) {
writer.guardNotClassConstructor(thisObjId);
if (isScripted) {
writer.guardFunctionHasJitEntry(thisObjId, /*isConstructing =*/false);
writer.guardFunctionHasJitEntry(thisObjId);
writer.callScriptedFunction(thisObjId, argcId, targetFlags,
ClampFixedArgc(argc_));
} else {
@ -11268,7 +11268,7 @@ AttachDecision CallIRGenerator::tryAttachFunApply(HandleFunction calleeFunc) {
if (isScripted) {
// Guard that function is scripted.
writer.guardFunctionHasJitEntry(thisObjId, /*constructing =*/false);
writer.guardFunctionHasJitEntry(thisObjId);
writer.callScriptedFunction(thisObjId, argcId, targetFlags, fixedArgc);
} else {
// Guard that function is native.
@ -12034,7 +12034,7 @@ void CallIRGenerator::emitCallScriptedGuards(ObjOperandId calleeObjId,
} else {
// Guard that object is a scripted function
writer.guardClass(calleeObjId, GuardClassKind::JSFunction);
writer.guardFunctionHasJitEntry(calleeObjId, isConstructing);
writer.guardFunctionHasJitEntry(calleeObjId);
if (isConstructing) {
// If callee is not a constructor, we have to throw.

Просмотреть файл

@ -4670,8 +4670,7 @@ bool CacheIRCompiler::emitGuardNoAllocationMetadataBuilder(
return true;
}
bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId,
bool constructing) {
bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId) {
JitSpew(JitSpew_Codegen, "%s", __FUNCTION__);
Register fun = allocator.useRegister(masm, funId);
@ -4680,7 +4679,7 @@ bool CacheIRCompiler::emitGuardFunctionHasJitEntry(ObjOperandId funId,
return false;
}
masm.branchIfFunctionHasNoJitEntry(fun, constructing, failure->label());
masm.branchIfFunctionHasNoJitEntry(fun, failure->label());
return true;
}
@ -4694,8 +4693,7 @@ bool CacheIRCompiler::emitGuardFunctionHasNoJitEntry(ObjOperandId funId) {
return false;
}
masm.branchIfFunctionHasJitEntry(obj, /*isConstructing =*/false,
failure->label());
masm.branchIfFunctionHasJitEntry(obj, failure->label());
return true;
}

Просмотреть файл

@ -750,7 +750,6 @@
cost_estimate: 1
args:
fun: ObjId
constructing: BoolImm
- name: GuardFunctionHasNoJitEntry
shared: true

Просмотреть файл

@ -5995,7 +5995,7 @@ void JitRuntime::generateIonGenericCallStub(MacroAssembler& masm,
masm.switchToObjectRealm(calleeReg, scratch);
// Load jitCodeRaw for callee if it exists.
masm.branchIfFunctionHasNoJitEntry(calleeReg, isConstructing, &noJitEntry);
masm.branchIfFunctionHasNoJitEntry(calleeReg, &noJitEntry);
// ****************************
// * Functions with jit entry *
@ -6769,7 +6769,7 @@ void CodeGenerator::emitApplyGeneric(T* apply) {
}
// Guard that calleereg is an interpreted function with a JSScript.
masm.branchIfFunctionHasNoJitEntry(calleereg, constructing, &invoke);
masm.branchIfFunctionHasNoJitEntry(calleereg, &invoke);
// Guard that callee allows the [[Call]] or [[Construct]] operation required.
if (constructing) {

Просмотреть файл

@ -484,17 +484,13 @@ void MacroAssembler::branchIfNotFunctionIsNonBuiltinCtor(Register fun,
branch32(Assembler::NotEqual, scratch, Imm32(expected), label);
}
void MacroAssembler::branchIfFunctionHasNoJitEntry(Register fun,
bool isConstructing,
Label* label) {
uint16_t flags = FunctionFlags::HasJitEntryFlags(isConstructing);
void MacroAssembler::branchIfFunctionHasNoJitEntry(Register fun, Label* label) {
uint16_t flags = FunctionFlags::HasJitEntryFlags();
branchTestFunctionFlags(fun, flags, Assembler::Zero, label);
}
void MacroAssembler::branchIfFunctionHasJitEntry(Register fun,
bool isConstructing,
Label* label) {
uint16_t flags = FunctionFlags::HasJitEntryFlags(isConstructing);
void MacroAssembler::branchIfFunctionHasJitEntry(Register fun, Label* label) {
uint16_t flags = FunctionFlags::HasJitEntryFlags();
branchTestFunctionFlags(fun, flags, Assembler::NonZero, label);
}

Просмотреть файл

@ -1727,10 +1727,8 @@ class MacroAssembler : public MacroAssemblerSpecific {
Register scratch,
Label* label);
inline void branchIfFunctionHasNoJitEntry(Register fun, bool isConstructing,
Label* label);
inline void branchIfFunctionHasJitEntry(Register fun, bool isConstructing,
Label* label);
inline void branchIfFunctionHasNoJitEntry(Register fun, Label* label);
inline void branchIfFunctionHasJitEntry(Register fun, Label* label);
inline void branchIfScriptHasJitScript(Register script, Label* label);
inline void branchIfScriptHasNoJitScript(Register script, Label* label);

Просмотреть файл

@ -1117,10 +1117,9 @@ bool WarpCacheIRTranspiler::emitGuardNoDenseElements(ObjOperandId objId) {
return true;
}
bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId,
bool constructing) {
bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId) {
MDefinition* fun = getOperand(funId);
uint16_t expectedFlags = FunctionFlags::HasJitEntryFlags(constructing);
uint16_t expectedFlags = FunctionFlags::HasJitEntryFlags();
uint16_t unexpectedFlags = 0;
auto* ins =
@ -1134,8 +1133,7 @@ bool WarpCacheIRTranspiler::emitGuardFunctionHasJitEntry(ObjOperandId funId,
bool WarpCacheIRTranspiler::emitGuardFunctionHasNoJitEntry(ObjOperandId funId) {
MDefinition* fun = getOperand(funId);
uint16_t expectedFlags = 0;
uint16_t unexpectedFlags =
FunctionFlags::HasJitEntryFlags(/*isConstructing=*/false);
uint16_t unexpectedFlags = FunctionFlags::HasJitEntryFlags();
auto* ins =
MGuardFunctionFlags::New(alloc(), fun, expectedFlags, unexpectedFlags);

Просмотреть файл

@ -436,12 +436,8 @@ class FunctionFlags {
FunctionFlags& setIsGhost() { return setFlags(GHOST_FUNCTION); }
bool isGhost() const { return hasFlags(GHOST_FUNCTION); }
static uint16_t HasJitEntryFlags(bool isConstructing) {
uint16_t flags = BASESCRIPT | SELFHOSTLAZY;
if (!isConstructing) {
flags |= NATIVE_JIT_ENTRY;
}
return flags;
static constexpr uint16_t HasJitEntryFlags() {
return BASESCRIPT | SELFHOSTLAZY | NATIVE_JIT_ENTRY;
}
static FunctionFlags clearMutableflags(FunctionFlags flags) {

Просмотреть файл

@ -1262,9 +1262,8 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
CACHEOP_CASE(GuardFunctionHasJitEntry) {
ObjOperandId funId = icregs.cacheIRReader.objOperandId();
bool constructing = icregs.cacheIRReader.readBool();
JSObject* fun = reinterpret_cast<JSObject*>(icregs.icVals[funId.id()]);
uint16_t flags = FunctionFlags::HasJitEntryFlags(constructing);
uint16_t flags = FunctionFlags::HasJitEntryFlags();
if (!fun->as<JSFunction>().flags().hasFlags(flags)) {
return ICInterpretOpResult::NextIC;
}
@ -1274,7 +1273,7 @@ ICInterpretOps(BaselineFrame* frame, VMFrameManager& frameMgr, State& state,
CACHEOP_CASE(GuardFunctionHasNoJitEntry) {
ObjOperandId funId = icregs.cacheIRReader.objOperandId();
JSObject* fun = reinterpret_cast<JSObject*>(icregs.icVals[funId.id()]);
uint16_t flags = FunctionFlags::HasJitEntryFlags(/*constructing =*/false);
uint16_t flags = FunctionFlags::HasJitEntryFlags();
if (fun->as<JSFunction>().flags().hasFlags(flags)) {
return ICInterpretOpResult::NextIC;
}