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

Side by Side Diff: src/ia32/cfg-ia32.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/cfg.cc ('k') | src/x64/cfg-x64.cc » ('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 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 115
116 void PositionInstr::Compile(MacroAssembler* masm) { 116 void PositionInstr::Compile(MacroAssembler* masm) {
117 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) { 117 if (FLAG_debug_info && pos_ != RelocInfo::kNoPosition) {
118 __ RecordStatementPosition(pos_); 118 __ RecordStatementPosition(pos_);
119 __ RecordPosition(pos_); 119 __ RecordPosition(pos_);
120 } 120 }
121 } 121 }
122 122
123 123
124 void MoveInstr::Compile(MacroAssembler* masm) {
125 location()->Move(masm, value());
126 }
127
128
124 void BinaryOpInstr::Compile(MacroAssembler* masm) { 129 void BinaryOpInstr::Compile(MacroAssembler* masm) {
125 // The right-hand value should not be on the stack---if it is a 130 // The right-hand value should not be on the stack---if it is a
126 // compiler-generated temporary it is in the accumulator. 131 // compiler-generated temporary it is in the accumulator.
127 ASSERT(!val1_->is_on_stack()); 132 ASSERT(!value1()->is_on_stack());
128 133
129 Comment cmnt(masm, "[ BinaryOpInstr"); 134 Comment cmnt(masm, "[ BinaryOpInstr");
130 // We can overwrite one of the operands if it is a temporary. 135 // We can overwrite one of the operands if it is a temporary.
131 OverwriteMode mode = NO_OVERWRITE; 136 OverwriteMode mode = NO_OVERWRITE;
132 if (val0_->is_temporary()) { 137 if (value0()->is_temporary()) {
133 mode = OVERWRITE_LEFT; 138 mode = OVERWRITE_LEFT;
134 } else if (val1_->is_temporary()) { 139 } else if (value1()->is_temporary()) {
135 mode = OVERWRITE_RIGHT; 140 mode = OVERWRITE_RIGHT;
136 } 141 }
137 142
138 // Push both operands and call the specialized stub. 143 // Push both operands and call the specialized stub.
139 if (!val0_->is_on_stack()) { 144 if (!value0()->is_on_stack()) {
140 val0_->Push(masm); 145 value0()->Push(masm);
141 } 146 }
142 val1_->Push(masm); 147 value1()->Push(masm);
143 GenericBinaryOpStub stub(op_, mode, SMI_CODE_IN_STUB); 148 GenericBinaryOpStub stub(op(), mode, SMI_CODE_IN_STUB);
144 __ CallStub(&stub); 149 __ CallStub(&stub);
145 loc_->Set(masm, eax); 150 location()->Set(masm, eax);
146 } 151 }
147 152
148 153
149 void ReturnInstr::Compile(MacroAssembler* masm) { 154 void ReturnInstr::Compile(MacroAssembler* masm) {
150 // The location should be 'Effect'. As a side effect, move the value to 155 // The location should be 'Effect'. As a side effect, move the value to
151 // the accumulator. 156 // the accumulator.
152 Comment cmnt(masm, "[ ReturnInstr"); 157 Comment cmnt(masm, "[ ReturnInstr");
153 value_->Get(masm, eax); 158 value_->Get(masm, eax);
154 } 159 }
155 160
(...skipping 18 matching lines...) Expand all
174 const int kOffset = JavaScriptFrameConstants::kLocal0Offset; 179 const int kOffset = JavaScriptFrameConstants::kLocal0Offset;
175 return Operand(ebp, kOffset - loc->index() * kPointerSize); 180 return Operand(ebp, kOffset - loc->index() * kPointerSize);
176 } 181 }
177 default: 182 default:
178 UNREACHABLE(); 183 UNREACHABLE();
179 return Operand(eax); 184 return Operand(eax);
180 } 185 }
181 } 186 }
182 187
183 188
189 void Constant::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
190 __ mov(ToOperand(loc), Immediate(handle_));
191 }
192
193
184 void SlotLocation::Get(MacroAssembler* masm, Register reg) { 194 void SlotLocation::Get(MacroAssembler* masm, Register reg) {
185 __ mov(reg, ToOperand(this)); 195 __ mov(reg, ToOperand(this));
186 } 196 }
187 197
188 198
189 void SlotLocation::Set(MacroAssembler* masm, Register reg) { 199 void SlotLocation::Set(MacroAssembler* masm, Register reg) {
190 __ mov(ToOperand(this), reg); 200 __ mov(ToOperand(this), reg);
191 } 201 }
192 202
193 203
194 void SlotLocation::Push(MacroAssembler* masm) { 204 void SlotLocation::Push(MacroAssembler* masm) {
195 __ push(ToOperand(this)); 205 __ push(ToOperand(this));
196 } 206 }
197 207
198 208
209 void SlotLocation::Move(MacroAssembler* masm, Value* value) {
210 // We dispatch to the value because in some cases (temp or constant)
211 // we can use a single instruction.
212 value->MoveToSlot(masm, this);
213 }
214
215 void SlotLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
216 // The accumulator is not live across a MoveInstr.
217 __ mov(eax, ToOperand(this));
218 __ mov(ToOperand(loc), eax);
219 }
220
221
199 void TempLocation::Get(MacroAssembler* masm, Register reg) { 222 void TempLocation::Get(MacroAssembler* masm, Register reg) {
200 switch (where_) { 223 switch (where_) {
201 case ACCUMULATOR: 224 case ACCUMULATOR:
202 if (!reg.is(eax)) __ mov(reg, eax); 225 if (!reg.is(eax)) __ mov(reg, eax);
203 break; 226 break;
204 case STACK: 227 case STACK:
205 __ pop(reg); 228 __ pop(reg);
206 break; 229 break;
207 case NOWHERE: 230 case NOT_ALLOCATED:
208 UNREACHABLE(); 231 UNREACHABLE();
209 break;
210 } 232 }
211 } 233 }
212 234
213 235
214 void TempLocation::Set(MacroAssembler* masm, Register reg) { 236 void TempLocation::Set(MacroAssembler* masm, Register reg) {
215 switch (where_) { 237 switch (where_) {
216 case ACCUMULATOR: 238 case ACCUMULATOR:
217 if (!reg.is(eax)) __ mov(eax, reg); 239 if (!reg.is(eax)) __ mov(eax, reg);
218 break; 240 break;
219 case STACK: 241 case STACK:
220 __ push(reg); 242 __ push(reg);
221 break; 243 break;
222 case NOWHERE: 244 case NOT_ALLOCATED:
223 UNREACHABLE(); 245 UNREACHABLE();
224 break;
225 } 246 }
226 } 247 }
227 248
228 249
229 void TempLocation::Push(MacroAssembler* masm) { 250 void TempLocation::Push(MacroAssembler* masm) {
230 switch (where_) { 251 switch (where_) {
231 case ACCUMULATOR: 252 case ACCUMULATOR:
232 __ push(eax); 253 __ push(eax);
233 break; 254 break;
234 case STACK: 255 case STACK:
235 case NOWHERE: 256 case NOT_ALLOCATED:
236 UNREACHABLE(); 257 UNREACHABLE();
258 }
259 }
260
261
262 void TempLocation::Move(MacroAssembler* masm, Value* value) {
263 switch (where_) {
264 case ACCUMULATOR:
265 value->Get(masm, eax);
237 break; 266 break;
267 case STACK:
268 value->Push(masm);
269 break;
270 case NOT_ALLOCATED:
271 UNREACHABLE();
272 }
273 }
274
275
276 void TempLocation::MoveToSlot(MacroAssembler* masm, SlotLocation* loc) {
277 switch (where_) {
278 case ACCUMULATOR:
279 __ mov(ToOperand(loc), eax);
280 break;
281 case STACK:
282 __ pop(ToOperand(loc));
283 break;
284 case NOT_ALLOCATED:
285 UNREACHABLE();
238 } 286 }
239 } 287 }
240 288
241 289
242 #undef __ 290 #undef __
243 291
244 } } // namespace v8::internal 292 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/cfg.cc ('k') | src/x64/cfg-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698