OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 | 430 |
431 #define __ ACCESS_MASM(masm()) | 431 #define __ ACCESS_MASM(masm()) |
432 | 432 |
433 Handle<Code> FastCodeGenerator::MakeCode(CompilationInfo* info) { | 433 Handle<Code> FastCodeGenerator::MakeCode(CompilationInfo* info) { |
434 // Label the AST before calling MakeCodePrologue, so AST node numbers are | 434 // Label the AST before calling MakeCodePrologue, so AST node numbers are |
435 // printed with the AST. | 435 // printed with the AST. |
436 AstLabeler labeler; | 436 AstLabeler labeler; |
437 labeler.Label(info); | 437 labeler.Label(info); |
438 | 438 |
439 LivenessAnalyzer analyzer; | |
440 analyzer.Analyze(info->function()); | |
441 | |
442 CodeGenerator::MakeCodePrologue(info); | 439 CodeGenerator::MakeCodePrologue(info); |
443 | 440 |
444 const int kInitialBufferSize = 4 * KB; | 441 const int kInitialBufferSize = 4 * KB; |
445 MacroAssembler masm(NULL, kInitialBufferSize); | 442 MacroAssembler masm(NULL, kInitialBufferSize); |
446 | 443 |
447 // Generate the fast-path code. | 444 // Generate the fast-path code. |
448 FastCodeGenerator fast_cgen(&masm); | 445 FastCodeGenerator fast_cgen(&masm); |
449 fast_cgen.Generate(info); | 446 fast_cgen.Generate(info); |
450 if (fast_cgen.HasStackOverflow()) { | 447 if (fast_cgen.HasStackOverflow()) { |
451 ASSERT(!Top::has_pending_exception()); | 448 ASSERT(!Top::has_pending_exception()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 ASSERT_EQ(NORMAL, lookup.type()); | 588 ASSERT_EQ(NORMAL, lookup.type()); |
592 ASSERT(lookup.IsDontDelete()); | 589 ASSERT(lookup.IsDontDelete()); |
593 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); | 590 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); |
594 | 591 |
595 // Global variable lookups do not have side effects, so we do not need to | 592 // Global variable lookups do not have side effects, so we do not need to |
596 // emit code if we are in an effect context. | 593 // emit code if we are in an effect context. |
597 if (!destination().is(no_reg)) { | 594 if (!destination().is(no_reg)) { |
598 Comment cmnt(masm(), ";; Global"); | 595 Comment cmnt(masm(), ";; Global"); |
599 if (FLAG_print_ir) { | 596 if (FLAG_print_ir) { |
600 SmartPointer<char> name = expr->name()->ToCString(); | 597 SmartPointer<char> name = expr->name()->ToCString(); |
601 PrintF("%d: t%d = Global(%s) // last_use = %d\n", expr->num(), | 598 PrintF("%d: t%d = Global(%s)\n", expr->num(), |
602 expr->num(), *name, expr->var_def()->last_use()->num()); | 599 expr->num(), *name); |
603 } | 600 } |
604 EmitGlobalVariableLoad(cell); | 601 EmitGlobalVariableLoad(cell); |
605 } | 602 } |
606 } | 603 } |
607 | 604 |
608 | 605 |
609 void FastCodeGenerator::VisitLiteral(Literal* expr) { | 606 void FastCodeGenerator::VisitLiteral(Literal* expr) { |
610 UNREACHABLE(); | 607 UNREACHABLE(); |
611 } | 608 } |
612 | 609 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 ASSERT(prop->obj()->AsVariableProxy()->var()->is_this()); | 643 ASSERT(prop->obj()->AsVariableProxy()->var()->is_this()); |
647 ASSERT(prop->key()->IsPropertyName()); | 644 ASSERT(prop->key()->IsPropertyName()); |
648 Handle<String> name = | 645 Handle<String> name = |
649 Handle<String>::cast(prop->key()->AsLiteral()->handle()); | 646 Handle<String>::cast(prop->key()->AsLiteral()->handle()); |
650 | 647 |
651 Comment cmnt(masm(), ";; Store to this"); | 648 Comment cmnt(masm(), ";; Store to this"); |
652 if (FLAG_print_ir) { | 649 if (FLAG_print_ir) { |
653 SmartPointer<char> name_string = name->ToCString(); | 650 SmartPointer<char> name_string = name->ToCString(); |
654 PrintF("%d: ", expr->num()); | 651 PrintF("%d: ", expr->num()); |
655 if (!destination().is(no_reg)) PrintF("t%d = ", expr->num()); | 652 if (!destination().is(no_reg)) PrintF("t%d = ", expr->num()); |
656 PrintF("Store(this, \"%s\", t%d) // last_use(this) = %d\n", *name_string, | 653 PrintF("Store(this, \"%s\", t%d)\n", *name_string, |
657 expr->value()->num(), | 654 expr->value()->num()); |
658 expr->var_def()->last_use()->num()); | |
659 } | 655 } |
660 | 656 |
661 EmitThisPropertyStore(name); | 657 EmitThisPropertyStore(name); |
662 } | 658 } |
663 | 659 |
664 | 660 |
665 void FastCodeGenerator::VisitThrow(Throw* expr) { | 661 void FastCodeGenerator::VisitThrow(Throw* expr) { |
666 UNREACHABLE(); | 662 UNREACHABLE(); |
667 } | 663 } |
668 | 664 |
669 | 665 |
670 void FastCodeGenerator::VisitProperty(Property* expr) { | 666 void FastCodeGenerator::VisitProperty(Property* expr) { |
671 ASSERT_NOT_NULL(expr->obj()->AsVariableProxy()); | 667 ASSERT_NOT_NULL(expr->obj()->AsVariableProxy()); |
672 ASSERT(expr->obj()->AsVariableProxy()->var()->is_this()); | 668 ASSERT(expr->obj()->AsVariableProxy()->var()->is_this()); |
673 ASSERT(expr->key()->IsPropertyName()); | 669 ASSERT(expr->key()->IsPropertyName()); |
674 if (!destination().is(no_reg)) { | 670 if (!destination().is(no_reg)) { |
675 Handle<String> name = | 671 Handle<String> name = |
676 Handle<String>::cast(expr->key()->AsLiteral()->handle()); | 672 Handle<String>::cast(expr->key()->AsLiteral()->handle()); |
677 | 673 |
678 Comment cmnt(masm(), ";; Load from this"); | 674 Comment cmnt(masm(), ";; Load from this"); |
679 if (FLAG_print_ir) { | 675 if (FLAG_print_ir) { |
680 SmartPointer<char> name_string = name->ToCString(); | 676 SmartPointer<char> name_string = name->ToCString(); |
681 PrintF("%d: t%d = Load(this, \"%s\") // last_use(this) = %d\n", | 677 PrintF("%d: t%d = Load(this, \"%s\")\n", |
682 expr->num(), expr->num(), *name_string, | 678 expr->num(), expr->num(), *name_string); |
683 expr->var_def()->last_use()->num()); | |
684 } | 679 } |
685 EmitThisPropertyLoad(name); | 680 EmitThisPropertyLoad(name); |
686 } | 681 } |
687 } | 682 } |
688 | 683 |
689 | 684 |
690 void FastCodeGenerator::VisitCall(Call* expr) { | 685 void FastCodeGenerator::VisitCall(Call* expr) { |
691 UNREACHABLE(); | 686 UNREACHABLE(); |
692 } | 687 } |
693 | 688 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 | 737 |
743 | 738 |
744 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 739 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
745 UNREACHABLE(); | 740 UNREACHABLE(); |
746 } | 741 } |
747 | 742 |
748 #undef __ | 743 #undef __ |
749 | 744 |
750 | 745 |
751 } } // namespace v8::internal | 746 } } // namespace v8::internal |
OLD | NEW |