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

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

Issue 9722043: Refactor code generation for global declarations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 VariableDeclaration* declaration) { 722 VariableDeclaration* declaration) {
723 // If it was not possible to allocate the variable at compile time, we 723 // If it was not possible to allocate the variable at compile time, we
724 // need to "declare" it at runtime to make sure it actually exists in the 724 // need to "declare" it at runtime to make sure it actually exists in the
725 // local context. 725 // local context.
726 VariableProxy* proxy = declaration->proxy(); 726 VariableProxy* proxy = declaration->proxy();
727 VariableMode mode = declaration->mode(); 727 VariableMode mode = declaration->mode();
728 Variable* variable = proxy->var(); 728 Variable* variable = proxy->var();
729 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; 729 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
730 switch (variable->location()) { 730 switch (variable->location()) {
731 case Variable::UNALLOCATED: 731 case Variable::UNALLOCATED:
732 ++global_count_; 732 globals_.Add(variable->name());
733 globals_.Add(variable->binding_needs_init()
734 ? isolate()->factory()->the_hole_value()
735 : isolate()->factory()->undefined_value());
733 break; 736 break;
734 737
735 case Variable::PARAMETER: 738 case Variable::PARAMETER:
736 case Variable::LOCAL: 739 case Variable::LOCAL:
737 if (hole_init) { 740 if (hole_init) {
738 Comment cmnt(masm_, "[ VariableDeclaration"); 741 Comment cmnt(masm_, "[ VariableDeclaration");
739 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); 742 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex);
740 __ movq(StackOperand(variable), kScratchRegister); 743 __ movq(StackOperand(variable), kScratchRegister);
741 } 744 }
742 break; 745 break;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 } 779 }
777 } 780 }
778 } 781 }
779 782
780 783
781 void FullCodeGenerator::VisitFunctionDeclaration( 784 void FullCodeGenerator::VisitFunctionDeclaration(
782 FunctionDeclaration* declaration) { 785 FunctionDeclaration* declaration) {
783 VariableProxy* proxy = declaration->proxy(); 786 VariableProxy* proxy = declaration->proxy();
784 Variable* variable = proxy->var(); 787 Variable* variable = proxy->var();
785 switch (variable->location()) { 788 switch (variable->location()) {
786 case Variable::UNALLOCATED: 789 case Variable::UNALLOCATED: {
787 ++global_count_; 790 globals_.Add(variable->name());
791 Handle<SharedFunctionInfo> function =
792 Compiler::BuildFunctionInfo(declaration->fun(), script());
793 // Check for stack-overflow exception.
794 if (function.is_null()) return SetStackOverflow();
795 globals_.Add(function);
788 break; 796 break;
797 }
789 798
790 case Variable::PARAMETER: 799 case Variable::PARAMETER:
791 case Variable::LOCAL: { 800 case Variable::LOCAL: {
792 Comment cmnt(masm_, "[ FunctionDeclaration"); 801 Comment cmnt(masm_, "[ FunctionDeclaration");
793 VisitForAccumulatorValue(declaration->fun()); 802 VisitForAccumulatorValue(declaration->fun());
794 __ movq(StackOperand(variable), result_register()); 803 __ movq(StackOperand(variable), result_register());
795 break; 804 break;
796 } 805 }
797 806
798 case Variable::CONTEXT: { 807 case Variable::CONTEXT: {
(...skipping 25 matching lines...) Expand all
824 } 833 }
825 } 834 }
826 } 835 }
827 836
828 837
829 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 838 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
830 VariableProxy* proxy = declaration->proxy(); 839 VariableProxy* proxy = declaration->proxy();
831 Variable* variable = proxy->var(); 840 Variable* variable = proxy->var();
832 switch (variable->location()) { 841 switch (variable->location()) {
833 case Variable::UNALLOCATED: 842 case Variable::UNALLOCATED:
834 ++global_count_; 843 // TODO(rossberg): initialize module instance object
835 break; 844 break;
836 845
837 case Variable::CONTEXT: { 846 case Variable::CONTEXT: {
838 Comment cmnt(masm_, "[ ModuleDeclaration"); 847 Comment cmnt(masm_, "[ ModuleDeclaration");
839 EmitDebugCheckDeclarationContext(variable); 848 EmitDebugCheckDeclarationContext(variable);
840 // TODO(rossberg): initialize module instance object 849 // TODO(rossberg): initialize module instance object
841 break; 850 break;
842 } 851 }
843 852
844 case Variable::PARAMETER: 853 case Variable::PARAMETER:
845 case Variable::LOCAL: 854 case Variable::LOCAL:
846 case Variable::LOOKUP: 855 case Variable::LOOKUP:
847 UNREACHABLE(); 856 UNREACHABLE();
848 } 857 }
849 } 858 }
850 859
851 860
852 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { 861 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) {
853 VariableProxy* proxy = declaration->proxy(); 862 VariableProxy* proxy = declaration->proxy();
854 Variable* variable = proxy->var(); 863 Variable* variable = proxy->var();
855 switch (variable->location()) { 864 switch (variable->location()) {
856 case Variable::UNALLOCATED: 865 case Variable::UNALLOCATED:
857 ++global_count_; 866 // TODO(rossberg)
858 break; 867 break;
859 868
860 case Variable::CONTEXT: { 869 case Variable::CONTEXT: {
861 Comment cmnt(masm_, "[ ImportDeclaration"); 870 Comment cmnt(masm_, "[ ImportDeclaration");
862 EmitDebugCheckDeclarationContext(variable); 871 EmitDebugCheckDeclarationContext(variable);
863 // TODO(rossberg) 872 // TODO(rossberg)
864 break; 873 break;
865 } 874 }
866 875
867 case Variable::PARAMETER: 876 case Variable::PARAMETER:
(...skipping 3628 matching lines...) Expand 10 before | Expand all | Expand 10 after
4496 *context_length = 0; 4505 *context_length = 0;
4497 return previous_; 4506 return previous_;
4498 } 4507 }
4499 4508
4500 4509
4501 #undef __ 4510 #undef __
4502 4511
4503 } } // namespace v8::internal 4512 } } // namespace v8::internal
4504 4513
4505 #endif // V8_TARGET_ARCH_X64 4514 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/full-codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698