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

Side by Side Diff: src/lithium.cc

Issue 186543002: Refactor lithium operand declaration a little bit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/lithium.h ('k') | src/lithium-allocator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 break; 110 break;
111 case DOUBLE_REGISTER: 111 case DOUBLE_REGISTER:
112 stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index())); 112 stream->Add("[%s|R]", DoubleRegister::AllocationIndexToString(index()));
113 break; 113 break;
114 case ARGUMENT: 114 case ARGUMENT:
115 stream->Add("[arg:%d]", index()); 115 stream->Add("[arg:%d]", index());
116 break; 116 break;
117 } 117 }
118 } 118 }
119 119
120 #define DEFINE_OPERAND_CACHE(name, type) \ 120
121 L##name* L##name::cache = NULL; \ 121 template<LOperand::Kind kOperandKind, int kNumCachedOperands>
122 \ 122 LSubKindOperand<kOperandKind, kNumCachedOperands>*
123 void L##name::SetUpCache() { \ 123 LSubKindOperand<kOperandKind, kNumCachedOperands>::cache = NULL;
124 if (cache) return; \ 124
125 cache = new L##name[kNumCachedOperands]; \ 125
126 for (int i = 0; i < kNumCachedOperands; i++) { \ 126 template<LOperand::Kind kOperandKind, int kNumCachedOperands>
127 cache[i].ConvertTo(type, i); \ 127 void LSubKindOperand<kOperandKind, kNumCachedOperands>::SetUpCache() {
128 } \ 128 if (cache) return;
129 } \ 129 cache = new LSubKindOperand[kNumCachedOperands];
130 \ 130 for (int i = 0; i < kNumCachedOperands; i++) {
131 void L##name::TearDownCache() { \ 131 cache[i].ConvertTo(kOperandKind, i);
132 delete[] cache; \
133 } 132 }
133 }
134 134
135 LITHIUM_OPERAND_LIST(DEFINE_OPERAND_CACHE) 135
136 #undef DEFINE_OPERAND_CACHE 136 template<LOperand::Kind kOperandKind, int kNumCachedOperands>
137 void LSubKindOperand<kOperandKind, kNumCachedOperands>::TearDownCache() {
138 delete[] cache;
139 }
140
137 141
138 void LOperand::SetUpCaches() { 142 void LOperand::SetUpCaches() {
139 #define LITHIUM_OPERAND_SETUP(name, type) L##name::SetUpCache(); 143 #define LITHIUM_OPERAND_SETUP(name, type, number) L##name::SetUpCache();
140 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP) 144 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_SETUP)
141 #undef LITHIUM_OPERAND_SETUP 145 #undef LITHIUM_OPERAND_SETUP
142 } 146 }
143 147
144 148
145 void LOperand::TearDownCaches() { 149 void LOperand::TearDownCaches() {
146 #define LITHIUM_OPERAND_TEARDOWN(name, type) L##name::TearDownCache(); 150 #define LITHIUM_OPERAND_TEARDOWN(name, type, number) L##name::TearDownCache();
147 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_TEARDOWN) 151 LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_TEARDOWN)
148 #undef LITHIUM_OPERAND_TEARDOWN 152 #undef LITHIUM_OPERAND_TEARDOWN
149 } 153 }
150 154
151 155
152 bool LParallelMove::IsRedundant() const { 156 bool LParallelMove::IsRedundant() const {
153 for (int i = 0; i < move_operands_.length(); ++i) { 157 for (int i = 0; i < move_operands_.length(); ++i) {
154 if (!move_operands_[i].IsRedundant()) return false; 158 if (!move_operands_[i].IsRedundant()) return false;
155 } 159 }
156 return true; 160 return true;
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 612
609 613
610 LPhase::~LPhase() { 614 LPhase::~LPhase() {
611 if (ShouldProduceTraceOutput()) { 615 if (ShouldProduceTraceOutput()) {
612 isolate()->GetHTracer()->TraceLithium(name(), chunk_); 616 isolate()->GetHTracer()->TraceLithium(name(), chunk_);
613 } 617 }
614 } 618 }
615 619
616 620
617 } } // namespace v8::internal 621 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium.h ('k') | src/lithium-allocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698