4#include <private/qv4bytecodegenerator_p.h>
5#include <private/qv4compilercontext_p.h>
6#include <private/qqmljsastfwd_p.h>
14 currentLine =
static_cast<int>(loc.
startLine);
15 currentSourceLocation = loc;
40void BytecodeGenerator::packInstruction(I &
i)
45 int instructionsAsInts[
sizeof(
Instr)/
sizeof(
int)] = {};
48 for (
int j = 0;
j < nMembers; ++
j) {
49 instructionsAsInts[
j] = qFromLittleEndian<qint32>(code +
j *
sizeof(
int));
55 for (
int n = 0;
n < nMembers; ++
n) {
56 if (
width ==
Normal && (
static_cast<qint8>(instructionsAsInts[
n]) != instructionsAsInts[
n])) {
65 for (
int n = 0;
n < nMembers; ++
n) {
71 if (
i.offsetForJump != -1)
72 i.offsetForJump =
i.size - 1;
80void BytecodeGenerator::adjustJumpOffsets()
83 auto &
i = instructions[
index];
84 if (
i.offsetForJump == -1)
86 Q_ASSERT(
i.linkedLabel != -1 && labels.at(
i.linkedLabel) != -1);
87 const auto &linkedInstruction = instructions.at(labels.at(
i.linkedLabel));
88 qint8 *
c =
reinterpret_cast<qint8*
>(
i.packed +
i.offsetForJump);
89 int jumpOffset = linkedInstruction.position - (
i.position +
i.size);
95 qToLittleEndian<qint32>(jumpOffset,
c);
105void BytecodeGenerator::compressInstructions()
109 for (
auto &
i : instructions) {
111 if (
i.offsetForJump == -1)
120 for (
auto &
i : instructions) {
122 if (
i.offsetForJump != -1)
133 compressInstructions();
140 currentStatement = -1;
144 if (instructions[
i].
line != currentLine || instructions[
i].statement != currentStatement) {
145 currentLine = instructions[
i].line;
146 currentStatement = instructions[
i].statement;
149 entry.line = currentLine;
150 entry.statement = currentStatement;
154 if (m_sourceLocationTable)
155 m_sourceLocationTable->entries[
i].offset =
static_cast<quint32>(code.
size());
157 code.
append(
reinterpret_cast<const char *
>(instructions[
i].
packed), instructions[
i].size);
161 context->lineAndStatementNumberMapping = lineAndStatementNumbers;
162 context->sourceLocationTable = std::move(m_sourceLocationTable);
164 context->labelInfo.reserve(
context->labelInfo.size() + _labelInfos.size());
165 for (
const auto &li : _labelInfos)
166 context->labelInfo.push_back(instructions.at(labels.at(li.labelIndex)).position);
170 if (lastInstrType ==
int(Instr::Type::StoreReg)) {
171 if (
type == Instr::Type::LoadReg) {
172 if (
i.LoadReg.reg == lastInstr.StoreReg.reg) {
177 if (
type == Instr::Type::MoveReg) {
178 if (
i.MoveReg.srcReg == lastInstr.StoreReg.reg) {
179 Instruction::StoreReg store;
180 store.reg =
i.MoveReg.destReg;
186 lastInstrType = int(
type);
189 if (debugMode &&
type != Instr::Type::Debug) {
192 if (instructions.isEmpty() || currentLine != instructions.constLast().
line) {
194 }
else if (
type == Instr::Type::Ret) {
195 currentLine = -currentLine;
197 currentLine = -currentLine;
203 const int pos = instructions.size();
206 int s = argCount*
sizeof(int);
207 if (offsetOfOffset != -1)
222 for (
int j = 0;
j < argCount; ++
j) {
223 qToLittleEndian<qint32>(
i.argumentsAsInts[
j], code);
227 instructions.append(instr);
228 if (m_sourceLocationTable)
229 m_sourceLocationTable->entries.append({ 0, currentSourceLocation });
void append(parameter_type t)
qsizetype size() const
Returns the number of characters in this string.
QString & append(QChar c)
void setLocation(const QQmlJS::SourceLocation &loc)
void addInstruction(const InstrData< InstrT > &data)
void incrementStatement()
void finalize(Compiler::Context *context)
int newRegisterArray(int n)
\qmltype Particle \inqmlmodule QtQuick.Particles
#define QT_WARNING_DISABLE_GCC(text)
GLsizei const GLfloat * v
[13]
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QT_BEGIN_NAMESPACE typedef signed char qint8
#define MOTH_NUM_INSTRUCTIONS()
if(qFloatDistance(a, b)<(1<< 7))
[0]
static const int argumentCount[]
static int encodedLength(Type t)
static Type wideInstructionType(Type t)
static Type unpack(const uchar *c)
static uchar * pack(uchar *c, Type t)
static bool isWide(Type t)
static Type narrowInstructionType(Type t)