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

Unified Diff: src/compiler/code-generator.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/code-generator.h ('k') | src/compiler/code-generator-impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/code-generator.cc
diff --git a/src/compiler/code-generator.cc b/src/compiler/code-generator.cc
index 3a56ece0c0cf794fe97a4a53ea562d875d2df43d..67dd1eca293655a597f0713406211a0f23f11511 100644
--- a/src/compiler/code-generator.cc
+++ b/src/compiler/code-generator.cc
@@ -12,6 +12,24 @@ namespace v8 {
namespace internal {
namespace compiler {
+class CodeGenerator::JumpTable FINAL : public ZoneObject {
+ public:
+ JumpTable(JumpTable* next, Label** targets, size_t target_count)
+ : next_(next), targets_(targets), target_count_(target_count) {}
+
+ Label* label() { return &label_; }
+ JumpTable* next() const { return next_; }
+ Label** targets() const { return targets_; }
+ size_t target_count() const { return target_count_; }
+
+ private:
+ Label label_;
+ JumpTable* const next_;
+ Label** const targets_;
+ size_t const target_count_;
+};
+
+
CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
InstructionSequence* code, CompilationInfo* info)
: frame_(frame),
@@ -28,6 +46,7 @@ CodeGenerator::CodeGenerator(Frame* frame, Linkage* linkage,
deoptimization_literals_(code->zone()),
translations_(code->zone()),
last_lazy_deopt_pc_(0),
+ jump_tables_(nullptr),
ools_(nullptr),
osr_pc_offset_(-1) {
for (int i = 0; i < code->InstructionBlockCount(); ++i) {
@@ -81,7 +100,7 @@ Handle<Code> CodeGenerator::GenerateCode() {
for (OutOfLineCode* ool = ools_; ool; ool = ool->next()) {
masm()->bind(ool->entry());
ool->Generate();
- masm()->jmp(ool->exit());
+ if (ool->exit()->is_bound()) masm()->jmp(ool->exit());
}
}
@@ -95,6 +114,15 @@ Handle<Code> CodeGenerator::GenerateCode() {
FinishCode(masm());
+ // Emit the jump tables.
+ if (jump_tables_) {
+ masm()->Align(kPointerSize);
+ for (JumpTable* table = jump_tables_; table; table = table->next()) {
+ masm()->bind(table->label());
+ AssembleJumpTable(table->targets(), table->target_count());
+ }
+ }
+
safepoints()->Emit(masm(), frame()->GetSpillSlotCount());
// TODO(titzer): what are the right code flags here?
@@ -292,6 +320,12 @@ void CodeGenerator::PopulateDeoptimizationData(Handle<Code> code_object) {
}
+Label* CodeGenerator::AddJumpTable(Label** targets, size_t target_count) {
+ jump_tables_ = new (zone()) JumpTable(jump_tables_, targets, target_count);
+ return jump_tables_->label();
+}
+
+
void CodeGenerator::AddSafepointAndDeopt(Instruction* instr) {
CallDescriptor::Flags flags(MiscField::decode(instr->opcode()));
« no previous file with comments | « src/compiler/code-generator.h ('k') | src/compiler/code-generator-impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698