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

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

Issue 2484623002: [wasm] Indirect calls without function table cause validation errors. (Closed)
Patch Set: try to export symbols Created 4 years, 1 month 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 | « no previous file | src/wasm/ast-decoder.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/wasm-compiler.h" 5 #include "src/compiler/wasm-compiler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 10
(...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args, 2161 Node* WasmGraphBuilder::CallIndirect(uint32_t sig_index, Node** args,
2162 Node*** rets, 2162 Node*** rets,
2163 wasm::WasmCodePosition position) { 2163 wasm::WasmCodePosition position) {
2164 DCHECK_NOT_NULL(args[0]); 2164 DCHECK_NOT_NULL(args[0]);
2165 DCHECK(module_ && module_->instance); 2165 DCHECK(module_ && module_->instance);
2166 2166
2167 // Assume only one table for now. 2167 // Assume only one table for now.
2168 uint32_t table_index = 0; 2168 uint32_t table_index = 0;
2169 wasm::FunctionSig* sig = module_->GetSignature(sig_index); 2169 wasm::FunctionSig* sig = module_->GetSignature(sig_index);
2170 2170
2171 if (!module_->IsValidTable(table_index)) { 2171 DCHECK(module_->IsValidTable(table_index));
2172 // No function table. Generate a trap and return a constant.
2173 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position);
2174 (*rets) = Buffer(sig->return_count());
2175 for (size_t i = 0; i < sig->return_count(); i++) {
2176 (*rets)[i] = trap_->GetTrapValue(sig->GetReturn(i));
2177 }
2178 return trap_->GetTrapValue(sig);
2179 }
2180 2172
2181 EnsureFunctionTableNodes(); 2173 EnsureFunctionTableNodes();
2182 MachineOperatorBuilder* machine = jsgraph()->machine(); 2174 MachineOperatorBuilder* machine = jsgraph()->machine();
2183 Node* key = args[0]; 2175 Node* key = args[0];
2184 2176
2185 // Bounds check against the table size. 2177 // Bounds check against the table size.
2186 Node* size = function_table_sizes_[table_index]; 2178 Node* size = function_table_sizes_[table_index];
2187 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size); 2179 Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
2188 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position); 2180 trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position);
2189 Node* table = function_tables_[table_index]; 2181 Node* table = function_tables_[table_index];
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 function_->code_start_offset), 3477 function_->code_start_offset),
3486 compile_ms); 3478 compile_ms);
3487 } 3479 }
3488 3480
3489 return code; 3481 return code;
3490 } 3482 }
3491 3483
3492 } // namespace compiler 3484 } // namespace compiler
3493 } // namespace internal 3485 } // namespace internal
3494 } // namespace v8 3486 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/wasm/ast-decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698