def _do_wast(wasm_path, wast_path, cwd=None): if not exists(wasm_path): print("Could not find wasm file at {}".format(wasm_path)) exit(1) if exists(wast_path): remove(wast_path) wavm_bin = find_command("wavm", POSSIBLE_BUILD_BINS) cmd = [ wavm_bin, "disassemble", wasm_path, wast_path, "--enable simd", "--enable atomics", ] cmd = " ".join(cmd) kwargs = { "shell": True, } if cwd: kwargs["cwd"] = cwd call(cmd, **kwargs) # call("head -40 {}".format(wast_path), shell=True) print("vim {}".format(wast_path))
def general(ctx, user, func, reps=10, cmd=None, data=None, reverse=False): """ Generates a flame graph for the given function """ print("Generating flame graph for {} reps of {}/{}".format( reps, user, func)) if not exists(FLAME_GRAPH_DIR): print("Cloning FlameGraph") run( "git clone https://github.com/brendangregg/FlameGraph", cwd=WORK_DIR, shell=True, check=True, ) # Set up the command to be perf'd if not cmd: simple_runner_bin = find_command("simple_runner") cmd = " ".join( [simple_runner_bin, user, func, str(reps), data if data else ""]) # Set up main perf command perf_cmd = ["perf", "record", "-k 1", "-F 99", "-g", cmd] perf_cmd = " ".join(perf_cmd) # Create list of commands to be run svg_file = join(PROJ_ROOT, "flame.svg") cmds = [ perf_cmd, "perf inject -i perf.data -j -o perf.data.jit", "perf script -i perf.data.jit > out.perf", "./stackcollapse-perf.pl out.perf > out.folded", "./flamegraph.pl {} out.folded > {}".format( "--reverse" if reverse else "", svg_file), ] # Execute each one in the flame graphs checkout for cmd in cmds: print(cmd) run(cmd, shell=True, check=True, cwd=FLAME_GRAPH_DIR) # Replace symbols in the SVG file replace_symbols_in_file(user, func, svg_file, prefix="wasm") print("\nFlame graph written to {}".format(svg_file))
def check(ctx): """ Detect if SGX is supported """ binary = find_command("detect_sgx") run(binary, shell=True)
def find_codegen_func(wamr=False): if wamr: return find_command("wamrc", POSSIBLE_BUILD_BINS) else: return find_command("codegen_func", POSSIBLE_BUILD_BINS)
def find_codegen_shared_lib(): return find_command("codegen_shared_obj", POSSIBLE_BUILD_BINS)
def find_codegen_func(): return find_command("codegen_func", POSSIBLE_BUILD_BINS)
def find_codegen_func(wamr=False): if wamr: return find_command("wamrc") else: return find_command("codegen_func")
def find_codegen_shared_lib(): return find_command("codegen_shared_obj")
def find_codegen_func(): return find_command("codegen_func")