Skip to content

Commit

Permalink
Revert "Merge branch '4598' into improve_remove"
Browse files Browse the repository at this point in the history
This reverts commit 7988682, reversing
changes made to 0da2d8c.
  • Loading branch information
aheejin committed Jul 12, 2022
1 parent 8955856 commit 1eed7e0
Show file tree
Hide file tree
Showing 43 changed files with 634 additions and 8,478 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ if(EMSCRIPTEN)
target_link_libraries(binaryen_wasm "-s NODERAWFS=0")
target_link_libraries(binaryen_wasm "-s EXPORT_NAME=Binaryen")
target_link_libraries(binaryen_wasm "-s EXPORT_ES6=1")
target_link_libraries(binaryen_wasm "-sEXPORTED_RUNTIME_METHODS=allocate")
target_link_libraries(binaryen_wasm "--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
target_link_libraries(binaryen_wasm "--extern-pre-js ${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-extern-pre.js")
target_link_libraries(binaryen_wasm optimized "--closure 1")
Expand Down Expand Up @@ -440,7 +439,6 @@ if(EMSCRIPTEN)
else()
target_link_libraries(binaryen_js "-s EXPORT_ES6=1")
endif()
target_link_libraries(binaryen_js "-sEXPORTED_RUNTIME_METHODS=allocate")
target_link_libraries(binaryen_js "--post-js ${CMAKE_CURRENT_SOURCE_DIR}/src/js/binaryen.js-post.js")
# js_of_ocaml needs a specified variable with special comment to provide the library to consumers
if(JS_OF_OCAML)
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,6 @@ The `check.py` script supports some options:
tool cannot be found, and you'll see a warning.
* We have tests from upstream in `tests/spec`, in git submodules. Running
`./check.py` should update those.

Note that we are trying to gradually port the legacy wasm-opt tests to use `lit` and `filecheck` as we modify them.
For `passes` tests that output wast, this can be done automatically with `scripts/port_passes_tests_to_lit.py` and for non-`passes` tests that output wast, see
https://github.com/WebAssembly/binaryen/pull/4779 for an example of how to do a simple manual port.

### Setting up dependencies

Expand Down
20 changes: 6 additions & 14 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,18 +263,7 @@ def is_git_repo():
# not all relaxed SIMD instructions are implemented in the interpreter
'relaxed-simd.wast',
# TODO fuzzer and interpreter support for strings
'strings.wast',
# ignore DWARF because it is incompatible with multivalue atm
'zlib.wasm',
'cubescript.wasm',
'class_with_dwarf_noprint.wasm',
'fib2_dwarf.wasm',
'fib_nonzero-low-pc_dwarf.wasm',
'inlined_to_start_dwarf.wasm',
'fannkuch3_manyopts_dwarf.wasm',
'fib2_emptylocspan_dwarf.wasm',
'fannkuch3_dwarf.wasm',
'multi_unit_abbrev_noprint.wasm',
'strings.wast'
]


Expand Down Expand Up @@ -361,6 +350,9 @@ def pick_initial_contents():
# )
# )
'--disable-multivalue',
# DWARF is incompatible with multivalue atm; it's more important to
# fuzz multivalue since we aren't actually fuzzing DWARF here
'--strip-dwarf',
]

# the given wasm may not work with the chosen feature opts. for example, if
Expand Down Expand Up @@ -831,8 +823,8 @@ def handle_pair(self, input, before_wasm, after_wasm, opts):
b1 = open('b1.wasm', 'rb').read()
b2 = open('b2.wasm', 'rb').read()
if (b1 != b2):
run([in_bin('wasm-dis'), 'b1.wasm', '-o', 'b1.wat'] + FEATURE_OPTS)
run([in_bin('wasm-dis'), 'b2.wasm', '-o', 'b2.wat'] + FEATURE_OPTS)
run([in_bin('wasm-dis'), 'b1.wasm', '-o', 'b1.wat', FEATURE_OPTS])
run([in_bin('wasm-dis'), 'b2.wasm', '-o', 'b2.wat', FEATURE_OPTS])
t1 = open('b1.wat', 'r').read()
t2 = open('b2.wat', 'r').read()
compare(t1, t2, 'Output must be deterministic.', verbose=False)
Expand Down
35 changes: 6 additions & 29 deletions scripts/gen-s-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,6 @@
("string.new_wtf8", "makeStringNew(s, StringNewWTF8)"),
("string.new_wtf16", "makeStringNew(s, StringNewWTF16)"),
("string.const", "makeStringConst(s)"),
("string.measure_wtf8", "makeStringMeasure(s, StringMeasureWTF8)"),
("string.measure_wtf16", "makeStringMeasure(s, StringMeasureWTF16)"),
("string.is_usv_sequence", "makeStringMeasure(s, StringMeasureIsUSV)"),
("string.encode_wtf8", "makeStringEncode(s, StringEncodeWTF8)"),
("string.encode_wtf16", "makeStringEncode(s, StringEncodeWTF16)"),
("string.concat", "makeStringConcat(s)"),
("string.eq", "makeStringEq(s)"),
]


Expand Down Expand Up @@ -693,7 +686,7 @@ def insert(self, inst, expr):
self.do_insert(inst, inst, expr)


def instruction_parser(new_parser=False):
def instruction_parser():
"""Build a trie out of all the instructions, then emit it as C++ code."""
trie = Node()
inst_length = 0
Expand All @@ -703,23 +696,12 @@ def instruction_parser(new_parser=False):

printer = CodePrinter()

if not new_parser:
printer.print_line("char op[{}] = {{'\\0'}};".format(inst_length + 1))
printer.print_line("strncpy(op, s[0]->c_str(), {});".format(inst_length))
printer.print_line("char op[{}] = {{'\\0'}};".format(inst_length + 1))
printer.print_line("strncpy(op, s[0]->c_str(), {});".format(inst_length))

def print_leaf(expr, inst):
if new_parser:
expr = expr.replace("()", "(ctx)")
expr = expr.replace("(s", "(ctx, in")
printer.print_line("if (op == \"{inst}\"sv) {{".format(inst=inst))
with printer.indent():
printer.print_line("auto ret = {expr};".format(expr=expr))
printer.print_line("CHECK_ERR(ret);")
printer.print_line("return *ret;")
printer.print_line("}")
else:
printer.print_line("if (strcmp(op, \"{inst}\") == 0) {{ return {expr}; }}"
.format(inst=inst, expr=expr))
printer.print_line("if (strcmp(op, \"{inst}\") == 0) {{ return {expr}; }}"
.format(inst=inst, expr=expr))
printer.print_line("goto parse_error;")

def emit(node, idx=0):
Expand Down Expand Up @@ -748,10 +730,7 @@ def emit(node, idx=0):
emit(trie)
printer.print_line("parse_error:")
with printer.indent():
if new_parser:
printer.print_line("return in.err(\"unrecognized instruction\");")
else:
printer.print_line("throw ParseException(std::string(op), s.line, s.col);")
printer.print_line("throw ParseException(std::string(op), s.line, s.col);")


def print_header():
Expand All @@ -777,8 +756,6 @@ def main():
sys.exit(1)
print_header()
generate_with_guard(instruction_parser, "INSTRUCTION_PARSER")
print()
generate_with_guard(lambda: instruction_parser(True), "NEW_INSTRUCTION_PARSER")
print_footer()


Expand Down
2 changes: 1 addition & 1 deletion scripts/update_lit_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
ALL_ITEMS = '|'.join(['type', 'import', 'global', 'memory', 'data', 'table',
'elem', 'tag', 'export', 'start', 'func'])
ITEM_NAME = r'\$?[^\s()]*|"[^\s()]*"'
ITEM_RE = re.compile(r'(?:^\s*\(rec\s*)?(^\s*)\((' + ALL_ITEMS + r')\s+(' + ITEM_NAME + ').*$',
ITEM_RE = re.compile(r'(^\s*)\((' + ALL_ITEMS + r')\s+(' + ITEM_NAME + ').*$',
re.MULTILINE)

FUZZ_EXEC_FUNC = re.compile(r'^\[fuzz-exec\] calling (?P<name>\S*)$')
Expand Down

0 comments on commit 1eed7e0

Please sign in to comment.