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

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

Issue 340058: Add conditional expressions (ternary choice operator) to fast compiler. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 1 month 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/compiler.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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 373 }
374 374
375 375
376 void FastCodeGenerator::VisitFunctionBoilerplateLiteral( 376 void FastCodeGenerator::VisitFunctionBoilerplateLiteral(
377 FunctionBoilerplateLiteral* expr) { 377 FunctionBoilerplateLiteral* expr) {
378 UNREACHABLE(); 378 UNREACHABLE();
379 } 379 }
380 380
381 381
382 void FastCodeGenerator::VisitConditional(Conditional* expr) { 382 void FastCodeGenerator::VisitConditional(Conditional* expr) {
383 UNREACHABLE(); 383 ASSERT_EQ(Expression::kTest, expr->condition()->context());
384 ASSERT_EQ(expr->context(), expr->then_expression()->context());
385 ASSERT_EQ(expr->context(), expr->else_expression()->context());
386
387
388 Label true_case, false_case, done;
389 Label* saved_true = true_label_;
390 Label* saved_false = false_label_;
391
392 true_label_ = &true_case;
393 false_label_ = &false_case;
394 Visit(expr->condition());
395 true_label_ = saved_true;
396 false_label_ = saved_false;
397
398 __ bind(&true_case);
399 Visit(expr->then_expression());
400 // If control flow falls through Visit, jump to done.
401 if (expr->context() == Expression::kEffect ||
402 expr->context() == Expression::kValue) {
403 __ jmp(&done);
404 }
405
406 __ bind(&false_case);
407 Visit(expr->else_expression());
408 // If control flow falls through Visit, merge it with true case here.
409 if (expr->context() == Expression::kEffect ||
410 expr->context() == Expression::kValue) {
411 __ bind(&done);
412 }
384 } 413 }
385 414
386 415
387 void FastCodeGenerator::VisitSlot(Slot* expr) { 416 void FastCodeGenerator::VisitSlot(Slot* expr) {
388 // Slots do not appear directly in the AST. 417 // Slots do not appear directly in the AST.
389 UNREACHABLE(); 418 UNREACHABLE();
390 } 419 }
391 420
392 421
393 void FastCodeGenerator::VisitLiteral(Literal* expr) { 422 void FastCodeGenerator::VisitLiteral(Literal* expr) {
(...skipping 23 matching lines...) Expand all
417 446
418 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { 447 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) {
419 UNREACHABLE(); 448 UNREACHABLE();
420 } 449 }
421 450
422 451
423 #undef __ 452 #undef __
424 453
425 454
426 } } // namespace v8::internal 455 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698