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

Unified Diff: src/compiler/wasm-compiler.cc

Issue 2049513003: [wasm] Support undefined indirect table entries, behind a flag. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/flag-definitions.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 619e639e1509a2a73e2e0908bd397869838c08f4..e0c2cd23239ff4952c91d77e597d63df0c3cc533 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -1926,10 +1926,28 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
// Bounds check the index.
int table_size = static_cast<int>(module_->FunctionTableSize());
if (table_size > 0) {
- // Bounds check against the table size.
- Node* size = Int32Constant(static_cast<int>(table_size));
- Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
- trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position);
+ if (FLAG_wasm_jit_prototype) {
+ int indirect_table_size =
+ static_cast<int>(module_->instance->function_table->length());
+
+ Node* upper_bound = Int32Constant(indirect_table_size / 2);
+ Node* less_than_upper_bound =
+ graph()->NewNode(machine->Uint32LessThan(), key, upper_bound);
+ trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, less_than_upper_bound,
+ position);
+
+ Node* lower_bound = Int32Constant(indirect_table_size / 2 -
+ module_->instance->padded_entries);
bradn 2016/06/14 02:02:46 Hey Ritesh. Actually this isn't quite right. We do
titzer 2016/06/14 20:58:05 Agree.
bradn 2016/06/14 21:00:25 Actually since it can't run (since we don't know t
+ Node* more_than_lower_bound =
+ graph()->NewNode(machine->Uint32LessThanOrEqual(), lower_bound, key);
+ trap_->AddTrapIfTrue(wasm::kTrapDefaultFuncCall, more_than_lower_bound,
+ position);
+ } else {
+ // Bounds check against the table size.
+ Node* size = Int32Constant(static_cast<int>(table_size));
+ Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size);
+ trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position);
+ }
} else {
// No function table. Generate a trap and return a constant.
trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position);
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | src/flag-definitions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698