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

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

Issue 2691993004: [wasm] Introduce WasmStackGuard builtin (Closed)
Patch Set: Rebase 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
« no previous file with comments | « src/builtins/builtins-wasm.cc ('k') | src/interface-descriptors.h » ('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 b461e2fab7c90eca9823f5180241620a856b53fb..5e6a900ee093cb05236994d19c29bb556890f777 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,
@@ -3004,7 +3008,7 @@ void WasmGraphBuilder::BuildWasmInterpreterEntry(
arg_buffer, // argument buffer
};
BuildCallToRuntime(Runtime::kWasmRunInterpreter, jsgraph(),
- jsgraph()->isolate()->native_context(), parameters,
+ instance->compiled_module()->native_context(), parameters,
arraysize(parameters), effect_, *control_);
// Read back the return value.
« no previous file with comments | « src/builtins/builtins-wasm.cc ('k') | src/interface-descriptors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698