MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / ShimFunction

Method ShimFunction

LiveRecomp/live_generator.cpp:1955–1974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1953}
1954
1955N64Recomp::ShimFunction::ShimFunction(recomp_func_ext_t* to_shim, uintptr_t value) {
1956 sljit_compiler* compiler = sljit_create_compiler(nullptr);
1957
1958 // Create the function.
1959 sljit_label* func_label = sljit_emit_label(compiler);
1960 sljit_emit_enter(compiler, 0, SLJIT_ARGS2V(P_R, P_R), 3, 0, 0);
1961
1962 // Move the provided value into the third argument.
1963 sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, sljit_sw(value));
1964
1965 // Tail call the provided function.
1966 sljit_emit_icall(compiler, SLJIT_CALL | SLJIT_CALL_RETURN, SLJIT_ARGS3V(P, P, W), SLJIT_IMM, sljit_sw(to_shim));
1967
1968 // Generate the function's code and get the address to the function.
1969 code = sljit_generate_code(compiler, 0, nullptr);
1970 func = reinterpret_cast<recomp_func_t*>(sljit_get_label_addr(func_label));
1971
1972 // Cleanup.
1973 sljit_free_compiler(compiler);
1974}
1975
1976N64Recomp::ShimFunction::~ShimFunction() {
1977 sljit_free_code(code, nullptr);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected