Revision: 6270
Author: [email protected]
Date: Tue Jan 11 05:50:12 2011
Log: 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
http://code.google.com/p/v8/source/detail?r=6270
Modified:
/branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
/branches/bleeding_edge/src/arm/lithium-codegen-arm.h
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
/branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h
/branches/bleeding_edge/src/lithium.cc
/branches/bleeding_edge/src/lithium.h
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jan 11
04:45:25 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Jan 11
05:50:12 2011
@@ -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 @@
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();
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Tue Jan 4
06:32:54 2011
+++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.h Tue Jan 11
05:50:12 2011
@@ -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 @@
// 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;
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Jan 11
05:48:49 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Jan 11
05:50:12 2011
@@ -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 @@
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();
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Wed Jan 5
03:17:37 2011
+++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.h Tue Jan 11
05:50:12 2011
@@ -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 @@
// 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;
=======================================
--- /branches/bleeding_edge/src/lithium.cc Mon Jan 10 03:31:21 2011
+++ /branches/bleeding_edge/src/lithium.cc Tue Jan 11 05:50:12 2011
@@ -60,23 +60,29 @@
};
-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::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_);
-
- for (int i = circle_operands.length() - 1; i > 0; --i) {
- LOperand* from = circle_operands[i];
- LOperand* to = circle_operands[i - 1];
+ cycle_operands.Add(marker_operand);
+
+ 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 @@
}
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);
=======================================
--- /branches/bleeding_edge/src/lithium.h Mon Jan 10 03:31:21 2011
+++ /branches/bleeding_edge/src/lithium.h Tue Jan 11 05:50:12 2011
@@ -37,8 +37,9 @@
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 @@
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_;
};
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev