@@ -13,11 +13,20 @@ use wasmtime_environ::{CompilerBuilder, Setting, SettingKind};
1313struct Builder {
1414 flags : settings:: Builder ,
1515 isa_flags : isa:: Builder ,
16+ linkopts : LinkOptions ,
17+ }
1618
17- // A debug-only setting used to synthetically insert 0-byte padding between
18- // compiled functions to simulate huge compiled artifacts and exercise logic
19- // related to jump veneers.
20- padding_between_functions : usize ,
19+ #[ derive( Clone , Default ) ]
20+ pub struct LinkOptions {
21+ /// A debug-only setting used to synthetically insert 0-byte padding between
22+ /// compiled functions to simulate huge compiled artifacts and exercise
23+ /// logic related to jump veneers.
24+ pub padding_between_functions : usize ,
25+
26+ /// A debug-only setting used to force inter-function calls in a wasm module
27+ /// to always go through "jump veneers" which are typically only generated
28+ /// when functions are very far from each other.
29+ pub force_jump_veneers : bool ,
2130}
2231
2332pub fn builder ( ) -> Box < dyn CompilerBuilder > {
@@ -37,7 +46,7 @@ pub fn builder() -> Box<dyn CompilerBuilder> {
3746 Box :: new ( Builder {
3847 flags,
3948 isa_flags : cranelift_native:: builder ( ) . expect ( "host machine is not a supported target" ) ,
40- padding_between_functions : 0 ,
49+ linkopts : LinkOptions :: default ( ) ,
4150 } )
4251}
4352
@@ -56,12 +65,17 @@ impl CompilerBuilder for Builder {
5665 }
5766
5867 fn set ( & mut self , name : & str , value : & str ) -> Result < ( ) > {
59- // Special wasmtime-cranelift-only setting.
60- if name == "padding_between_functions" {
61- self . padding_between_functions = value. parse ( ) ?;
68+ // Special wasmtime-cranelift-only settings first
69+ if name == "linkopt_padding_between_functions" {
70+ self . linkopts . padding_between_functions = value. parse ( ) ?;
71+ return Ok ( ( ) ) ;
72+ }
73+ if name == "linkopt_force_jump_veneer" {
74+ self . linkopts . force_jump_veneers = value == "true" ;
6275 return Ok ( ( ) ) ;
6376 }
6477
78+ // ... then forward this to Cranelift
6579 if let Err ( err) = self . flags . set ( name, value) {
6680 match err {
6781 SetError :: BadName ( _) => {
@@ -92,10 +106,7 @@ impl CompilerBuilder for Builder {
92106 . isa_flags
93107 . clone ( )
94108 . finish ( settings:: Flags :: new ( self . flags . clone ( ) ) ) ;
95- Box :: new ( crate :: compiler:: Compiler :: new (
96- isa,
97- self . padding_between_functions ,
98- ) )
109+ Box :: new ( crate :: compiler:: Compiler :: new ( isa, self . linkopts . clone ( ) ) )
99110 }
100111
101112 fn settings ( & self ) -> Vec < Setting > {
0 commit comments