@@ -30,7 +30,7 @@ struct SystemJs {
30
30
export_values : Vec < Box < Expr > > ,
31
31
tla : bool ,
32
32
enter_async_fn : u32 ,
33
- enter_fn : u32 ,
33
+ is_global_this : bool ,
34
34
root_fn_decl_idents : Vec < Ident > ,
35
35
module_item_meta_list : Vec < ModuleItemMeta > ,
36
36
import_idents : Vec < Id > ,
@@ -48,9 +48,9 @@ pub fn system_js(unresolved_mark: Mark, config: Config) -> impl Fold {
48
48
export_map : Default :: default ( ) ,
49
49
export_names : vec ! [ ] ,
50
50
export_values : vec ! [ ] ,
51
+ is_global_this : true ,
51
52
tla : false ,
52
53
enter_async_fn : 0 ,
53
- enter_fn : 0 ,
54
54
root_fn_decl_idents : vec ! [ ] ,
55
55
module_item_meta_list : vec ! [ ] ,
56
56
import_idents : vec ! [ ] ,
@@ -69,14 +69,13 @@ pub fn system_js_with_resolver(
69
69
unresolved_mark,
70
70
resolver : Resolver :: Real { base, resolver } ,
71
71
config,
72
-
72
+ is_global_this : true ,
73
73
declare_var_idents : vec ! [ ] ,
74
74
export_map : Default :: default ( ) ,
75
75
export_names : vec ! [ ] ,
76
76
export_values : vec ! [ ] ,
77
77
tla : false ,
78
78
enter_async_fn : 0 ,
79
- enter_fn : 0 ,
80
79
root_fn_decl_idents : vec ! [ ] ,
81
80
module_item_meta_list : vec ! [ ] ,
82
81
import_idents : vec ! [ ] ,
@@ -94,6 +93,19 @@ struct ModuleItemMeta {
94
93
}
95
94
96
95
impl SystemJs {
96
+ fn fold_children_with_non_global_this < T > ( & mut self , n : T ) -> T
97
+ where
98
+ T : FoldWith < Self > ,
99
+ {
100
+ let is_global_this = self . is_global_this ;
101
+
102
+ self . is_global_this = false ;
103
+ let node = n. fold_children_with ( self ) ;
104
+ self . is_global_this = is_global_this;
105
+
106
+ node
107
+ }
108
+
97
109
fn export_call ( & self , name : JsWord , span : Span , expr : Expr ) -> CallExpr {
98
110
CallExpr {
99
111
span,
@@ -568,7 +580,7 @@ impl Fold for SystemJs {
568
580
Expr :: Await ( await_expr)
569
581
}
570
582
Expr :: This ( this_expr) => {
571
- if !self . config . allow_top_level_this && self . enter_fn == 0 {
583
+ if !self . config . allow_top_level_this && self . is_global_this {
572
584
return * undefined ( DUMMY_SP ) ;
573
585
}
574
586
Expr :: This ( this_expr)
@@ -582,15 +594,21 @@ impl Fold for SystemJs {
582
594
if is_async {
583
595
self . enter_async_fn += 1 ;
584
596
}
585
- self . enter_fn += 1 ;
586
597
let fold_fn_expr = fn_decl. fold_children_with ( self ) ;
587
598
if is_async {
588
599
self . enter_async_fn -= 1 ;
589
600
}
590
- self . enter_fn -= 1 ;
591
601
fold_fn_expr
592
602
}
593
603
604
+ fn fold_class_expr ( & mut self , n : ClassExpr ) -> ClassExpr {
605
+ self . fold_children_with_non_global_this ( n)
606
+ }
607
+
608
+ fn fold_function ( & mut self , n : Function ) -> Function {
609
+ self . fold_children_with_non_global_this ( n)
610
+ }
611
+
594
612
fn fold_prop ( & mut self , prop : Prop ) -> Prop {
595
613
match prop {
596
614
Prop :: Shorthand ( shorthand) => Prop :: KeyValue ( KeyValueProp {
1 commit comments
github-actions[bot] commentedon Jan 27, 2023
Benchmark
es/full/bugs-1
307310
ns/iter (± 7141
)306021
ns/iter (± 6471
)1.00
es/full/minify/libraries/antd
1775438096
ns/iter (± 29670486
)1849225829
ns/iter (± 70491537
)0.96
es/full/minify/libraries/d3
320412755
ns/iter (± 10008443
)337198501
ns/iter (± 13412572
)0.95
es/full/minify/libraries/echarts
1369806138
ns/iter (± 6708576
)1452618812
ns/iter (± 46850334
)0.94
es/full/minify/libraries/jquery
93944088
ns/iter (± 1502872
)97052380
ns/iter (± 1466854
)0.97
es/full/minify/libraries/lodash
110657938
ns/iter (± 699265
)109370594
ns/iter (± 1633612
)1.01
es/full/minify/libraries/moment
54126863
ns/iter (± 366070
)53486510
ns/iter (± 916938
)1.01
es/full/minify/libraries/react
19849433
ns/iter (± 181909
)19061869
ns/iter (± 353261
)1.04
es/full/minify/libraries/terser
270740946
ns/iter (± 1996805
)251325689
ns/iter (± 8683446
)1.08
es/full/minify/libraries/three
495582457
ns/iter (± 7166054
)476661812
ns/iter (± 44480660
)1.04
es/full/minify/libraries/typescript
3314590921
ns/iter (± 18576229
)3466435799
ns/iter (± 60573546
)0.96
es/full/minify/libraries/victory
772722472
ns/iter (± 14628241
)716266510
ns/iter (± 21482563
)1.08
es/full/minify/libraries/vue
141210759
ns/iter (± 1846699
)131899966
ns/iter (± 1626509
)1.07
es/full/codegen/es3
26032
ns/iter (± 259
)26334
ns/iter (± 105
)0.99
es/full/codegen/es5
26048
ns/iter (± 45
)26454
ns/iter (± 80
)0.98
es/full/codegen/es2015
26014
ns/iter (± 38
)26147
ns/iter (± 220
)0.99
es/full/codegen/es2016
26016
ns/iter (± 34
)26405
ns/iter (± 206
)0.99
es/full/codegen/es2017
26014
ns/iter (± 41
)26035
ns/iter (± 108
)1.00
es/full/codegen/es2018
26047
ns/iter (± 34
)26398
ns/iter (± 182
)0.99
es/full/codegen/es2019
26080
ns/iter (± 43
)26017
ns/iter (± 120
)1.00
es/full/codegen/es2020
26075
ns/iter (± 34
)26311
ns/iter (± 104
)0.99
es/full/all/es3
167153820
ns/iter (± 4353250
)172974880
ns/iter (± 2798010
)0.97
es/full/all/es5
159351259
ns/iter (± 2396729
)163842635
ns/iter (± 1710916
)0.97
es/full/all/es2015
122602625
ns/iter (± 486726
)124634039
ns/iter (± 1620973
)0.98
es/full/all/es2016
122464996
ns/iter (± 702741
)123777189
ns/iter (± 992729
)0.99
es/full/all/es2017
121048292
ns/iter (± 776505
)124033693
ns/iter (± 3357007
)0.98
es/full/all/es2018
118666999
ns/iter (± 793195
)121689486
ns/iter (± 1748684
)0.98
es/full/all/es2019
118190304
ns/iter (± 901041
)119729317
ns/iter (± 1901903
)0.99
es/full/all/es2020
113207174
ns/iter (± 816576
)121202477
ns/iter (± 5363739
)0.93
es/full/parser
536425
ns/iter (± 10541
)544370
ns/iter (± 10646
)0.99
es/full/base/fixer
21873
ns/iter (± 63
)21395
ns/iter (± 126
)1.02
es/full/base/resolver_and_hygiene
79624
ns/iter (± 89
)77786
ns/iter (± 724
)1.02
serialization of ast node
127
ns/iter (± 0
)124
ns/iter (± 1
)1.02
serialization of serde
129
ns/iter (± 0
)128
ns/iter (± 1
)1.01
css/minify/libraries/bootstrap
28391707
ns/iter (± 258127
)27584094
ns/iter (± 328503
)1.03
css/visitor/compare/clone
2050487
ns/iter (± 20495
)2060326
ns/iter (± 21524
)1.00
css/visitor/compare/visit_mut_span
2290409
ns/iter (± 11379
)2215699
ns/iter (± 9978
)1.03
css/visitor/compare/visit_mut_span_panic
2319043
ns/iter (± 11296
)2251875
ns/iter (± 49931
)1.03
css/visitor/compare/fold_span
3045012
ns/iter (± 15773
)3028661
ns/iter (± 41253
)1.01
css/visitor/compare/fold_span_panic
3201156
ns/iter (± 18560
)3119186
ns/iter (± 38935
)1.03
css/lexer/bootstrap_5_1_3
5203486
ns/iter (± 52950
)5135993
ns/iter (± 41761
)1.01
css/lexer/foundation_6_7_4
4383149
ns/iter (± 3723
)4273851
ns/iter (± 46494
)1.03
css/lexer/tailwind_3_1_1
830003
ns/iter (± 320
)822742
ns/iter (± 1443
)1.01
css/parser/bootstrap_5_1_3
21623208
ns/iter (± 108628
)21488830
ns/iter (± 333637
)1.01
css/parser/foundation_6_7_4
17305626
ns/iter (± 45495
)17267829
ns/iter (± 270285
)1.00
css/parser/tailwind_3_1_1
3304339
ns/iter (± 1648
)3293886
ns/iter (± 7879
)1.00
es/codegen/colors
326272
ns/iter (± 184450
)330138
ns/iter (± 186048
)0.99
es/codegen/large
1191343
ns/iter (± 613436
)1161136
ns/iter (± 609606
)1.03
es/codegen/with-parser/colors
48274
ns/iter (± 482
)47333
ns/iter (± 270
)1.02
es/codegen/with-parser/large
536740
ns/iter (± 2703
)527162
ns/iter (± 5749
)1.02
es/minify/libraries/antd
1528782713
ns/iter (± 17573217
)1618655186
ns/iter (± 22770803
)0.94
es/minify/libraries/d3
258468160
ns/iter (± 2091149
)268647556
ns/iter (± 7675990
)0.96
es/minify/libraries/echarts
1136247344
ns/iter (± 9660464
)1190640971
ns/iter (± 28188014
)0.95
es/minify/libraries/jquery
78929260
ns/iter (± 369614
)78016612
ns/iter (± 932142
)1.01
es/minify/libraries/lodash
96633165
ns/iter (± 745333
)97719292
ns/iter (± 2325303
)0.99
es/minify/libraries/moment
46254360
ns/iter (± 248783
)47097750
ns/iter (± 2095515
)0.98
es/minify/libraries/react
17135630
ns/iter (± 112663
)17116966
ns/iter (± 1196977
)1.00
es/minify/libraries/terser
219574791
ns/iter (± 4634906
)220766050
ns/iter (± 6114685
)0.99
es/minify/libraries/three
386403588
ns/iter (± 7492599
)352852135
ns/iter (± 6226934
)1.10
es/minify/libraries/typescript
2798016025
ns/iter (± 10001474
)2838129105
ns/iter (± 52454532
)0.99
es/minify/libraries/victory
612604411
ns/iter (± 13449516
)590879426
ns/iter (± 22578031
)1.04
es/minify/libraries/vue
117642481
ns/iter (± 775934
)117951167
ns/iter (± 2330396
)1.00
es/visitor/compare/clone
2378637
ns/iter (± 12781
)2419973
ns/iter (± 31576
)0.98
es/visitor/compare/visit_mut_span
2761926
ns/iter (± 11808
)2760919
ns/iter (± 28143
)1.00
es/visitor/compare/visit_mut_span_panic
2832950
ns/iter (± 17658
)2791016
ns/iter (± 99600
)1.02
es/visitor/compare/fold_span
3934690
ns/iter (± 22973
)3929498
ns/iter (± 22062
)1.00
es/visitor/compare/fold_span_panic
4103723
ns/iter (± 14463
)4079292
ns/iter (± 30041
)1.01
es/lexer/colors
17372
ns/iter (± 19
)16905
ns/iter (± 157
)1.03
es/lexer/angular
8256757
ns/iter (± 2508
)8196139
ns/iter (± 96814
)1.01
es/lexer/backbone
1083476
ns/iter (± 499
)1082479
ns/iter (± 18817
)1.00
es/lexer/jquery
5975665
ns/iter (± 3841
)5846307
ns/iter (± 58677
)1.02
es/lexer/jquery mobile
9219562
ns/iter (± 5207
)8954131
ns/iter (± 31972
)1.03
es/lexer/mootools
4692146
ns/iter (± 4637
)4588317
ns/iter (± 30145
)1.02
es/lexer/underscore
901643
ns/iter (± 819
)874147
ns/iter (± 9595
)1.03
es/lexer/three
28132666
ns/iter (± 29613
)27101557
ns/iter (± 391743
)1.04
es/lexer/yui
5059350
ns/iter (± 9757
)4892215
ns/iter (± 49730
)1.03
es/parser/colors
31299
ns/iter (± 246
)29708
ns/iter (± 209
)1.05
es/parser/angular
16452273
ns/iter (± 152489
)15250964
ns/iter (± 235707
)1.08
es/parser/backbone
2335583
ns/iter (± 11803
)2252404
ns/iter (± 21711
)1.04
es/parser/jquery
12685899
ns/iter (± 70875
)12396591
ns/iter (± 233226
)1.02
es/parser/jquery mobile
20133766
ns/iter (± 172748
)19493827
ns/iter (± 623642
)1.03
es/parser/mootools
9634366
ns/iter (± 70250
)9473490
ns/iter (± 46803
)1.02
es/parser/underscore
1978292
ns/iter (± 11868
)1937625
ns/iter (± 14927
)1.02
es/parser/three
58940694
ns/iter (± 625558
)57948478
ns/iter (± 1377786
)1.02
es/parser/yui
9722571
ns/iter (± 80942
)9371170
ns/iter (± 144149
)1.04
es/preset-env/usage/builtin_type
138150
ns/iter (± 30603
)139871
ns/iter (± 31649
)0.99
es/preset-env/usage/property
21020
ns/iter (± 77
)21020
ns/iter (± 166
)1
es/resolver/typescript
118717393
ns/iter (± 1747991
)122707721
ns/iter (± 3623902
)0.97
es/fixer/typescript
96633750
ns/iter (± 1546640
)97909800
ns/iter (± 1991726
)0.99
es/hygiene/typescript
199095890
ns/iter (± 1498220
)220695542
ns/iter (± 8780147
)0.90
es/resolver_with_hygiene/typescript
338599478
ns/iter (± 4592477
)385468101
ns/iter (± 5794358
)0.88
es/visitor/base-perf/module_clone
75461
ns/iter (± 1429
)76001
ns/iter (± 1500
)0.99
es/visitor/base-perf/fold_empty
84775
ns/iter (± 1472
)85907
ns/iter (± 1986
)0.99
es/visitor/base-perf/fold_noop_impl_all
85499
ns/iter (± 1219
)85790
ns/iter (± 1194
)1.00
es/visitor/base-perf/fold_noop_impl_vec
85778
ns/iter (± 979
)85770
ns/iter (± 2288
)1.00
es/visitor/base-perf/boxing_boxed_clone
59
ns/iter (± 0
)55
ns/iter (± 0
)1.07
es/visitor/base-perf/boxing_unboxed_clone
59
ns/iter (± 0
)59
ns/iter (± 0
)1
es/visitor/base-perf/boxing_boxed
105
ns/iter (± 0
)103
ns/iter (± 0
)1.02
es/visitor/base-perf/boxing_unboxed
103
ns/iter (± 0
)101
ns/iter (± 1
)1.02
es/visitor/base-perf/visit_contains_this
3442
ns/iter (± 35
)3421
ns/iter (± 75
)1.01
es/base/parallel/resolver/typescript
5760295923
ns/iter (± 532047171
)5581251540
ns/iter (± 511003143
)1.03
es/base/parallel/hygiene/typescript
2389699161
ns/iter (± 21274405
)2787109578
ns/iter (± 49152496
)0.86
misc/visitors/time-complexity/time 5
93
ns/iter (± 0
)93
ns/iter (± 0
)1
misc/visitors/time-complexity/time 10
311
ns/iter (± 4
)298
ns/iter (± 0
)1.04
misc/visitors/time-complexity/time 15
648
ns/iter (± 0
)624
ns/iter (± 10
)1.04
misc/visitors/time-complexity/time 20
1208
ns/iter (± 0
)1142
ns/iter (± 0
)1.06
misc/visitors/time-complexity/time 40
6193
ns/iter (± 1
)6083
ns/iter (± 17
)1.02
misc/visitors/time-complexity/time 60
15575
ns/iter (± 5
)15346
ns/iter (± 13
)1.01
es/full-target/es2016
187828
ns/iter (± 487
)187117
ns/iter (± 480
)1.00
es/full-target/es2017
182819
ns/iter (± 465
)182327
ns/iter (± 320
)1.00
es/full-target/es2018
171908
ns/iter (± 599
)171534
ns/iter (± 461
)1.00
es2020_nullish_coalescing
66793
ns/iter (± 159
)66666
ns/iter (± 161
)1.00
es2020_optional_chaining
95622
ns/iter (± 308
)95265
ns/iter (± 238
)1.00
es2022_class_properties
93769
ns/iter (± 192
)93481
ns/iter (± 442
)1.00
es2018_object_rest_spread
71335
ns/iter (± 138
)71185
ns/iter (± 138
)1.00
es2019_optional_catch_binding
61295
ns/iter (± 82
)60884
ns/iter (± 61
)1.01
es2017_async_to_generator
61820
ns/iter (± 110
)61701
ns/iter (± 54
)1.00
es2016_exponentiation
64969
ns/iter (± 135
)64750
ns/iter (± 103
)1.00
es2015_arrow
70158
ns/iter (± 154
)69807
ns/iter (± 201
)1.01
es2015_block_scoped_fn
66004
ns/iter (± 109
)66549
ns/iter (± 171
)0.99
es2015_block_scoping
157273
ns/iter (± 9068
)139649
ns/iter (± 6214
)1.13
es2015_classes
117243
ns/iter (± 488
)117063
ns/iter (± 653
)1.00
es2015_computed_props
61086
ns/iter (± 92
)61269
ns/iter (± 86
)1.00
es2015_destructuring
115779
ns/iter (± 191
)117521
ns/iter (± 348
)0.99
es2015_duplicate_keys
63788
ns/iter (± 109
)63937
ns/iter (± 73
)1.00
es2015_parameters
79511
ns/iter (± 274
)79477
ns/iter (± 164
)1.00
es2015_fn_name
66822
ns/iter (± 503
)67349
ns/iter (± 645
)0.99
es2015_for_of
64670
ns/iter (± 136
)63863
ns/iter (± 76
)1.01
es2015_instanceof
63141
ns/iter (± 202
)63292
ns/iter (± 102
)1.00
es2015_shorthand_property
61155
ns/iter (± 127
)61000
ns/iter (± 82
)1.00
es2015_spread
61034
ns/iter (± 77
)60853
ns/iter (± 125
)1.00
es2015_sticky_regex
62186
ns/iter (± 79
)62371
ns/iter (± 177
)1.00
es2015_typeof_symbol
62280
ns/iter (± 188
)62262
ns/iter (± 72
)1.00
es/transform/baseline/base
51780
ns/iter (± 265
)51626
ns/iter (± 97
)1.00
es/transform/baseline/common_reserved_word
62733
ns/iter (± 145
)62618
ns/iter (± 75
)1.00
es/transform/baseline/common_typescript
142972
ns/iter (± 905
)145633
ns/iter (± 6620
)0.98
es/target/es3
169385
ns/iter (± 1303
)169092
ns/iter (± 229
)1.00
es/target/es2015
600574
ns/iter (± 793
)631753
ns/iter (± 1316
)0.95
es/target/es2016
63765
ns/iter (± 81
)64909
ns/iter (± 110
)0.98
es/target/es2017
60584
ns/iter (± 80
)61940
ns/iter (± 67
)0.98
es/target/es2018
79766
ns/iter (± 79
)81154
ns/iter (± 145
)0.98
es/target/es2020
128938
ns/iter (± 144
)132389
ns/iter (± 267
)0.97
babelify-only
671140
ns/iter (± 1582
)677272
ns/iter (± 7097
)0.99
parse_and_babelify_angular
48048052
ns/iter (± 1494730
)47363656
ns/iter (± 1796621
)1.01
parse_and_babelify_backbone
5703378
ns/iter (± 68751
)5734432
ns/iter (± 211048
)0.99
parse_and_babelify_jquery
33719882
ns/iter (± 330880
)36212475
ns/iter (± 1407531
)0.93
parse_and_babelify_jquery_mobile
57685855
ns/iter (± 755620
)62126619
ns/iter (± 1250727
)0.93
parse_and_babelify_mootools
34969493
ns/iter (± 445430
)38145024
ns/iter (± 1113431
)0.92
parse_and_babelify_underscore
4432410
ns/iter (± 20873
)4443362
ns/iter (± 134924
)1.00
parse_and_babelify_yui
34802239
ns/iter (± 637378
)37520066
ns/iter (± 1492798
)0.93
html/minify/document/css_spec
45013382
ns/iter (± 797181
)43165158
ns/iter (± 503425
)1.04
html/minify/document/github
18214368
ns/iter (± 86758
)17702259
ns/iter (± 156357
)1.03
html/minify/document/stackoverflow
16573824
ns/iter (± 64967
)15755745
ns/iter (± 115935
)1.05
html/minify/document_fragment/css_spec
41051626
ns/iter (± 287768
)41897196
ns/iter (± 681163
)0.98
html/minify/document_fragment/github
16883401
ns/iter (± 28941
)17093045
ns/iter (± 131613
)0.99
html/minify/document_fragment/stackoverflow
15397700
ns/iter (± 44024
)15572767
ns/iter (± 147606
)0.99
html/document/visitor/compare/clone
341703
ns/iter (± 1863
)349836
ns/iter (± 3636
)0.98
html/document/visitor/compare/visit_mut_span
375336
ns/iter (± 2147
)371909
ns/iter (± 4268
)1.01
html/document/visitor/compare/visit_mut_span_panic
378883
ns/iter (± 1096
)383950
ns/iter (± 2170
)0.99
html/document/visitor/compare/fold_span
406583
ns/iter (± 2328
)403998
ns/iter (± 1764
)1.01
html/document/visitor/compare/fold_span_panic
462469
ns/iter (± 2299
)461727
ns/iter (± 1929
)1.00
html/document_fragment/visitor/compare/clone
341249
ns/iter (± 1532
)338761
ns/iter (± 1916
)1.01
html/document_fragment/visitor/compare/visit_mut_span
368585
ns/iter (± 2699
)370782
ns/iter (± 2348
)0.99
html/document_fragment/visitor/compare/visit_mut_span_panic
373619
ns/iter (± 2279
)377251
ns/iter (± 1990
)0.99
html/document_fragment/visitor/compare/fold_span
405879
ns/iter (± 2517
)410785
ns/iter (± 2401
)0.99
html/document_fragment/visitor/compare/fold_span_panic
459831
ns/iter (± 1890
)460067
ns/iter (± 2365
)1.00
html/lexer/css_2021_spec
15655265
ns/iter (± 140011
)15552749
ns/iter (± 8685
)1.01
html/lexer/github_com_17_05_2022
6063251
ns/iter (± 3763
)6049547
ns/iter (± 1318
)1.00
html/lexer/stackoverflow_com_17_05_2022
5685322
ns/iter (± 3243
)5657741
ns/iter (± 3689
)1.00
html/parser/parser_document/css_2021_spec
25737322
ns/iter (± 162170
)26198550
ns/iter (± 237977
)0.98
html/parser/parser_document/github_com_17_05_2022
8766869
ns/iter (± 9113
)8778489
ns/iter (± 64617
)1.00
html/parser/parser_document/stackoverflow_com_17_05_2022
7713336
ns/iter (± 4019
)7696762
ns/iter (± 5949
)1.00
html/parser/parser_document_fragment/css_2021_spec
26056013
ns/iter (± 121316
)26176487
ns/iter (± 236878
)1.00
html/parser/parser_document_fragment/github_com_17_05_2022
8798545
ns/iter (± 14459
)8748294
ns/iter (± 8560
)1.01
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022
7722655
ns/iter (± 6412
)7714356
ns/iter (± 12157
)1.00
This comment was automatically generated by workflow using github-action-benchmark.