Commit b1cb079
committed
Class members which capture super via dot (super.constructor) end up getting the wrong value
We were using the wrong bytecode register when emitting LdHomeObjProto in the case of a lambda capturing super via a dot reference. Consider this Javascript:
```javascript
class A { }
class B extends A {
foo() {
const _s = () => super.constructor;
console.log(_s().name);
}
}
```
The member function foo correctly stashes this and super but the lambda needs to load them from the environment and it was loading them into the same register. Here's the incorrect bytecode:
```
Function _s ( (#1.5), #6) (In0) (size: 8 [8])
5 locals (2 temps from R3), 1 inline cache
Constant Table:
======== =====
R1 LdRoot
Line 13: super.constructor
Col 26: ^
0000 ProfiledLdEnvSlot R3 = [1][2] <0>
0006 ProfiledLdEnvSlot R3 = [1][3] <1>
000c LdHomeObjProto R4 R3
0011 ProfiledLdSuperFld R0 = R4(this=R3). #0 <0>
0019 Br x:001e ( 2)
001c LdUndef R0
```
With the fix in this PR, here's the bytecode we get for _s:
```
Function _s ( (#1.5), #6) (In0) (size: 8 [8])
6 locals (3 temps from R3), 1 inline cache
Constant Table:
======== =====
R1 LdRoot
Line 56: super.constructor
Col 26: ^
0000 ProfiledLdEnvSlot R3 = [1][2] <0>
0006 ProfiledLdEnvSlot R4 = [1][3] <1>
000c LdHomeObjProto R5 R3
0011 ProfiledLdSuperFld R0 = R5(this=R4). #0 <0>
0019 Br x:001e ( 2)
001c LdUndef R0
```1 parent 9c289b8 commit b1cb079
File tree
3 files changed
+105
-24
lines changed- lib/Runtime/ByteCode
- test/es6
3 files changed
+105
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10833 | 10833 | | |
10834 | 10834 | | |
10835 | 10835 | | |
10836 | | - | |
10837 | | - | |
10838 | | - | |
10839 | 10836 | | |
10840 | 10837 | | |
10841 | 10838 | | |
10842 | 10839 | | |
| 10840 | + | |
| 10841 | + | |
| 10842 | + | |
| 10843 | + | |
| 10844 | + | |
| 10845 | + | |
| 10846 | + | |
| 10847 | + | |
| 10848 | + | |
| 10849 | + | |
| 10850 | + | |
| 10851 | + | |
10843 | 10852 | | |
10844 | 10853 | | |
10845 | | - | |
10846 | 10854 | | |
10847 | 10855 | | |
10848 | 10856 | | |
10849 | 10857 | | |
10850 | | - | |
10851 | | - | |
10852 | | - | |
10853 | | - | |
10854 | | - | |
10855 | | - | |
10856 | | - | |
10857 | 10858 | | |
10858 | 10859 | | |
| 10860 | + | |
| 10861 | + | |
| 10862 | + | |
| 10863 | + | |
10859 | 10864 | | |
10860 | 10865 | | |
10861 | | - | |
10862 | | - | |
10863 | | - | |
10864 | | - | |
10865 | | - | |
10866 | | - | |
10867 | | - | |
10868 | | - | |
10869 | | - | |
10870 | | - | |
10871 | | - | |
10872 | | - | |
10873 | | - | |
| 10866 | + | |
10874 | 10867 | | |
10875 | 10868 | | |
10876 | 10869 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1505 | 1505 | | |
1506 | 1506 | | |
1507 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1508 | 1514 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments