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 globals_.Add(variable->name()); | 760 globals_->Add(variable->name()); |
761 globals_.Add(variable->binding_needs_init() | 761 globals_->Add(variable->binding_needs_init() |
762 ? isolate()->factory()->the_hole_value() | 762 ? isolate()->factory()->the_hole_value() |
763 : isolate()->factory()->undefined_value()); | 763 : isolate()->factory()->undefined_value()); |
764 break; | 764 break; |
765 | 765 |
766 case Variable::PARAMETER: | 766 case Variable::PARAMETER: |
767 case Variable::LOCAL: | 767 case Variable::LOCAL: |
768 if (hole_init) { | 768 if (hole_init) { |
769 Comment cmnt(masm_, "[ VariableDeclaration"); | 769 Comment cmnt(masm_, "[ VariableDeclaration"); |
770 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 770 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
771 __ str(ip, StackOperand(variable)); | 771 __ str(ip, StackOperand(variable)); |
772 } | 772 } |
773 break; | 773 break; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 | 812 |
813 void FullCodeGenerator::VisitFunctionDeclaration( | 813 void FullCodeGenerator::VisitFunctionDeclaration( |
814 FunctionDeclaration* declaration) { | 814 FunctionDeclaration* declaration) { |
815 VariableProxy* proxy = declaration->proxy(); | 815 VariableProxy* proxy = declaration->proxy(); |
816 Variable* variable = proxy->var(); | 816 Variable* variable = proxy->var(); |
817 switch (variable->location()) { | 817 switch (variable->location()) { |
818 case Variable::UNALLOCATED: { | 818 case Variable::UNALLOCATED: { |
819 globals_.Add(variable->name()); | 819 globals_->Add(variable->name()); |
820 Handle<SharedFunctionInfo> function = | 820 Handle<SharedFunctionInfo> function = |
821 Compiler::BuildFunctionInfo(declaration->fun(), script()); | 821 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
822 // Check for stack-overflow exception. | 822 // Check for stack-overflow exception. |
823 if (function.is_null()) return SetStackOverflow(); | 823 if (function.is_null()) return SetStackOverflow(); |
824 globals_.Add(function); | 824 globals_->Add(function); |
825 break; | 825 break; |
826 } | 826 } |
827 | 827 |
828 case Variable::PARAMETER: | 828 case Variable::PARAMETER: |
829 case Variable::LOCAL: { | 829 case Variable::LOCAL: { |
830 Comment cmnt(masm_, "[ FunctionDeclaration"); | 830 Comment cmnt(masm_, "[ FunctionDeclaration"); |
831 VisitForAccumulatorValue(declaration->fun()); | 831 VisitForAccumulatorValue(declaration->fun()); |
832 __ str(result_register(), StackOperand(variable)); | 832 __ str(result_register(), StackOperand(variable)); |
833 break; | 833 break; |
834 } | 834 } |
(...skipping 27 matching lines...) Expand all Loading... |
862 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 862 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
863 break; | 863 break; |
864 } | 864 } |
865 } | 865 } |
866 } | 866 } |
867 | 867 |
868 | 868 |
869 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 869 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
870 VariableProxy* proxy = declaration->proxy(); | 870 VariableProxy* proxy = declaration->proxy(); |
871 Variable* variable = proxy->var(); | 871 Variable* variable = proxy->var(); |
| 872 Handle<JSModule> instance = declaration->module()->interface()->Instance(); |
| 873 // TODO(rossberg): temporary hack until URL import is implemented: |
| 874 if (instance.is_null()) return; |
| 875 ASSERT(!instance.is_null()); |
| 876 |
872 switch (variable->location()) { | 877 switch (variable->location()) { |
873 case Variable::UNALLOCATED: | 878 case Variable::UNALLOCATED: { |
874 // TODO(rossberg): initialize module instance object | 879 Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 880 globals_->Add(variable->name()); |
| 881 globals_->Add(instance); |
| 882 Visit(declaration->module()); |
875 break; | 883 break; |
| 884 } |
876 | 885 |
877 case Variable::CONTEXT: { | 886 case Variable::CONTEXT: { |
878 Comment cmnt(masm_, "[ ModuleDeclaration"); | 887 Comment cmnt(masm_, "[ ModuleDeclaration"); |
879 EmitDebugCheckDeclarationContext(variable); | 888 EmitDebugCheckDeclarationContext(variable); |
880 // TODO(rossberg): initialize module instance object | 889 __ mov(r1, Operand(instance)); |
| 890 __ str(r1, ContextOperand(cp, variable->index())); |
| 891 Visit(declaration->module()); |
881 break; | 892 break; |
882 } | 893 } |
883 | 894 |
884 case Variable::PARAMETER: | 895 case Variable::PARAMETER: |
885 case Variable::LOCAL: | 896 case Variable::LOCAL: |
886 case Variable::LOOKUP: | 897 case Variable::LOOKUP: |
887 UNREACHABLE(); | 898 UNREACHABLE(); |
888 } | 899 } |
889 } | 900 } |
890 | 901 |
(...skipping 3568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4459 } | 4470 } |
4460 | 4471 |
4461 | 4472 |
4462 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4473 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
4463 __ ldr(dst, ContextOperand(cp, context_index)); | 4474 __ ldr(dst, ContextOperand(cp, context_index)); |
4464 } | 4475 } |
4465 | 4476 |
4466 | 4477 |
4467 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4478 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
4468 Scope* declaration_scope = scope()->DeclarationScope(); | 4479 Scope* declaration_scope = scope()->DeclarationScope(); |
4469 if (declaration_scope->is_global_scope()) { | 4480 if (declaration_scope->is_global_scope() || |
| 4481 declaration_scope->is_module_scope()) { |
4470 // Contexts nested in the global context have a canonical empty function | 4482 // Contexts nested in the global context have a canonical empty function |
4471 // as their closure, not the anonymous closure containing the global | 4483 // as their closure, not the anonymous closure containing the global |
4472 // code. Pass a smi sentinel and let the runtime look up the empty | 4484 // code. Pass a smi sentinel and let the runtime look up the empty |
4473 // function. | 4485 // function. |
4474 __ mov(ip, Operand(Smi::FromInt(0))); | 4486 __ mov(ip, Operand(Smi::FromInt(0))); |
4475 } else if (declaration_scope->is_eval_scope()) { | 4487 } else if (declaration_scope->is_eval_scope()) { |
4476 // Contexts created by a call to eval have the same closure as the | 4488 // Contexts created by a call to eval have the same closure as the |
4477 // context calling eval, not the anonymous closure containing the eval | 4489 // context calling eval, not the anonymous closure containing the eval |
4478 // code. Fetch it from the context. | 4490 // code. Fetch it from the context. |
4479 __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); | 4491 __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4539 *context_length = 0; | 4551 *context_length = 0; |
4540 return previous_; | 4552 return previous_; |
4541 } | 4553 } |
4542 | 4554 |
4543 | 4555 |
4544 #undef __ | 4556 #undef __ |
4545 | 4557 |
4546 } } // namespace v8::internal | 4558 } } // namespace v8::internal |
4547 | 4559 |
4548 #endif // V8_TARGET_ARCH_ARM | 4560 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |