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

Unified Diff: src/a64/lithium-gap-resolver-a64.cc

Issue 148293020: Merge experimental/a64 to bleeding_edge. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove ARM from OWNERS Created 6 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/a64/lithium-gap-resolver-a64.h ('k') | src/a64/macro-assembler-a64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/a64/lithium-gap-resolver-a64.cc
diff --git a/src/arm/lithium-gap-resolver-arm.cc b/src/a64/lithium-gap-resolver-a64.cc
similarity index 56%
copy from src/arm/lithium-gap-resolver-arm.cc
copy to src/a64/lithium-gap-resolver-a64.cc
index 0c6b2adadfdf45c549f1b7c749fc00def5d7172f..7c6c9b216345a637f4271249579b900394bd1b00 100644
--- a/src/arm/lithium-gap-resolver-arm.cc
+++ b/src/a64/lithium-gap-resolver-a64.cc
@@ -1,4 +1,4 @@
-// Copyright 2012 the V8 project authors. All rights reserved.
+// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -27,46 +27,62 @@
#include "v8.h"
-#include "arm/lithium-gap-resolver-arm.h"
-#include "arm/lithium-codegen-arm.h"
+#include "a64/lithium-gap-resolver-a64.h"
+#include "a64/lithium-codegen-a64.h"
namespace v8 {
namespace internal {
-static const Register kSavedValueRegister = { 9 };
+// We use the root register to spill a value while breaking a cycle in parallel
+// moves. We don't need access to roots while resolving the move list and using
+// the root register has two advantages:
+// - It is not in crankshaft allocatable registers list, so it can't interfere
+// with any of the moves we are resolving.
+// - We don't need to push it on the stack, as we can reload it with its value
+// once we have resolved a cycle.
+#define kSavedValue root
LGapResolver::LGapResolver(LCodeGen* owner)
: cgen_(owner), moves_(32, owner->zone()), root_index_(0), in_cycle_(false),
- saved_destination_(NULL) { }
+ saved_destination_(NULL), need_to_restore_root_(false) { }
+#define __ ACCESS_MASM(cgen_->masm())
+
void LGapResolver::Resolve(LParallelMove* parallel_move) {
ASSERT(moves_.is_empty());
+
// Build up a worklist of moves.
BuildInitialMoveList(parallel_move);
for (int i = 0; i < moves_.length(); ++i) {
LMoveOperands move = moves_[i];
- // Skip constants to perform them last. They don't block other moves
+
+ // Skip constants to perform them last. They don't block other moves
// and skipping such moves with register destinations keeps those
// registers free for the whole algorithm.
if (!move.IsEliminated() && !move.source()->IsConstantOperand()) {
- root_index_ = i; // Any cycle is found when by reaching this move again.
+ root_index_ = i; // Any cycle is found when we reach this move again.
PerformMove(i);
- if (in_cycle_) {
- RestoreValue();
- }
+ if (in_cycle_) RestoreValue();
}
}
// Perform the moves with constant sources.
for (int i = 0; i < moves_.length(); ++i) {
- if (!moves_[i].IsEliminated()) {
- ASSERT(moves_[i].source()->IsConstantOperand());
+ LMoveOperands move = moves_[i];
+
+ if (!move.IsEliminated()) {
+ ASSERT(move.source()->IsConstantOperand());
EmitMove(i);
}
}
+ if (need_to_restore_root_) {
+ ASSERT(kSavedValue.Is(root));
+ __ InitializeRootRegister();
+ }
+
moves_.Rewind(0);
}
@@ -87,31 +103,23 @@ void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) {
void LGapResolver::PerformMove(int index) {
// Each call to this function performs a move and deletes it from the move
- // graph. We first recursively perform any move blocking this one. We
+ // graph. We first recursively perform any move blocking this one. We
// mark a move as "pending" on entry to PerformMove in order to detect
// cycles in the move graph.
+ LMoveOperands& current_move = moves_[index];
- // We can only find a cycle, when doing a depth-first traversal of moves,
- // be encountering the starting move again. So by spilling the source of
- // the starting move, we break the cycle. All moves are then unblocked,
- // and the starting move is completed by writing the spilled value to
- // its destination. All other moves from the spilled source have been
- // completed prior to breaking the cycle.
- // An additional complication is that moves to MemOperands with large
- // offsets (more than 1K or 4K) require us to spill this spilled value to
- // the stack, to free up the register.
- ASSERT(!moves_[index].IsPending());
- ASSERT(!moves_[index].IsRedundant());
+ ASSERT(!current_move.IsPending());
+ ASSERT(!current_move.IsRedundant());
// Clear this move's destination to indicate a pending move. The actual
- // destination is saved in a stack allocated local. Multiple moves can
+ // destination is saved in a stack allocated local. Multiple moves can
// be pending because this function is recursive.
- ASSERT(moves_[index].source() != NULL); // Or else it will look eliminated.
- LOperand* destination = moves_[index].destination();
- moves_[index].set_destination(NULL);
+ ASSERT(current_move.source() != NULL); // Otherwise it will look eliminated.
+ LOperand* destination = current_move.destination();
+ current_move.set_destination(NULL);
// Perform a depth-first traversal of the move graph to resolve
- // dependencies. Any unperformed, unpending move with a source the same
+ // dependencies. Any unperformed, unpending move with a source the same
// as this one's destination blocks this one so recursively perform all
// such moves.
for (int i = 0; i < moves_.length(); ++i) {
@@ -126,7 +134,7 @@ void LGapResolver::PerformMove(int index) {
// We are about to resolve this move and don't need it marked as
// pending, so restore its destination.
- moves_[index].set_destination(destination);
+ current_move.set_destination(destination);
// The move may be blocked on a pending move, which must be the starting move.
// In this case, we have a cycle, and we save the source of this move to
@@ -155,29 +163,44 @@ void LGapResolver::Verify() {
#endif
}
-#define __ ACCESS_MASM(cgen_->masm())
void LGapResolver::BreakCycle(int index) {
- // We save in a register the value that should end up in the source of
- // moves_[root_index]. After performing all moves in the tree rooted
- // in that move, we save the value to that source.
ASSERT(moves_[index].destination()->Equals(moves_[root_index_].source()));
ASSERT(!in_cycle_);
+
+ // We use a register which is not allocatable by crankshaft to break the cycle
+ // to be sure it doesn't interfere with the moves we are resolving.
+ ASSERT(!kSavedValue.IsAllocatable());
+ need_to_restore_root_ = true;
+
+ // We save in a register the source of that move and we remember its
+ // destination. Then we mark this move as resolved so the cycle is
+ // broken and we can perform the other moves.
in_cycle_ = true;
LOperand* source = moves_[index].source();
saved_destination_ = moves_[index].destination();
+
if (source->IsRegister()) {
- __ mov(kSavedValueRegister, cgen_->ToRegister(source));
+ __ Mov(kSavedValue, cgen_->ToRegister(source));
} else if (source->IsStackSlot()) {
- __ ldr(kSavedValueRegister, cgen_->ToMemOperand(source));
+ __ Ldr(kSavedValue, cgen_->ToMemOperand(source));
} else if (source->IsDoubleRegister()) {
- __ vmov(kScratchDoubleReg, cgen_->ToDoubleRegister(source));
+ // TODO(all): We should use a double register to store the value to avoid
+ // the penalty of the mov across register banks. We are going to reserve
+ // d31 to hold 0.0 value. We could clobber this register while breaking the
+ // cycle and restore it after like we do with the root register.
+ // LGapResolver::RestoreValue() will need to be updated as well when we'll
+ // do that.
+ __ Fmov(kSavedValue, cgen_->ToDoubleRegister(source));
} else if (source->IsDoubleStackSlot()) {
- __ vldr(kScratchDoubleReg, cgen_->ToMemOperand(source));
+ __ Ldr(kSavedValue, cgen_->ToMemOperand(source));
} else {
UNREACHABLE();
}
- // This move will be done by restoring the saved value to the destination.
+
+ // Mark this move as resolved.
+ // This move will be actually performed by moving the saved value to this
+ // move's destination in LGapResolver::RestoreValue().
moves_[index].Eliminate();
}
@@ -186,15 +209,14 @@ void LGapResolver::RestoreValue() {
ASSERT(in_cycle_);
ASSERT(saved_destination_ != NULL);
- // Spilled value is in kSavedValueRegister or kSavedDoubleValueRegister.
if (saved_destination_->IsRegister()) {
- __ mov(cgen_->ToRegister(saved_destination_), kSavedValueRegister);
+ __ Mov(cgen_->ToRegister(saved_destination_), kSavedValue);
} else if (saved_destination_->IsStackSlot()) {
- __ str(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_));
+ __ Str(kSavedValue, cgen_->ToMemOperand(saved_destination_));
} else if (saved_destination_->IsDoubleRegister()) {
- __ vmov(cgen_->ToDoubleRegister(saved_destination_), kScratchDoubleReg);
+ __ Fmov(cgen_->ToDoubleRegister(saved_destination_), kSavedValue);
} else if (saved_destination_->IsDoubleStackSlot()) {
- __ vstr(kScratchDoubleReg, cgen_->ToMemOperand(saved_destination_));
+ __ Str(kSavedValue, cgen_->ToMemOperand(saved_destination_));
} else {
UNREACHABLE();
}
@@ -214,105 +236,90 @@ void LGapResolver::EmitMove(int index) {
if (source->IsRegister()) {
Register source_register = cgen_->ToRegister(source);
if (destination->IsRegister()) {
- __ mov(cgen_->ToRegister(destination), source_register);
+ __ Mov(cgen_->ToRegister(destination), source_register);
} else {
ASSERT(destination->IsStackSlot());
- __ str(source_register, cgen_->ToMemOperand(destination));
+ __ Str(source_register, cgen_->ToMemOperand(destination));
}
+
} else if (source->IsStackSlot()) {
MemOperand source_operand = cgen_->ToMemOperand(source);
if (destination->IsRegister()) {
- __ ldr(cgen_->ToRegister(destination), source_operand);
+ __ Ldr(cgen_->ToRegister(destination), source_operand);
} else {
ASSERT(destination->IsStackSlot());
- MemOperand destination_operand = cgen_->ToMemOperand(destination);
- if (in_cycle_) {
- if (!destination_operand.OffsetIsUint12Encodable()) {
- // ip is overwritten while saving the value to the destination.
- // Therefore we can't use ip. It is OK if the read from the source
- // destroys ip, since that happens before the value is read.
- __ vldr(kScratchDoubleReg.low(), source_operand);
- __ vstr(kScratchDoubleReg.low(), destination_operand);
- } else {
- __ ldr(ip, source_operand);
- __ str(ip, destination_operand);
- }
- } else {
- __ ldr(kSavedValueRegister, source_operand);
- __ str(kSavedValueRegister, destination_operand);
- }
+ EmitStackSlotMove(index);
}
} else if (source->IsConstantOperand()) {
LConstantOperand* constant_source = LConstantOperand::cast(source);
if (destination->IsRegister()) {
Register dst = cgen_->ToRegister(destination);
- Representation r = cgen_->IsSmi(constant_source)
- ? Representation::Smi() : Representation::Integer32();
- if (cgen_->IsInteger32(constant_source)) {
- __ mov(dst, Operand(cgen_->ToRepresentation(constant_source, r)));
+ if (cgen_->IsSmi(constant_source)) {
+ __ Mov(dst, Operand(cgen_->ToSmi(constant_source)));
+ } else if (cgen_->IsInteger32Constant(constant_source)) {
+ __ Mov(dst, cgen_->ToInteger32(constant_source));
} else {
- __ Move(dst, cgen_->ToHandle(constant_source));
+ __ LoadObject(dst, cgen_->ToHandle(constant_source));
}
} else if (destination->IsDoubleRegister()) {
- DwVfpRegister result = cgen_->ToDoubleRegister(destination);
- double v = cgen_->ToDouble(constant_source);
- __ Vmov(result, v, ip);
+ DoubleRegister result = cgen_->ToDoubleRegister(destination);
+ __ Fmov(result, cgen_->ToDouble(constant_source));
} else {
ASSERT(destination->IsStackSlot());
ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone.
- Representation r = cgen_->IsSmi(constant_source)
- ? Representation::Smi() : Representation::Integer32();
- if (cgen_->IsInteger32(constant_source)) {
- __ mov(kSavedValueRegister,
- Operand(cgen_->ToRepresentation(constant_source, r)));
+ need_to_restore_root_ = true;
+ if (cgen_->IsSmi(constant_source)) {
+ __ Mov(kSavedValue, Operand(cgen_->ToSmi(constant_source)));
+ } else if (cgen_->IsInteger32Constant(constant_source)) {
+ __ Mov(kSavedValue, cgen_->ToInteger32(constant_source));
} else {
- __ Move(kSavedValueRegister,
- cgen_->ToHandle(constant_source));
+ __ LoadObject(kSavedValue, cgen_->ToHandle(constant_source));
}
- __ str(kSavedValueRegister, cgen_->ToMemOperand(destination));
+ __ Str(kSavedValue, cgen_->ToMemOperand(destination));
}
} else if (source->IsDoubleRegister()) {
- DwVfpRegister source_register = cgen_->ToDoubleRegister(source);
+ DoubleRegister src = cgen_->ToDoubleRegister(source);
if (destination->IsDoubleRegister()) {
- __ vmov(cgen_->ToDoubleRegister(destination), source_register);
+ __ Fmov(cgen_->ToDoubleRegister(destination), src);
} else {
ASSERT(destination->IsDoubleStackSlot());
- __ vstr(source_register, cgen_->ToMemOperand(destination));
+ __ Str(src, cgen_->ToMemOperand(destination));
}
} else if (source->IsDoubleStackSlot()) {
- MemOperand source_operand = cgen_->ToMemOperand(source);
+ MemOperand src = cgen_->ToMemOperand(source);
if (destination->IsDoubleRegister()) {
- __ vldr(cgen_->ToDoubleRegister(destination), source_operand);
+ __ Ldr(cgen_->ToDoubleRegister(destination), src);
} else {
ASSERT(destination->IsDoubleStackSlot());
- MemOperand destination_operand = cgen_->ToMemOperand(destination);
- if (in_cycle_) {
- // kSavedDoubleValueRegister was used to break the cycle,
- // but kSavedValueRegister is free.
- MemOperand source_high_operand =
- cgen_->ToHighMemOperand(source);
- MemOperand destination_high_operand =
- cgen_->ToHighMemOperand(destination);
- __ ldr(kSavedValueRegister, source_operand);
- __ str(kSavedValueRegister, destination_operand);
- __ ldr(kSavedValueRegister, source_high_operand);
- __ str(kSavedValueRegister, destination_high_operand);
- } else {
- __ vldr(kScratchDoubleReg, source_operand);
- __ vstr(kScratchDoubleReg, destination_operand);
- }
+ EmitStackSlotMove(index);
}
+
} else {
UNREACHABLE();
}
+ // The move has been emitted, we can eliminate it.
moves_[index].Eliminate();
}
-#undef __
+void LGapResolver::EmitStackSlotMove(int index) {
+ // We need a temp register to perform a stack slot to stack slot move, and
+ // the register must not be involved in breaking cycles.
+
+ // Use the Crankshaft double scratch register as the temporary.
+ DoubleRegister temp = crankshaft_fp_scratch;
+
+ LOperand* src = moves_[index].source();
+ LOperand* dst = moves_[index].destination();
+
+ ASSERT(src->IsStackSlot());
+ ASSERT(dst->IsStackSlot());
+ __ Ldr(temp, cgen_->ToMemOperand(src));
+ __ Str(temp, cgen_->ToMemOperand(dst));
+}
} } // namespace v8::internal
« no previous file with comments | « src/a64/lithium-gap-resolver-a64.h ('k') | src/a64/macro-assembler-a64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698