33
44use crate :: {
55 programs:: {
6+ FuncMiddleware , Middleware , ModuleMod , STYLUS_ENTRY_POINT , StylusData ,
67 config:: CompileConfig , counter:: Counter , depth:: DepthChecker , dynamic:: DynamicMeter ,
7- heap:: HeapBound , meter:: Meter , start:: StartMover , FuncMiddleware , Middleware , ModuleMod ,
8- StylusData , STYLUS_ENTRY_POINT ,
8+ heap:: HeapBound , meter:: Meter , start:: StartMover ,
99 } ,
1010 value:: { ArbValueType , FunctionType , IntegerValType , Value } ,
1111} ;
1212use arbutil:: {
13- evm:: ARBOS_VERSION_STYLUS_CHARGING_FIXES , math:: SaturatingSum , Bytes32 , Color , DebugColor ,
13+ Bytes32 , Color , DebugColor , evm:: ARBOS_VERSION_STYLUS_CHARGING_FIXES , math:: SaturatingSum ,
1414} ;
15- use eyre:: { bail , ensure , eyre , Result , WrapErr } ;
15+ use eyre:: { Result , WrapErr , bail , ensure , eyre } ;
1616use fnv:: { FnvHashMap as HashMap , FnvHashSet as HashSet } ;
1717use nom:: {
1818 branch:: alt,
@@ -22,7 +22,7 @@ use nom::{
2222} ;
2323use serde:: { Deserialize , Serialize } ;
2424use std:: { convert:: TryInto , fmt:: Debug , hash:: Hash , mem, path:: Path , str:: FromStr } ;
25- use wasmer_types:: { entity :: EntityRef , ExportIndex , FunctionIndex , LocalFunctionIndex } ;
25+ use wasmer_types:: { ExportIndex , FunctionIndex , LocalFunctionIndex , entity :: EntityRef } ;
2626use wasmparser:: {
2727 Data , Element , ExternalKind , MemoryType , Name , NameSectionReader , Naming , Operator , Parser ,
2828 Payload , TableType , TypeRef , ValType , Validator , WasmFeatures ,
@@ -255,6 +255,8 @@ impl From<ExportIndex> for ExportKind {
255255 E :: Table ( _) => Self :: Table ,
256256 E :: Memory ( _) => Self :: Memory ,
257257 E :: Global ( _) => Self :: Global ,
258+ #[ cfg( feature = "sp1" ) ]
259+ E :: Tag ( _) => Self :: Tag ,
258260 }
259261 }
260262}
@@ -301,6 +303,7 @@ pub struct WasmBinary<'a> {
301303}
302304
303305pub fn parse < ' a > ( input : & ' a [ u8 ] , path : & ' _ Path ) -> Result < WasmBinary < ' a > > {
306+ #[ cfg( not( feature = "sp1" ) ) ]
304307 let features = WasmFeatures {
305308 mutable_global : true ,
306309 saturating_float_to_int : true ,
@@ -324,6 +327,17 @@ pub fn parse<'a>(input: &'a [u8], path: &'_ Path) -> Result<WasmBinary<'a>> {
324327 component_model_values : false ,
325328 component_model_nested_names : false ,
326329 } ;
330+ #[ cfg( feature = "sp1" ) ]
331+ let features = {
332+ let mut features = WasmFeatures :: empty ( ) ;
333+ features. set ( WasmFeatures :: MUTABLE_GLOBAL , true ) ;
334+ features. set ( WasmFeatures :: SATURATING_FLOAT_TO_INT , true ) ;
335+ features. set ( WasmFeatures :: SIGN_EXTENSION , true ) ;
336+ features. set ( WasmFeatures :: MULTI_VALUE , true ) ;
337+ features. set ( WasmFeatures :: BULK_MEMORY , true ) ; // not all ops supported yet
338+ features. set ( WasmFeatures :: FLOATS , true ) ;
339+ features
340+ } ;
327341 Validator :: new_with_features ( features)
328342 . validate_all ( input)
329343 . wrap_err_with ( || eyre ! ( "failed to validate {}" , path. to_string_lossy( ) . red( ) ) ) ?;
@@ -429,7 +443,11 @@ pub fn parse<'a>(input: &'a [u8], path: &'_ Path) -> Result<WasmBinary<'a>> {
429443 }
430444
431445 // CHECK: maybe reader.data_offset()
446+ #[ cfg( not( feature = "sp1" ) ) ]
432447 let name_reader = NameSectionReader :: new ( reader. data ( ) , 0 ) ;
448+ #[ cfg( feature = "sp1" ) ]
449+ let name_reader =
450+ NameSectionReader :: new ( wasmparser:: BinaryReader :: new ( reader. data ( ) , 0 ) ) ;
433451
434452 for name in name_reader {
435453 match name? {
0 commit comments