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

Side by Side Diff: src/x64/cfg-x64.cc

Issue 165056: Add support for (some) assignment expressions to the CFG builder and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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/ia32/cfg-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 124
125 125
126 void PositionInstr::Compile(MacroAssembler* masm) { 126 void PositionInstr::Compile(MacroAssembler* masm) {
127 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { 127 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
128 __ RecordStatementPosition(pos_); 128 __ RecordStatementPosition(pos_);
129 __ RecordPosition(pos_); 129 __ RecordPosition(pos_);
130 } 130 }
131 } 131 }
132 132
133 133
134 void MoveInstr::Compile(MacroAssembler* masm) {
135 location()->Move(masm, value());
136 }
137
138
134 void BinaryOpInstr::Compile(MacroAssembler* masm) { 139 void BinaryOpInstr::Compile(MacroAssembler* masm) {
135 // The right-hand value should not be on the stack---if it is a 140 // The right-hand value should not be on the stack---if it is a
136 // compiler-generated temporary it is in the accumulator. 141 // compiler-generated temporary it is in the accumulator.
137 ASSERT(!val1_->is_on_stack()); 142 ASSERT(!value1()->is_on_stack());
138 143
139 Comment cmnt(masm, "[ BinaryOpInstr"); 144 Comment cmnt(masm, "[ BinaryOpInstr");
140 // We can overwrite one of the operands if it is a temporary. 145 // We can overwrite one of the operands if it is a temporary.
141 OverwriteMode mode = NO_OVERWRITE; 146 OverwriteMode mode = NO_OVERWRITE;
142 if (val0_->is_temporary()) { 147 if (value0()->is_temporary()) {
143 mode = OVERWRITE_LEFT; 148 mode = OVERWRITE_LEFT;
144 } else if (val1_->is_temporary()) { 149 } else if (value1()->is_temporary()) {
145 mode = OVERWRITE_RIGHT; 150 mode = OVERWRITE_RIGHT;
146 } 151 }
147 152
148 // Push both operands and call the specialized stub. 153 // Push both operands and call the specialized stub.
149 if (!val0_->is_on_stack()) { 154 if (!value0()->is_on_stack()) {
150 val0_->Push(masm); 155 value0()->Push(masm);
151 } 156 }
152 val1_->Push(masm); 157 value1()->Push(masm);
153 GenericBinaryOpStub stub(op_, mode, SMI_CODE_IN_STUB); 158 GenericBinaryOpStub stub(op(), mode, SMI_CODE_IN_STUB);
154 __ CallStub(&stub); 159 __ CallStub(&stub);
155 loc_->Set(masm, rax); 160 location()->Set(masm, rax);
156 } 161 }
157 162
158 163
159 void ReturnInstr::Compile(MacroAssembler* masm) { 164 void ReturnInstr::Compile(MacroAssembler* masm) {
160 // The location should be 'Effect'. As a side effect, move the value to 165 // The location should be 'Effect'. As a side effect, move the value to
161 // the accumulator. 166 // the accumulator.
162 Comment cmnt(masm, "[ ReturnInstr"); 167 Comment cmnt(masm, "[ ReturnInstr");
163 value_->Get(masm, rax); 168 value_->Get(masm, rax);
164 } 169 }
165 170
(...skipping 18 matching lines...) Expand all
184 const int kOffset = JavaScriptFrameConstants::kLocal0Offset; 189 const int kOffset = JavaScriptFrameConstants::kLocal0Offset;
185 return Operand(rbp, kOffset - loc->index() * kPointerSize); 190 return Operand(rbp, kOffset - loc->index() * kPointerSize);
186 } 191 }
187 default: 192 default:
188 UNREACHABLE(); 193 UNREACHABLE();
189 return Operand(rax, 0); 194 return Operand(rax, 0);
190 } 195 }
191 } 196 }
192 197
193 198
199 void Constant::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
200 __ Move(ToOperand(loc), handle_);
201 }
202
203
194 void SlotLocation::Get(MacroAssembler* masm, Register reg) { 204 void SlotLocation::Get(MacroAssembler* masm, Register reg) {
195 __ movq(reg, ToOperand(this)); 205 __ movq(reg, ToOperand(this));
196 } 206 }
197 207
198 208
199 void SlotLocation::Set(MacroAssembler* masm, Register reg) { 209 void SlotLocation::Set(MacroAssembler* masm, Register reg) {
200 __ movq(ToOperand(this), reg); 210 __ movq(ToOperand(this), reg);
201 } 211 }
202 212
203 213
214 void SlotLocation::Move(MacroAssembler* masm, Value* value) {
215 // We dispatch to the value because in some cases (temp or constant) we
216 // can use special instruction sequences.
217 value->MoveToSlot(masm, this);
218 }
219
220
221 void SlotLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
222 __ movq(kScratchRegister, ToOperand(this));
223 __ movq(ToOperand(loc), kScratchRegister);
224 }
225
226
204 void SlotLocation::Push(MacroAssembler* masm) { 227 void SlotLocation::Push(MacroAssembler* masm) {
205 __ push(ToOperand(this)); 228 __ push(ToOperand(this));
206 } 229 }
207 230
208 231
209 void TempLocation::Get(MacroAssembler* masm, Register reg) { 232 void TempLocation::Get(MacroAssembler* masm, Register reg) {
210 switch (where_) { 233 switch (where_) {
211 case ACCUMULATOR: 234 case ACCUMULATOR:
212 if (!reg.is(rax)) __ movq(reg, rax); 235 if (!reg.is(rax)) __ movq(reg, rax);
213 break; 236 break;
214 case STACK: 237 case STACK:
215 __ pop(reg); 238 __ pop(reg);
216 break; 239 break;
217 case NOWHERE: 240 case NOT_ALLOCATED:
218 UNREACHABLE(); 241 UNREACHABLE();
219 break;
220 } 242 }
221 } 243 }
222 244
223 245
224 void TempLocation::Set(MacroAssembler* masm, Register reg) { 246 void TempLocation::Set(MacroAssembler* masm, Register reg) {
225 switch (where_) { 247 switch (where_) {
226 case ACCUMULATOR: 248 case ACCUMULATOR:
227 if (!reg.is(rax)) __ movq(rax, reg); 249 if (!reg.is(rax)) __ movq(rax, reg);
228 break; 250 break;
229 case STACK: 251 case STACK:
230 __ push(reg); 252 __ push(reg);
231 break; 253 break;
232 case NOWHERE: 254 case NOT_ALLOCATED:
233 UNREACHABLE(); 255 UNREACHABLE();
234 break;
235 } 256 }
236 } 257 }
237 258
238 259
239 void TempLocation::Push(MacroAssembler* masm) { 260 void TempLocation::Push(MacroAssembler* masm) {
240 switch (where_) { 261 switch (where_) {
241 case ACCUMULATOR: 262 case ACCUMULATOR:
242 __ push(rax); 263 __ push(rax);
243 break; 264 break;
244 case STACK: 265 case STACK:
245 case NOWHERE: 266 case NOT_ALLOCATED:
246 UNREACHABLE(); 267 UNREACHABLE();
268 }
269 }
270
271
272 void TempLocation::Move(MacroAssembler* masm, Value* value) {
273 switch (where_) {
274 case ACCUMULATOR:
275 value->Get(masm, rax);
247 break; 276 break;
277 case STACK:
278 value->Push(masm);
279 break;
280 case NOT_ALLOCATED:
281 UNREACHABLE();
282 }
283 }
284
285
286 void TempLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
287 switch (where_) {
288 case ACCUMULATOR:
289 __ movq(ToOperand(loc), rax);
290 break;
291 case STACK:
292 __ pop(ToOperand(loc));
293 break;
294 case NOT_ALLOCATED:
295 UNREACHABLE();
248 } 296 }
249 } 297 }
250 298
251 299
252 #undef __ 300 #undef __
253 301
254 } } // namespace v8::internal 302 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/cfg-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698