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

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

Issue 2148743004: WIP: wasm oob trap handling experiments (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Undoing spurious changes Created 3 years, 11 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/compiler/wasm-compiler.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..af2d963dc5c35410dfbc183df17762621b1902f5 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,45 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
RecordWriteMode const mode_;
};
+class OutOfLineTrap final : public OutOfLineCode {
+ public:
+ OutOfLineTrap(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 {
+ const auto landing = __ GetPC();
+
+ // Save the location of this OOL code so the trap handler can find it.
+ const auto offset =
+ reinterpret_cast<intptr_t>(landing) - reinterpret_cast<intptr_t>(pc_);
+ RelocInfo rinfo(isolate(), pc_, RelocInfo::WASM_TRAP_LANDING, offset, NULL);
+ __ RecordRelocInfo(&rinfo);
+
+ if (needs_frame_) {
+ __ EnterFrame(StackFrame::WASM);
+ }
+
+ // TODO(eholk): plumb these two arguments from wasm-compiler.cc
+ auto trap_id = wasm::kTrapMemOutOfBounds;
+ auto 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 +1889,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 +1898,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ movl(i.OutputRegister(), i.InputOperand(0));
}
} else {
+ auto pc = __ GetPC();
__ movl(i.OutputRegister(), i.MemoryOperand());
+
+ if (arch_opcode == kX64TrapMovl) {
+ const auto needs_frame = !frame_access_state()->has_frame();
+ new (zone()) OutOfLineTrap(this, pc, needs_frame,
+ i.InputRegister(2), i.InputInt32(3));
+ }
}
__ AssertZeroExtended(i.OutputRegister());
} else {
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698