File tree 4 files changed +116
-34
lines changed
4 files changed +116
-34
lines changed Original file line number Diff line number Diff line change @@ -106,15 +106,13 @@ export function FREE(ref: usize): void {
106
106
/** ArrayBuffer base class. */
107
107
export abstract class ArrayBufferBase {
108
108
get byteLength ( ) : i32 {
109
- var header = changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) ;
110
- return header . payloadSize ;
109
+ return changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) . payloadSize ;
111
110
}
112
111
}
113
112
114
113
/** String base class. */
115
114
export abstract class StringBase {
116
115
get length ( ) : i32 {
117
- var header = changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) ;
118
- return header . payloadSize >>> 1 ;
116
+ return changetype < HEADER > ( changetype < usize > ( this ) - HEADER_SIZE ) . payloadSize >> 1 ;
119
117
}
120
118
}
Original file line number Diff line number Diff line change 32
32
(global $std/runtime/ref3 (mut i32 ) (i32.const 0 ))
33
33
(global $std/runtime/ref4 (mut i32 ) (i32.const 0 ))
34
34
(global $std/runtime/header4 (mut i32 ) (i32.const 0 ))
35
+ (global $std/runtime/ref5 (mut i32 ) (i32.const 0 ))
35
36
(export " memory" (memory $0 ))
36
37
(export " table" (table $0 ))
37
38
(start $start )
2707
2708
else
2708
2709
i32.const 0
2709
2710
i32.const 56
2710
- i32.const 32
2711
+ i32.const 34
2711
2712
i32.const 2
2712
2713
call $~lib/env/abort
2713
2714
unreachable
2818
2819
if
2819
2820
i32.const 0
2820
2821
i32.const 56
2821
- i32.const 47
2822
+ i32.const 49
2822
2823
i32.const 0
2823
2824
call $~lib/env/abort
2824
2825
unreachable
2830
2831
if
2831
2832
i32.const 0
2832
2833
i32.const 56
2833
- i32.const 48
2834
+ i32.const 50
2834
2835
i32.const 0
2835
2836
call $~lib/env/abort
2836
2837
unreachable
2844
2845
if
2845
2846
i32.const 0
2846
2847
i32.const 56
2847
- i32.const 49
2848
+ i32.const 51
2848
2849
i32.const 0
2849
2850
call $~lib/env/abort
2850
2851
unreachable
2856
2857
if
2857
2858
i32.const 0
2858
2859
i32.const 56
2859
- i32.const 50
2860
+ i32.const 52
2860
2861
i32.const 0
2861
2862
call $~lib/env/abort
2862
2863
unreachable
2871
2872
if
2872
2873
i32.const 0
2873
2874
i32.const 56
2874
- i32.const 52
2875
+ i32.const 54
2875
2876
i32.const 0
2876
2877
call $~lib/env/abort
2877
2878
unreachable
2887
2888
if
2888
2889
i32.const 0
2889
2890
i32.const 56
2890
- i32.const 54
2891
+ i32.const 56
2891
2892
i32.const 0
2892
2893
call $~lib/env/abort
2893
2894
unreachable
2904
2905
if
2905
2906
i32.const 0
2906
2907
i32.const 56
2907
- i32.const 57
2908
+ i32.const 59
2908
2909
i32.const 0
2909
2910
call $~lib/env/abort
2910
2911
unreachable
2929
2930
if
2930
2931
i32.const 0
2931
2932
i32.const 56
2932
- i32.const 61
2933
+ i32.const 63
2933
2934
i32.const 0
2934
2935
call $~lib/env/abort
2935
2936
unreachable
2940
2941
if
2941
2942
i32.const 0
2942
2943
i32.const 56
2943
- i32.const 62
2944
+ i32.const 64
2944
2945
i32.const 0
2945
2946
call $~lib/env/abort
2946
2947
unreachable
2956
2957
if
2957
2958
i32.const 0
2958
2959
i32.const 56
2959
- i32.const 64
2960
+ i32.const 66
2960
2961
i32.const 0
2961
2962
call $~lib/env/abort
2962
2963
unreachable
2968
2969
if
2969
2970
i32.const 0
2970
2971
i32.const 56
2971
- i32.const 65
2972
+ i32.const 67
2973
+ i32.const 0
2974
+ call $~lib/env/abort
2975
+ unreachable
2976
+ end
2977
+ i32.const 10
2978
+ call $~lib/runtime/index/ALLOC
2979
+ global.set $std/runtime/ref5
2980
+ global.get $std/runtime/ref5
2981
+ i32.const 16
2982
+ i32.sub
2983
+ i32.load offset = 4
2984
+ i32.const 10
2985
+ i32.ne
2986
+ if
2987
+ i32.const 0
2988
+ i32.const 56
2989
+ i32.const 70
2990
+ i32.const 0
2991
+ call $~lib/env/abort
2992
+ unreachable
2993
+ end
2994
+ global.get $std/runtime/ref5
2995
+ i32.const 16
2996
+ i32.sub
2997
+ i32.load offset = 4
2998
+ i32.const 1
2999
+ i32.shr_u
3000
+ i32.const 5
3001
+ i32.ne
3002
+ if
3003
+ i32.const 0
3004
+ i32.const 56
3005
+ i32.const 71
2972
3006
i32.const 0
2973
3007
call $~lib/env/abort
2974
3008
unreachable
Original file line number Diff line number Diff line change @@ -16,7 +16,9 @@ import {
16
16
ALLOC ,
17
17
REALLOC ,
18
18
FREE ,
19
- REGISTER
19
+ REGISTER ,
20
+ ArrayBufferBase ,
21
+ StringBase
20
22
} from "runtime" ;
21
23
22
24
class A { }
@@ -63,3 +65,7 @@ assert(register_parentRef == ref3);
63
65
var header4 = changetype < HEADER > ( register_ref - HEADER_SIZE ) ;
64
66
assert ( header4 . classId == __rt_classid < A > ( ) ) ;
65
67
assert ( header4 . payloadSize == barrier1 ) ;
68
+
69
+ var ref5 = ALLOC ( 10 ) ;
70
+ assert ( changetype < ArrayBufferBase > ( ref5 ) . byteLength == 10 ) ;
71
+ assert ( changetype < StringBase > ( ref5 ) . length == 5 ) ;
Original file line number Diff line number Diff line change 48
48
(global $std/runtime/ref3 (mut i32 ) (i32.const 0 ))
49
49
(global $std/runtime/ref4 (mut i32 ) (i32.const 0 ))
50
50
(global $std/runtime/header4 (mut i32 ) (i32.const 0 ))
51
+ (global $std/runtime/ref5 (mut i32 ) (i32.const 0 ))
51
52
(global $~lib/memory/HEAP_BASE i32 (i32.const 208 ))
52
53
(export " memory" (memory $0 ))
53
54
(export " table" (table $0 ))
3398
3399
local.get $1
3399
3400
global.set $std/runtime/register_parentRef
3400
3401
)
3401
- (func $start:std/runtime (; 32 ;) (type $FUNCSIG$v )
3402
+ (func $~lib/runtime/index/ArrayBufferBase#get:byteLength (; 32 ;) (type $FUNCSIG$ii ) (param $0 i32 ) (result i32 )
3403
+ local.get $0
3404
+ i32.const 16
3405
+ i32.sub
3406
+ i32.load offset = 4
3407
+ )
3408
+ (func $~lib/runtime/index/StringBase#get:length (; 33 ;) (type $FUNCSIG$ii ) (param $0 i32 ) (result i32 )
3409
+ local.get $0
3410
+ i32.const 16
3411
+ i32.sub
3412
+ i32.load offset = 4
3413
+ i32.const 1
3414
+ i32.shr_u
3415
+ )
3416
+ (func $start:std/runtime (; 34 ;) (type $FUNCSIG$v )
3402
3417
(local $0 i32 )
3403
3418
(local $1 i32 )
3404
3419
call $start:~lib/allocator/tlsf
3409
3424
if
3410
3425
i32.const 0
3411
3426
i32.const 56
3412
- i32.const 24
3427
+ i32.const 26
3413
3428
i32.const 0
3414
3429
call $~lib/env/abort
3415
3430
unreachable
3422
3437
if
3423
3438
i32.const 0
3424
3439
i32.const 56
3425
- i32.const 30
3440
+ i32.const 32
3426
3441
i32.const 0
3427
3442
call $~lib/env/abort
3428
3443
unreachable
3443
3458
if
3444
3459
i32.const 0
3445
3460
i32.const 56
3446
- i32.const 32
3461
+ i32.const 34
3447
3462
i32.const 2
3448
3463
call $~lib/env/abort
3449
3464
unreachable
3546
3561
if
3547
3562
i32.const 0
3548
3563
i32.const 56
3549
- i32.const 47
3564
+ i32.const 49
3550
3565
i32.const 0
3551
3566
call $~lib/env/abort
3552
3567
unreachable
3559
3574
if
3560
3575
i32.const 0
3561
3576
i32.const 56
3562
- i32.const 48
3577
+ i32.const 50
3563
3578
i32.const 0
3564
3579
call $~lib/env/abort
3565
3580
unreachable
3573
3588
if
3574
3589
i32.const 0
3575
3590
i32.const 56
3576
- i32.const 49
3591
+ i32.const 51
3577
3592
i32.const 0
3578
3593
call $~lib/env/abort
3579
3594
unreachable
3586
3601
if
3587
3602
i32.const 0
3588
3603
i32.const 56
3589
- i32.const 50
3604
+ i32.const 52
3590
3605
i32.const 0
3591
3606
call $~lib/env/abort
3592
3607
unreachable
3602
3617
if
3603
3618
i32.const 0
3604
3619
i32.const 56
3605
- i32.const 52
3620
+ i32.const 54
3606
3621
i32.const 0
3607
3622
call $~lib/env/abort
3608
3623
unreachable
3619
3634
if
3620
3635
i32.const 0
3621
3636
i32.const 56
3622
- i32.const 54
3637
+ i32.const 56
3623
3638
i32.const 0
3624
3639
call $~lib/env/abort
3625
3640
unreachable
3636
3651
if
3637
3652
i32.const 0
3638
3653
i32.const 56
3639
- i32.const 57
3654
+ i32.const 59
3640
3655
i32.const 0
3641
3656
call $~lib/env/abort
3642
3657
unreachable
3664
3679
if
3665
3680
i32.const 0
3666
3681
i32.const 56
3667
- i32.const 61
3682
+ i32.const 63
3668
3683
i32.const 0
3669
3684
call $~lib/env/abort
3670
3685
unreachable
3676
3691
if
3677
3692
i32.const 0
3678
3693
i32.const 56
3679
- i32.const 62
3694
+ i32.const 64
3680
3695
i32.const 0
3681
3696
call $~lib/env/abort
3682
3697
unreachable
3693
3708
if
3694
3709
i32.const 0
3695
3710
i32.const 56
3696
- i32.const 64
3711
+ i32.const 66
3697
3712
i32.const 0
3698
3713
call $~lib/env/abort
3699
3714
unreachable
3706
3721
if
3707
3722
i32.const 0
3708
3723
i32.const 56
3709
- i32.const 65
3724
+ i32.const 67
3725
+ i32.const 0
3726
+ call $~lib/env/abort
3727
+ unreachable
3728
+ end
3729
+ i32.const 10
3730
+ call $~lib/runtime/index/ALLOC
3731
+ global.set $std/runtime/ref5
3732
+ global.get $std/runtime/ref5
3733
+ call $~lib/runtime/index/ArrayBufferBase#get:byteLength
3734
+ i32.const 10
3735
+ i32.eq
3736
+ i32.eqz
3737
+ if
3738
+ i32.const 0
3739
+ i32.const 56
3740
+ i32.const 70
3741
+ i32.const 0
3742
+ call $~lib/env/abort
3743
+ unreachable
3744
+ end
3745
+ global.get $std/runtime/ref5
3746
+ call $~lib/runtime/index/StringBase#get:length
3747
+ i32.const 5
3748
+ i32.eq
3749
+ i32.eqz
3750
+ if
3751
+ i32.const 0
3752
+ i32.const 56
3753
+ i32.const 71
3710
3754
i32.const 0
3711
3755
call $~lib/env/abort
3712
3756
unreachable
3713
3757
end
3714
3758
)
3715
- (func $start (; 33 ;) (type $FUNCSIG$v )
3759
+ (func $start (; 35 ;) (type $FUNCSIG$v )
3716
3760
call $start:std/runtime
3717
3761
)
3718
- (func $null (; 34 ;) (type $FUNCSIG$v )
3762
+ (func $null (; 36 ;) (type $FUNCSIG$v )
3719
3763
)
3720
3764
)
You can’t perform that action at this time.
0 commit comments