| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qv4instr_moth_p.h" |
| 5 | #include <private/qv4compileddata_p.h> |
| 6 | #include <private/qv4calldata_p.h> |
| 7 | |
| 8 | #include <QtCore/qdebug.h> |
| 9 | |
| 10 | using namespace QV4; |
| 11 | using namespace QV4::Moth; |
| 12 | |
| 13 | int InstrInfo::size(Instr::Type type) |
| 14 | { |
| 15 | #define MOTH_RETURN_INSTR_SIZE(I) case Instr::Type::I: case Instr::Type::I##_Wide: return InstrMeta<int(Instr::Type::I)>::Size; |
| 16 | switch (type) { |
| 17 | FOR_EACH_MOTH_INSTR_ALL(MOTH_RETURN_INSTR_SIZE) |
| 18 | } |
| 19 | #undef MOTH_RETURN_INSTR_SIZE |
| 20 | Q_UNREACHABLE(); |
| 21 | } |
| 22 | |
| 23 | static QByteArray alignedNumber(int n) { |
| 24 | QByteArray number = QByteArray::number(n); |
| 25 | return number.prepend(n: 8 - number.size(), ch: ' '); |
| 26 | } |
| 27 | |
| 28 | static QByteArray alignedLineNumber(int line) { |
| 29 | if (line > 0) |
| 30 | return alignedNumber(n: static_cast<int>(line)); |
| 31 | return QByteArray(" " ); |
| 32 | } |
| 33 | |
| 34 | static QByteArray rawBytes(const char *data, int n) |
| 35 | { |
| 36 | QByteArray ba; |
| 37 | while (n) { |
| 38 | uint num = *reinterpret_cast<const uchar *>(data); |
| 39 | if (num < 16) |
| 40 | ba += '0'; |
| 41 | ba += QByteArray::number(num, base: 16) + " " ; |
| 42 | ++data; |
| 43 | --n; |
| 44 | } |
| 45 | while (ba.size() < 25) |
| 46 | ba += ' '; |
| 47 | return ba; |
| 48 | } |
| 49 | |
| 50 | #define ABSOLUTE_OFFSET() \ |
| 51 | (code + beginOffset - start + offset) |
| 52 | |
| 53 | #define MOTH_BEGIN_INSTR(instr) \ |
| 54 | { \ |
| 55 | INSTR_##instr(MOTH_DECODE_WITH_BASE) \ |
| 56 | if (static_cast<int>(Instr::Type::instr) >= 0x100) \ |
| 57 | --base_ptr; \ |
| 58 | s << alignedLineNumber(line) << alignedNumber(beginOffset + codeOffset).constData() << ": " \ |
| 59 | << rawBytes(base_ptr, int(code - base_ptr)) << #instr << " "; |
| 60 | |
| 61 | #define MOTH_END_INSTR(instr) \ |
| 62 | s << "\n"; \ |
| 63 | continue; \ |
| 64 | } |
| 65 | |
| 66 | QT_BEGIN_NAMESPACE |
| 67 | namespace QV4 { |
| 68 | namespace Moth { |
| 69 | |
| 70 | const int InstrInfo::argumentCount[] = { |
| 71 | FOR_EACH_MOTH_INSTR_ALL(MOTH_COLLECT_NARGS) |
| 72 | }; |
| 73 | |
| 74 | QString dumpRegister(int reg, int nFormals) |
| 75 | { |
| 76 | Q_STATIC_ASSERT(offsetof(CallData, function) == 0); |
| 77 | Q_STATIC_ASSERT(offsetof(CallData, context) == sizeof(StaticValue)); |
| 78 | Q_STATIC_ASSERT(offsetof(CallData, accumulator) == 2*sizeof(StaticValue)); |
| 79 | Q_STATIC_ASSERT(offsetof(CallData, thisObject) == 3*sizeof(StaticValue)); |
| 80 | if (reg == CallData::Function) |
| 81 | return QStringLiteral("(function)" ); |
| 82 | else if (reg == CallData::Context) |
| 83 | return QStringLiteral("(context)" ); |
| 84 | else if (reg == CallData::Accumulator) |
| 85 | return QStringLiteral("(accumulator)" ); |
| 86 | else if (reg == CallData::NewTarget) |
| 87 | return QStringLiteral("(new.target)" ); |
| 88 | else if (reg == CallData::This) |
| 89 | return QStringLiteral("(this)" ); |
| 90 | else if (reg == CallData::Argc) |
| 91 | return QStringLiteral("(argc)" ); |
| 92 | reg -= CallData::HeaderSize(); |
| 93 | if (reg < nFormals) |
| 94 | return QStringLiteral("a%1" ).arg(a: reg); |
| 95 | reg -= nFormals; |
| 96 | return QStringLiteral("r%1" ).arg(a: reg); |
| 97 | |
| 98 | } |
| 99 | |
| 100 | QString dumpArguments(int argc, int argv, int nFormals) |
| 101 | { |
| 102 | if (!argc) |
| 103 | return QStringLiteral("()" ); |
| 104 | return QStringLiteral("(" ) + dumpRegister(reg: argv, nFormals) + QStringLiteral(", " ) + QString::number(argc) + QStringLiteral(")" ); |
| 105 | } |
| 106 | |
| 107 | QString dumpBytecode( |
| 108 | const char *code, int len, int nLocals, int nFormals, int /*startLine*/, |
| 109 | const QVector<CompiledData::CodeOffsetToLineAndStatement> &lineAndStatementNumberMapping) |
| 110 | { |
| 111 | return dumpBytecode(bytecode: code, len, nLocals, nFormals, beginOffset: 0, endOffset: len - 1, lineAndStatementNumberMapping); |
| 112 | } |
| 113 | |
| 114 | QString dumpBytecode( |
| 115 | const char *code, int len, int nLocals, int nFormals, int beginOffset, int endOffset, |
| 116 | const QVector<CompiledData::CodeOffsetToLineAndStatement> &lineAndStatementNumberMapping) |
| 117 | { |
| 118 | Q_ASSERT(beginOffset <= endOffset && 0 <= beginOffset && endOffset <= len); |
| 119 | |
| 120 | MOTH_JUMP_TABLE; |
| 121 | |
| 122 | auto findLine = [](const CompiledData::CodeOffsetToLineAndStatement &entry, uint offset) { |
| 123 | return entry.codeOffset < offset; |
| 124 | }; |
| 125 | |
| 126 | QString output; |
| 127 | QTextStream s{ &output }; |
| 128 | |
| 129 | int lastLine = -1; |
| 130 | code += beginOffset; |
| 131 | const char *start = code; |
| 132 | const char *end = code + (endOffset - beginOffset) + 1; |
| 133 | while (code < end) { |
| 134 | const auto codeToLine = std::lower_bound( |
| 135 | first: lineAndStatementNumberMapping.constBegin(), |
| 136 | last: lineAndStatementNumberMapping.constEnd(), |
| 137 | val: static_cast<uint>(code - start + beginOffset) + 1, comp: findLine) - 1; |
| 138 | int line = int(codeToLine->line); |
| 139 | if (line != lastLine) |
| 140 | lastLine = line; |
| 141 | else |
| 142 | line = -1; |
| 143 | |
| 144 | int codeOffset = int(code - start); |
| 145 | |
| 146 | MOTH_DISPATCH() |
| 147 | |
| 148 | MOTH_BEGIN_INSTR(LoadReg) |
| 149 | s << dumpRegister(reg, nFormals); |
| 150 | MOTH_END_INSTR(LoadReg) |
| 151 | |
| 152 | MOTH_BEGIN_INSTR(StoreReg) |
| 153 | s << dumpRegister(reg, nFormals); |
| 154 | MOTH_END_INSTR(StoreReg) |
| 155 | |
| 156 | MOTH_BEGIN_INSTR(MoveReg) |
| 157 | s << dumpRegister(reg: srcReg, nFormals) << ", " << dumpRegister(reg: destReg, nFormals); |
| 158 | MOTH_END_INSTR(MoveReg) |
| 159 | |
| 160 | MOTH_BEGIN_INSTR(LoadImport) |
| 161 | s << "i" << index; |
| 162 | MOTH_END_INSTR(LoadImport) |
| 163 | |
| 164 | MOTH_BEGIN_INSTR(LoadConst) |
| 165 | s << "C" << index; |
| 166 | MOTH_END_INSTR(LoadConst) |
| 167 | |
| 168 | MOTH_BEGIN_INSTR(LoadNull) |
| 169 | MOTH_END_INSTR(LoadNull) |
| 170 | |
| 171 | MOTH_BEGIN_INSTR(LoadZero) |
| 172 | MOTH_END_INSTR(LoadZero) |
| 173 | |
| 174 | MOTH_BEGIN_INSTR(LoadTrue) |
| 175 | MOTH_END_INSTR(LoadTrue) |
| 176 | |
| 177 | MOTH_BEGIN_INSTR(LoadFalse) |
| 178 | MOTH_END_INSTR(LoadFalse) |
| 179 | |
| 180 | MOTH_BEGIN_INSTR(LoadUndefined) |
| 181 | MOTH_END_INSTR(LoadUndefined) |
| 182 | |
| 183 | MOTH_BEGIN_INSTR(LoadInt) |
| 184 | s << value; |
| 185 | MOTH_END_INSTR(LoadInt) |
| 186 | |
| 187 | MOTH_BEGIN_INSTR(MoveConst) |
| 188 | s << "C" << constIndex << ", " << dumpRegister(reg: destTemp, nFormals); |
| 189 | MOTH_END_INSTR(MoveConst) |
| 190 | |
| 191 | MOTH_BEGIN_INSTR(LoadLocal) |
| 192 | if (index < nLocals) |
| 193 | s << "l" << index; |
| 194 | else |
| 195 | s << "a" << (index - nLocals); |
| 196 | MOTH_END_INSTR(LoadLocal) |
| 197 | |
| 198 | MOTH_BEGIN_INSTR(StoreLocal) |
| 199 | if (index < nLocals) |
| 200 | s << "l" << index; |
| 201 | else |
| 202 | s << "a" << (index - nLocals); |
| 203 | MOTH_END_INSTR(StoreLocal) |
| 204 | |
| 205 | MOTH_BEGIN_INSTR(LoadScopedLocal) |
| 206 | if (index < nLocals) |
| 207 | s << "l" << index << "@" << scope; |
| 208 | else |
| 209 | s << "a" << (index - nLocals) << "@" << scope; |
| 210 | MOTH_END_INSTR(LoadScopedLocal) |
| 211 | |
| 212 | MOTH_BEGIN_INSTR(StoreScopedLocal) |
| 213 | if (index < nLocals) |
| 214 | s << ", " << "l" << index << "@" << scope; |
| 215 | else |
| 216 | s << ", " << "a" << (index - nLocals) << "@" << scope; |
| 217 | MOTH_END_INSTR(StoreScopedLocal) |
| 218 | |
| 219 | MOTH_BEGIN_INSTR(LoadRuntimeString) |
| 220 | s << stringId; |
| 221 | MOTH_END_INSTR(LoadRuntimeString) |
| 222 | |
| 223 | MOTH_BEGIN_INSTR(MoveRegExp) |
| 224 | s << regExpId << ", " << dumpRegister(reg: destReg, nFormals); |
| 225 | MOTH_END_INSTR(MoveRegExp) |
| 226 | |
| 227 | MOTH_BEGIN_INSTR(LoadClosure) |
| 228 | s << value; |
| 229 | MOTH_END_INSTR(LoadClosure) |
| 230 | |
| 231 | MOTH_BEGIN_INSTR(LoadName) |
| 232 | s << name; |
| 233 | MOTH_END_INSTR(LoadName) |
| 234 | |
| 235 | MOTH_BEGIN_INSTR(LoadGlobalLookup) |
| 236 | s << index; |
| 237 | MOTH_END_INSTR(LoadGlobalLookup) |
| 238 | |
| 239 | MOTH_BEGIN_INSTR(LoadQmlContextPropertyLookup) |
| 240 | s << index; |
| 241 | MOTH_END_INSTR(LoadQmlContextPropertyLookup) |
| 242 | |
| 243 | MOTH_BEGIN_INSTR(StoreNameSloppy) |
| 244 | s << name; |
| 245 | MOTH_END_INSTR(StoreNameSloppy) |
| 246 | |
| 247 | MOTH_BEGIN_INSTR(StoreNameStrict) |
| 248 | s << name; |
| 249 | MOTH_END_INSTR(StoreNameStrict) |
| 250 | |
| 251 | MOTH_BEGIN_INSTR(LoadElement) |
| 252 | s << dumpRegister(reg: base, nFormals) << "[acc]" ; |
| 253 | MOTH_END_INSTR(LoadElement) |
| 254 | |
| 255 | MOTH_BEGIN_INSTR(StoreElement) |
| 256 | s << dumpRegister(reg: base, nFormals) << "[" << dumpRegister(reg: index, nFormals) << "]" ; |
| 257 | MOTH_END_INSTR(StoreElement) |
| 258 | |
| 259 | MOTH_BEGIN_INSTR(LoadProperty) |
| 260 | s << "acc[" << name << "]" ; |
| 261 | MOTH_END_INSTR(LoadProperty) |
| 262 | |
| 263 | MOTH_BEGIN_INSTR(LoadOptionalProperty) |
| 264 | s << "acc[" << name << "], jump(" << ABSOLUTE_OFFSET() << ")" ; |
| 265 | MOTH_END_INSTR(LoadOptionalProperty) |
| 266 | |
| 267 | MOTH_BEGIN_INSTR(GetLookup) |
| 268 | s << "acc(" << index << ")" ; |
| 269 | MOTH_END_INSTR(GetLookup) |
| 270 | |
| 271 | MOTH_BEGIN_INSTR(GetOptionalLookup) |
| 272 | s << "acc(" << index << "), jump(" << ABSOLUTE_OFFSET() << ")" ; |
| 273 | MOTH_END_INSTR(GetOptionalLookup) |
| 274 | |
| 275 | MOTH_BEGIN_INSTR(StoreProperty) |
| 276 | s << dumpRegister(reg: base, nFormals) << "[" << name<< "]" ; |
| 277 | MOTH_END_INSTR(StoreProperty) |
| 278 | |
| 279 | MOTH_BEGIN_INSTR(SetLookup) |
| 280 | s << dumpRegister(reg: base, nFormals) << "(" << index << ")" ; |
| 281 | MOTH_END_INSTR(SetLookup) |
| 282 | |
| 283 | MOTH_BEGIN_INSTR(LoadSuperProperty) |
| 284 | s << dumpRegister(reg: property, nFormals); |
| 285 | MOTH_END_INSTR(LoadSuperProperty) |
| 286 | |
| 287 | MOTH_BEGIN_INSTR(StoreSuperProperty) |
| 288 | s << dumpRegister(reg: property, nFormals); |
| 289 | MOTH_END_INSTR(StoreSuperProperty) |
| 290 | |
| 291 | MOTH_BEGIN_INSTR(Yield) |
| 292 | MOTH_END_INSTR(Yield) |
| 293 | |
| 294 | MOTH_BEGIN_INSTR(YieldStar) |
| 295 | MOTH_END_INSTR(YieldStar) |
| 296 | |
| 297 | MOTH_BEGIN_INSTR(Resume) |
| 298 | s << ABSOLUTE_OFFSET(); |
| 299 | MOTH_END_INSTR(Resume) |
| 300 | |
| 301 | MOTH_BEGIN_INSTR(CallValue) |
| 302 | s << dumpRegister(reg: name, nFormals) << dumpArguments(argc, argv, nFormals); |
| 303 | MOTH_END_INSTR(CallValue) |
| 304 | |
| 305 | MOTH_BEGIN_INSTR(CallWithReceiver) |
| 306 | s << dumpRegister(reg: name, nFormals) << dumpRegister(reg: thisObject, nFormals) |
| 307 | << dumpArguments(argc, argv, nFormals); |
| 308 | MOTH_END_INSTR(CallWithReceiver) |
| 309 | |
| 310 | MOTH_BEGIN_INSTR(CallProperty) |
| 311 | s << dumpRegister(reg: base, nFormals) << "." << name << dumpArguments(argc, argv, nFormals) |
| 312 | ; |
| 313 | MOTH_END_INSTR(CallProperty) |
| 314 | |
| 315 | MOTH_BEGIN_INSTR(CallPropertyLookup) |
| 316 | s << dumpRegister(reg: base, nFormals) << "." << lookupIndex |
| 317 | << dumpArguments(argc, argv, nFormals); |
| 318 | MOTH_END_INSTR(CallPropertyLookup) |
| 319 | |
| 320 | MOTH_BEGIN_INSTR(CallName) |
| 321 | s << name << dumpArguments(argc, argv, nFormals); |
| 322 | MOTH_END_INSTR(CallName) |
| 323 | |
| 324 | MOTH_BEGIN_INSTR(CallPossiblyDirectEval) |
| 325 | s << dumpArguments(argc, argv, nFormals); |
| 326 | MOTH_END_INSTR(CallPossiblyDirectEval) |
| 327 | |
| 328 | MOTH_BEGIN_INSTR(CallGlobalLookup) |
| 329 | s << index << dumpArguments(argc, argv, nFormals); |
| 330 | MOTH_END_INSTR(CallGlobalLookup) |
| 331 | |
| 332 | MOTH_BEGIN_INSTR(CallQmlContextPropertyLookup) |
| 333 | s << index << dumpArguments(argc, argv, nFormals); |
| 334 | MOTH_END_INSTR(CallQmlContextPropertyLookup) |
| 335 | |
| 336 | MOTH_BEGIN_INSTR(CallWithSpread) |
| 337 | s << "new " << dumpRegister(reg: func, nFormals) << dumpRegister(reg: thisObject, nFormals) |
| 338 | << dumpArguments(argc, argv, nFormals); |
| 339 | MOTH_END_INSTR(CallWithSpread) |
| 340 | |
| 341 | MOTH_BEGIN_INSTR(Construct) |
| 342 | s << "new " << dumpRegister(reg: func, nFormals) << dumpArguments(argc, argv, nFormals); |
| 343 | MOTH_END_INSTR(Construct) |
| 344 | |
| 345 | MOTH_BEGIN_INSTR(ConstructWithSpread) |
| 346 | s << "new " << dumpRegister(reg: func, nFormals) << dumpArguments(argc, argv, nFormals); |
| 347 | MOTH_END_INSTR(ConstructWithSpread) |
| 348 | |
| 349 | MOTH_BEGIN_INSTR(SetUnwindHandler) |
| 350 | if (offset) |
| 351 | s << ABSOLUTE_OFFSET(); |
| 352 | else |
| 353 | s << "<null>" ; |
| 354 | MOTH_END_INSTR(SetUnwindHandler) |
| 355 | |
| 356 | MOTH_BEGIN_INSTR(UnwindDispatch) |
| 357 | MOTH_END_INSTR(UnwindDispatch) |
| 358 | |
| 359 | MOTH_BEGIN_INSTR(UnwindToLabel) |
| 360 | s << "(" << level << ") " << ABSOLUTE_OFFSET(); |
| 361 | MOTH_END_INSTR(UnwindToLabel) |
| 362 | |
| 363 | MOTH_BEGIN_INSTR(DeadTemporalZoneCheck) |
| 364 | s << name; |
| 365 | MOTH_END_INSTR(DeadTemporalZoneCheck) |
| 366 | |
| 367 | MOTH_BEGIN_INSTR(ThrowException) |
| 368 | MOTH_END_INSTR(ThrowException) |
| 369 | |
| 370 | MOTH_BEGIN_INSTR(GetException) |
| 371 | MOTH_END_INSTR(HasException) |
| 372 | |
| 373 | MOTH_BEGIN_INSTR(SetException) |
| 374 | MOTH_END_INSTR(SetExceptionFlag) |
| 375 | |
| 376 | MOTH_BEGIN_INSTR(CreateCallContext) |
| 377 | MOTH_END_INSTR(CreateCallContext) |
| 378 | |
| 379 | MOTH_BEGIN_INSTR(PushCatchContext) |
| 380 | s << index << ", " << name; |
| 381 | MOTH_END_INSTR(PushCatchContext) |
| 382 | |
| 383 | MOTH_BEGIN_INSTR(PushWithContext) |
| 384 | MOTH_END_INSTR(PushWithContext) |
| 385 | |
| 386 | MOTH_BEGIN_INSTR(PushBlockContext) |
| 387 | s << index; |
| 388 | MOTH_END_INSTR(PushBlockContext) |
| 389 | |
| 390 | MOTH_BEGIN_INSTR(CloneBlockContext) |
| 391 | MOTH_END_INSTR(CloneBlockContext) |
| 392 | |
| 393 | MOTH_BEGIN_INSTR(PushScriptContext) |
| 394 | s << index; |
| 395 | MOTH_END_INSTR(PushScriptContext) |
| 396 | |
| 397 | MOTH_BEGIN_INSTR(PopScriptContext) |
| 398 | MOTH_END_INSTR(PopScriptContext) |
| 399 | |
| 400 | MOTH_BEGIN_INSTR(PopContext) |
| 401 | MOTH_END_INSTR(PopContext) |
| 402 | |
| 403 | MOTH_BEGIN_INSTR(GetIterator) |
| 404 | s << iterator; |
| 405 | MOTH_END_INSTR(GetIterator) |
| 406 | |
| 407 | MOTH_BEGIN_INSTR(IteratorNext) |
| 408 | s << dumpRegister(reg: value, nFormals) << ", " << ABSOLUTE_OFFSET(); |
| 409 | MOTH_END_INSTR(IteratorNext) |
| 410 | |
| 411 | MOTH_BEGIN_INSTR(IteratorNextForYieldStar) |
| 412 | s << dumpRegister(reg: iterator, nFormals) << ", " << dumpRegister(reg: object, nFormals) |
| 413 | << ABSOLUTE_OFFSET(); |
| 414 | MOTH_END_INSTR(IteratorNextForYieldStar) |
| 415 | |
| 416 | MOTH_BEGIN_INSTR(IteratorClose) |
| 417 | MOTH_END_INSTR(IteratorClose) |
| 418 | |
| 419 | MOTH_BEGIN_INSTR(DestructureRestElement) |
| 420 | MOTH_END_INSTR(DestructureRestElement) |
| 421 | |
| 422 | MOTH_BEGIN_INSTR(DeleteProperty) |
| 423 | s << dumpRegister(reg: base, nFormals) << "[" << dumpRegister(reg: index, nFormals) << "]" ; |
| 424 | MOTH_END_INSTR(DeleteProperty) |
| 425 | |
| 426 | MOTH_BEGIN_INSTR(DeleteName) |
| 427 | s << name; |
| 428 | MOTH_END_INSTR(DeleteName) |
| 429 | |
| 430 | MOTH_BEGIN_INSTR(TypeofName) |
| 431 | s << name; |
| 432 | MOTH_END_INSTR(TypeofName) |
| 433 | |
| 434 | MOTH_BEGIN_INSTR(TypeofValue) |
| 435 | MOTH_END_INSTR(TypeofValue) |
| 436 | |
| 437 | MOTH_BEGIN_INSTR(DeclareVar) |
| 438 | s << isDeletable << ", " << varName; |
| 439 | MOTH_END_INSTR(DeclareVar) |
| 440 | |
| 441 | MOTH_BEGIN_INSTR(DefineArray) |
| 442 | s << dumpRegister(reg: args, nFormals) << ", " << argc; |
| 443 | MOTH_END_INSTR(DefineArray) |
| 444 | |
| 445 | MOTH_BEGIN_INSTR(DefineObjectLiteral) |
| 446 | s << internalClassId |
| 447 | << ", " << argc |
| 448 | << ", " << dumpRegister(reg: args, nFormals); |
| 449 | MOTH_END_INSTR(DefineObjectLiteral) |
| 450 | |
| 451 | MOTH_BEGIN_INSTR(CreateClass) |
| 452 | s << classIndex |
| 453 | << ", " << dumpRegister(reg: heritage, nFormals) |
| 454 | << ", " << dumpRegister(reg: computedNames, nFormals); |
| 455 | MOTH_END_INSTR(CreateClass) |
| 456 | |
| 457 | MOTH_BEGIN_INSTR(CreateMappedArgumentsObject) |
| 458 | MOTH_END_INSTR(CreateMappedArgumentsObject) |
| 459 | |
| 460 | MOTH_BEGIN_INSTR(CreateUnmappedArgumentsObject) |
| 461 | MOTH_END_INSTR(CreateUnmappedArgumentsObject) |
| 462 | |
| 463 | MOTH_BEGIN_INSTR(CreateRestParameter) |
| 464 | s << argIndex; |
| 465 | MOTH_END_INSTR(CreateRestParameter) |
| 466 | |
| 467 | MOTH_BEGIN_INSTR(ConvertThisToObject) |
| 468 | MOTH_END_INSTR(ConvertThisToObject) |
| 469 | |
| 470 | MOTH_BEGIN_INSTR(LoadSuperConstructor) |
| 471 | MOTH_END_INSTR(LoadSuperConstructor) |
| 472 | |
| 473 | MOTH_BEGIN_INSTR(ToObject) |
| 474 | MOTH_END_INSTR(ToObject) |
| 475 | |
| 476 | MOTH_BEGIN_INSTR(Jump) |
| 477 | s << ABSOLUTE_OFFSET(); |
| 478 | MOTH_END_INSTR(Jump) |
| 479 | |
| 480 | MOTH_BEGIN_INSTR(JumpTrue) |
| 481 | s << ABSOLUTE_OFFSET(); |
| 482 | MOTH_END_INSTR(JumpTrue) |
| 483 | |
| 484 | MOTH_BEGIN_INSTR(JumpFalse) |
| 485 | s << ABSOLUTE_OFFSET(); |
| 486 | MOTH_END_INSTR(JumpFalse) |
| 487 | |
| 488 | MOTH_BEGIN_INSTR(JumpNotUndefined) |
| 489 | s << ABSOLUTE_OFFSET(); |
| 490 | MOTH_END_INSTR(JumpNotUndefined) |
| 491 | |
| 492 | MOTH_BEGIN_INSTR(JumpNoException) |
| 493 | s << ABSOLUTE_OFFSET(); |
| 494 | MOTH_END_INSTR(JumpNoException) |
| 495 | |
| 496 | MOTH_BEGIN_INSTR(CheckException) |
| 497 | MOTH_END_INSTR(CheckException) |
| 498 | |
| 499 | MOTH_BEGIN_INSTR(CmpEqNull) |
| 500 | MOTH_END_INSTR(CmpEqNull) |
| 501 | |
| 502 | MOTH_BEGIN_INSTR(CmpNeNull) |
| 503 | MOTH_END_INSTR(CmpNeNull) |
| 504 | |
| 505 | MOTH_BEGIN_INSTR(CmpEqInt) |
| 506 | s << lhs; |
| 507 | MOTH_END_INSTR(CmpEq) |
| 508 | |
| 509 | MOTH_BEGIN_INSTR(CmpNeInt) |
| 510 | s << lhs; |
| 511 | MOTH_END_INSTR(CmpNeInt) |
| 512 | |
| 513 | MOTH_BEGIN_INSTR(CmpEq) |
| 514 | s << dumpRegister(reg: lhs, nFormals); |
| 515 | MOTH_END_INSTR(CmpEq) |
| 516 | |
| 517 | MOTH_BEGIN_INSTR(CmpNe) |
| 518 | s << dumpRegister(reg: lhs, nFormals); |
| 519 | MOTH_END_INSTR(CmpNe) |
| 520 | |
| 521 | MOTH_BEGIN_INSTR(CmpGt) |
| 522 | s << dumpRegister(reg: lhs, nFormals); |
| 523 | MOTH_END_INSTR(CmpGt) |
| 524 | |
| 525 | MOTH_BEGIN_INSTR(CmpGe) |
| 526 | s << dumpRegister(reg: lhs, nFormals); |
| 527 | MOTH_END_INSTR(CmpGe) |
| 528 | |
| 529 | MOTH_BEGIN_INSTR(CmpLt) |
| 530 | s << dumpRegister(reg: lhs, nFormals); |
| 531 | MOTH_END_INSTR(CmpLt) |
| 532 | |
| 533 | MOTH_BEGIN_INSTR(CmpLe) |
| 534 | s << dumpRegister(reg: lhs, nFormals); |
| 535 | MOTH_END_INSTR(CmpLe) |
| 536 | |
| 537 | MOTH_BEGIN_INSTR(CmpStrictEqual) |
| 538 | s << dumpRegister(reg: lhs, nFormals); |
| 539 | MOTH_END_INSTR(CmpStrictEqual) |
| 540 | |
| 541 | MOTH_BEGIN_INSTR(CmpStrictNotEqual) |
| 542 | s << dumpRegister(reg: lhs, nFormals); |
| 543 | MOTH_END_INSTR(CmpStrictNotEqual) |
| 544 | |
| 545 | MOTH_BEGIN_INSTR(UNot) |
| 546 | MOTH_END_INSTR(UNot) |
| 547 | |
| 548 | MOTH_BEGIN_INSTR(UPlus) |
| 549 | MOTH_END_INSTR(UPlus) |
| 550 | |
| 551 | MOTH_BEGIN_INSTR(UMinus) |
| 552 | MOTH_END_INSTR(UMinus) |
| 553 | |
| 554 | MOTH_BEGIN_INSTR(UCompl) |
| 555 | MOTH_END_INSTR(UCompl) |
| 556 | |
| 557 | MOTH_BEGIN_INSTR(Increment) |
| 558 | MOTH_END_INSTR(Increment) |
| 559 | |
| 560 | MOTH_BEGIN_INSTR(Decrement) |
| 561 | MOTH_END_INSTR(Decrement) |
| 562 | |
| 563 | MOTH_BEGIN_INSTR(Add) |
| 564 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 565 | MOTH_END_INSTR(Add) |
| 566 | |
| 567 | MOTH_BEGIN_INSTR(BitAnd) |
| 568 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 569 | MOTH_END_INSTR(BitAnd) |
| 570 | |
| 571 | MOTH_BEGIN_INSTR(BitOr) |
| 572 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 573 | MOTH_END_INSTR(BitOr) |
| 574 | |
| 575 | MOTH_BEGIN_INSTR(BitXor) |
| 576 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 577 | MOTH_END_INSTR(BitXor) |
| 578 | |
| 579 | MOTH_BEGIN_INSTR(UShr) |
| 580 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 581 | MOTH_END_INSTR(UShr) |
| 582 | |
| 583 | MOTH_BEGIN_INSTR(Shr) |
| 584 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 585 | MOTH_END_INSTR(Shr) |
| 586 | |
| 587 | MOTH_BEGIN_INSTR(Shl) |
| 588 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 589 | MOTH_END_INSTR(Shl) |
| 590 | |
| 591 | MOTH_BEGIN_INSTR(BitAndConst) |
| 592 | s << "acc, " << rhs; |
| 593 | MOTH_END_INSTR(BitAndConst) |
| 594 | |
| 595 | MOTH_BEGIN_INSTR(BitOrConst) |
| 596 | s << "acc, " << rhs; |
| 597 | MOTH_END_INSTR(BitOr) |
| 598 | |
| 599 | MOTH_BEGIN_INSTR(BitXorConst) |
| 600 | s << "acc, " << rhs; |
| 601 | MOTH_END_INSTR(BitXor) |
| 602 | |
| 603 | MOTH_BEGIN_INSTR(UShrConst) |
| 604 | s << "acc, " << rhs; |
| 605 | MOTH_END_INSTR(UShrConst) |
| 606 | |
| 607 | MOTH_BEGIN_INSTR(ShrConst) |
| 608 | s << "acc, " << rhs; |
| 609 | MOTH_END_INSTR(ShrConst) |
| 610 | |
| 611 | MOTH_BEGIN_INSTR(ShlConst) |
| 612 | s << "acc, " << rhs; |
| 613 | MOTH_END_INSTR(ShlConst) |
| 614 | |
| 615 | MOTH_BEGIN_INSTR(Exp) |
| 616 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 617 | MOTH_END_INSTR(Exp) |
| 618 | |
| 619 | MOTH_BEGIN_INSTR(Mul) |
| 620 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 621 | MOTH_END_INSTR(Mul) |
| 622 | |
| 623 | MOTH_BEGIN_INSTR(Div) |
| 624 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 625 | MOTH_END_INSTR(Div) |
| 626 | |
| 627 | MOTH_BEGIN_INSTR(Mod) |
| 628 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 629 | MOTH_END_INSTR(Mod) |
| 630 | |
| 631 | MOTH_BEGIN_INSTR(Sub) |
| 632 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 633 | MOTH_END_INSTR(Sub) |
| 634 | |
| 635 | MOTH_BEGIN_INSTR(As) |
| 636 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 637 | MOTH_END_INSTR(Sub) |
| 638 | |
| 639 | MOTH_BEGIN_INSTR(CmpIn) |
| 640 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 641 | MOTH_END_INSTR(CmpIn) |
| 642 | |
| 643 | MOTH_BEGIN_INSTR(CmpInstanceOf) |
| 644 | s << dumpRegister(reg: lhs, nFormals) << ", acc" ; |
| 645 | MOTH_END_INSTR(CmpInstanceOf) |
| 646 | |
| 647 | MOTH_BEGIN_INSTR(Ret) |
| 648 | MOTH_END_INSTR(Ret) |
| 649 | |
| 650 | MOTH_BEGIN_INSTR(Debug) |
| 651 | MOTH_END_INSTR(Debug) |
| 652 | |
| 653 | MOTH_BEGIN_INSTR(InitializeBlockDeadTemporalZone) |
| 654 | s << dumpRegister(reg: firstReg, nFormals) << ", " << count; |
| 655 | MOTH_END_INSTR(InitializeBlockDeadTemporalZone) |
| 656 | |
| 657 | MOTH_BEGIN_INSTR(ThrowOnNullOrUndefined) |
| 658 | MOTH_END_INSTR(ThrowOnNullOrUndefined) |
| 659 | |
| 660 | MOTH_BEGIN_INSTR(GetTemplateObject) |
| 661 | s << index; |
| 662 | MOTH_END_INSTR(GetTemplateObject) |
| 663 | |
| 664 | MOTH_BEGIN_INSTR(TailCall) |
| 665 | s << dumpRegister(reg: func, nFormals) << dumpRegister(reg: thisObject, nFormals) << dumpArguments(argc, argv, nFormals); |
| 666 | MOTH_END_INSTR(TailCall) |
| 667 | } |
| 668 | return output; |
| 669 | } |
| 670 | |
| 671 | } |
| 672 | } |
| 673 | QT_END_NAMESPACE |
| 674 | |