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

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

Issue 2403093002: [wasm] Canonicalize function signature indices for matching in indirect calls. (Closed)
Patch Set: Add TODO for myself 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
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 const WasmIndirectFunctionTable* table =
Clemens Hammacher 2016/10/10 17:35:03 Maybe place a TODO to think about caching this ins
titzer 2016/10/10 17:45:21 Added a TODO here.
1424 &module()->function_tables[0];
1425 int function_key = table->map_.Find(target->function->sig);
1426 if (function_key < 0 ||
1427 (function_key !=
1428 table->map_.Find(module()->signatures[operand.index]))) {
1429 return DoTrap(kTrapFuncSigMismatch, pc);
1430 }
1423 } 1431 }
1424 1432
1425 DoCall(target, &pc, pc + 1 + operand.length, &limit); 1433 DoCall(target, &pc, pc + 1 + operand.length, &limit);
1426 code = target; 1434 code = target;
1427 decoder.Reset(code->start, code->end); 1435 decoder.Reset(code->start, code->end);
1428 continue; 1436 continue;
1429 } 1437 }
1430 case kExprGetGlobal: { 1438 case kExprGetGlobal: {
1431 GlobalIndexOperand operand(&decoder, code->at(pc)); 1439 GlobalIndexOperand operand(&decoder, code->at(pc));
1432 const WasmGlobal* global = &module()->globals[operand.index]; 1440 const WasmGlobal* global = &module()->globals[operand.index];
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 1843
1836 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( 1844 ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting(
1837 Zone* zone, const byte* start, const byte* end) { 1845 Zone* zone, const byte* start, const byte* end) {
1838 ControlTransfers targets(zone, nullptr, nullptr, start, end); 1846 ControlTransfers targets(zone, nullptr, nullptr, start, end);
1839 return targets.map_; 1847 return targets.map_;
1840 } 1848 }
1841 1849
1842 } // namespace wasm 1850 } // namespace wasm
1843 } // namespace internal 1851 } // namespace internal
1844 } // namespace v8 1852 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698