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

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

Issue 2288773002: [wasm] Check the input of grow-memory before calling the runtime. (Closed)
Patch Set: Comments. Created 4 years, 4 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/runtime/runtime-wasm.cc » ('j') | no next file with comments »
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 30c545ec515bb07c2459b52b11dc25d3e1fcedd9..cfeac987eb8ac472303f4262add81cac1015e728 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -1668,13 +1668,18 @@ Node* WasmGraphBuilder::BuildFloatToIntConversionInstruction(
}
Node* WasmGraphBuilder::BuildGrowMemory(Node* input) {
+ Diamond check_input_range(
+ graph(), jsgraph()->common(),
+ graph()->NewNode(
+ jsgraph()->machine()->Uint32LessThanOrEqual(), input,
+ jsgraph()->Uint32Constant(wasm::WasmModule::kMaxMemPages)),
+ BranchHint::kTrue);
+
Runtime::FunctionId function_id = Runtime::kWasmGrowMemory;
const Runtime::Function* function = Runtime::FunctionForId(function_id);
CallDescriptor* desc = Linkage::GetRuntimeCallDescriptor(
jsgraph()->zone(), function_id, function->nargs, Operator::kNoThrow,
CallDescriptor::kNoFlags);
- Node** control_ptr = control_;
- Node** effect_ptr = effect_;
wasm::ModuleEnv* module = module_;
input = BuildChangeUint32ToSmi(input);
Node* inputs[] = {
@@ -1683,13 +1688,19 @@ Node* WasmGraphBuilder::BuildGrowMemory(Node* input) {
ExternalReference(function_id, jsgraph()->isolate())), // ref
jsgraph()->Int32Constant(function->nargs), // arity
jsgraph()->HeapConstant(module->instance->context), // context
- *effect_ptr,
- *control_ptr};
- Node* node = graph()->NewNode(jsgraph()->common()->Call(desc),
+ *effect_,
+ check_input_range.if_true};
+ Node* call = graph()->NewNode(jsgraph()->common()->Call(desc),
static_cast<int>(arraysize(inputs)), inputs);
- *effect_ptr = node;
- node = BuildChangeSmiToInt32(node);
- return node;
+
+ Node* result = BuildChangeSmiToInt32(call);
+
+ result = check_input_range.Phi(MachineRepresentation::kWord32, result,
+ jsgraph()->Int32Constant(-1));
+ *effect_ = graph()->NewNode(jsgraph()->common()->EffectPhi(2), call, *effect_,
+ check_input_range.merge);
+ *control_ = check_input_range.merge;
+ return result;
}
Node* WasmGraphBuilder::BuildI32DivS(Node* left, Node* right,
« no previous file with comments | « no previous file | src/runtime/runtime-wasm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698