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

Unified Diff: test/cctest/compiler/test-gap-resolver.cc

Issue 1075863002: [turbofan] Make AllocatedOperand an InstructionOperand::Kind. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/register-allocator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-gap-resolver.cc
diff --git a/test/cctest/compiler/test-gap-resolver.cc b/test/cctest/compiler/test-gap-resolver.cc
index a7664e06484a8592a1423fff88e139d92f797657..caf9a628698023346c6cd8b1ea84d9dfc1a359cb 100644
--- a/test/cctest/compiler/test-gap-resolver.cc
+++ b/test/cctest/compiler/test-gap-resolver.cc
@@ -32,8 +32,28 @@ class InterpreterState {
}
private:
+ struct Key {
+ bool is_constant;
+ AllocatedOperand::AllocatedKind kind;
+ int index;
+
+ bool operator<(const Key& other) const {
+ if (this->is_constant != other.is_constant) {
+ return this->is_constant;
+ }
+ if (this->kind != other.kind) {
+ return this->kind < other.kind;
+ }
+ return this->index < other.index;
+ }
+
+ bool operator==(const Key& other) const {
+ return this->is_constant == other.is_constant &&
+ this->kind == other.kind && this->index == other.index;
+ }
+ };
+
// Internally, the state is a normalized permutation of (kind,index) pairs.
- typedef std::pair<InstructionOperand::Kind, int> Key;
typedef Key Value;
typedef std::map<Key, Value> OperandMap;
@@ -51,22 +71,27 @@ class InterpreterState {
}
static Key KeyFor(const InstructionOperand* op) {
- int v = op->IsConstant() ? ConstantOperand::cast(op)->virtual_register()
- : AllocatedOperand::cast(op)->index();
- return Key(op->kind(), v);
+ bool is_constant = op->IsConstant();
+ AllocatedOperand::AllocatedKind kind;
+ int index;
+ if (!is_constant) {
+ index = AllocatedOperand::cast(op)->index();
+ kind = AllocatedOperand::cast(op)->allocated_kind();
+ } else {
+ index = ConstantOperand::cast(op)->virtual_register();
+ kind = AllocatedOperand::REGISTER;
+ }
+ Key key = {is_constant, kind, index};
+ return key;
}
- static Value ValueFor(const InstructionOperand* op) {
- int v = op->IsConstant() ? ConstantOperand::cast(op)->virtual_register()
- : AllocatedOperand::cast(op)->index();
- return Value(op->kind(), v);
- }
+ static Value ValueFor(const InstructionOperand* op) { return KeyFor(op); }
static InstructionOperand FromKey(Key key) {
- if (key.first == InstructionOperand::CONSTANT) {
- return ConstantOperand(key.second);
+ if (key.is_constant) {
+ return ConstantOperand(key.index);
}
- return AllocatedOperand(key.first, key.second);
+ return AllocatedOperand(key.kind, key.index);
}
friend std::ostream& operator<<(std::ostream& os,
« no previous file with comments | « src/compiler/register-allocator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698