V4: Store instruction pointer before CmpIn

The "in" operator may throw an exception.

Change-Id: I7d0b6e2212ac6ec237fbf14719349f8e23810028
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2021-01-27 10:07:28 +01:00
parent a34f927033
commit b7bbdf7e7d
3 changed files with 15 additions and 0 deletions

View File

@ -829,6 +829,7 @@ void BaselineJIT::generate_CmpStrictNotEqual(int lhs) { as->cmpStrictNotEqual(lh
void BaselineJIT::generate_CmpIn(int lhs)
{
STORE_IP();
STORE_ACC();
as->prepareCallWithArgCount(3);
as->passAccumulatorAsArg(2);

View File

@ -1210,6 +1210,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine,
MOTH_END_INSTR(CmpStrictNotEqual)
MOTH_BEGIN_INSTR(CmpIn)
STORE_IP();
STORE_ACC();
acc = Runtime::In::call(engine, STACK_VALUE(lhs), accumulator);
CHECK_EXCEPTION;

View File

@ -400,6 +400,7 @@ private slots:
void proxyIteration();
void proxyHandlerTraps();
void gcCrashRegressionTest();
void cmpInThrows();
private:
// static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter);
@ -9693,6 +9694,18 @@ void tst_qqmlecmascript::proxyHandlerTraps()
QVERIFY(value.isString() && value.toString() == QStringLiteral("SUCCESS"));
}
void tst_qqmlecmascript::cmpInThrows()
{
QJSEngine engine;
QStringList stacktrace;
QJSValue value = engine.evaluate(QStringLiteral("\n\n'foo' in 1"), QStringLiteral("foo.js"), 12,
&stacktrace);
QVERIFY(value.isError());
QCOMPARE(value.errorType(), QJSValue::TypeError);
QVERIFY(!stacktrace.isEmpty());
QCOMPARE(stacktrace.at(0), QStringLiteral("%entry:14:-1:file:foo.js"));
}
QTEST_MAIN(tst_qqmlecmascript)
#include "tst_qqmlecmascript.moc"