|
20 | 20 | #include "src/wasm/wasm-constants.h"
|
21 | 21 | #include "src/wasm/wasm-debug.h"
|
22 | 22 | #include "src/wasm/wasm-engine.h"
|
| 23 | +#include "src/wasm/wasm-module.h" |
23 | 24 | #include "src/wasm/wasm-objects.h"
|
24 | 25 | #include "src/wasm/wasm-subtyping.h"
|
25 | 26 | #include "src/wasm/wasm-value.h"
|
@@ -470,10 +471,29 @@ RUNTIME_FUNCTION(Runtime_TierUpWasmToJSWrapper) {
|
470 | 471 | instance = handle(WasmInstanceObject::cast(tuple->value1()), isolate);
|
471 | 472 | origin = handle(tuple->value2(), isolate);
|
472 | 473 | }
|
473 |
| - // Get the function's canonical signature index. Note that the function's |
474 |
| - // signature may not be present in the importing module. |
475 |
| - uint32_t canonical_sig_index = |
476 |
| - wasm::GetTypeCanonicalizer()->AddRecursiveGroup(&sig); |
| 474 | + |
| 475 | + uint32_t canonical_sig_index = std::numeric_limits<uint32_t>::max(); |
| 476 | + const wasm::WasmModule* module = instance->module(); |
| 477 | + if (WasmApiFunctionRef::CallOriginIsImportIndex(origin)) { |
| 478 | + int func_index = WasmApiFunctionRef::CallOriginAsIndex(origin); |
| 479 | + canonical_sig_index = |
| 480 | + module->isorecursive_canonical_type_ids[module->functions[func_index] |
| 481 | + .sig_index]; |
| 482 | + } else { |
| 483 | + // Indirect function table index. |
| 484 | + int entry_index = WasmApiFunctionRef::CallOriginAsIndex(origin); |
| 485 | + int table_count = instance->indirect_function_tables()->length(); |
| 486 | + // We have to find the table which contains the correct entry. |
| 487 | + for (int table_index = 0; table_index < table_count; ++table_index) { |
| 488 | + Handle<WasmIndirectFunctionTable> table = |
| 489 | + instance->GetIndirectFunctionTable(isolate, table_index); |
| 490 | + if (table->refs()->get(entry_index) == *ref) { |
| 491 | + canonical_sig_index = table->sig_ids()->get(entry_index); |
| 492 | + break; |
| 493 | + } |
| 494 | + } |
| 495 | + } |
| 496 | + DCHECK_NE(canonical_sig_index, std::numeric_limits<uint32_t>::max()); |
477 | 497 |
|
478 | 498 | // Compile a wrapper for the target callable.
|
479 | 499 | Handle<JSReceiver> callable(JSReceiver::cast(ref->callable()), isolate);
|
|
0 commit comments