OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_CONSTANTS_DBC_H_ | 5 #ifndef VM_CONSTANTS_DBC_H_ |
6 #define VM_CONSTANTS_DBC_H_ | 6 #define VM_CONSTANTS_DBC_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // | opcode | T | T: signed 24-bit operand | 76 // | opcode | T | T: signed 24-bit operand |
77 // +--------+--------+--------+--------+ | 77 // +--------+--------+--------+--------+ |
78 // | 78 // |
79 // | 79 // |
80 // INSTRUCTIONS | 80 // INSTRUCTIONS |
81 // | 81 // |
82 // - Trap | 82 // - Trap |
83 // | 83 // |
84 // Unreachable instruction. | 84 // Unreachable instruction. |
85 // | 85 // |
86 // - Nop | 86 // - Nop D |
87 // | 87 // |
88 // This instuction does nothing. | 88 // This instuction does nothing. It may refer to an object in the constant |
| 89 // pool that may be decoded by other instructions. |
89 // | 90 // |
90 // - Compile | 91 // - Compile |
91 // | 92 // |
92 // Compile current function and start executing newly produced code | 93 // Compile current function and start executing newly produced code |
93 // (used to implement LazyCompileStub); | 94 // (used to implement LazyCompileStub); |
94 // | 95 // |
95 // - Intrinsic id | 96 // - Intrinsic id |
96 // | 97 // |
97 // Execute intrinsic with the given id. If intrinsic returns true then | 98 // Execute intrinsic with the given id. If intrinsic returns true then |
98 // return from the current function to the caller passing value produced | 99 // return from the current function to the caller passing value produced |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // | 216 // |
216 // Skips the next instruction unless the given condition holds. 'Num' | 217 // Skips the next instruction unless the given condition holds. 'Num' |
217 // variants perform number check while non-Num variants just compare | 218 // variants perform number check while non-Num variants just compare |
218 // RawObject pointers. | 219 // RawObject pointers. |
219 // | 220 // |
220 // Used to implement conditional jump: | 221 // Used to implement conditional jump: |
221 // | 222 // |
222 // IfNeStrictTOS | 223 // IfNeStrictTOS |
223 // Jump T ;; jump if not equal | 224 // Jump T ;; jump if not equal |
224 // | 225 // |
| 226 // - If<Cond>Null rA |
| 227 // |
| 228 // Cond is Eq or Ne. Skips the next instruction unless the given condition |
| 229 // holds. |
| 230 // |
225 // - CreateArrayTOS | 231 // - CreateArrayTOS |
226 // | 232 // |
227 // Allocate array of length SP[0] with type arguments SP[-1]. | 233 // Allocate array of length SP[0] with type arguments SP[-1]. |
228 // | 234 // |
229 // - Allocate D | 235 // - Allocate D |
230 // | 236 // |
231 // Allocate object of class PP[D] with no type arguments. | 237 // Allocate object of class PP[D] with no type arguments. |
232 // | 238 // |
233 // - AllocateT | 239 // - AllocateT |
234 // | 240 // |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 // - AssertBoolean A | 370 // - AssertBoolean A |
365 // | 371 // |
366 // Assert that TOS is a boolean (A = 1) or that TOS is not null (A = 0). | 372 // Assert that TOS is a boolean (A = 1) or that TOS is not null (A = 0). |
367 // | 373 // |
368 // - CheckSmi rA | 374 // - CheckSmi rA |
369 // | 375 // |
370 // If FP[rA] is a Smi, then skip the next instruction. | 376 // If FP[rA] is a Smi, then skip the next instruction. |
371 // | 377 // |
372 // - CheckClassId rA, D | 378 // - CheckClassId rA, D |
373 // | 379 // |
374 // If the object at FP[rA]'s class id matches hthe class id in PP[D], then | 380 // If the object at FP[rA]'s class id matches the class id D, then skip the |
375 // skip the following instruction. | 381 // following instruction. |
| 382 // |
| 383 // - CheckDenseSwitch rA, D |
| 384 // |
| 385 // Skips the next 3 instructions if the object at FP[rA] is a valid class for |
| 386 // a dense switch with low cid encoded in the following Nop instruction, and |
| 387 // the cid mask encoded in the Nop instruction after that, or if D == 1 and |
| 388 // FP[rA] is a Smi. Skips 2 instructions otherwise. |
| 389 // |
| 390 // - CheckCids rA, rB, rC |
| 391 // |
| 392 // Skips rC + 1 instructions if the object at FP[rA] is a Smi and |
| 393 // rB == 1, or if FP[rA]'s cid is found in the array of cids encoded by the |
| 394 // following rC Nop instructions. Otherwise skips only rC instructions. |
376 // | 395 // |
377 // - CheckStack | 396 // - CheckStack |
378 // | 397 // |
379 // Compare SP against isolate stack limit and call StackOverflow handler if | 398 // Compare SP against isolate stack limit and call StackOverflow handler if |
380 // necessary. | 399 // necessary. |
381 // | 400 // |
382 // - DebugStep, DebugBreak A | 401 // - DebugStep, DebugBreak A |
383 // | 402 // |
384 // Debugger support. DebugBreak is bytecode that can be patched into the | 403 // Debugger support. DebugBreak is bytecode that can be patched into the |
385 // instruction stream to trigger in place breakpoint. | 404 // instruction stream to trigger in place breakpoint. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 // reg register (unsigned FP relative local) | 448 // reg register (unsigned FP relative local) |
430 // xeg x-register (signed FP relative local) | 449 // xeg x-register (signed FP relative local) |
431 // tgt jump target relative to the PC of the current instruction | 450 // tgt jump target relative to the PC of the current instruction |
432 // | 451 // |
433 // TODO(vegorov) jump targets should be encoded relative to PC of the next | 452 // TODO(vegorov) jump targets should be encoded relative to PC of the next |
434 // instruction because PC is incremeted immediately after fetch | 453 // instruction because PC is incremeted immediately after fetch |
435 // and before decoding. | 454 // and before decoding. |
436 // | 455 // |
437 #define BYTECODES_LIST(V) \ | 456 #define BYTECODES_LIST(V) \ |
438 V(Trap, 0, ___, ___, ___) \ | 457 V(Trap, 0, ___, ___, ___) \ |
439 V(Nop, 0, ___, ___, ___) \ | 458 V(Nop, D, lit, ___, ___) \ |
440 V(Compile, 0, ___, ___, ___) \ | 459 V(Compile, 0, ___, ___, ___) \ |
441 V(HotCheck, A_D, num, num, ___) \ | 460 V(HotCheck, A_D, num, num, ___) \ |
442 V(Intrinsic, A, num, ___, ___) \ | 461 V(Intrinsic, A, num, ___, ___) \ |
443 V(Drop1, 0, ___, ___, ___) \ | 462 V(Drop1, 0, ___, ___, ___) \ |
444 V(DropR, A, num, ___, ___) \ | 463 V(DropR, A, num, ___, ___) \ |
445 V(Drop, A, num, ___, ___) \ | 464 V(Drop, A, num, ___, ___) \ |
446 V(Jump, T, tgt, ___, ___) \ | 465 V(Jump, T, tgt, ___, ___) \ |
447 V(Return, A, reg, ___, ___) \ | 466 V(Return, A, reg, ___, ___) \ |
448 V(ReturnTOS, 0, ___, ___, ___) \ | 467 V(ReturnTOS, 0, ___, ___, ___) \ |
449 V(Move, A_X, reg, xeg, ___) \ | 468 V(Move, A_X, reg, xeg, ___) \ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 V(PushStatic, D, lit, ___, ___) \ | 507 V(PushStatic, D, lit, ___, ___) \ |
489 V(InitStaticTOS, 0, ___, ___, ___) \ | 508 V(InitStaticTOS, 0, ___, ___, ___) \ |
490 V(IfNeStrictTOS, 0, ___, ___, ___) \ | 509 V(IfNeStrictTOS, 0, ___, ___, ___) \ |
491 V(IfEqStrictTOS, 0, ___, ___, ___) \ | 510 V(IfEqStrictTOS, 0, ___, ___, ___) \ |
492 V(IfNeStrictNumTOS, 0, ___, ___, ___) \ | 511 V(IfNeStrictNumTOS, 0, ___, ___, ___) \ |
493 V(IfEqStrictNumTOS, 0, ___, ___, ___) \ | 512 V(IfEqStrictNumTOS, 0, ___, ___, ___) \ |
494 V(IfNeStrict, A_D, reg, reg, ___) \ | 513 V(IfNeStrict, A_D, reg, reg, ___) \ |
495 V(IfEqStrict, A_D, reg, reg, ___) \ | 514 V(IfEqStrict, A_D, reg, reg, ___) \ |
496 V(IfNeStrictNum, A_D, reg, reg, ___) \ | 515 V(IfNeStrictNum, A_D, reg, reg, ___) \ |
497 V(IfEqStrictNum, A_D, reg, reg, ___) \ | 516 V(IfEqStrictNum, A_D, reg, reg, ___) \ |
| 517 V(IfEqNull, A, reg, ___, ___) \ |
| 518 V(IfNeNull, A, reg, ___, ___) \ |
498 V(CreateArrayTOS, 0, ___, ___, ___) \ | 519 V(CreateArrayTOS, 0, ___, ___, ___) \ |
499 V(Allocate, D, lit, ___, ___) \ | 520 V(Allocate, D, lit, ___, ___) \ |
500 V(AllocateT, 0, ___, ___, ___) \ | 521 V(AllocateT, 0, ___, ___, ___) \ |
501 V(StoreIndexedTOS, 0, ___, ___, ___) \ | 522 V(StoreIndexedTOS, 0, ___, ___, ___) \ |
502 V(StoreIndexed, A_B_C, reg, reg, reg) \ | 523 V(StoreIndexed, A_B_C, reg, reg, reg) \ |
503 V(StoreField, A_B_C, reg, num, reg) \ | 524 V(StoreField, A_B_C, reg, num, reg) \ |
504 V(StoreFieldTOS, D, num, ___, ___) \ | 525 V(StoreFieldTOS, D, num, ___, ___) \ |
505 V(LoadField, A_B_C, reg, reg, num) \ | 526 V(LoadField, A_B_C, reg, reg, num) \ |
506 V(LoadFieldTOS, D, num, ___, ___) \ | 527 V(LoadFieldTOS, D, num, ___, ___) \ |
507 V(BooleanNegateTOS, 0, ___, ___, ___) \ | 528 V(BooleanNegateTOS, 0, ___, ___, ___) \ |
508 V(BooleanNegate, A_D, reg, reg, ___) \ | 529 V(BooleanNegate, A_D, reg, reg, ___) \ |
509 V(Throw, A, num, ___, ___) \ | 530 V(Throw, A, num, ___, ___) \ |
510 V(Entry, A_B_C, num, num, num) \ | 531 V(Entry, A_B_C, num, num, num) \ |
511 V(EntryOptional, A_B_C, num, num, num) \ | 532 V(EntryOptional, A_B_C, num, num, num) \ |
512 V(EntryOptimized, A_D, num, num, ___) \ | 533 V(EntryOptimized, A_D, num, num, ___) \ |
513 V(Frame, D, num, ___, ___) \ | 534 V(Frame, D, num, ___, ___) \ |
514 V(SetFrame, A, num, ___, num) \ | 535 V(SetFrame, A, num, ___, num) \ |
515 V(AllocateContext, D, num, ___, ___) \ | 536 V(AllocateContext, D, num, ___, ___) \ |
516 V(CloneContext, 0, ___, ___, ___) \ | 537 V(CloneContext, 0, ___, ___, ___) \ |
517 V(MoveSpecial, A_D, reg, num, ___) \ | 538 V(MoveSpecial, A_D, reg, num, ___) \ |
518 V(InstantiateType, D, lit, ___, ___) \ | 539 V(InstantiateType, D, lit, ___, ___) \ |
519 V(InstantiateTypeArgumentsTOS, A_D, num, lit, ___) \ | 540 V(InstantiateTypeArgumentsTOS, A_D, num, lit, ___) \ |
520 V(InstanceOf, A, num, ___, ___) \ | 541 V(InstanceOf, A, num, ___, ___) \ |
521 V(AssertAssignable, D, num, lit, ___) \ | 542 V(AssertAssignable, D, num, lit, ___) \ |
522 V(AssertBoolean, A, num, ___, ___) \ | 543 V(AssertBoolean, A, num, ___, ___) \ |
523 V(CheckSmi, A, reg, ___, ___) \ | 544 V(CheckSmi, A, reg, ___, ___) \ |
524 V(CheckClassId, A_D, reg, lit, ___) \ | 545 V(CheckClassId, A_D, reg, num, ___) \ |
| 546 V(CheckDenseSwitch, A_D, reg, num, ___) \ |
| 547 V(CheckCids, A_B_C, reg, num, ___) \ |
525 V(CheckStack, 0, ___, ___, ___) \ | 548 V(CheckStack, 0, ___, ___, ___) \ |
526 V(DebugStep, 0, ___, ___, ___) \ | 549 V(DebugStep, 0, ___, ___, ___) \ |
527 V(DebugBreak, A, num, ___, ___) \ | 550 V(DebugBreak, A, num, ___, ___) \ |
528 V(Deopt, A_D, num, num, ___) \ | 551 V(Deopt, A_D, num, num, ___) \ |
529 | 552 |
530 typedef uint32_t Instr; | 553 typedef uint32_t Instr; |
531 | 554 |
532 class Bytecode { | 555 class Bytecode { |
533 public: | 556 public: |
534 enum Opcode { | 557 enum Opcode { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 kNumberOfDummyFpuRegisters, | 660 kNumberOfDummyFpuRegisters, |
638 }; | 661 }; |
639 const FpuRegister FpuTMP = kFakeFpuRegister; | 662 const FpuRegister FpuTMP = kFakeFpuRegister; |
640 const intptr_t kNumberOfFpuRegisters = 1; | 663 const intptr_t kNumberOfFpuRegisters = 1; |
641 | 664 |
642 enum Condition { EQ, NE }; | 665 enum Condition { EQ, NE }; |
643 | 666 |
644 } // namespace dart | 667 } // namespace dart |
645 | 668 |
646 #endif // VM_CONSTANTS_DBC_H_ | 669 #endif // VM_CONSTANTS_DBC_H_ |
OLD | NEW |