@@ -1380,31 +1380,35 @@ impl<'a> EncodingState<'a> {
13801380 ShimKind :: TaskPoll { async_ } => self
13811381 . component
13821382 . task_poll ( * async_, self . memory_index . unwrap ( ) ) ,
1383- ShimKind :: ErrorNew { for_module } | ShimKind :: ErrorDebugMessage { for_module } => {
1384- let metadata = self . info . module_metadata_for ( * for_module) ;
1385- let exports = self . info . exports_for ( * for_module) ;
1386- let instance_index = self . instance_for ( * for_module) ;
1387- let encoding = metadata. general_purpose_encoding ( ) ;
1388- let realloc = exports. general_purpose_realloc ( ) ;
1389- let realloc_index = realloc
1390- . map ( |name| self . core_alias_export ( instance_index, name, ExportKind :: Func ) ) ;
1391-
1392- match & shim. kind {
1393- ShimKind :: ErrorNew { .. } => self . component . error_new (
1394- ( RequiredOptions :: MEMORY | RequiredOptions :: STRING_ENCODING )
1395- . into_iter ( encoding, self . memory_index , realloc_index) ?
1396- . collect :: < Vec < _ > > ( ) ,
1397- ) ,
1398- ShimKind :: ErrorDebugMessage { .. } => self . component . error_debug_message (
1383+ ShimKind :: ErrorContextNew {
1384+ for_module,
1385+ encoding,
1386+ }
1387+ | ShimKind :: ErrorContextDebugMessage {
1388+ for_module,
1389+ encoding,
1390+ ..
1391+ } => match & shim. kind {
1392+ ShimKind :: ErrorContextNew { .. } => self . component . error_context_new (
1393+ ( RequiredOptions :: MEMORY | RequiredOptions :: STRING_ENCODING )
1394+ . into_iter ( * encoding, self . memory_index , None ) ?
1395+ . collect :: < Vec < _ > > ( ) ,
1396+ ) ,
1397+ ShimKind :: ErrorContextDebugMessage { realloc, .. } => {
1398+ let instance_index = self . instance_for ( * for_module) ;
1399+ let realloc_index =
1400+ Some ( self . core_alias_export ( instance_index, realloc, ExportKind :: Func ) ) ;
1401+
1402+ self . component . error_context_debug_message (
13991403 ( RequiredOptions :: MEMORY
14001404 | RequiredOptions :: STRING_ENCODING
14011405 | RequiredOptions :: REALLOC )
1402- . into_iter ( encoding, self . memory_index , realloc_index) ?
1406+ . into_iter ( * encoding, self . memory_index , realloc_index) ?
14031407 . collect :: < Vec < _ > > ( ) ,
1404- ) ,
1405- _ => unreachable ! ( ) ,
1408+ )
14061409 }
1407- }
1410+ _ => unreachable ! ( ) ,
1411+ } ,
14081412 } ;
14091413
14101414 exports. push ( ( shim. name . as_str ( ) , ExportKind :: Func , core_func_index) ) ;
@@ -1802,26 +1806,35 @@ impl<'a> EncodingState<'a> {
18021806 let index = self . component . future_close_writable ( type_index) ;
18031807 return Ok ( ( ExportKind :: Func , index) ) ;
18041808 }
1805- Import :: ErrorNew => {
1809+ Import :: ErrorContextNew { encoding } => {
18061810 let index = self . component . core_alias_export (
18071811 self . shim_instance_index
18081812 . expect ( "shim should be instantiated" ) ,
1809- & shims. shims [ & ShimKind :: ErrorNew { for_module } ] . name ,
1813+ & shims. shims [ & ShimKind :: ErrorContextNew {
1814+ for_module,
1815+ encoding : * encoding,
1816+ } ]
1817+ . name ,
18101818 ExportKind :: Func ,
18111819 ) ;
18121820 return Ok ( ( ExportKind :: Func , index) ) ;
18131821 }
1814- Import :: ErrorDebugMessage => {
1822+ Import :: ErrorContextDebugMessage { encoding , realloc } => {
18151823 let index = self . component . core_alias_export (
18161824 self . shim_instance_index
18171825 . expect ( "shim should be instantiated" ) ,
1818- & shims. shims [ & ShimKind :: ErrorDebugMessage { for_module } ] . name ,
1826+ & shims. shims [ & ShimKind :: ErrorContextDebugMessage {
1827+ for_module,
1828+ encoding : * encoding,
1829+ realloc,
1830+ } ]
1831+ . name ,
18191832 ExportKind :: Func ,
18201833 ) ;
18211834 return Ok ( ( ExportKind :: Func , index) ) ;
18221835 }
1823- Import :: ErrorDrop => {
1824- let index = self . component . error_drop ( ) ;
1836+ Import :: ErrorContextDrop => {
1837+ let index = self . component . error_context_drop ( ) ;
18251838 return Ok ( ( ExportKind :: Func , index) ) ;
18261839 }
18271840 Import :: WorldFunc ( key, name, abi) => ( key, name, None , * abi) ,
@@ -2059,11 +2072,14 @@ enum ShimKind<'a> {
20592072 TaskPoll {
20602073 async_ : bool ,
20612074 } ,
2062- ErrorNew {
2075+ ErrorContextNew {
20632076 for_module : CustomModule < ' a > ,
2077+ encoding : StringEncoding ,
20642078 } ,
2065- ErrorDebugMessage {
2079+ ErrorContextDebugMessage {
20662080 for_module : CustomModule < ' a > ,
2081+ encoding : StringEncoding ,
2082+ realloc : & ' a str ,
20672083 } ,
20682084}
20692085
@@ -2135,7 +2151,7 @@ impl<'a> Shims<'a> {
21352151 | Import :: ExportedResourceDrop ( ..)
21362152 | Import :: ExportedResourceRep ( ..)
21372153 | Import :: ExportedResourceNew ( ..)
2138- | Import :: ErrorDrop
2154+ | Import :: ErrorContextDrop
21392155 | Import :: TaskBackpressure
21402156 | Import :: TaskYield { .. }
21412157 | Import :: SubtaskDrop
@@ -2234,13 +2250,16 @@ impl<'a> Shims<'a> {
22342250 continue ;
22352251 }
22362252
2237- Import :: ErrorNew => {
2253+ Import :: ErrorContextNew { encoding } => {
22382254 let name = self . shims . len ( ) . to_string ( ) ;
22392255 self . push ( Shim {
22402256 name,
22412257 debug_name : "error-new" . to_string ( ) ,
22422258 options : RequiredOptions :: empty ( ) ,
2243- kind : ShimKind :: ErrorNew { for_module } ,
2259+ kind : ShimKind :: ErrorContextNew {
2260+ for_module,
2261+ encoding : * encoding,
2262+ } ,
22442263 sig : WasmSignature {
22452264 params : vec ! [ WasmType :: I32 ; 2 ] ,
22462265 results : vec ! [ WasmType :: I32 ] ,
@@ -2251,13 +2270,17 @@ impl<'a> Shims<'a> {
22512270 continue ;
22522271 }
22532272
2254- Import :: ErrorDebugMessage => {
2273+ Import :: ErrorContextDebugMessage { encoding , realloc } => {
22552274 let name = self . shims . len ( ) . to_string ( ) ;
22562275 self . push ( Shim {
22572276 name,
22582277 debug_name : "error-debug-message" . to_string ( ) ,
22592278 options : RequiredOptions :: empty ( ) ,
2260- kind : ShimKind :: ErrorDebugMessage { for_module } ,
2279+ kind : ShimKind :: ErrorContextDebugMessage {
2280+ for_module,
2281+ encoding : * encoding,
2282+ realloc,
2283+ } ,
22612284 sig : WasmSignature {
22622285 params : vec ! [ WasmType :: I32 ; 2 ] ,
22632286 results : vec ! [ ] ,
0 commit comments