V4: check for exceptions after convertThisToObject

The method_convertThisToObject method was invalidly tagged as not
needing exception checks. As a side-effect method_pushCatchScope and
method_popScope are now correctly tagged with a NoThrowEngine.

Change-Id: I11d987e62136216a29eadcbd641546311030058f
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Erik Verbruggen 2016-11-23 12:55:30 +01:00
parent 4b22e2093f
commit 5e6bf607ee
3 changed files with 6 additions and 11 deletions

View File

@ -1259,7 +1259,7 @@ ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine)
*
* Instead the push/pop pair acts as a non local scope.
*/
void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine)
void Runtime::method_pushWithScope(const Value &o, NoThrowEngine *engine)
{
engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine)));
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
@ -1272,7 +1272,7 @@ void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameI
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
}
void Runtime::method_popScope(ExecutionEngine *engine)
void Runtime::method_popScope(NoThrowEngine *engine)
{
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
engine->popContext();

View File

@ -63,11 +63,6 @@ template <typename T>
struct ExceptionCheck {
enum { NeedsCheck = 1 };
};
// push_catch and pop context methods shouldn't check for exceptions
template <>
struct ExceptionCheck<void (*)(QV4::ExecutionEngine *)> {
enum { NeedsCheck = 0 };
};
template <typename A>
struct ExceptionCheck<void (*)(A, QV4::NoThrowEngine)> {
enum { NeedsCheck = 0 };
@ -244,9 +239,9 @@ struct Q_QML_PRIVATE_EXPORT Runtime {
// exceptions & scopes
RUNTIME_METHOD(void, throwException, (ExecutionEngine *engine, const Value &value));
RUNTIME_METHOD(ReturnedValue, unwindException, (ExecutionEngine *engine));
RUNTIME_METHOD(void, pushWithScope, (const Value &o, ExecutionEngine *engine));
RUNTIME_METHOD(void, pushWithScope, (const Value &o, NoThrowEngine *engine));
RUNTIME_METHOD(void, pushCatchScope, (NoThrowEngine *engine, int exceptionVarNameIndex));
RUNTIME_METHOD(void, popScope, (ExecutionEngine *engine));
RUNTIME_METHOD(void, popScope, (NoThrowEngine *engine));
// closures
RUNTIME_METHOD(ReturnedValue, closure, (ExecutionEngine *engine, int functionId));

View File

@ -662,13 +662,13 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code
MOTH_END_INSTR(CallBuiltinPushCatchScope)
MOTH_BEGIN_INSTR(CallBuiltinPushScope)
engine->runtime.pushWithScope(VALUE(instr.arg), engine);
engine->runtime.pushWithScope(VALUE(instr.arg), static_cast<QV4::NoThrowEngine*>(engine));
context = engine->currentContext;
CHECK_EXCEPTION;
MOTH_END_INSTR(CallBuiltinPushScope)
MOTH_BEGIN_INSTR(CallBuiltinPopScope)
engine->runtime.popScope(engine);
engine->runtime.popScope(static_cast<QV4::NoThrowEngine*>(engine));
context = engine->currentContext;
MOTH_END_INSTR(CallBuiltinPopScope)