Commit 66964e68 authored by clemensh's avatar clemensh Committed by Commit bot

[wasm] Also unwrap exported debugged functions

The previous fix (http://crrev.com/2720813002) was problematic for
functions containing i64 parameters or returns. Those would throw a
TypeError when called via WASM_TO_JS and JS_TO_WASM.

Instead, we now unwrap the WASM_INTERPRETER_ENTRY function and call it
directly. This removes the option to later redirect back to the
original wasm function, but this functionality is not needed currently.

Plus drive-by fix to put functions in anonymous namespace in
wasm-compiler.cc.

R=ahaas@chromium.org, titzer@chromium.org
BUG=v8:5971, v8:5822

Review-Url: https://codereview.chromium.org/2725333002
Cr-Commit-Position: refs/heads/master@{#43603}
parent 437dece4
......@@ -2740,23 +2740,21 @@ Node* WasmGraphBuilder::BuildHeapNumberValueIndexConstant() {
return jsgraph()->IntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag);
}
namespace {
bool IsJSCompatible(wasm::ValueType type) {
return (type != wasm::kWasmI64) && (type != wasm::kWasmS128);
return type != wasm::kWasmI64 && type != wasm::kWasmS128;
}
bool HasJSCompatibleSignature(wasm::FunctionSig* sig) {
for (size_t i = 0; i < sig->parameter_count(); i++) {
if (!IsJSCompatible(sig->GetParam(i))) {
return false;
}
if (!IsJSCompatible(sig->GetParam(i))) return false;
}
for (size_t i = 0; i < sig->return_count(); i++) {
if (!IsJSCompatible(sig->GetReturn(i))) {
return false;
}
if (!IsJSCompatible(sig->GetReturn(i))) return false;
}
return true;
}
} // namespace
void WasmGraphBuilder::BuildJSToWasmWrapper(Handle<Code> wasm_code,
wasm::FunctionSig* sig) {
......
......@@ -869,20 +869,17 @@ static Handle<Code> UnwrapImportWrapper(Handle<Object> import_wrapper) {
for (RelocIterator it(*export_wrapper_code, mask);; it.next()) {
DCHECK(!it.done());
Code* target = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
if (target->kind() == Code::WASM_INTERPRETER_ENTRY) {
// Don't call the interpreter entry directly, otherwise we cannot
// disable the breakpoint later by patching the exported code.
return Handle<Code>::null();
}
if (target->kind() != Code::WASM_FUNCTION &&
target->kind() != Code::WASM_TO_JS_FUNCTION)
target->kind() != Code::WASM_TO_JS_FUNCTION &&
target->kind() != Code::WASM_INTERPRETER_ENTRY)
continue;
// There should only be this one call to wasm code.
#ifdef DEBUG
for (it.next(); !it.done(); it.next()) {
Code* code = Code::GetCodeFromTargetAddress(it.rinfo()->target_address());
DCHECK(code->kind() != Code::WASM_FUNCTION &&
code->kind() != Code::WASM_TO_JS_FUNCTION);
code->kind() != Code::WASM_TO_JS_FUNCTION &&
code->kind() != Code::WASM_INTERPRETER_ENTRY);
}
#endif
return handle(target);
......@@ -901,10 +898,7 @@ Handle<Code> CompileImportWrapper(Isolate* isolate, int index, FunctionSig* sig,
if (!sig->Equals(other_func->sig)) return Handle<Code>::null();
// Signature matched. Unwrap the JS->WASM wrapper and return the raw
// WASM function code.
Handle<Code> code = UnwrapImportWrapper(target);
// If we got no code (imported function is being debugged), fall through
// to CompileWasmToJSWrapper.
if (!code.is_null()) return code;
return UnwrapImportWrapper(target);
}
// No wasm function or being debugged. Compile a new wrapper for the new
// signature.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment