Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ FOREACH(SUFFIX "_DEBUG" "_RELEASE" "_RELWITHDEBINFO" "_MINSIZEREL" "")
ENDFOREACH()

IF(MSVC)
IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0") # VS2013 and older explicitly need /arch:sse2 set, VS2015 no longer has that option, but always enabled.
IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.0") # VS2013 and older explicitly need /arch:sse2 set, VS2015 no longer has that option, but always enabled.
ADD_COMPILE_FLAG("/arch:sse2")
ENDIF()
ADD_COMPILE_FLAG("/wd4146") # Ignore warning "warning C4146: unary minus operator applied to unsigned type, result still unsigned", this pattern is used somewhat commonly in the code.
Expand Down Expand Up @@ -189,7 +189,7 @@ SET(binaryen_SOURCES
src/binaryen-c.cpp
)
IF(BUILD_STATIC_LIB)
ADD_LIBRARY(binaryen STATIC ${binaryen_SOURCES})
ADD_LIBRARY(binaryen STATIC ${binaryen_SOURCES})
ELSE()
ADD_LIBRARY(binaryen SHARED ${binaryen_SOURCES})
ENDIF()
Expand Down Expand Up @@ -243,6 +243,16 @@ SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET asm2wasm PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS asm2wasm DESTINATION ${CMAKE_INSTALL_BINDIR})

SET(wasm2asm_SOURCES
src/wasm2asm-main.cpp
)
ADD_EXECUTABLE(wasm2asm
${wasm2asm_SOURCES})
TARGET_LINK_LIBRARIES(wasm2asm passes wasm asmjs emscripten-optimizer ast cfg support)
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm2asm PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm2asm DESTINATION ${CMAKE_INSTALL_BINDIR})

SET(s2wasm_SOURCES
src/tools/s2wasm.cpp
src/wasm-emscripten.cpp
Expand Down Expand Up @@ -284,4 +294,3 @@ TARGET_LINK_LIBRARIES(wasm-ctor-eval emscripten-optimizer passes wasm asmjs ast
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD 11)
SET_PROPERTY(TARGET wasm-ctor-eval PROPERTY CXX_STANDARD_REQUIRED ON)
INSTALL(TARGETS wasm-ctor-eval DESTINATION bin)

2 changes: 2 additions & 0 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)

import scripts.test.s2wasm as s2wasm
import scripts.test.wasm2asm as wasm2asm

if options.interpreter:
print '[ using wasm interpreter at "%s" ]' % options.interpreter
Expand Down Expand Up @@ -423,6 +424,7 @@ def fix(x):

s2wasm.test_s2wasm()
s2wasm.test_linker()
# wasm2asm.test_wasm2asm()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentionally not enabled?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since there aren't many tests right now anyway. I was planning to enable the tests in a future PR that would finish 32 bit support and add more tests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.


print '\n[ running validation tests... ]\n'
# Ensure the tests validate by default
Expand Down
1 change: 1 addition & 0 deletions scripts/test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def is_exe(fpath):
WASM_AS = [os.path.join(options.binaryen_bin, 'wasm-as')]
WASM_DIS = [os.path.join(options.binaryen_bin, 'wasm-dis')]
ASM2WASM = [os.path.join(options.binaryen_bin, 'asm2wasm')]
WASM2ASM = [os.path.join(options.binaryen_bin, 'wasm2asm')]
WASM_CTOR_EVAL = [os.path.join(options.binaryen_bin, 'wasm-ctor-eval')]
WASM_SHELL = [os.path.join(options.binaryen_bin, 'wasm-shell')]
WASM_MERGE = [os.path.join(options.binaryen_bin, 'wasm-merge')]
Expand Down
7 changes: 5 additions & 2 deletions scripts/test/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ def to_end(j):
return ret


def run_command(cmd, expected_status=0, stderr=None, expected_err=None):
def run_command(cmd, expected_status=0, stderr=None,
expected_err=None, err_contains=False):
if expected_err is not None:
assert stderr == subprocess.PIPE or stderr is None,\
"Can't redirect stderr if using expected_err"
Expand All @@ -157,7 +158,9 @@ def run_command(cmd, expected_status=0, stderr=None, expected_err=None):
out, err = proc.communicate()
if proc.returncode != expected_status:
raise Exception(('run_command failed', err))
if expected_err is not None and err != expected_err:
err_correct = expected_err is None or \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need the new contained-but-not-equal mode? is equality too much for some test?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the MOZJS case in test_wasm2asm() cannot use equality because the error message contains timing information that is not test-independent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need timing information? What is actually used there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full stderr of mozjs for successful test looks like a.2asm.js:warning: Successfully compiled asm.js code (total compilation time 4ms; caching disabled by missing command-line arguments). The only part the test cares about is Successfully compiled asm.js code. I don't know of a way to stop the timing information from being emitted, which would allow us to use equality here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. Yeah, that's hard to remove. Looks good then, maybe add a comment though to say why we just check for the subset (if there isn't one already).

(expected_err in err if err_contains else expected_err == err)
if not err_correct:
raise Exception(('run_command unexpected stderr',
"expected '%s', actual '%s'" % (expected_err, err)))
return out
51 changes: 51 additions & 0 deletions scripts/test/wasm2asm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env python2

import os

from support import run_command
from shared import (WASM2ASM, MOZJS, NODEJS, fail_if_not_identical, tests)


def test_wasm2asm():
print '\n[ checking wasm2asm testcases... ]\n'

# tests with i64s, invokes, etc.
blacklist = ['atomics.wast', 'address.wast']
spec_tests = [os.path.join('spec', t) for t in
sorted(os.listdir(os.path.join('test', 'spec')))]
for wasm in tests + spec_tests:
if not wasm.endswith('.wast') or os.path.basename(wasm) in blacklist:
continue

asm = os.path.basename(wasm).replace('.wast', '.2asm.js')
expected_file = os.path.join('test', asm)
if not os.path.exists(expected_file):
continue

print '..', wasm

cmd = WASM2ASM + [os.path.join('test', wasm)]
out = run_command(cmd)

# verify output
expected = open(expected_file).read()
fail_if_not_identical(out, expected)

open('a.2asm.js', 'w').write(out)

if NODEJS:
# verify asm.js is valid js
out = run_command([NODEJS, 'a.2asm.js'])
fail_if_not_identical(out, '')

if MOZJS:
# verify asm.js validates
# check only subset of err because mozjs emits timing info
out = run_command([MOZJS, '-w', 'a.2asm.js'],
expected_err='Successfully compiled asm.js code',
err_contains=True)
fail_if_not_identical(out, '')


if __name__ == "__main__":
test_wasm2asm()
1 change: 0 additions & 1 deletion src/asmjs/shared-constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ cashew::IString GLOBAL("global"),
INSTRUMENT("instrument"),
MATH_IMUL("Math_imul"),
MATH_CLZ32("Math_clz32"),
MATH_CTZ32("Math_ctz32"),
MATH_POPCNT32("Math_popcnt32"),
MATH_ABS("Math_abs"),
MATH_CEIL("Math_ceil"),
Expand Down
1 change: 0 additions & 1 deletion src/asmjs/shared-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ extern cashew::IString GLOBAL,
INSTRUMENT,
MATH_IMUL,
MATH_CLZ32,
MATH_CTZ32,
MATH_POPCNT32,
MATH_ABS,
MATH_CEIL,
Expand Down
Loading