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

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

Issue 892513003: [turbofan] Initial support for Switch. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Wuschelstudio build. Created 5 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/compiler/verifier.cc ('k') | src/disassembler.cc » ('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 f5117f292a8cc300c98ec0273e40edb6f473fd7f..bad87b2fff73c65d44e0fc1bb7f90f08d5e1cca9 100644
--- a/src/compiler/x64/code-generator-x64.cc
+++ b/src/compiler/x64/code-generator-x64.cc
@@ -532,6 +532,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
case kArchJmp:
AssembleArchJump(i.InputRpo(0));
break;
+ case kArchSwitch:
+ AssembleArchSwitch(instr);
+ break;
case kArchNop:
// don't emit code for nops.
break;
@@ -1067,6 +1070,19 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) {
}
+void CodeGenerator::AssembleArchSwitch(Instruction* instr) {
+ X64OperandConverter i(this, instr);
+ size_t const label_count = instr->InputCount() - 1;
+ Label** labels = zone()->NewArray<Label*>(static_cast<int>(label_count));
+ for (size_t index = 0; index < label_count; ++index) {
+ labels[index] = GetLabel(i.InputRpo(static_cast<int>(index + 1)));
+ }
+ Label* const table = AddJumpTable(labels, label_count);
+ __ leaq(kScratchRegister, Operand(table));
+ __ jmp(Operand(kScratchRegister, i.InputRegister(0), times_8, 0));
+}
+
+
// Assembles boolean materializations after this instruction.
void CodeGenerator::AssembleArchBoolean(Instruction* instr,
FlagsCondition condition) {
@@ -1380,6 +1396,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source,
}
+void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) {
+ for (size_t index = 0; index < target_count; ++index) {
+ __ dq(targets[index]);
+ }
+}
+
+
void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); }
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698