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

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

Issue 2691993004: [wasm] Introduce WasmStackGuard builtin (Closed)
Patch Set: Add builtins-wasm.cc ;) Created 3 years, 10 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
Index: src/compiler/wasm-compiler.cc
diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
index 9754bd6805f716748a8a25dc7ae256aa6ff46990..dd5f735b29491a523d1a79889d378adcb66c2f74 100644
--- a/src/compiler/wasm-compiler.cc
+++ b/src/compiler/wasm-compiler.cc
@@ -474,40 +474,44 @@ Node* WasmGraphBuilder::Int64Constant(int64_t value) {
void WasmGraphBuilder::StackCheck(wasm::WasmCodePosition position,
Node** effect, Node** control) {
if (FLAG_wasm_no_stack_checks) return;
- if (effect == nullptr) {
- effect = effect_;
- }
- if (control == nullptr) {
- control = control_;
- }
// We do not generate stack checks for cctests.
- if (module_ && !module_->instance->context.is_null()) {
- Node* limit = graph()->NewNode(
- jsgraph()->machine()->Load(MachineType::Pointer()),
- jsgraph()->ExternalConstant(
- ExternalReference::address_of_stack_limit(jsgraph()->isolate())),
- jsgraph()->IntPtrConstant(0), *effect, *control);
- Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer());
-
- Node* check =
- graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer);
-
- Diamond stack_check(graph(), jsgraph()->common(), check, BranchHint::kTrue);
- stack_check.Chain(*control);
- Node* effect_true = *effect;
-
- // Generate a call to the runtime if there is a stack check failure.
- Node* call = BuildCallToRuntime(Runtime::kStackGuard, jsgraph(),
- module_->instance->context, nullptr, 0,
- effect, stack_check.if_false);
- SetSourcePosition(call, position);
-
- Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2),
- effect_true, call, stack_check.merge);
-
- *control = stack_check.merge;
- *effect = ephi;
- }
+ if (!module_ || module_->instance->context.is_null()) return;
+ if (effect == nullptr) effect = effect_;
+ if (control == nullptr) control = control_;
+
+ Node* limit = graph()->NewNode(
+ jsgraph()->machine()->Load(MachineType::Pointer()),
+ jsgraph()->ExternalConstant(
+ ExternalReference::address_of_stack_limit(jsgraph()->isolate())),
+ jsgraph()->IntPtrConstant(0), *effect, *control);
+ Node* pointer = graph()->NewNode(jsgraph()->machine()->LoadStackPointer());
+
+ Node* check =
+ graph()->NewNode(jsgraph()->machine()->UintLessThan(), limit, pointer);
+
+ Diamond stack_check(graph(), jsgraph()->common(), check, BranchHint::kTrue);
+ stack_check.Chain(*control);
+ Node* effect_true = *effect;
+
+ Handle<Code> code = jsgraph()->isolate()->builtins()->WasmStackGuard();
+ CallInterfaceDescriptor idesc =
+ WasmStackGuardDescriptor(jsgraph()->isolate());
+ CallDescriptor* desc = Linkage::GetStubCallDescriptor(
+ jsgraph()->isolate(), jsgraph()->zone(), idesc, 0,
+ CallDescriptor::kNoFlags, Operator::kNoProperties);
+ Node* stub_code = jsgraph()->HeapConstant(code);
+
+ Node* context = jsgraph()->SmiConstant(0);
+ Node* call = graph()->NewNode(jsgraph()->common()->Call(desc), stub_code,
+ context, *effect, stack_check.if_false);
+
+ SetSourcePosition(call, position);
+
+ Node* ephi = graph()->NewNode(jsgraph()->common()->EffectPhi(2), effect_true,
+ call, stack_check.merge);
+
+ *control = stack_check.merge;
+ *effect = ephi;
}
Node* WasmGraphBuilder::Binop(wasm::WasmOpcode opcode, Node* left, Node* right,

Powered by Google App Engine
This is Rietveld 408576698