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

Side by Side Diff: src/fast-codegen.h

Issue 546075: First step of refactoring expression contexts in the toplevel code... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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
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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void DoTest(Expression::Context context); 243 void DoTest(Expression::Context context);
244 244
245 void Move(Slot* dst, Register source, Register scratch1, Register scratch2); 245 void Move(Slot* dst, Register source, Register scratch1, Register scratch2);
246 void Move(Register dst, Slot* source); 246 void Move(Register dst, Slot* source);
247 247
248 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot. 248 // Return an operand used to read/write to a known (ie, non-LOOKUP) slot.
249 // May emit code to traverse the context chain, destroying the scratch 249 // May emit code to traverse the context chain, destroying the scratch
250 // register. 250 // register.
251 MemOperand EmitSlotSearch(Slot* slot, Register scratch); 251 MemOperand EmitSlotSearch(Slot* slot, Register scratch);
252 252
253 void VisitForEffect(Expression* expr) {
254 Expression::Context saved_context = context_;
255 context_ = Expression::kEffect;
256 Visit(expr);
257 context_ = saved_context;
258 }
259
253 void VisitForValue(Expression* expr, Location where) { 260 void VisitForValue(Expression* expr, Location where) {
254 ASSERT(expr->context() == Expression::kValue); 261 Expression::Context saved_context = context_;
255 Location saved_location = location_; 262 Location saved_location = location_;
263 context_ = Expression::kValue;
256 location_ = where; 264 location_ = where;
257 Visit(expr); 265 Visit(expr);
266 context_ = saved_context;
258 location_ = saved_location; 267 location_ = saved_location;
259 } 268 }
260 269
261 void VisitForControl(Expression* expr, Label* if_true, Label* if_false) { 270 void VisitForControl(Expression* expr, Label* if_true, Label* if_false) {
262 ASSERT(expr->context() == Expression::kTest || 271 Expression::Context saved_context = context_;
263 expr->context() == Expression::kValueTest ||
264 expr->context() == Expression::kTestValue);
265 Label* saved_true = true_label_; 272 Label* saved_true = true_label_;
266 Label* saved_false = false_label_; 273 Label* saved_false = false_label_;
274 context_ = Expression::kTest;
267 true_label_ = if_true; 275 true_label_ = if_true;
268 false_label_ = if_false; 276 false_label_ = if_false;
269 Visit(expr); 277 Visit(expr);
278 context_ = saved_context;
279 true_label_ = saved_true;
280 false_label_ = saved_false;
281 }
282
283 void VisitForValueControl(Expression* expr,
284 Location where,
285 Label* if_true,
286 Label* if_false) {
287 Expression::Context saved_context = context_;
288 Location saved_location = location_;
289 Label* saved_true = true_label_;
290 Label* saved_false = false_label_;
291 context_ = Expression::kValueTest;
292 location_ = where;
293 true_label_ = if_true;
294 false_label_ = if_false;
295 Visit(expr);
296 context_ = saved_context;
297 location_ = saved_location;
298 true_label_ = saved_true;
299 false_label_ = saved_false;
300 }
301
302 void VisitForControlValue(Expression* expr,
303 Location where,
304 Label* if_true,
305 Label* if_false) {
306 Expression::Context saved_context = context_;
307 Location saved_location = location_;
308 Label* saved_true = true_label_;
309 Label* saved_false = false_label_;
310 context_ = Expression::kTestValue;
311 location_ = where;
312 true_label_ = if_true;
313 false_label_ = if_false;
314 Visit(expr);
315 context_ = saved_context;
316 location_ = saved_location;
270 true_label_ = saved_true; 317 true_label_ = saved_true;
271 false_label_ = saved_false; 318 false_label_ = saved_false;
272 } 319 }
273 320
274 void VisitDeclarations(ZoneList<Declaration*>* declarations); 321 void VisitDeclarations(ZoneList<Declaration*>* declarations);
275 void DeclareGlobals(Handle<FixedArray> pairs); 322 void DeclareGlobals(Handle<FixedArray> pairs);
276 323
277 // Platform-specific return sequence 324 // Platform-specific return sequence
278 void EmitReturnSequence(int position); 325 void EmitReturnSequence(int position);
279 326
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 void EmitLogicalOperation(BinaryOperation* expr); 396 void EmitLogicalOperation(BinaryOperation* expr);
350 397
351 MacroAssembler* masm_; 398 MacroAssembler* masm_;
352 FunctionLiteral* function_; 399 FunctionLiteral* function_;
353 Handle<Script> script_; 400 Handle<Script> script_;
354 bool is_eval_; 401 bool is_eval_;
355 Label return_label_; 402 Label return_label_;
356 NestedStatement* nesting_stack_; 403 NestedStatement* nesting_stack_;
357 int loop_depth_; 404 int loop_depth_;
358 405
406 Expression::Context context_;
359 Location location_; 407 Location location_;
360 Label* true_label_; 408 Label* true_label_;
361 Label* false_label_; 409 Label* false_label_;
362 410
363 friend class NestedStatement; 411 friend class NestedStatement;
364 412
365 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator); 413 DISALLOW_COPY_AND_ASSIGN(FastCodeGenerator);
366 }; 414 };
367 415
368 416
369 } } // namespace v8::internal 417 } } // namespace v8::internal
370 418
371 #endif // V8_FAST_CODEGEN_H_ 419 #endif // V8_FAST_CODEGEN_H_
OLDNEW
« src/compiler.cc ('K') | « src/compiler.cc ('k') | src/fast-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698