mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Issue #3049 - Call minimal LoongArch JIT directly from interpreter
This commit is contained in:
parent
ba01d5f92e
commit
1ffcb2202c
3 changed files with 49 additions and 7 deletions
|
|
@ -546,25 +546,30 @@ class MinimalLoongArchCompiler
|
|||
}
|
||||
};
|
||||
|
||||
static bool
|
||||
CanUseMinimalJit(JSScript* script, const CallArgs& args)
|
||||
{
|
||||
if (!script || script->numArgs() > 2)
|
||||
return false;
|
||||
|
||||
if (args.length() < script->numArgs())
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < script->numArgs(); i++) {
|
||||
if (!args[i].isInt32())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
CanUseMinimalJit(RunState& state, InvokeState& invoke)
|
||||
{
|
||||
if (invoke.constructing())
|
||||
return false;
|
||||
|
||||
JSScript* script = state.script();
|
||||
if (!script || script->numArgs() > 2)
|
||||
return false;
|
||||
|
||||
if (invoke.args().length() < script->numArgs())
|
||||
return false;
|
||||
|
||||
for (unsigned i = 0; i < script->numArgs(); i++) {
|
||||
if (!invoke.args()[i].isInt32())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return CanUseMinimalJit(state.script(), invoke.args());
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -607,6 +612,33 @@ LookupOrCompileMinimalJit(JSContext* cx, JSScript* script, TinyLoongArchJitCode*
|
|||
|
||||
} // namespace
|
||||
|
||||
bool
|
||||
TryCallLoongArchMinimalJit(JSContext* cx, HandleFunction fun, const CallArgs& args, bool* handled)
|
||||
{
|
||||
*handled = false;
|
||||
|
||||
if (!fun || !fun->isInterpreted())
|
||||
return true;
|
||||
|
||||
JSScript* script = fun->nonLazyScript();
|
||||
if (!CanUseMinimalJit(script, args))
|
||||
return true;
|
||||
|
||||
TinyLoongArchJitCode fn;
|
||||
if (!LookupOrCompileMinimalJit(cx, script, &fn))
|
||||
return false;
|
||||
|
||||
int32_t result = 0;
|
||||
int32_t arg0 = script->numArgs() >= 1 ? args[0].toInt32() : 0;
|
||||
int32_t arg1 = script->numArgs() >= 2 ? args[1].toInt32() : 0;
|
||||
if (!fn(arg0, arg1, &result))
|
||||
return true;
|
||||
|
||||
args.rval().setInt32(result);
|
||||
*handled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
TryEnterLoongArchMinimalJit(JSContext* cx, RunState& state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#define jit_LoongArchMinimalJit_h
|
||||
|
||||
#include "jspubtd.h"
|
||||
#include "js/CallArgs.h"
|
||||
|
||||
namespace js {
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ class RunState;
|
|||
namespace jit {
|
||||
|
||||
[[nodiscard]] bool TryEnterLoongArchMinimalJit(JSContext* cx, RunState& state);
|
||||
[[nodiscard]] bool TryCallLoongArchMinimalJit(JSContext* cx, HandleFunction fun, const CallArgs& args, bool* handled);
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
|
|
|||
|
|
@ -503,6 +503,14 @@ js::InternalCallOrConstruct(JSContext* cx, const CallArgs& args, MaybeConstruct
|
|||
if (!JSFunction::getOrCreateScript(cx, fun))
|
||||
return false;
|
||||
|
||||
if (construct != CONSTRUCT) {
|
||||
bool handled;
|
||||
if (!jit::TryCallLoongArchMinimalJit(cx, fun, args, &handled))
|
||||
return false;
|
||||
if (handled)
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Run function until JSOP_RETRVAL, JSOP_RETURN or error. */
|
||||
InvokeState state(cx, args, construct);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue