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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 VariableDeclaration* declaration) { | 810 VariableDeclaration* declaration) { |
811 // If it was not possible to allocate the variable at compile time, we | 811 // If it was not possible to allocate the variable at compile time, we |
812 // need to "declare" it at runtime to make sure it actually exists in the | 812 // need to "declare" it at runtime to make sure it actually exists in the |
813 // local context. | 813 // local context. |
814 VariableProxy* proxy = declaration->proxy(); | 814 VariableProxy* proxy = declaration->proxy(); |
815 VariableMode mode = declaration->mode(); | 815 VariableMode mode = declaration->mode(); |
816 Variable* variable = proxy->var(); | 816 Variable* variable = proxy->var(); |
817 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; | 817 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; |
818 switch (variable->location()) { | 818 switch (variable->location()) { |
819 case Variable::UNALLOCATED: | 819 case Variable::UNALLOCATED: |
820 globals_.Add(variable->name()); | 820 globals_->Add(variable->name()); |
821 globals_.Add(variable->binding_needs_init() | 821 globals_->Add(variable->binding_needs_init() |
822 ? isolate()->factory()->the_hole_value() | 822 ? isolate()->factory()->the_hole_value() |
823 : isolate()->factory()->undefined_value()); | 823 : isolate()->factory()->undefined_value()); |
824 break; | 824 break; |
825 | 825 |
826 case Variable::PARAMETER: | 826 case Variable::PARAMETER: |
827 case Variable::LOCAL: | 827 case Variable::LOCAL: |
828 if (hole_init) { | 828 if (hole_init) { |
829 Comment cmnt(masm_, "[ VariableDeclaration"); | 829 Comment cmnt(masm_, "[ VariableDeclaration"); |
830 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); | 830 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
831 __ sw(t0, StackOperand(variable)); | 831 __ sw(t0, StackOperand(variable)); |
832 } | 832 } |
833 break; | 833 break; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 } | 870 } |
871 } | 871 } |
872 | 872 |
873 | 873 |
874 void FullCodeGenerator::VisitFunctionDeclaration( | 874 void FullCodeGenerator::VisitFunctionDeclaration( |
875 FunctionDeclaration* declaration) { | 875 FunctionDeclaration* declaration) { |
876 VariableProxy* proxy = declaration->proxy(); | 876 VariableProxy* proxy = declaration->proxy(); |
877 Variable* variable = proxy->var(); | 877 Variable* variable = proxy->var(); |
878 switch (variable->location()) { | 878 switch (variable->location()) { |
879 case Variable::UNALLOCATED: { | 879 case Variable::UNALLOCATED: { |
880 globals_.Add(variable->name()); | 880 globals_->Add(variable->name()); |
881 Handle<SharedFunctionInfo> function = | 881 Handle<SharedFunctionInfo> function = |
882 Compiler::BuildFunctionInfo(declaration->fun(), script()); | 882 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
883 // Check for stack-overflow exception. | 883 // Check for stack-overflow exception. |
884 if (function.is_null()) return SetStackOverflow(); | 884 if (function.is_null()) return SetStackOverflow(); |
885 globals_.Add(function); | 885 globals_->Add(function); |
886 break; | 886 break; |
887 } | 887 } |
888 | 888 |
889 case Variable::PARAMETER: | 889 case Variable::PARAMETER: |
890 case Variable::LOCAL: { | 890 case Variable::LOCAL: { |
891 Comment cmnt(masm_, "[ FunctionDeclaration"); | 891 Comment cmnt(masm_, "[ FunctionDeclaration"); |
892 VisitForAccumulatorValue(declaration->fun()); | 892 VisitForAccumulatorValue(declaration->fun()); |
893 __ sw(result_register(), StackOperand(variable)); | 893 __ sw(result_register(), StackOperand(variable)); |
894 break; | 894 break; |
895 } | 895 } |
(...skipping 27 matching lines...) Expand all Loading... |
923 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 923 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
924 break; | 924 break; |
925 } | 925 } |
926 } | 926 } |
927 } | 927 } |
928 | 928 |
929 | 929 |
930 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 930 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
931 VariableProxy* proxy = declaration->proxy(); | 931 VariableProxy* proxy = declaration->proxy(); |
932 Variable* variable = proxy->var(); | 932 Variable* variable = proxy->var(); |
| 933 Handle<JSModule> instance = declaration->module()->interface()->Instance(); |
| 934 ASSERT(!instance.is_null()); |
| 935 |
933 switch (variable->location()) { | 936 switch (variable->location()) { |
934 case Variable::UNALLOCATED: | 937 case Variable::UNALLOCATED: { |
935 // TODO(rossberg): initialize module instance object | 938 Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 939 globals_->Add(variable->name()); |
| 940 globals_->Add(instance); |
| 941 Visit(declaration->module()); |
936 break; | 942 break; |
| 943 } |
937 | 944 |
938 case Variable::CONTEXT: { | 945 case Variable::CONTEXT: { |
939 Comment cmnt(masm_, "[ ModuleDeclaration"); | 946 Comment cmnt(masm_, "[ ModuleDeclaration"); |
940 EmitDebugCheckDeclarationContext(variable); | 947 EmitDebugCheckDeclarationContext(variable); |
941 // TODO(rossberg): initialize module instance object | 948 __ li(a1, Operand(instance)); |
| 949 __ sw(a1, ContextOperand(cp, variable->index())); |
| 950 Visit(declaration->module()); |
942 break; | 951 break; |
943 } | 952 } |
944 | 953 |
945 case Variable::PARAMETER: | 954 case Variable::PARAMETER: |
946 case Variable::LOCAL: | 955 case Variable::LOCAL: |
947 case Variable::LOOKUP: | 956 case Variable::LOOKUP: |
948 UNREACHABLE(); | 957 UNREACHABLE(); |
949 } | 958 } |
950 } | 959 } |
951 | 960 |
(...skipping 3616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4568 } | 4577 } |
4569 | 4578 |
4570 | 4579 |
4571 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4580 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
4572 __ lw(dst, ContextOperand(cp, context_index)); | 4581 __ lw(dst, ContextOperand(cp, context_index)); |
4573 } | 4582 } |
4574 | 4583 |
4575 | 4584 |
4576 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4585 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
4577 Scope* declaration_scope = scope()->DeclarationScope(); | 4586 Scope* declaration_scope = scope()->DeclarationScope(); |
4578 if (declaration_scope->is_global_scope()) { | 4587 if (declaration_scope->is_global_scope() || |
| 4588 declaration_scope->is_module_scope()) { |
4579 // Contexts nested in the global context have a canonical empty function | 4589 // Contexts nested in the global context have a canonical empty function |
4580 // as their closure, not the anonymous closure containing the global | 4590 // as their closure, not the anonymous closure containing the global |
4581 // code. Pass a smi sentinel and let the runtime look up the empty | 4591 // code. Pass a smi sentinel and let the runtime look up the empty |
4582 // function. | 4592 // function. |
4583 __ li(at, Operand(Smi::FromInt(0))); | 4593 __ li(at, Operand(Smi::FromInt(0))); |
4584 } else if (declaration_scope->is_eval_scope()) { | 4594 } else if (declaration_scope->is_eval_scope()) { |
4585 // Contexts created by a call to eval have the same closure as the | 4595 // Contexts created by a call to eval have the same closure as the |
4586 // context calling eval, not the anonymous closure containing the eval | 4596 // context calling eval, not the anonymous closure containing the eval |
4587 // code. Fetch it from the context. | 4597 // code. Fetch it from the context. |
4588 __ lw(at, ContextOperand(cp, Context::CLOSURE_INDEX)); | 4598 __ lw(at, ContextOperand(cp, Context::CLOSURE_INDEX)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4649 *context_length = 0; | 4659 *context_length = 0; |
4650 return previous_; | 4660 return previous_; |
4651 } | 4661 } |
4652 | 4662 |
4653 | 4663 |
4654 #undef __ | 4664 #undef __ |
4655 | 4665 |
4656 } } // namespace v8::internal | 4666 } } // namespace v8::internal |
4657 | 4667 |
4658 #endif // V8_TARGET_ARCH_MIPS | 4668 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |