diff options
Diffstat (limited to 'src/qml/jit/qv4baselineassembler.cpp')
-rw-r--r-- | src/qml/jit/qv4baselineassembler.cpp | 117 |
1 files changed, 58 insertions, 59 deletions
diff --git a/src/qml/jit/qv4baselineassembler.cpp b/src/qml/jit/qv4baselineassembler.cpp index 25652e0a63..496624c752 100644 --- a/src/qml/jit/qv4baselineassembler.cpp +++ b/src/qml/jit/qv4baselineassembler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QBuffer> #include <QFile> @@ -55,6 +19,8 @@ #undef ENABLE_ALL_ASSEMBLERS_FOR_REFACTORING_PURPOSES +#if QT_CONFIG(qml_jit) + QT_BEGIN_NAMESPACE namespace QV4 { namespace JIT { @@ -89,6 +55,8 @@ public: PlatformAssemblerCommon::callRuntime(funcPtr); if (dest == CallResultDestination::InAccumulator) saveReturnValueInAccumulator(); + else if (AccumulatorRegister == ReturnValueRegister) + loadUndefined(); } void saveReturnValueInAccumulator() @@ -178,7 +146,9 @@ public: void toBoolean(std::function<void(RegisterID)> continuation) { urshift64(AccumulatorRegister, TrustedImm32(Value::IsIntegerConvertible_Shift), ScratchRegister); - auto needsConversion = branch32(NotEqual, TrustedImm32(1), ScratchRegister); + auto needsConversion = branch32( + NotEqual, TrustedImm32(Value::IsIntegerConvertible_Value), ScratchRegister); + continuation(AccumulatorRegister); Jump done = jump(); @@ -196,8 +166,10 @@ public: void toNumber() { - urshift64(AccumulatorRegister, TrustedImm32(Value::QuickType_Shift), ScratchRegister); - auto isNumber = branch32(GreaterThanOrEqual, ScratchRegister, TrustedImm32(Value::QT_Int)); + move(TrustedImm64(Value::NumberMask), ScratchRegister); + and64(AccumulatorRegister, ScratchRegister); + move(TrustedImm64(Value::NumberDiscriminator), ScratchRegister2); + auto isNumber = branch64(GreaterThanOrEqual, ScratchRegister, ScratchRegister2); move(AccumulatorRegister, registerForArg(0)); callHelper(toNumberHelper); @@ -278,7 +250,7 @@ public: Jump isIntOrBool() { urshift64(AccumulatorRegister, TrustedImm32(Value::IsIntegerOrBool_Shift), ScratchRegister); - return branch32(Equal, TrustedImm32(3), ScratchRegister); + return branch32(Equal, TrustedImm32(Value::IsIntegerOrBool_Value), ScratchRegister); } void jumpStrictEqualStackSlotInt(int lhs, int rhs, int offset) @@ -312,7 +284,7 @@ public: void encodeDoubleIntoAccumulator(FPRegisterID src) { moveDoubleTo64(src, AccumulatorRegister); - move(TrustedImm64(Value::NaNEncodeMask), ScratchRegister); + move(TrustedImm64(Value::EncodeMask), ScratchRegister); xor64(ScratchRegister, AccumulatorRegister); } @@ -351,7 +323,8 @@ public: Jump unopIntPath(std::function<Jump(void)> fastPath) { urshift64(AccumulatorRegister, TrustedImm32(Value::IsIntegerConvertible_Shift), ScratchRegister); - Jump accNotIntConvertible = branch32(NotEqual, TrustedImm32(1), ScratchRegister); + Jump accNotIntConvertible = branch32( + NotEqual, TrustedImm32(Value::IsIntegerConvertible_Value), ScratchRegister); // both integer Jump failure = fastPath(); @@ -388,6 +361,8 @@ public: PlatformAssemblerCommon::callRuntime(funcPtr); if (dest == CallResultDestination::InAccumulator) saveReturnValueInAccumulator(); + else if (AccumulatorRegisterValue == ReturnValueRegisterValue) + loadUndefined(); } void saveReturnValueInAccumulator() @@ -479,8 +454,12 @@ public: void toNumber() { - urshift32(AccumulatorRegisterTag, TrustedImm32(Value::QuickType_Shift - 32), ScratchRegister); - auto isNumber = branch32(GreaterThanOrEqual, ScratchRegister, TrustedImm32(Value::QT_Int)); + and32(TrustedImm32(Value::NumberMask >> Value::Tag_Shift), + AccumulatorRegisterTag, ScratchRegister); + auto isNumber = branch32( + GreaterThanOrEqual, ScratchRegister, + TrustedImm32(Value::NumberDiscriminator >> Value::Tag_Shift)); + if (ArgInRegCount < 2) { subPtr(TrustedImm32(2 * PointerSize), StackPointerRegister); // stack alignment @@ -629,7 +608,7 @@ public: Jump isIntOrBool() { urshift32(AccumulatorRegisterTag, TrustedImm32(Value::IsIntegerOrBool_Shift - 32), ScratchRegister); - return branch32(Equal, TrustedImm32(3), ScratchRegister); + return branch32(Equal, TrustedImm32(Value::IsIntegerOrBool_Value), ScratchRegister); } void pushValue(ReturnedValue v) @@ -660,7 +639,8 @@ public: { urshift32(AccumulatorRegisterTag, TrustedImm32(Value::IsIntegerConvertible_Shift - 32), ScratchRegister); - auto needsConversion = branch32(NotEqual, TrustedImm32(1), ScratchRegister); + auto needsConversion = branch32( + NotEqual, TrustedImm32(Value::IsIntegerConvertible_Value), ScratchRegister); continuation(AccumulatorRegisterValue); Jump done = jump(); @@ -737,7 +717,7 @@ public: void encodeDoubleIntoAccumulator(FPRegisterID src) { moveDoubleToInts(src, AccumulatorRegisterValue, AccumulatorRegisterTag); - xor32(TrustedImm32(Value::NaNEncodeMask >> 32), AccumulatorRegisterTag); + xor32(TrustedImm32(Value::EncodeMask >> 32), AccumulatorRegisterTag); } void pushValueAligned(ReturnedValue v) @@ -884,7 +864,7 @@ void BaselineAssembler::storeReg(int reg) void BaselineAssembler::loadLocal(int index, int level) { Heap::CallContext ctx; - Q_UNUSED(ctx) + Q_UNUSED(ctx); pasm()->loadPointerFromValue(regAddr(CallData::Context), PlatformAssembler::ScratchRegister); while (level) { pasm()->loadPtr(Address(PlatformAssembler::ScratchRegister, ctx.outer.offset), PlatformAssembler::ScratchRegister); @@ -896,7 +876,7 @@ void BaselineAssembler::loadLocal(int index, int level) void BaselineAssembler::storeLocal(int index, int level) { Heap::CallContext ctx; - Q_UNUSED(ctx) + Q_UNUSED(ctx); pasm()->loadPtr(regAddr(CallData::Context), PlatformAssembler::ScratchRegister); while (level) { pasm()->loadPtr(Address(PlatformAssembler::ScratchRegister, ctx.outer.offset), PlatformAssembler::ScratchRegister); @@ -923,7 +903,7 @@ void BaselineAssembler::storeHeapObject(int reg) void BaselineAssembler::loadImport(int index) { Address addr = pasm()->loadCompilationUnitPtr(PlatformAssembler::ScratchRegister); - addr.offset = offsetof(QV4::CompiledData::CompilationUnitBase, imports); + addr.offset = offsetof(QV4::CompilationUnitRuntimeData, imports); pasm()->loadPtr(addr, PlatformAssembler::ScratchRegister); addr.offset = index * int(sizeof(QV4::Value*)); pasm()->loadPtr(addr, PlatformAssembler::ScratchRegister); @@ -1409,6 +1389,23 @@ int BaselineAssembler::jumpNotUndefined(int offset) return offset; } +int BaselineAssembler::jumpEqNull(int offset) +{ + saveAccumulatorInFrame(); + cmpeqNull(); + + pasm()->toBoolean([this, offset](PlatformAssembler::RegisterID resultReg) { + auto isFalse = pasm()->branch32(PlatformAssembler::Equal, TrustedImm32(0), resultReg); + loadValue(Encode::undefined()); + pasm()->addJumpToOffset(pasm()->jump(), offset); + isFalse.link(pasm()); + loadAccumulatorFromFrame(); + }); + + return offset; +} + + void BaselineAssembler::prepareCallWithArgCount(int argc) { pasm()->prepareCallWithArgCount(argc); @@ -1471,7 +1468,7 @@ void BaselineAssembler::loadAccumulatorFromFrame() offsetof(CallData, accumulator))); } -static ReturnedValue TheJitIs__Tail_Calling__ToTheRuntimeSoTheJitFrameIsMissing(CppStackFrame *frame, ExecutionEngine *engine) +static ReturnedValue TheJitIs__Tail_Calling__ToTheRuntimeSoTheJitFrameIsMissing(JSTypesStackFrame *frame, ExecutionEngine *engine) { return Runtime::TailCall::call(frame, engine); } @@ -1553,15 +1550,15 @@ void BaselineAssembler::clearUnwindHandler() void JIT::BaselineAssembler::unwindDispatch() { checkException(); - pasm()->load32(Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel)), PlatformAssembler::ScratchRegister); + pasm()->load32(Address(PlatformAssembler::CppStackFrameRegister, offsetof(JSTypesStackFrame, unwindLevel)), PlatformAssembler::ScratchRegister); auto noUnwind = pasm()->branch32(PlatformAssembler::Equal, PlatformAssembler::ScratchRegister, TrustedImm32(0)); pasm()->sub32(TrustedImm32(1), PlatformAssembler::ScratchRegister); - pasm()->store32(PlatformAssembler::ScratchRegister, Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel))); + pasm()->store32(PlatformAssembler::ScratchRegister, Address(PlatformAssembler::CppStackFrameRegister, offsetof(JSTypesStackFrame, unwindLevel))); auto jump = pasm()->branch32(PlatformAssembler::Equal, PlatformAssembler::ScratchRegister, TrustedImm32(0)); gotoCatchException(); jump.link(pasm()); - pasm()->loadPtr(Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLabel)), PlatformAssembler::ScratchRegister); + pasm()->loadPtr(Address(PlatformAssembler::CppStackFrameRegister, offsetof(JSTypesStackFrame, unwindLabel)), PlatformAssembler::ScratchRegister); pasm()->jump(PlatformAssembler::ScratchRegister); noUnwind.link(pasm()); @@ -1569,9 +1566,9 @@ void JIT::BaselineAssembler::unwindDispatch() int JIT::BaselineAssembler::unwindToLabel(int level, int offset) { - auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLabel))); + auto l = pasm()->storePtrWithPatch(TrustedImmPtr(nullptr), Address(PlatformAssembler::CppStackFrameRegister, offsetof(JSTypesStackFrame, unwindLabel))); pasm()->addEHTarget(l, offset); - pasm()->store32(TrustedImm32(level), Address(PlatformAssembler::CppStackFrameRegister, offsetof(CppStackFrame, unwindLevel))); + pasm()->store32(TrustedImm32(level), Address(PlatformAssembler::CppStackFrameRegister, offsetof(JSTypesStackFrame, unwindLevel))); gotoCatchException(); return offset; } @@ -1588,7 +1585,7 @@ void BaselineAssembler::pushCatchContext(int index, int name) void BaselineAssembler::popContext() { Heap::CallContext ctx; - Q_UNUSED(ctx) + Q_UNUSED(ctx); pasm()->loadPointerFromValue(regAddr(CallData::Context), PlatformAssembler::ScratchRegister); pasm()->loadPtr(Address(PlatformAssembler::ScratchRegister, ctx.outer.offset), PlatformAssembler::ScratchRegister); pasm()->storeHeapObject(PlatformAssembler::ScratchRegister, regAddr(CallData::Context)); @@ -1615,3 +1612,5 @@ void BaselineAssembler::ret() } // QV4 namepsace QT_END_NAMESPACE + +#endif // QT_CONFIG(qml_jit) |