Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/wasm/wasm-interpreter.cc

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Address review comments Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/signature-map.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/wasm-interpreter.h" 5 #include "src/wasm/wasm-interpreter.h"
6 6
7 #include "src/utils.h" 7 #include "src/utils.h"
8 #include "src/wasm/ast-decoder.h" 8 #include "src/wasm/ast-decoder.h"
9 #include "src/wasm/decoder.h" 9 #include "src/wasm/decoder.h"
10 #include "src/wasm/wasm-external-refs.h" 10 #include "src/wasm/wasm-external-refs.h"
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 } 1412 }
1413 case kExprCallIndirect: { 1413 case kExprCallIndirect: {
1414 CallIndirectOperand operand(&decoder, code->at(pc)); 1414 CallIndirectOperand operand(&decoder, code->at(pc));
1415 uint32_t entry_index = Pop().to<uint32_t>(); 1415 uint32_t entry_index = Pop().to<uint32_t>();
1416 // Assume only one table for now. 1416 // Assume only one table for now.
1417 DCHECK_LE(module()->function_tables.size(), 1u); 1417 DCHECK_LE(module()->function_tables.size(), 1u);
1418 InterpreterCode* target = codemap()->GetIndirectCode(0, entry_index); 1418 InterpreterCode* target = codemap()->GetIndirectCode(0, entry_index);
1419 if (target == nullptr) { 1419 if (target == nullptr) {
1420 return DoTrap(kTrapFuncInvalid, pc); 1420 return DoTrap(kTrapFuncInvalid, pc);
1421 } else if (target->function->sig_index != operand.index) { 1421 } else if (target->function->sig_index != operand.index) {
1422 return DoTrap(kTrapFuncSigMismatch, pc); 1422 // If not an exact match, we have to do a canonical check.
1423 // TODO(titzer): make this faster with some kind of caching?
1424 const WasmIndirectFunctionTable* table =
1425 &module()->function_tables[0];
1426 int function_key = table->map.Find(target->function->sig);
1427 if (function_key < 0 ||
1428 (function_key !=
1429 table->map.Find(module()->signatures[operand.index]))) {
1430 return DoTrap(kTrapFuncSigMismatch, pc);
1431 }
1423 } 1432 }
1424 1433
1425 DoCall(target, &pc, pc + 1 + operand.length, &limit); 1434 DoCall(target, &pc, pc + 1 + operand.length, &limit);
1426 code = target; 1435 code = target;
1427 decoder.Reset(code->start, code->end); 1436 decoder.Reset(code->start, code->end);
1428 continue; 1437 continue;
1429 } 1438 }
1430 case kExprGetGlobal: { 1439 case kExprGetGlobal: {
1431 GlobalIndexOperand operand(&decoder, code->at(pc)); 1440 GlobalIndexOperand operand(&decoder, code->at(pc));
1432 const WasmGlobal* global = &module()->globals[operand.index]; 1441 const WasmGlobal* global = &module()->globals[operand.index];
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 1844
1836 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1845 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1837 Zone* zone, const byte* start, const byte* end) { 1846 Zone* zone, const byte* start, const byte* end) {
1838 ControlTransfers targets(zone, nullptr, nullptr, start, end); 1847 ControlTransfers targets(zone, nullptr, nullptr, start, end);
1839 return targets.map_; 1848 return targets.map_;
1840 } 1849 }
1841 1850
1842 } // namespace wasm 1851 } // namespace wasm
1843 } // namespace internal 1852 } // namespace internal
1844 } // namespace v8 1853 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/signature-map.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698