Skip to content

Commit 4e278be

Browse files
authoredMay 5, 2023
build(cargo): Update wasmer to v3.3 (#7352)
1 parent e9f3371 commit 4e278be

File tree

6 files changed

+49
-67
lines changed

6 files changed

+49
-67
lines changed
 

‎Cargo.lock

+30-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎crates/swc_common/src/plugin/metadata.rs

-22
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ impl From<u32> for TransformPluginMetadataContextKind {
2626
}
2727
}
2828

29-
/*
30-
impl TransformPluginMetadataContextKind {
31-
pub fn from(key: u32) -> TransformPluginMetadataContextKind {
32-
match key {
33-
1 => TransformPluginMetadataContextKind::Filename,
34-
2 => TransformPluginMetadataContextKind::Env,
35-
3 => TransformPluginMetadataContextKind::Cwd,
36-
_ => panic!("Invalid TransformPluginMetadataContextKind key"),
37-
}
38-
}
39-
}
40-
41-
impl Into<u32> for TransformPluginMetadataContextKind {
42-
fn into(self) -> u32 {
43-
match self {
44-
TransformPluginMetadataContextKind::Filename => 1,
45-
TransformPluginMetadataContextKind::Env => 2,
46-
TransformPluginMetadataContextKind::Cwd => 3,
47-
}
48-
}
49-
}*/
50-
5129
/// Host side metadata context plugin may need to access.
5230
/// This is a global context - any plugin in single transform will have same
5331
/// values.

‎crates/swc_plugin_proxy/src/metadata/transform_plugin_metadata.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ use crate::memory_interop::read_returned_result_from_host;
99
#[cfg_attr(not(target_arch = "wasm32"), allow(unused))]
1010
use crate::{PluginCommentsProxy, PluginSourceMapProxy};
1111

12-
//#[cfg_attr(not(target_arch = "wasm32"), allow(unused))]
13-
//use crate::memory_interop::read_returned_result_from_host;
14-
1512
/// An arbitary metadata for given Program to run transform in plugin.
1613
/// These are not directly attached to Program's AST structures
1714
/// but required for certain transforms.
@@ -33,7 +30,7 @@ pub struct TransformPluginProgramMetadata {
3330
extern "C" {
3431
fn __copy_context_key_to_host_env(bytes_ptr: u32, bytes_ptr_len: u32);
3532
fn __get_transform_plugin_config(allocated_ret_ptr: u32) -> u32;
36-
fn __get_transform_context(key: u32, allocated_ret_ptr: u32) -> u32;
33+
fn __get_transform_context(key: u32, allocated_ret_ptr: u32) -> i32;
3734
fn __get_experimental_transform_context(allocated_ret_ptr: u32) -> u32;
3835
fn __get_raw_experiemtal_transform_context(allocated_ret_ptr: u32) -> u32;
3936
}
@@ -61,7 +58,7 @@ impl TransformPluginProgramMetadata {
6158
) -> Option<String> {
6259
#[cfg(target_arch = "wasm32")]
6360
return read_returned_result_from_host(|serialized_ptr| unsafe {
64-
__get_transform_context(*key as u32, serialized_ptr)
61+
__get_transform_context(*key as u32, serialized_ptr) as u32
6562
});
6663

6764
#[cfg(not(target_arch = "wasm32"))]

‎crates/swc_plugin_runner/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ parking_lot = "0.12.0"
5555
serde = { version = "1.0.126", features = ["derive"] }
5656
serde_json = "1.0.64"
5757
tracing = "0.1.32"
58-
wasmer = { version = "3.2.0", default-features = false }
59-
wasmer-wasix = { version = "0.3.0", default-features = false }
58+
wasmer = { version = "3.3.0", default-features = false }
59+
wasmer-wasix = { version = "0.4.0", default-features = false }
6060

6161
swc_common = { version = "0.31.5", path = "../swc_common", features = [
6262
"concurrent",
@@ -66,8 +66,8 @@ swc_ecma_ast = { version = "0.103.5", path = "../swc_ecma_ast", optional = true
6666
swc_plugin_proxy = { version = "0.32.5", path = "../swc_plugin_proxy" }
6767

6868
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
69-
wasmer-cache = { version = "3.2.0", optional = true }
70-
wasmer-compiler-cranelift = { version = "3.2.0", default-features = false }
69+
wasmer-cache = { version = "3.3.0", optional = true }
70+
wasmer-compiler-cranelift = { version = "3.3.0", default-features = false }
7171

7272
[dev-dependencies]
7373
criterion = "0.3"

‎crates/swc_plugin_runner/src/imported_fn/metadata_context.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,17 @@ pub fn get_transform_context(
114114
.metadata_context
115115
.get(&TransformPluginMetadataContextKind::from(key));
116116

117-
if let Some(value) = value {
118-
let serialized =
119-
PluginSerializedBytes::try_serialize(&value).expect("Should be serializable");
117+
let serialized = PluginSerializedBytes::try_serialize(&value).expect("Should be serializable");
120118

121-
allocate_return_values_into_guest(
122-
memory,
123-
&mut env.as_store_mut(),
124-
alloc_guest_memory,
125-
allocated_ret_ptr,
126-
&serialized,
127-
);
119+
allocate_return_values_into_guest(
120+
memory,
121+
&mut env.as_store_mut(),
122+
alloc_guest_memory,
123+
allocated_ret_ptr,
124+
&serialized,
125+
);
128126

129-
return 1;
130-
}
131-
0
127+
return 1;
132128
}
133129

134130
#[tracing::instrument(level = "info", skip_all)]

‎crates/swc_plugin_runner/tests/fixture/swc_internal_plugin/src/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ pub fn process(program: Program, metadata: TransformPluginProgramMetadata) -> Pr
7070
name = Ident::new("ref".into(), DUMMY_SP)
7171
);
7272

73+
let filename = metadata
74+
.get_context(&TransformPluginMetadataContextKind::Filename)
75+
.expect("Filename should exists");
76+
7377
let env = metadata
7478
.get_context(&TransformPluginMetadataContextKind::Env)
7579
.expect("Metadata should exists");

1 commit comments

Comments
 (1)

github-actions[bot] commented on May 5, 2023

@github-actions[bot]

Benchmark

Benchmark suite Current: 4e278be Previous: e0de83e Ratio
es/full/bugs-1 295686 ns/iter (± 15081) 249405 ns/iter (± 1761) 1.19
es/full/minify/libraries/antd 1664963713 ns/iter (± 23423849) 1204267059 ns/iter (± 10102667) 1.38
es/full/minify/libraries/d3 307607216 ns/iter (± 8643244) 233453237 ns/iter (± 2382064) 1.32
es/full/minify/libraries/echarts 1248293151 ns/iter (± 23384943) 948653790 ns/iter (± 7173981) 1.32
es/full/minify/libraries/jquery 91196760 ns/iter (± 928158) 75976710 ns/iter (± 386019) 1.20
es/full/minify/libraries/lodash 106703434 ns/iter (± 1431880) 85555958 ns/iter (± 184434) 1.25
es/full/minify/libraries/moment 52390398 ns/iter (± 503417) 45663980 ns/iter (± 559650) 1.15
es/full/minify/libraries/react 19122135 ns/iter (± 133343) 16242408 ns/iter (± 243261) 1.18
es/full/minify/libraries/terser 250577477 ns/iter (± 4174203) 197466562 ns/iter (± 3443154) 1.27
es/full/minify/libraries/three 447055544 ns/iter (± 6526520) 335557911 ns/iter (± 2755784) 1.33
es/full/minify/libraries/typescript 3103291449 ns/iter (± 18558854) 2438847280 ns/iter (± 42745081) 1.27
es/full/minify/libraries/victory 693657753 ns/iter (± 14980483) 519076330 ns/iter (± 11568076) 1.34
es/full/minify/libraries/vue 130879387 ns/iter (± 959617) 107486099 ns/iter (± 795596) 1.22
es/full/codegen/es3 28838 ns/iter (± 51) 26038 ns/iter (± 665) 1.11
es/full/codegen/es5 28923 ns/iter (± 49) 26014 ns/iter (± 59) 1.11
es/full/codegen/es2015 28884 ns/iter (± 36) 25994 ns/iter (± 144) 1.11
es/full/codegen/es2016 28857 ns/iter (± 56) 25959 ns/iter (± 98) 1.11
es/full/codegen/es2017 28873 ns/iter (± 47) 25977 ns/iter (± 91) 1.11
es/full/codegen/es2018 28867 ns/iter (± 47) 26131 ns/iter (± 120) 1.10
es/full/codegen/es2019 28850 ns/iter (± 32) 26036 ns/iter (± 104) 1.11
es/full/codegen/es2020 28849 ns/iter (± 68) 25898 ns/iter (± 68) 1.11
es/full/all/es3 180053725 ns/iter (± 2393067) 160662264 ns/iter (± 1105692) 1.12
es/full/all/es5 173474601 ns/iter (± 2656956) 149946458 ns/iter (± 1018955) 1.16
es/full/all/es2015 132324760 ns/iter (± 1748979) 110520734 ns/iter (± 714962) 1.20
es/full/all/es2016 132328269 ns/iter (± 2548545) 112433763 ns/iter (± 946581) 1.18
es/full/all/es2017 128449874 ns/iter (± 1398887) 109506342 ns/iter (± 597968) 1.17
es/full/all/es2018 124305061 ns/iter (± 1725247) 107835584 ns/iter (± 662594) 1.15
es/full/all/es2019 123964352 ns/iter (± 1678110) 107454017 ns/iter (± 1063552) 1.15
es/full/all/es2020 116820657 ns/iter (± 518103) 103371072 ns/iter (± 1069150) 1.13
es/full/parser 516321 ns/iter (± 6828) 458801 ns/iter (± 4606) 1.13
es/full/base/fixer 23744 ns/iter (± 29) 17522 ns/iter (± 48) 1.36
es/full/base/resolver_and_hygiene 85755 ns/iter (± 473) 78708 ns/iter (± 170) 1.09
serialization of serde 121 ns/iter (± 0) 112 ns/iter (± 0) 1.08
css/minify/libraries/bootstrap 27519707 ns/iter (± 111765) 23532214 ns/iter (± 27165) 1.17
css/visitor/compare/clone 2068061 ns/iter (± 21616) 1665245 ns/iter (± 2687) 1.24
css/visitor/compare/visit_mut_span 2289272 ns/iter (± 101711) 1803760 ns/iter (± 3965) 1.27
css/visitor/compare/visit_mut_span_panic 2345599 ns/iter (± 4644) 1883320 ns/iter (± 3946) 1.25
css/visitor/compare/fold_span 3050974 ns/iter (± 10517) 2580626 ns/iter (± 17079) 1.18
css/visitor/compare/fold_span_panic 3208954 ns/iter (± 9153) 2778717 ns/iter (± 9559) 1.15
css/lexer/bootstrap_5_1_3 5187688 ns/iter (± 12951) 4536240 ns/iter (± 8129) 1.14
css/lexer/foundation_6_7_4 4355381 ns/iter (± 9381) 3826916 ns/iter (± 7159) 1.14
css/lexer/tailwind_3_1_1 828222 ns/iter (± 711) 728336 ns/iter (± 915) 1.14
css/parser/bootstrap_5_1_3 21273308 ns/iter (± 495946) 18127067 ns/iter (± 480967) 1.17
css/parser/foundation_6_7_4 16827563 ns/iter (± 75136) 14496827 ns/iter (± 22607) 1.16
css/parser/tailwind_3_1_1 3241279 ns/iter (± 8002) 2797123 ns/iter (± 3096) 1.16
es/codegen/colors 327880 ns/iter (± 186266) 328768 ns/iter (± 186837) 1.00
es/codegen/large 1246832 ns/iter (± 652812) 1229137 ns/iter (± 659466) 1.01
es/codegen/with-parser/colors 48408 ns/iter (± 362) 41462 ns/iter (± 438) 1.17
es/codegen/with-parser/large 514384 ns/iter (± 1081) 467237 ns/iter (± 829) 1.10
es/minify/libraries/antd 1463096990 ns/iter (± 24403339) 1045643161 ns/iter (± 14417283) 1.40
es/minify/libraries/d3 262616887 ns/iter (± 3666250) 205999071 ns/iter (± 2798867) 1.27
es/minify/libraries/echarts 1081740357 ns/iter (± 19353004) 867638971 ns/iter (± 13294026) 1.25
es/minify/libraries/jquery 79770040 ns/iter (± 675619) 67155499 ns/iter (± 645098) 1.19
es/minify/libraries/lodash 96022970 ns/iter (± 967475) 78113664 ns/iter (± 1177126) 1.23
es/minify/libraries/moment 45654196 ns/iter (± 297674) 39063407 ns/iter (± 265072) 1.17
es/minify/libraries/react 17244102 ns/iter (± 210365) 14541441 ns/iter (± 66139) 1.19
es/minify/libraries/terser 213343052 ns/iter (± 3981622) 172679574 ns/iter (± 2995922) 1.24
es/minify/libraries/three 367452417 ns/iter (± 7539847) 293665323 ns/iter (± 4709079) 1.25
es/minify/libraries/typescript 2657283948 ns/iter (± 16415030) 2241567858 ns/iter (± 64908910) 1.19
es/minify/libraries/victory 579761273 ns/iter (± 12944730) 465645218 ns/iter (± 24934692) 1.25
es/minify/libraries/vue 116609216 ns/iter (± 1301683) 97567013 ns/iter (± 2416839) 1.20
es/visitor/compare/clone 2348287 ns/iter (± 14664) 1986168 ns/iter (± 1551) 1.18
es/visitor/compare/visit_mut_span 2705830 ns/iter (± 5051) 2318598 ns/iter (± 3509) 1.17
es/visitor/compare/visit_mut_span_panic 2757506 ns/iter (± 3515) 2344269 ns/iter (± 8551) 1.18
es/visitor/compare/fold_span 3818076 ns/iter (± 7057) 3380978 ns/iter (± 46620) 1.13
es/visitor/compare/fold_span_panic 3956288 ns/iter (± 14027) 3538875 ns/iter (± 4000) 1.12
es/lexer/colors 13188 ns/iter (± 38) 11646 ns/iter (± 21) 1.13
es/lexer/angular 6384597 ns/iter (± 1423) 5711135 ns/iter (± 37399) 1.12
es/lexer/backbone 788023 ns/iter (± 1844) 741068 ns/iter (± 643) 1.06
es/lexer/jquery 4413712 ns/iter (± 26929) 4151299 ns/iter (± 31012) 1.06
es/lexer/jquery mobile 6896519 ns/iter (± 11829) 6424083 ns/iter (± 46064) 1.07
es/lexer/mootools 3472870 ns/iter (± 994) 3248217 ns/iter (± 35191) 1.07
es/lexer/underscore 652100 ns/iter (± 1351) 613162 ns/iter (± 13709) 1.06
es/lexer/three 20968071 ns/iter (± 7627) 19806262 ns/iter (± 74742) 1.06
es/lexer/yui 3869315 ns/iter (± 1297) 3616622 ns/iter (± 1468) 1.07
es/parser/colors 29031 ns/iter (± 72) 25950 ns/iter (± 105) 1.12
es/parser/angular 15109516 ns/iter (± 171323) 13305372 ns/iter (± 148676) 1.14
es/parser/backbone 2151663 ns/iter (± 15022) 1957235 ns/iter (± 8115) 1.10
es/parser/jquery 11823841 ns/iter (± 112579) 10571806 ns/iter (± 68746) 1.12
es/parser/jquery mobile 18379448 ns/iter (± 309908) 16314472 ns/iter (± 59816) 1.13
es/parser/mootools 8898746 ns/iter (± 47265) 8153332 ns/iter (± 163878) 1.09
es/parser/underscore 1811573 ns/iter (± 8558) 1656107 ns/iter (± 16332) 1.09
es/parser/three 56069885 ns/iter (± 297366) 44738891 ns/iter (± 430154) 1.25
es/parser/yui 9036109 ns/iter (± 96356) 7994069 ns/iter (± 102502) 1.13
es/preset-env/usage/builtin_type 140731 ns/iter (± 34662) 143094 ns/iter (± 38767) 0.98
es/preset-env/usage/property 19589 ns/iter (± 62) 15345 ns/iter (± 159) 1.28
es/resolver/typescript 121909491 ns/iter (± 2142847) 87213297 ns/iter (± 1257191) 1.40
es/fixer/typescript 89618352 ns/iter (± 2706459) 64088123 ns/iter (± 977336) 1.40
es/hygiene/typescript 191644639 ns/iter (± 1512169) 128697734 ns/iter (± 714936) 1.49
es/resolver_with_hygiene/typescript 329649220 ns/iter (± 3419994) 233396100 ns/iter (± 1810371) 1.41
es/visitor/base-perf/module_clone 81010 ns/iter (± 489) 58509 ns/iter (± 362) 1.38
es/visitor/base-perf/fold_empty 90906 ns/iter (± 553) 62518 ns/iter (± 187) 1.45
es/visitor/base-perf/fold_noop_impl_all 90935 ns/iter (± 311) 62585 ns/iter (± 199) 1.45
es/visitor/base-perf/fold_noop_impl_vec 90945 ns/iter (± 388) 62869 ns/iter (± 217) 1.45
es/visitor/base-perf/boxing_boxed_clone 56 ns/iter (± 0) 52 ns/iter (± 0) 1.08
es/visitor/base-perf/boxing_unboxed_clone 41 ns/iter (± 0) 37 ns/iter (± 0) 1.11
es/visitor/base-perf/boxing_boxed 102 ns/iter (± 1) 105 ns/iter (± 0) 0.97
es/visitor/base-perf/boxing_unboxed 78 ns/iter (± 0) 76 ns/iter (± 0) 1.03
es/visitor/base-perf/visit_contains_this 3552 ns/iter (± 56) 2712 ns/iter (± 19) 1.31
es/base/parallel/resolver/typescript 6086863004 ns/iter (± 471638812) 3696985159 ns/iter (± 289404216) 1.65
es/base/parallel/hygiene/typescript 2201366994 ns/iter (± 20421651) 1418455338 ns/iter (± 14690979) 1.55
misc/visitors/time-complexity/time 5 106 ns/iter (± 0) 102 ns/iter (± 2) 1.04
misc/visitors/time-complexity/time 10 345 ns/iter (± 0) 254 ns/iter (± 0) 1.36
misc/visitors/time-complexity/time 15 665 ns/iter (± 0) 587 ns/iter (± 2) 1.13
misc/visitors/time-complexity/time 20 1233 ns/iter (± 3) 1144 ns/iter (± 43) 1.08
misc/visitors/time-complexity/time 40 6222 ns/iter (± 63) 3483 ns/iter (± 7) 1.79
misc/visitors/time-complexity/time 60 15599 ns/iter (± 7) 8722 ns/iter (± 28) 1.79
es/full-target/es2016 253746 ns/iter (± 268) 225447 ns/iter (± 1101) 1.13
es/full-target/es2017 245448 ns/iter (± 390) 214190 ns/iter (± 883) 1.15
es/full-target/es2018 235321 ns/iter (± 331) 204656 ns/iter (± 684) 1.15
es2020_nullish_coalescing 92532 ns/iter (± 302) 67706 ns/iter (± 279) 1.37
es2020_optional_chaining 124070 ns/iter (± 665) 95892 ns/iter (± 373) 1.29
es2022_class_properties 149192 ns/iter (± 321) 114955 ns/iter (± 377) 1.30
es2018_object_rest_spread 95795 ns/iter (± 164) 72229 ns/iter (± 279) 1.33
es2019_optional_catch_binding 85547 ns/iter (± 156) 60673 ns/iter (± 334) 1.41
es2017_async_to_generator 85393 ns/iter (± 168) 62658 ns/iter (± 169) 1.36
es2016_exponentiation 90281 ns/iter (± 256) 67734 ns/iter (± 233) 1.33
es2015_arrow 93801 ns/iter (± 157) 69220 ns/iter (± 241) 1.36
es2015_block_scoped_fn 91946 ns/iter (± 209) 66917 ns/iter (± 235) 1.37
es2015_block_scoping 169392 ns/iter (± 209) 118725 ns/iter (± 662) 1.43

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.