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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 VariableDeclaration* declaration) { | 769 VariableDeclaration* declaration) { |
770 // If it was not possible to allocate the variable at compile time, we | 770 // If it was not possible to allocate the variable at compile time, we |
771 // need to "declare" it at runtime to make sure it actually exists in the | 771 // need to "declare" it at runtime to make sure it actually exists in the |
772 // local context. | 772 // local context. |
773 VariableProxy* proxy = declaration->proxy(); | 773 VariableProxy* proxy = declaration->proxy(); |
774 VariableMode mode = declaration->mode(); | 774 VariableMode mode = declaration->mode(); |
775 Variable* variable = proxy->var(); | 775 Variable* variable = proxy->var(); |
776 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; | 776 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; |
777 switch (variable->location()) { | 777 switch (variable->location()) { |
778 case Variable::UNALLOCATED: | 778 case Variable::UNALLOCATED: |
779 ++global_count_; | 779 globals_.Add(variable->name()); |
| 780 globals_.Add(variable->binding_needs_init() |
| 781 ? isolate()->factory()->the_hole_value() |
| 782 : isolate()->factory()->undefined_value()); |
780 break; | 783 break; |
781 | 784 |
782 case Variable::PARAMETER: | 785 case Variable::PARAMETER: |
783 case Variable::LOCAL: | 786 case Variable::LOCAL: |
784 if (hole_init) { | 787 if (hole_init) { |
785 Comment cmnt(masm_, "[ VariableDeclaration"); | 788 Comment cmnt(masm_, "[ VariableDeclaration"); |
786 __ mov(StackOperand(variable), | 789 __ mov(StackOperand(variable), |
787 Immediate(isolate()->factory()->the_hole_value())); | 790 Immediate(isolate()->factory()->the_hole_value())); |
788 } | 791 } |
789 break; | 792 break; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 } | 826 } |
824 } | 827 } |
825 } | 828 } |
826 | 829 |
827 | 830 |
828 void FullCodeGenerator::VisitFunctionDeclaration( | 831 void FullCodeGenerator::VisitFunctionDeclaration( |
829 FunctionDeclaration* declaration) { | 832 FunctionDeclaration* declaration) { |
830 VariableProxy* proxy = declaration->proxy(); | 833 VariableProxy* proxy = declaration->proxy(); |
831 Variable* variable = proxy->var(); | 834 Variable* variable = proxy->var(); |
832 switch (variable->location()) { | 835 switch (variable->location()) { |
833 case Variable::UNALLOCATED: | 836 case Variable::UNALLOCATED: { |
834 ++global_count_; | 837 globals_.Add(variable->name()); |
| 838 Handle<SharedFunctionInfo> function = |
| 839 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
| 840 // Check for stack-overflow exception. |
| 841 if (function.is_null()) return SetStackOverflow(); |
| 842 globals_.Add(function); |
835 break; | 843 break; |
| 844 } |
836 | 845 |
837 case Variable::PARAMETER: | 846 case Variable::PARAMETER: |
838 case Variable::LOCAL: { | 847 case Variable::LOCAL: { |
839 Comment cmnt(masm_, "[ FunctionDeclaration"); | 848 Comment cmnt(masm_, "[ FunctionDeclaration"); |
840 VisitForAccumulatorValue(declaration->fun()); | 849 VisitForAccumulatorValue(declaration->fun()); |
841 __ mov(StackOperand(variable), result_register()); | 850 __ mov(StackOperand(variable), result_register()); |
842 break; | 851 break; |
843 } | 852 } |
844 | 853 |
845 case Variable::CONTEXT: { | 854 case Variable::CONTEXT: { |
(...skipping 24 matching lines...) Expand all Loading... |
870 } | 879 } |
871 } | 880 } |
872 } | 881 } |
873 | 882 |
874 | 883 |
875 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 884 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
876 VariableProxy* proxy = declaration->proxy(); | 885 VariableProxy* proxy = declaration->proxy(); |
877 Variable* variable = proxy->var(); | 886 Variable* variable = proxy->var(); |
878 switch (variable->location()) { | 887 switch (variable->location()) { |
879 case Variable::UNALLOCATED: | 888 case Variable::UNALLOCATED: |
880 ++global_count_; | 889 // TODO(rossberg): initialize module instance object |
881 break; | 890 break; |
882 | 891 |
883 case Variable::CONTEXT: { | 892 case Variable::CONTEXT: { |
884 Comment cmnt(masm_, "[ ModuleDeclaration"); | 893 Comment cmnt(masm_, "[ ModuleDeclaration"); |
885 EmitDebugCheckDeclarationContext(variable); | 894 EmitDebugCheckDeclarationContext(variable); |
886 // TODO(rossberg): initialize module instance object | 895 // TODO(rossberg): initialize module instance object |
887 break; | 896 break; |
888 } | 897 } |
889 | 898 |
890 case Variable::PARAMETER: | 899 case Variable::PARAMETER: |
891 case Variable::LOCAL: | 900 case Variable::LOCAL: |
892 case Variable::LOOKUP: | 901 case Variable::LOOKUP: |
893 UNREACHABLE(); | 902 UNREACHABLE(); |
894 } | 903 } |
895 } | 904 } |
896 | 905 |
897 | 906 |
898 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { | 907 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { |
899 VariableProxy* proxy = declaration->proxy(); | 908 VariableProxy* proxy = declaration->proxy(); |
900 Variable* variable = proxy->var(); | 909 Variable* variable = proxy->var(); |
901 switch (variable->location()) { | 910 switch (variable->location()) { |
902 case Variable::UNALLOCATED: | 911 case Variable::UNALLOCATED: |
903 ++global_count_; | 912 // TODO(rossberg) |
904 break; | 913 break; |
905 | 914 |
906 case Variable::CONTEXT: { | 915 case Variable::CONTEXT: { |
907 Comment cmnt(masm_, "[ ImportDeclaration"); | 916 Comment cmnt(masm_, "[ ImportDeclaration"); |
908 EmitDebugCheckDeclarationContext(variable); | 917 EmitDebugCheckDeclarationContext(variable); |
909 // TODO(rossberg) | 918 // TODO(rossberg) |
910 break; | 919 break; |
911 } | 920 } |
912 | 921 |
913 case Variable::PARAMETER: | 922 case Variable::PARAMETER: |
(...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4562 *context_length = 0; | 4571 *context_length = 0; |
4563 return previous_; | 4572 return previous_; |
4564 } | 4573 } |
4565 | 4574 |
4566 | 4575 |
4567 #undef __ | 4576 #undef __ |
4568 | 4577 |
4569 } } // namespace v8::internal | 4578 } } // namespace v8::internal |
4570 | 4579 |
4571 #endif // V8_TARGET_ARCH_IA32 | 4580 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |