@@ -157,6 +157,7 @@ def is_exe(fpath):
157157 which ('g++' ) or which ('clang++' ))
158158NODEJS = os .getenv ('NODE' , which ('nodejs' ) or which ('node' ))
159159MOZJS = which ('mozjs' ) or which ('spidermonkey' )
160+ V8 = which ('v8' ) or which ('d8' )
160161EMCC = which ('emcc' )
161162
162163BINARYEN_INSTALL_DIR = os .path .dirname (options .binaryen_bin )
@@ -190,7 +191,13 @@ def wrap_with_valgrind(cmd):
190191 ASM2WASM = wrap_with_valgrind (ASM2WASM )
191192 WASM_SHELL = wrap_with_valgrind (WASM_SHELL )
192193
193- os .environ ['BINARYEN' ] = os .getcwd ()
194+
195+ def in_binaryen (* args ):
196+ __rootpath__ = os .path .abspath (os .path .dirname (os .path .dirname (os .path .dirname (__file__ ))))
197+ return os .path .join (__rootpath__ , * args )
198+
199+
200+ os .environ ['BINARYEN' ] = in_binaryen ()
194201
195202
196203def get_platform ():
@@ -204,6 +211,19 @@ def has_shell_timeout():
204211 return get_platform () != 'windows' and os .system ('timeout 1s pwd' ) == 0
205212
206213
214+ # Default options to pass to v8. These enable all features.
215+ V8_OPTS = [
216+ '--experimental-wasm-eh' ,
217+ '--experimental-wasm-mv' ,
218+ '--experimental-wasm-sat-f2i-conversions' ,
219+ '--experimental-wasm-se' ,
220+ '--experimental-wasm-threads' ,
221+ '--experimental-wasm-simd' ,
222+ '--experimental-wasm-anyref' ,
223+ '--experimental-wasm-bulk-memory' ,
224+ '--experimental-wasm-return-call'
225+ ]
226+
207227has_vanilla_llvm = False
208228
209229# external tools
@@ -377,8 +397,18 @@ def fail_if_not_identical_to_file(actual, expected_file):
377397
378398# check utilities
379399
400+
401+ def validate_binary (wasm ):
402+ if V8 :
403+ cmd = [V8 ] + V8_OPTS + [in_binaryen ('scripts' , 'validation_shell.js' ), '--' , wasm ]
404+ print ' ' , ' ' .join (cmd )
405+ subprocess .check_call (cmd , stdout = subprocess .PIPE )
406+ else :
407+ print '(skipping v8 binary validation)'
408+
409+
380410def binary_format_check (wast , verify_final_result = True , wasm_as_args = ['-g' ],
381- binary_suffix = '.fromBinary' ):
411+ binary_suffix = '.fromBinary' , original_wast = None ):
382412 # checks we can convert the wast to binary and back
383413
384414 print ' (binary format check)'
@@ -389,6 +419,13 @@ def binary_format_check(wast, verify_final_result=True, wasm_as_args=['-g'],
389419 subprocess .check_call (cmd , stdout = subprocess .PIPE )
390420 assert os .path .exists ('a.wasm' )
391421
422+ # make sure it is a valid wasm, using a real wasm VM
423+ if os .path .basename (original_wast or wast ) not in [
424+ 'atomics.wast' , # https://bugs.chromium.org/p/v8/issues/detail?id=9425
425+ 'simd.wast' , # https://bugs.chromium.org/p/v8/issues/detail?id=8460
426+ ]:
427+ validate_binary ('a.wasm' )
428+
392429 cmd = WASM_DIS + ['a.wasm' , '-o' , 'ab.wast' ]
393430 print ' ' , ' ' .join (cmd )
394431 if os .path .exists ('ab.wast' ):
0 commit comments