OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 VariableDeclaration* declaration) { | 750 VariableDeclaration* declaration) { |
751 // If it was not possible to allocate the variable at compile time, we | 751 // If it was not possible to allocate the variable at compile time, we |
752 // need to "declare" it at runtime to make sure it actually exists in the | 752 // need to "declare" it at runtime to make sure it actually exists in the |
753 // local context. | 753 // local context. |
754 VariableProxy* proxy = declaration->proxy(); | 754 VariableProxy* proxy = declaration->proxy(); |
755 VariableMode mode = declaration->mode(); | 755 VariableMode mode = declaration->mode(); |
756 Variable* variable = proxy->var(); | 756 Variable* variable = proxy->var(); |
757 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; | 757 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; |
758 switch (variable->location()) { | 758 switch (variable->location()) { |
759 case Variable::UNALLOCATED: | 759 case Variable::UNALLOCATED: |
760 ++global_count_; | 760 globals_.Add(variable->name()); |
| 761 globals_.Add(variable->binding_needs_init() |
| 762 ? isolate()->factory()->the_hole_value() |
| 763 : isolate()->factory()->undefined_value()); |
761 break; | 764 break; |
762 | 765 |
763 case Variable::PARAMETER: | 766 case Variable::PARAMETER: |
764 case Variable::LOCAL: | 767 case Variable::LOCAL: |
765 if (hole_init) { | 768 if (hole_init) { |
766 Comment cmnt(masm_, "[ VariableDeclaration"); | 769 Comment cmnt(masm_, "[ VariableDeclaration"); |
767 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 770 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
768 __ str(ip, StackOperand(variable)); | 771 __ str(ip, StackOperand(variable)); |
769 } | 772 } |
770 break; | 773 break; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 } | 808 } |
806 } | 809 } |
807 } | 810 } |
808 | 811 |
809 | 812 |
810 void FullCodeGenerator::VisitFunctionDeclaration( | 813 void FullCodeGenerator::VisitFunctionDeclaration( |
811 FunctionDeclaration* declaration) { | 814 FunctionDeclaration* declaration) { |
812 VariableProxy* proxy = declaration->proxy(); | 815 VariableProxy* proxy = declaration->proxy(); |
813 Variable* variable = proxy->var(); | 816 Variable* variable = proxy->var(); |
814 switch (variable->location()) { | 817 switch (variable->location()) { |
815 case Variable::UNALLOCATED: | 818 case Variable::UNALLOCATED: { |
816 ++global_count_; | 819 globals_.Add(variable->name()); |
| 820 Handle<SharedFunctionInfo> function = |
| 821 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
| 822 // Check for stack-overflow exception. |
| 823 if (function.is_null()) return SetStackOverflow(); |
| 824 globals_.Add(function); |
817 break; | 825 break; |
| 826 } |
818 | 827 |
819 case Variable::PARAMETER: | 828 case Variable::PARAMETER: |
820 case Variable::LOCAL: { | 829 case Variable::LOCAL: { |
821 Comment cmnt(masm_, "[ FunctionDeclaration"); | 830 Comment cmnt(masm_, "[ FunctionDeclaration"); |
822 VisitForAccumulatorValue(declaration->fun()); | 831 VisitForAccumulatorValue(declaration->fun()); |
823 __ str(result_register(), StackOperand(variable)); | 832 __ str(result_register(), StackOperand(variable)); |
824 break; | 833 break; |
825 } | 834 } |
826 | 835 |
827 case Variable::CONTEXT: { | 836 case Variable::CONTEXT: { |
(...skipping 27 matching lines...) Expand all Loading... |
855 } | 864 } |
856 } | 865 } |
857 } | 866 } |
858 | 867 |
859 | 868 |
860 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 869 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
861 VariableProxy* proxy = declaration->proxy(); | 870 VariableProxy* proxy = declaration->proxy(); |
862 Variable* variable = proxy->var(); | 871 Variable* variable = proxy->var(); |
863 switch (variable->location()) { | 872 switch (variable->location()) { |
864 case Variable::UNALLOCATED: | 873 case Variable::UNALLOCATED: |
865 ++global_count_; | 874 // TODO(rossberg): initialize module instance object |
866 break; | 875 break; |
867 | 876 |
868 case Variable::CONTEXT: { | 877 case Variable::CONTEXT: { |
869 Comment cmnt(masm_, "[ ModuleDeclaration"); | 878 Comment cmnt(masm_, "[ ModuleDeclaration"); |
870 EmitDebugCheckDeclarationContext(variable); | 879 EmitDebugCheckDeclarationContext(variable); |
871 // TODO(rossberg): initialize module instance object | 880 // TODO(rossberg): initialize module instance object |
872 break; | 881 break; |
873 } | 882 } |
874 | 883 |
875 case Variable::PARAMETER: | 884 case Variable::PARAMETER: |
876 case Variable::LOCAL: | 885 case Variable::LOCAL: |
877 case Variable::LOOKUP: | 886 case Variable::LOOKUP: |
878 UNREACHABLE(); | 887 UNREACHABLE(); |
879 } | 888 } |
880 } | 889 } |
881 | 890 |
882 | 891 |
883 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | 892 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
884 VariableProxy* proxy = declaration->proxy(); | 893 VariableProxy* proxy = declaration->proxy(); |
885 Variable* variable = proxy->var(); | 894 Variable* variable = proxy->var(); |
886 switch (variable->location()) { | 895 switch (variable->location()) { |
887 case Variable::UNALLOCATED: | 896 case Variable::UNALLOCATED: |
888 ++global_count_; | 897 // TODO(rossberg) |
889 break; | 898 break; |
890 | 899 |
891 case Variable::CONTEXT: { | 900 case Variable::CONTEXT: { |
892 Comment cmnt(masm_, "[ ImportDeclaration"); | 901 Comment cmnt(masm_, "[ ImportDeclaration"); |
893 EmitDebugCheckDeclarationContext(variable); | 902 EmitDebugCheckDeclarationContext(variable); |
894 // TODO(rossberg) | 903 // TODO(rossberg) |
895 break; | 904 break; |
896 } | 905 } |
897 | 906 |
898 case Variable::PARAMETER: | 907 case Variable::PARAMETER: |
(...skipping 3631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4530 *context_length = 0; | 4539 *context_length = 0; |
4531 return previous_; | 4540 return previous_; |
4532 } | 4541 } |
4533 | 4542 |
4534 | 4543 |
4535 #undef __ | 4544 #undef __ |
4536 | 4545 |
4537 } } // namespace v8::internal | 4546 } } // namespace v8::internal |
4538 | 4547 |
4539 #endif // V8_TARGET_ARCH_ARM | 4548 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |