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

Unified Diff: src/compiler/x64/code-generator-x64.cc

Issue 2301833004: [wasm] Trap handling: ProtectedLoad instruction (Closed)
Patch Set: Manual Created 4 years, 3 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/x64/code-generator-x64.cc
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc
index 4c2f6e80dfb78459a22684bf2c7ab9168ca14188..09eda881e6463f31c2ee4799889d3635cdf07ddd 100644
--- a/src/compiler/x64/code-generator-x64.cc
+++ b/src/compiler/x64/code-generator-x64.cc
@@ -9,6 +9,7 @@
#include "src/compiler/gap-resolver.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/osr.h"
+#include "src/wasm/wasm-module.h"
#include "src/x64/assembler-x64.h"
#include "src/x64/macro-assembler-x64.h"
@@ -260,6 +261,40 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
RecordWriteMode const mode_;
};
+class WasmOutOfLineTrap final : public OutOfLineCode {
+ public:
+ WasmOutOfLineTrap(CodeGenerator* gen, Address pc, bool needs_frame,
+ Register context, int32_t position)
+ : OutOfLineCode(gen),
+ pc_(pc),
+ needs_frame_(needs_frame),
+ context_(context),
+ position_(position) {}
+
+ void Generate() final {
+ // TODO(eholk): record pc_ and the current pc in a table so that
+ // the signal handler can find it.
+ USE(pc_);
+
+ if (needs_frame_) {
+ __ EnterFrame(StackFrame::WASM);
+ }
+
+ wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds;
+ int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id);
+ __ Push(Smi::FromInt(trap_reason));
+ __ Push(Smi::FromInt(position_));
+ __ Move(rsi, context_);
+ __ CallRuntime(Runtime::kThrowWasmError);
+ }
+
+ private:
+ Address pc_;
+ bool needs_frame_;
+ Register context_;
+ int32_t position_;
+};
+
} // namespace
@@ -1849,6 +1884,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
case kX64Movl:
+ case kX64TrapMovl:
if (instr->HasOutput()) {
if (instr->addressing_mode() == kMode_None) {
if (instr->InputAt(0)->IsRegister()) {
@@ -1857,7 +1893,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ movl(i.OutputRegister(), i.InputOperand(0));
}
} else {
+ Address pc = __ pc();
__ movl(i.OutputRegister(), i.MemoryOperand());
+
+ if (arch_opcode == kX64TrapMovl) {
+ bool needs_frame = !frame_access_state()->has_frame();
titzer 2016/09/08 17:06:35 Can we invert the sense of this and just call it f
Eric Holk 2016/09/08 21:11:56 Isn't inverting the sense at odds with calling it
titzer 2016/09/09 15:36:56 Yes, you are correct, sir!
+ new (zone()) WasmOutOfLineTrap(this, pc, needs_frame,
+ i.InputRegister(2), i.InputInt32(3));
+ }
}
__ AssertZeroExtended(i.OutputRegister());
} else {

Powered by Google App Engine
This is Rietveld 408576698