| 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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 ASSERT_EQ(NORMAL, lookup.type()); | 792 ASSERT_EQ(NORMAL, lookup.type()); |
| 796 ASSERT(lookup.IsDontDelete()); | 793 ASSERT(lookup.IsDontDelete()); |
| 797 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); | 794 Handle<Object> cell(info()->global_object()->GetPropertyCell(&lookup)); |
| 798 | 795 |
| 799 // Global variable lookups do not have side effects, so we do not need to | 796 // Global variable lookups do not have side effects, so we do not need to |
| 800 // emit code if we are in an effect context. | 797 // emit code if we are in an effect context. |
| 801 if (!destination().is(no_reg)) { | 798 if (!destination().is(no_reg)) { |
| 802 Comment cmnt(masm(), ";; Global"); | 799 Comment cmnt(masm(), ";; Global"); |
| 803 if (FLAG_print_ir) { | 800 if (FLAG_print_ir) { |
| 804 SmartPointer<char> name = expr->name()->ToCString(); | 801 SmartPointer<char> name = expr->name()->ToCString(); |
| 805 PrintF("%d: t%d = Global(%s) // last_use = %d\n", expr->num(), | 802 PrintF("%d: t%d = Global(%s)\n", expr->num(), |
| 806 expr->num(), *name, expr->var_def()->last_use()->num()); | 803 expr->num(), *name); |
| 807 } | 804 } |
| 808 EmitGlobalVariableLoad(cell); | 805 EmitGlobalVariableLoad(cell); |
| 809 } | 806 } |
| 810 } | 807 } |
| 811 | 808 |
| 812 | 809 |
| 813 void FastCodeGenerator::VisitLiteral(Literal* expr) { | 810 void FastCodeGenerator::VisitLiteral(Literal* expr) { |
| 814 UNREACHABLE(); | 811 UNREACHABLE(); |
| 815 } | 812 } |
| 816 | 813 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 ASSERT(prop->obj()->AsVariableProxy()->var()->is_this()); | 847 ASSERT(prop->obj()->AsVariableProxy()->var()->is_this()); |
| 851 ASSERT(prop->key()->IsPropertyName()); | 848 ASSERT(prop->key()->IsPropertyName()); |
| 852 Handle<String> name = | 849 Handle<String> name = |
| 853 Handle<String>::cast(prop->key()->AsLiteral()->handle()); | 850 Handle<String>::cast(prop->key()->AsLiteral()->handle()); |
| 854 | 851 |
| 855 Comment cmnt(masm(), ";; Store to this"); | 852 Comment cmnt(masm(), ";; Store to this"); |
| 856 if (FLAG_print_ir) { | 853 if (FLAG_print_ir) { |
| 857 SmartPointer<char> name_string = name->ToCString(); | 854 SmartPointer<char> name_string = name->ToCString(); |
| 858 PrintF("%d: ", expr->num()); | 855 PrintF("%d: ", expr->num()); |
| 859 if (!destination().is(no_reg)) PrintF("t%d = ", expr->num()); | 856 if (!destination().is(no_reg)) PrintF("t%d = ", expr->num()); |
| 860 PrintF("Store(this, \"%s\", t%d) // last_use(this) = %d\n", *name_string, | 857 PrintF("Store(this, \"%s\", t%d)\n", *name_string, |
| 861 expr->value()->num(), | 858 expr->value()->num()); |
| 862 expr->var_def()->last_use()->num()); | |
| 863 } | 859 } |
| 864 | 860 |
| 865 EmitThisPropertyStore(name); | 861 EmitThisPropertyStore(name); |
| 866 } | 862 } |
| 867 | 863 |
| 868 | 864 |
| 869 void FastCodeGenerator::VisitThrow(Throw* expr) { | 865 void FastCodeGenerator::VisitThrow(Throw* expr) { |
| 870 UNREACHABLE(); | 866 UNREACHABLE(); |
| 871 } | 867 } |
| 872 | 868 |
| 873 | 869 |
| 874 void FastCodeGenerator::VisitProperty(Property* expr) { | 870 void FastCodeGenerator::VisitProperty(Property* expr) { |
| 875 ASSERT_NOT_NULL(expr->obj()->AsVariableProxy()); | 871 ASSERT_NOT_NULL(expr->obj()->AsVariableProxy()); |
| 876 ASSERT(expr->obj()->AsVariableProxy()->var()->is_this()); | 872 ASSERT(expr->obj()->AsVariableProxy()->var()->is_this()); |
| 877 ASSERT(expr->key()->IsPropertyName()); | 873 ASSERT(expr->key()->IsPropertyName()); |
| 878 if (!destination().is(no_reg)) { | 874 if (!destination().is(no_reg)) { |
| 879 Handle<String> name = | 875 Handle<String> name = |
| 880 Handle<String>::cast(expr->key()->AsLiteral()->handle()); | 876 Handle<String>::cast(expr->key()->AsLiteral()->handle()); |
| 881 | 877 |
| 882 Comment cmnt(masm(), ";; Load from this"); | 878 Comment cmnt(masm(), ";; Load from this"); |
| 883 if (FLAG_print_ir) { | 879 if (FLAG_print_ir) { |
| 884 SmartPointer<char> name_string = name->ToCString(); | 880 SmartPointer<char> name_string = name->ToCString(); |
| 885 PrintF("%d: t%d = Load(this, \"%s\") // last_use(this) = %d\n", | 881 PrintF("%d: t%d = Load(this, \"%s\")\n", |
| 886 expr->num(), expr->num(), *name_string, | 882 expr->num(), expr->num(), *name_string); |
| 887 expr->var_def()->last_use()->num()); | |
| 888 } | 883 } |
| 889 EmitThisPropertyLoad(name); | 884 EmitThisPropertyLoad(name); |
| 890 } | 885 } |
| 891 } | 886 } |
| 892 | 887 |
| 893 | 888 |
| 894 void FastCodeGenerator::VisitCall(Call* expr) { | 889 void FastCodeGenerator::VisitCall(Call* expr) { |
| 895 UNREACHABLE(); | 890 UNREACHABLE(); |
| 896 } | 891 } |
| 897 | 892 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 | 941 |
| 947 | 942 |
| 948 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { | 943 void FastCodeGenerator::VisitThisFunction(ThisFunction* expr) { |
| 949 UNREACHABLE(); | 944 UNREACHABLE(); |
| 950 } | 945 } |
| 951 | 946 |
| 952 #undef __ | 947 #undef __ |
| 953 | 948 |
| 954 | 949 |
| 955 } } // namespace v8::internal | 950 } } // namespace v8::internal |
| OLD | NEW |