aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2024-06-14 16:31:59 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2024-06-18 14:56:51 +0200
commitef715b350077cdcbe6419fbc74b06a2d6be6f08e (patch)
tree84be21d41c4b7cc89c288f36050d144063c95ec7 /src
parentfae951b94e68cfcbe41220a6e70124bfe584fd95 (diff)
JIT: storeLocal needs to go through WriteBarrier
The interpreter already has the necessary setup, but the JIT did simply write the value without marking so far. We fix this by adding a new runtime function call, which simply uses QV4::WriteBarrier::markCustom to mark the given value. Both the StoreLocal and StoreScopedLocal bytecode instructions are handled by adding the code to BaselineAssembler::storeLocal. Pick-to: 6.8 Change-Id: I4b9226848bff029a076c0cfa6daf899ca9b84622 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jit/qv4baselineassembler.cpp14
-rw-r--r--src/qml/jit/qv4baselinejit_p.h6
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp17
-rw-r--r--src/qml/jsruntime/qv4runtimeapi_p.h6
4 files changed, 40 insertions, 3 deletions
diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp
index 496624c752..ba681cdbf1 100644
--- a/src/qml/jit/qv4baselineassembler.cpp
+++ b/src/qml/jit/qv4baselineassembler.cpp
@@ -883,6 +883,20 @@ void BaselineAssembler::storeLocal(int index, int level)
--level;
}
pasm()->storeAccumulator(Address(PlatformAssembler::ScratchRegister, ctx.locals.offset + offsetof(ValueArray<0>, values) + sizeof(Value)*index));
+ // check if we need a write barrier
+ auto skipBarrier = pasm()->branch8(
+ PlatformAssembler::Equal,
+ PlatformAssembler::Address(PlatformAssembler::EngineRegister,
+ offsetof(EngineBase, isGCOngoing)),
+ TrustedImm32(0));
+ saveAccumulatorInFrame();
+ // if so, do a runtime call
+ pasm()->prepareCallWithArgCount(1);
+ pasm()->passAccumulatorAsArg(0);
+ pasm()->callRuntime((void*)Runtime::MarkCustom::call, CallResultDestination::Ignore);
+ loadAccumulatorFromFrame();
+ skipBarrier.link(pasm());
+
}
void BaselineAssembler::loadString(int stringId)
diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h
index 40138ea700..85569d6218 100644
--- a/src/qml/jit/qv4baselinejit_p.h
+++ b/src/qml/jit/qv4baselinejit_p.h
@@ -33,10 +33,10 @@ class BaselineAssembler;
class BaselineJIT final: public Moth::ByteCodeHandler
{
public:
- BaselineJIT(QV4::Function *);
- ~BaselineJIT() override;
+ Q_AUTOTEST_EXPORT BaselineJIT(QV4::Function *);
+ Q_AUTOTEST_EXPORT ~BaselineJIT() override;
- void generate();
+ Q_AUTOTEST_EXPORT void generate();
void generate_Ret() override;
void generate_Debug() override;
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index 8582f44668..b5c497be49 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1807,6 +1807,21 @@ void Runtime::ThrowOnNullOrUndefined::call(ExecutionEngine *engine, const Value
engine->throwTypeError();
}
+void Runtime::MarkCustom::call(const Value &toBeMarked)
+{
+ auto *h = toBeMarked.heapObject();
+ if (!h)
+ return;
+ Q_ASSERT(h->internalClass);
+ auto engine = h->internalClass->engine;
+ Q_ASSERT(engine);
+ // runtime function is only meant to be called while gc is ongoing
+ Q_ASSERT(engine->isGCOngoing);
+ QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *ms) {
+ h->mark(ms);
+ });
+}
+
ReturnedValue Runtime::ConvertThisToObject::call(ExecutionEngine *engine, const Value &t)
{
if (!t.isObject()) {
@@ -2493,6 +2508,8 @@ QHash<const void *, const char *> Runtime::symbolTable()
{symbol<Closure>(), "Closure" },
+ {symbol<MarkCustom>(), "MarkCustom"},
+
{symbol<ConvertThisToObject>(), "ConvertThisToObject" },
{symbol<DeclareVar>(), "DeclareVar" },
{symbol<CreateMappedArgumentsObject>(), "CreateMappedArgumentsObject" },
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h
index fdee6ac580..e4a8c09370 100644
--- a/src/qml/jsruntime/qv4runtimeapi_p.h
+++ b/src/qml/jsruntime/qv4runtimeapi_p.h
@@ -230,6 +230,12 @@ struct Q_QML_EXPORT Runtime {
static void call(ExecutionEngine *, const Value &);
};
+ /* garbage collection */
+ struct Q_QML_EXPORT MarkCustom : PureMethod
+ {
+ static void call(const Value &toBeMarked);
+ };
+
/* closures */
struct Q_QML_EXPORT Closure : Method<Throws::No>
{