| Index: src/compiler/gap-resolver.cc
|
| diff --git a/src/compiler/gap-resolver.cc b/src/compiler/gap-resolver.cc
|
| index 7c397002cb59e6c51efcfebd896a70561448d4c0..4af4a665a385751c4309e3721a1e73f3e5dd8cca 100644
|
| --- a/src/compiler/gap-resolver.cc
|
| +++ b/src/compiler/gap-resolver.cc
|
| @@ -8,6 +8,8 @@
|
| #include <functional>
|
| #include <set>
|
|
|
| +#include "src/base/adapters.h"
|
| +
|
| namespace v8 {
|
| namespace internal {
|
| namespace compiler {
|
| @@ -34,6 +36,90 @@ void GapResolver::Resolve(ParallelMove* moves) const {
|
| }
|
| }
|
|
|
| +namespace {
|
| +
|
| +bool IsValidPush(InstructionOperand source,
|
| + GapResolver::PushTypeFlags push_type) {
|
| + if (source.IsImmediate() &&
|
| + ((push_type & GapResolver::kImmediatePush) != 0)) {
|
| + return true;
|
| + }
|
| + if ((source.IsRegister() || source.IsStackSlot()) &&
|
| + ((push_type & GapResolver::kScalarPush) != 0)) {
|
| + return true;
|
| + }
|
| + if ((source.IsFloatRegister() || source.IsFloatStackSlot()) &&
|
| + ((push_type & GapResolver::kFloat32Push) != 0)) {
|
| + return true;
|
| + }
|
| + if ((source.IsDoubleRegister() || source.IsFloatStackSlot()) &&
|
| + ((push_type & GapResolver::kFloat64Push) != 0)) {
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +void GapResolver::GetPushCompatibleMoves(Zone* zone, Instruction* instr,
|
| + PushTypeFlags push_type,
|
| + ZoneVector<MoveOperands*>* pushes) {
|
| + pushes->clear();
|
| + for (int i = Instruction::FIRST_GAP_POSITION;
|
| + i <= Instruction::LAST_GAP_POSITION; ++i) {
|
| + Instruction::GapPosition inner_pos =
|
| + static_cast<Instruction::GapPosition>(i);
|
| + ParallelMove* parallel_move = instr->GetParallelMove(inner_pos);
|
| + if (parallel_move != nullptr) {
|
| + for (auto move : *parallel_move) {
|
| + InstructionOperand source = move->source();
|
| + InstructionOperand destination = move->destination();
|
| + int first_push_compatible_index =
|
| + V8_TARGET_ARCH_STORES_RETURN_ADDRESS_ON_STACK ? 1 : 0;
|
| + // If there are any moves from slots that will be overridden by pushes,
|
| + // then the full gap resolver must be used since optimization with
|
| + // pushes don't participate in the parallel move and might clobber
|
| + // values needed for the gap resolve.
|
| + if (source.IsStackSlot() &&
|
| + LocationOperand::cast(source).index() >=
|
| + first_push_compatible_index) {
|
| + pushes->clear();
|
| + return;
|
| + }
|
| + // TODO(danno): Right now, only consider moves from the FIRST gap for
|
| + // pushes. Theoretically, we could extract pushes for both gaps (there
|
| + // are cases where this happens), but the logic for that would also have
|
| + // to check to make sure that non-memory inputs to the pushes from the
|
| + // LAST gap don't get clobbered in the FIRST gap.
|
| + if (i == Instruction::FIRST_GAP_POSITION) {
|
| + if (destination.IsStackSlot() &&
|
| + LocationOperand::cast(destination).index() >=
|
| + first_push_compatible_index) {
|
| + int index = LocationOperand::cast(destination).index();
|
| + if (IsValidPush(source, push_type)) {
|
| + if (index >= static_cast<int>(pushes->size())) {
|
| + pushes->resize(index + 1);
|
| + }
|
| + (*pushes)[index] = move;
|
| + }
|
| + }
|
| + }
|
| + }
|
| + }
|
| + }
|
| +
|
| + // For now, only support a set of continuous pushes at the end of the list.
|
| + size_t push_count_upper_bound = pushes->size();
|
| + size_t push_begin = push_count_upper_bound;
|
| + for (auto move : base::Reversed(*pushes)) {
|
| + if (move == nullptr) break;
|
| + push_begin--;
|
| + }
|
| + size_t push_count = pushes->size() - push_begin;
|
| + std::copy(pushes->begin() + push_begin,
|
| + pushes->begin() + push_begin + push_count, pushes->begin());
|
| + pushes->resize(push_count);
|
| +}
|
|
|
| void GapResolver::PerformMove(ParallelMove* moves, MoveOperands* move) const {
|
| // Each call to this function performs a move and deletes it from the move
|
|
|