diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2018-05-31 14:06:22 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-06-27 10:04:28 +0000 |
commit | 0ec2c4720c47282109b618370bf8397bb1d13a56 (patch) | |
tree | 55cbcc6d4539fdfc262a360e24712fc95bd3a951 /src/qml | |
parent | 1b35f7b706b97adbc1d8935b14144b51389c0484 (diff) |
Simplify storeElement runtime API
We can do the isStrict() check and throwTypeError() call in the runtime
function instead of doing it twice on the two call sites.
Change-Id: I70df3d7fe4333921a85c11b1573e234f7da2f47d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jit/qv4baselinejit.cpp | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 3 |
4 files changed, 8 insertions, 15 deletions
diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index 87b6478e0d..9046926196 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -245,13 +245,6 @@ void BaselineJIT::generate_LoadElement(int base) as->checkException(); } -static void storeElementHelper(QV4::Function *f, const Value &base, const Value &index, const Value &value) -{ - auto engine = f->internalClass->engine; - if (!Runtime::method_storeElement(engine, base, index, value) && f->isStrict()) - engine->throwTypeError(); -} - void BaselineJIT::generate_StoreElement(int base, int index) { STORE_IP(); @@ -260,8 +253,8 @@ void BaselineJIT::generate_StoreElement(int base, int index) as->passAccumulatorAsArg(3); as->passRegAsArg(index, 2); as->passRegAsArg(base, 1); - as->passFunctionAsArg(0); - JIT_GENERATE_RUNTIME_CALL(storeElementHelper, Assembler::IgnoreResult); + as->passEngineAsArg(0); + JIT_GENERATE_RUNTIME_CALL(Runtime::method_storeElement, Assembler::IgnoreResult); as->checkException(); } diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 48b5657c7f..bcedfa06b5 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -696,7 +696,7 @@ static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Val return o->put(name, value); } -bool Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) +void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { uint idx = 0; if (index.asArrayIndex(idx)) { @@ -707,14 +707,15 @@ bool Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, Heap::SimpleArrayData *s = o->arrayData.cast<Heap::SimpleArrayData>(); if (idx < s->values.size) { s->setData(engine, idx, value); - return true; + return; } } } } } - return setElementFallback(engine, object, index, value); + if (!setElementFallback(engine, object, index, value) && engine->currentStackFrame->v4Function->isStrict()) + engine->throwTypeError(); } ReturnedValue Runtime::method_getIterator(ExecutionEngine *engine, const Value &in, int iterator) diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index 824d2fb0ea..f0d7b205b3 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -109,7 +109,7 @@ struct ExceptionCheck<void (*)(QV4::NoThrowEngine *, A, B, C)> { F(void, storeNameStrict, (ExecutionEngine *engine, int nameIndex, const Value &value)) \ F(void, storeNameSloppy, (ExecutionEngine *engine, int nameIndex, const Value &value)) \ F(bool, storeProperty, (ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)) \ - F(bool, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \ + F(void, storeElement, (ExecutionEngine *engine, const Value &object, const Value &index, const Value &value)) \ F(ReturnedValue, loadProperty, (ExecutionEngine *engine, const Value &object, int nameIndex)) \ F(ReturnedValue, loadName, (ExecutionEngine *engine, int nameIndex)) \ F(ReturnedValue, loadElement, (ExecutionEngine *engine, const Value &object, const Value &index)) \ diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index f19e1b1988..861ec4231f 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -629,8 +629,7 @@ QV4::ReturnedValue VME::interpret(CppStackFrame &frame, const char *code) MOTH_BEGIN_INSTR(StoreElement) STORE_IP(); STORE_ACC(); - if (!Runtime::method_storeElement(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator) && function->isStrict()) - engine->throwTypeError(); + Runtime::method_storeElement(engine, STACK_VALUE(base), STACK_VALUE(index), accumulator); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElement) |