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

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

Issue 7046073: First steps towards better code generation for LBranch: (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 6 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/full-codegen.h ('k') | src/hydrogen.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 434
435 void FullCodeGenerator::StackValueContext::Plug(Register reg) const { 435 void FullCodeGenerator::StackValueContext::Plug(Register reg) const {
436 __ push(reg); 436 __ push(reg);
437 } 437 }
438 438
439 439
440 void FullCodeGenerator::TestContext::Plug(Register reg) const { 440 void FullCodeGenerator::TestContext::Plug(Register reg) const {
441 // For simplicity we always test the accumulator register. 441 // For simplicity we always test the accumulator register.
442 __ Move(result_register(), reg); 442 __ Move(result_register(), reg);
443 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 443 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
444 codegen()->DoTest(true_label_, false_label_, fall_through_); 444 codegen()->DoTest(this);
445 } 445 }
446 446
447 447
448 void FullCodeGenerator::EffectContext::PlugTOS() const { 448 void FullCodeGenerator::EffectContext::PlugTOS() const {
449 __ Drop(1); 449 __ Drop(1);
450 } 450 }
451 451
452 452
453 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const { 453 void FullCodeGenerator::AccumulatorValueContext::PlugTOS() const {
454 __ pop(result_register()); 454 __ pop(result_register());
455 } 455 }
456 456
457 457
458 void FullCodeGenerator::StackValueContext::PlugTOS() const { 458 void FullCodeGenerator::StackValueContext::PlugTOS() const {
459 } 459 }
460 460
461 461
462 void FullCodeGenerator::TestContext::PlugTOS() const { 462 void FullCodeGenerator::TestContext::PlugTOS() const {
463 // For simplicity we always test the accumulator register. 463 // For simplicity we always test the accumulator register.
464 __ pop(result_register()); 464 __ pop(result_register());
465 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 465 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
466 codegen()->DoTest(true_label_, false_label_, fall_through_); 466 codegen()->DoTest(this);
467 } 467 }
468 468
469 469
470 void FullCodeGenerator::EffectContext::PrepareTest( 470 void FullCodeGenerator::EffectContext::PrepareTest(
471 Label* materialize_true, 471 Label* materialize_true,
472 Label* materialize_false, 472 Label* materialize_false,
473 Label** if_true, 473 Label** if_true,
474 Label** if_false, 474 Label** if_false,
475 Label** fall_through) const { 475 Label** fall_through) const {
476 // In an effect context, the true and the false case branch to the 476 // In an effect context, the true and the false case branch to the
(...skipping 29 matching lines...) Expand all
506 Label* materialize_false, 506 Label* materialize_false,
507 Label** if_true, 507 Label** if_true,
508 Label** if_false, 508 Label** if_false,
509 Label** fall_through) const { 509 Label** fall_through) const {
510 *if_true = true_label_; 510 *if_true = true_label_;
511 *if_false = false_label_; 511 *if_false = false_label_;
512 *fall_through = fall_through_; 512 *fall_through = fall_through_;
513 } 513 }
514 514
515 515
516 void FullCodeGenerator::DoTest(const TestContext* context) {
517 DoTest(context->condition(),
518 context->true_label(),
519 context->false_label(),
520 context->fall_through());
521 }
522
523
516 void FullCodeGenerator::VisitDeclarations( 524 void FullCodeGenerator::VisitDeclarations(
517 ZoneList<Declaration*>* declarations) { 525 ZoneList<Declaration*>* declarations) {
518 int length = declarations->length(); 526 int length = declarations->length();
519 int globals = 0; 527 int globals = 0;
520 for (int i = 0; i < length; i++) { 528 for (int i = 0; i < length; i++) {
521 Declaration* decl = declarations->at(i); 529 Declaration* decl = declarations->at(i);
522 Variable* var = decl->proxy()->var(); 530 Variable* var = decl->proxy()->var();
523 Slot* slot = var->AsSlot(); 531 Slot* slot = var->AsSlot();
524 532
525 // If it was not possible to allocate the variable at compile 533 // If it was not possible to allocate the variable at compile
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 ForwardBailoutToChild(expr); 735 ForwardBailoutToChild(expr);
728 736
729 } else if (context()->IsAccumulatorValue()) { 737 } else if (context()->IsAccumulatorValue()) {
730 VisitForAccumulatorValue(left); 738 VisitForAccumulatorValue(left);
731 // We want the value in the accumulator for the test, and on the stack in 739 // We want the value in the accumulator for the test, and on the stack in
732 // case we need it. 740 // case we need it.
733 __ push(result_register()); 741 __ push(result_register());
734 Label discard, restore; 742 Label discard, restore;
735 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 743 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
736 if (is_logical_and) { 744 if (is_logical_and) {
737 DoTest(&discard, &restore, &restore); 745 DoTest(left, &discard, &restore, &restore);
738 } else { 746 } else {
739 DoTest(&restore, &discard, &restore); 747 DoTest(left, &restore, &discard, &restore);
740 } 748 }
741 __ bind(&restore); 749 __ bind(&restore);
742 __ pop(result_register()); 750 __ pop(result_register());
743 __ jmp(&done); 751 __ jmp(&done);
744 __ bind(&discard); 752 __ bind(&discard);
745 __ Drop(1); 753 __ Drop(1);
746 PrepareForBailoutForId(right_id, NO_REGISTERS); 754 PrepareForBailoutForId(right_id, NO_REGISTERS);
747 755
748 } else if (context()->IsStackValue()) { 756 } else if (context()->IsStackValue()) {
749 VisitForAccumulatorValue(left); 757 VisitForAccumulatorValue(left);
750 // We want the value in the accumulator for the test, and on the stack in 758 // We want the value in the accumulator for the test, and on the stack in
751 // case we need it. 759 // case we need it.
752 __ push(result_register()); 760 __ push(result_register());
753 Label discard; 761 Label discard;
754 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); 762 PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
755 if (is_logical_and) { 763 if (is_logical_and) {
756 DoTest(&discard, &done, &discard); 764 DoTest(left, &discard, &done, &discard);
757 } else { 765 } else {
758 DoTest(&done, &discard, &discard); 766 DoTest(left, &done, &discard, &discard);
759 } 767 }
760 __ bind(&discard); 768 __ bind(&discard);
761 __ Drop(1); 769 __ Drop(1);
762 PrepareForBailoutForId(right_id, NO_REGISTERS); 770 PrepareForBailoutForId(right_id, NO_REGISTERS);
763 771
764 } else { 772 } else {
765 ASSERT(context()->IsEffect()); 773 ASSERT(context()->IsEffect());
766 Label eval_right; 774 Label eval_right;
767 if (is_logical_and) { 775 if (is_logical_and) {
768 VisitForControl(left, &eval_right, &done, &eval_right); 776 VisitForControl(left, &eval_right, &done, &eval_right);
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 __ Drop(stack_depth); 1289 __ Drop(stack_depth);
1282 __ PopTryHandler(); 1290 __ PopTryHandler();
1283 return 0; 1291 return 0;
1284 } 1292 }
1285 1293
1286 1294
1287 #undef __ 1295 #undef __
1288 1296
1289 1297
1290 } } // namespace v8::internal 1298 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/full-codegen.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698