()
| 39 | } |
| 40 | |
| 41 | function cover_codegen_paths() { |
| 42 | var x = 1; |
| 43 | |
| 44 | // This test depends on the fixed order of register allocation. We try to |
| 45 | // get values in specific registers (ia32, x64): |
| 46 | var a; // Register eax, rax. |
| 47 | var b; // Register ebx, rbx. |
| 48 | var c; // Register ecx, rcx. |
| 49 | var d; // Register edx, rdx. |
| 50 | var di; // Register edi, rdi. |
| 51 | |
| 52 | while (x == 1) { |
| 53 | // The call will spill registers and leave x in {eax,rax}. |
| 54 | x = identity(1); |
| 55 | // The add will spill x and reuse {eax,rax} for the result. |
| 56 | a = x + 1; |
| 57 | // A fresh register {ebx,rbx} will be allocated for x, then reused for |
| 58 | // the result. |
| 59 | b = x + 1; |
| 60 | // Et cetera. |
| 61 | c = x + 1; |
| 62 | d = x + 1; |
| 63 | di = x + 1; |
| 64 | // Locals are in the corresponding registers here. |
| 65 | assertEquals(8, c << a); |
| 66 | |
| 67 | x = identity(1); |
| 68 | a = x + 1; |
| 69 | b = x + 1; |
| 70 | c = x + 1; |
| 71 | d = x + 1; |
| 72 | di = x + 1; |
| 73 | assertEquals(8, a << c); |
| 74 | |
| 75 | x = identity(1); |
| 76 | a = x + 1; |
| 77 | b = x + 1; |
| 78 | c = x + 1; |
| 79 | d = x + 1; |
| 80 | di = x + 1; |
| 81 | c = 0; // Free register ecx. |
| 82 | assertEquals(8, a << d); |
| 83 | |
| 84 | x = identity(1); |
| 85 | a = x + 1; |
| 86 | b = x + 1; |
| 87 | c = x + 1; |
| 88 | d = x + 1; |
| 89 | di = x + 1; |
| 90 | b = 0; // Free register ebx. |
| 91 | assertEquals(8, a << d); |
| 92 | |
| 93 | // Test the non-commutative subtraction operation with a smi on the |
| 94 | // left, all available registers on the right, and a non-smi result. |
| 95 | x = identity(-1073741824); // Least (31-bit) smi. |
| 96 | a = x + 1; // Still a smi, the greatest smi negated. |
| 97 | b = x + 1; |
| 98 | c = x + 1; |
no test coverage detected