Reuse the gap move resolver.
Rather than allocating a fresh gap move resolver for every parallel move, use a single one per Lithium code generator. This avoids always reallocating the temporary zone-allocated lists used by the gap move resolver. Review URL: http://codereview.chromium.org/6128007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6270 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
404fbb5b0b
commit
a7c743d3ac
@ -1,4 +1,4 @@
|
||||
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
// Copyright 2011 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:
|
||||
@ -601,8 +601,8 @@ void LCodeGen::DoParallelMove(LParallelMove* move) {
|
||||
Register core_scratch = scratch0();
|
||||
bool destroys_core_scratch = false;
|
||||
|
||||
LGapResolver resolver(move->move_operands(), &marker_operand);
|
||||
const ZoneList<LMoveOperands>* moves = resolver.ResolveInReverseOrder();
|
||||
const ZoneList<LMoveOperands>* moves =
|
||||
resolver_.Resolve(move->move_operands(), &marker_operand);
|
||||
for (int i = moves->length() - 1; i >= 0; --i) {
|
||||
LMoveOperands move = moves->at(i);
|
||||
LOperand* from = move.from();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
// Copyright 2011 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:
|
||||
@ -239,6 +239,9 @@ class LCodeGen BASE_EMBEDDED {
|
||||
// itself is emitted at the end of the generated code.
|
||||
SafepointTableBuilder safepoints_;
|
||||
|
||||
// Compiler from a set of parallel moves to a sequential list of moves.
|
||||
LGapResolver resolver_;
|
||||
|
||||
friend class LDeferredCode;
|
||||
friend class LEnvironment;
|
||||
friend class SafepointGenerator;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
// Copyright 2011 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:
|
||||
@ -564,8 +564,8 @@ void LCodeGen::DoParallelMove(LParallelMove* move) {
|
||||
Register cpu_scratch = esi;
|
||||
bool destroys_cpu_scratch = false;
|
||||
|
||||
LGapResolver resolver(move->move_operands(), &marker_operand);
|
||||
const ZoneList<LMoveOperands>* moves = resolver.ResolveInReverseOrder();
|
||||
const ZoneList<LMoveOperands>* moves =
|
||||
resolver_.Resolve(move->move_operands(), &marker_operand);
|
||||
for (int i = moves->length() - 1; i >= 0; --i) {
|
||||
LMoveOperands move = moves->at(i);
|
||||
LOperand* from = move.from();
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2010 the V8 project authors. All rights reserved.
|
||||
// Copyright 2011 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:
|
||||
@ -230,6 +230,9 @@ class LCodeGen BASE_EMBEDDED {
|
||||
// itself is emitted at the end of the generated code.
|
||||
SafepointTableBuilder safepoints_;
|
||||
|
||||
// Compiler from a set of parallel moves to a sequential list of moves.
|
||||
LGapResolver resolver_;
|
||||
|
||||
friend class LDeferredCode;
|
||||
friend class LEnvironment;
|
||||
friend class SafepointGenerator;
|
||||
|
@ -60,23 +60,29 @@ class LGapNode: public ZoneObject {
|
||||
};
|
||||
|
||||
|
||||
LGapResolver::LGapResolver(const ZoneList<LMoveOperands>* moves,
|
||||
LOperand* marker_operand)
|
||||
: nodes_(4),
|
||||
LGapResolver::LGapResolver()
|
||||
: nodes_(32),
|
||||
identified_cycles_(4),
|
||||
result_(4),
|
||||
marker_operand_(marker_operand),
|
||||
result_(16),
|
||||
next_visited_id_(0) {
|
||||
}
|
||||
|
||||
|
||||
const ZoneList<LMoveOperands>* LGapResolver::Resolve(
|
||||
const ZoneList<LMoveOperands>* moves,
|
||||
LOperand* marker_operand) {
|
||||
nodes_.Rewind(0);
|
||||
identified_cycles_.Rewind(0);
|
||||
result_.Rewind(0);
|
||||
next_visited_id_ = 0;
|
||||
|
||||
for (int i = 0; i < moves->length(); ++i) {
|
||||
LMoveOperands move = moves->at(i);
|
||||
if (!move.IsRedundant()) RegisterMove(move);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const ZoneList<LMoveOperands>* LGapResolver::ResolveInReverseOrder() {
|
||||
for (int i = 0; i < identified_cycles_.length(); ++i) {
|
||||
ResolveCycle(identified_cycles_[i]);
|
||||
ResolveCycle(identified_cycles_[i], marker_operand);
|
||||
}
|
||||
|
||||
int unresolved_nodes;
|
||||
@ -105,20 +111,20 @@ void LGapResolver::AddResultMove(LOperand* from, LOperand* to) {
|
||||
}
|
||||
|
||||
|
||||
void LGapResolver::ResolveCycle(LGapNode* start) {
|
||||
ZoneList<LOperand*> circle_operands(8);
|
||||
circle_operands.Add(marker_operand_);
|
||||
void LGapResolver::ResolveCycle(LGapNode* start, LOperand* marker_operand) {
|
||||
ZoneList<LOperand*> cycle_operands(8);
|
||||
cycle_operands.Add(marker_operand);
|
||||
LGapNode* cur = start;
|
||||
do {
|
||||
cur->MarkResolved();
|
||||
circle_operands.Add(cur->operand());
|
||||
cycle_operands.Add(cur->operand());
|
||||
cur = cur->assigned_from();
|
||||
} while (cur != start);
|
||||
circle_operands.Add(marker_operand_);
|
||||
cycle_operands.Add(marker_operand);
|
||||
|
||||
for (int i = circle_operands.length() - 1; i > 0; --i) {
|
||||
LOperand* from = circle_operands[i];
|
||||
LOperand* to = circle_operands[i - 1];
|
||||
for (int i = cycle_operands.length() - 1; i > 0; --i) {
|
||||
LOperand* from = cycle_operands[i];
|
||||
LOperand* to = cycle_operands[i - 1];
|
||||
AddResultMove(from, to);
|
||||
}
|
||||
}
|
||||
@ -156,7 +162,7 @@ void LGapResolver::RegisterMove(LMoveOperands move) {
|
||||
}
|
||||
ASSERT(!to->IsAssigned());
|
||||
if (CanReach(from, to)) {
|
||||
// This introduces a circle. Save.
|
||||
// This introduces a cycle. Save.
|
||||
identified_cycles_.Add(from);
|
||||
}
|
||||
to->set_assigned_from(from);
|
||||
|
@ -37,8 +37,9 @@ class LGapNode;
|
||||
|
||||
class LGapResolver BASE_EMBEDDED {
|
||||
public:
|
||||
LGapResolver(const ZoneList<LMoveOperands>* moves, LOperand* marker_operand);
|
||||
const ZoneList<LMoveOperands>* ResolveInReverseOrder();
|
||||
LGapResolver();
|
||||
const ZoneList<LMoveOperands>* Resolve(const ZoneList<LMoveOperands>* moves,
|
||||
LOperand* marker_operand);
|
||||
|
||||
private:
|
||||
LGapNode* LookupNode(LOperand* operand);
|
||||
@ -47,14 +48,12 @@ class LGapResolver BASE_EMBEDDED {
|
||||
void RegisterMove(LMoveOperands move);
|
||||
void AddResultMove(LOperand* from, LOperand* to);
|
||||
void AddResultMove(LGapNode* from, LGapNode* to);
|
||||
void ResolveCycle(LGapNode* start);
|
||||
void ResolveCycle(LGapNode* start, LOperand* marker_operand);
|
||||
|
||||
ZoneList<LGapNode*> nodes_;
|
||||
ZoneList<LGapNode*> identified_cycles_;
|
||||
ZoneList<LMoveOperands> result_;
|
||||
LOperand* marker_operand_;
|
||||
int next_visited_id_;
|
||||
int bailout_after_ast_id_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user