From b7eebec9597b38fed52710bc1dcc166d456a415d Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 7 Mar 2019 11:53:56 +0100 Subject: V4: Add trace slot for UPlus Change-Id: I0bb5055024e30c32b82e1555c820ea5ced8923f5 Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4codegen.cpp | 12 ++++++------ src/qml/compiler/qv4compileddata_p.h | 8 +++++++- src/qml/compiler/qv4instr_moth.cpp | 1 + src/qml/compiler/qv4instr_moth_p.h | 2 +- src/qml/jit/qv4baselinejit.cpp | 2 +- src/qml/jit/qv4baselinejit_p.h | 2 +- src/qml/jit/qv4graphbuilder.cpp | 2 +- src/qml/jit/qv4graphbuilder_p.h | 2 +- src/qml/jsruntime/qv4vme_moth.cpp | 19 ++++++++++++++++++- 9 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 448fbff27b..1149c9ff1e 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -293,8 +293,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr) } case UPlus: { expr.loadInAccumulator(); - Instruction::UPlus uplus; - bytecodeGenerator->addInstruction(uplus); + Instruction::UPlus uplus = {}; + bytecodeGenerator->addTracingInstruction(uplus); return Reference::fromAccumulator(this); } case Not: { @@ -313,8 +313,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr) if (!_expr.accept(nx) || requiresReturnValue) { Reference e = expr.asLValue(); e.loadInAccumulator(); - Instruction::UPlus uplus; - bytecodeGenerator->addInstruction(uplus); + Instruction::UPlus uplus = {}; + bytecodeGenerator->addTracingInstruction(uplus); Reference originalValue = Reference::fromStackSlot(this).storeRetainAccumulator(); Instruction::Increment inc = {}; bytecodeGenerator->addTracingInstruction(inc); @@ -339,8 +339,8 @@ Codegen::Reference Codegen::unop(UnaryOperation op, const Reference &expr) if (!_expr.accept(nx) || requiresReturnValue) { Reference e = expr.asLValue(); e.loadInAccumulator(); - Instruction::UPlus uplus; - bytecodeGenerator->addInstruction(uplus); + Instruction::UPlus uplus = {}; + bytecodeGenerator->addTracingInstruction(uplus); Reference originalValue = Reference::fromStackSlot(this).storeRetainAccumulator(); Instruction::Decrement dec = {}; bytecodeGenerator->addTracingInstruction(dec); diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index 1aaba13241..726b82fea9 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -73,7 +73,13 @@ QT_BEGIN_NAMESPACE // Bump this whenever the compiler data structures change in an incompatible way. -#define QV4_DATA_STRUCTURE_VERSION 0x1b +// +// IMPORTANT: +// +// Also change the comment behind the number to describe the latest change. This has the added +// benefit that if another patch changes the version too, it will result in a merge conflict, and +// not get removed silently. +#define QV4_DATA_STRUCTURE_VERSION 0x1c // Add trace slot to UPlus class QIODevice; class QQmlPropertyData; diff --git a/src/qml/compiler/qv4instr_moth.cpp b/src/qml/compiler/qv4instr_moth.cpp index c0b1be1492..f528e1f9d3 100644 --- a/src/qml/compiler/qv4instr_moth.cpp +++ b/src/qml/compiler/qv4instr_moth.cpp @@ -615,6 +615,7 @@ void dumpBytecode(const char *code, int len, int nLocals, int nFormals, int /*st MOTH_END_INSTR(UNot) MOTH_BEGIN_INSTR(UPlus) + d << TRACE_SLOT; MOTH_END_INSTR(UPlus) MOTH_BEGIN_INSTR(UMinus) diff --git a/src/qml/compiler/qv4instr_moth_p.h b/src/qml/compiler/qv4instr_moth_p.h index 3996143843..f853c1f1ab 100644 --- a/src/qml/compiler/qv4instr_moth_p.h +++ b/src/qml/compiler/qv4instr_moth_p.h @@ -171,7 +171,7 @@ QT_BEGIN_NAMESPACE #define INSTR_CmpIn(op) INSTRUCTION(op, CmpIn, 1, lhs) #define INSTR_CmpInstanceOf(op) INSTRUCTION(op, CmpInstanceOf, 1, lhs) #define INSTR_UNot(op) INSTRUCTION(op, UNot, 0) -#define INSTR_UPlus(op) INSTRUCTION(op, UPlus, 0) +#define INSTR_UPlus(op) INSTRUCTION(op, UPlus, 1, traceSlot) #define INSTR_UMinus(op) INSTRUCTION(op, UMinus, 1, traceSlot) #define INSTR_UCompl(op) INSTRUCTION(op, UCompl, 0) #define INSTR_Increment(op) INSTRUCTION(op, Increment, 1, traceSlot) diff --git a/src/qml/jit/qv4baselinejit.cpp b/src/qml/jit/qv4baselinejit.cpp index f2f7a12598..6635ee7530 100644 --- a/src/qml/jit/qv4baselinejit.cpp +++ b/src/qml/jit/qv4baselinejit.cpp @@ -891,7 +891,7 @@ void BaselineJIT::generate_CmpInstanceOf(int lhs) } void BaselineJIT::generate_UNot() { as->unot(); } -void BaselineJIT::generate_UPlus() { as->toNumber(); } +void BaselineJIT::generate_UPlus(int /*traceSlot*/) { as->toNumber(); } void BaselineJIT::generate_UMinus(int /*traceSlot*/) { as->uminus(); } void BaselineJIT::generate_UCompl() { as->ucompl(); } void BaselineJIT::generate_Increment(int /*traceSlot*/) { as->inc(); } diff --git a/src/qml/jit/qv4baselinejit_p.h b/src/qml/jit/qv4baselinejit_p.h index 5f3cb7eb2e..df263b066b 100644 --- a/src/qml/jit/qv4baselinejit_p.h +++ b/src/qml/jit/qv4baselinejit_p.h @@ -188,7 +188,7 @@ public: void generate_CmpIn(int lhs) override; void generate_CmpInstanceOf(int lhs) override; void generate_UNot() override; - void generate_UPlus() override; + void generate_UPlus(int) override; void generate_UMinus(int traceSlot) override; void generate_UCompl() override; void generate_Increment(int traceSlot) override; diff --git a/src/qml/jit/qv4graphbuilder.cpp b/src/qml/jit/qv4graphbuilder.cpp index 94b8e86e08..19f83ad0ec 100644 --- a/src/qml/jit/qv4graphbuilder.cpp +++ b/src/qml/jit/qv4graphbuilder.cpp @@ -1472,7 +1472,7 @@ void GraphBuilder::generate_UNot() createToBoolean(env()->accumulator()))); } -void GraphBuilder::generate_UPlus() +void GraphBuilder::generate_UPlus(int /*traceSlot*/) { Node* control = createNode(opBuilder()->get(), env()->accumulator()); diff --git a/src/qml/jit/qv4graphbuilder_p.h b/src/qml/jit/qv4graphbuilder_p.h index 6393cab9ef..b6b2931ff0 100644 --- a/src/qml/jit/qv4graphbuilder_p.h +++ b/src/qml/jit/qv4graphbuilder_p.h @@ -261,7 +261,7 @@ protected: // ByteCodeHandler void generate_CmpIn(int lhs) override; void generate_CmpInstanceOf(int lhs) override; void generate_UNot() override; - void generate_UPlus() override; + void generate_UPlus(int traceSlot) override; void generate_UMinus(int traceSlot) override; void generate_UCompl() override; void generate_Increment(int traceSlot) override; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 3098837e1c..e3cdc4552a 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -388,6 +388,18 @@ static inline void traceValue(ReturnedValue acc, Function *f, int slot) #endif } +static inline void traceIntValue(Function *f, int slot) +{ +#if QT_CONFIG(qml_tracing) + quint8 *traceInfo = f->traceInfo(slot); + Q_ASSERT(traceInfo); + *traceInfo |= quint8(ObservedTraceValues::Integer); +#else + Q_UNUSED(f); + Q_UNUSED(slot); +#endif +} + static inline void traceDoubleValue(Function *f, int slot) { #if QT_CONFIG(qml_tracing) @@ -1285,7 +1297,12 @@ QV4::ReturnedValue VME::interpret(CppStackFrame *frame, ExecutionEngine *engine, MOTH_END_INSTR(UNot) MOTH_BEGIN_INSTR(UPlus) - if (Q_UNLIKELY(!ACC.isNumber())) { + if (Q_LIKELY(ACC.isNumber())) { + if (ACC.isDouble()) + traceDoubleValue(function, traceSlot); + else + traceIntValue(function, traceSlot); + } else { acc = Encode(ACC.toNumberImpl()); CHECK_EXCEPTION; } -- cgit v1.2.3