| 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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 globals_.Add(variable->name()); | 732 globals_->Add(variable->name()); |
| 733 globals_.Add(variable->binding_needs_init() | 733 globals_->Add(variable->binding_needs_init() |
| 734 ? isolate()->factory()->the_hole_value() | 734 ? isolate()->factory()->the_hole_value() |
| 735 : isolate()->factory()->undefined_value()); | 735 : isolate()->factory()->undefined_value()); |
| 736 break; | 736 break; |
| 737 | 737 |
| 738 case Variable::PARAMETER: | 738 case Variable::PARAMETER: |
| 739 case Variable::LOCAL: | 739 case Variable::LOCAL: |
| 740 if (hole_init) { | 740 if (hole_init) { |
| 741 Comment cmnt(masm_, "[ VariableDeclaration"); | 741 Comment cmnt(masm_, "[ VariableDeclaration"); |
| 742 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 742 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
| 743 __ movq(StackOperand(variable), kScratchRegister); | 743 __ movq(StackOperand(variable), kScratchRegister); |
| 744 } | 744 } |
| 745 break; | 745 break; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 | 783 |
| 784 void FullCodeGenerator::VisitFunctionDeclaration( | 784 void FullCodeGenerator::VisitFunctionDeclaration( |
| 785 FunctionDeclaration* declaration) { | 785 FunctionDeclaration* declaration) { |
| 786 VariableProxy* proxy = declaration->proxy(); | 786 VariableProxy* proxy = declaration->proxy(); |
| 787 Variable* variable = proxy->var(); | 787 Variable* variable = proxy->var(); |
| 788 switch (variable->location()) { | 788 switch (variable->location()) { |
| 789 case Variable::UNALLOCATED: { | 789 case Variable::UNALLOCATED: { |
| 790 globals_.Add(variable->name()); | 790 globals_->Add(variable->name()); |
| 791 Handle<SharedFunctionInfo> function = | 791 Handle<SharedFunctionInfo> function = |
| 792 Compiler::BuildFunctionInfo(declaration->fun(), script()); | 792 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
| 793 // Check for stack-overflow exception. | 793 // Check for stack-overflow exception. |
| 794 if (function.is_null()) return SetStackOverflow(); | 794 if (function.is_null()) return SetStackOverflow(); |
| 795 globals_.Add(function); | 795 globals_->Add(function); |
| 796 break; | 796 break; |
| 797 } | 797 } |
| 798 | 798 |
| 799 case Variable::PARAMETER: | 799 case Variable::PARAMETER: |
| 800 case Variable::LOCAL: { | 800 case Variable::LOCAL: { |
| 801 Comment cmnt(masm_, "[ FunctionDeclaration"); | 801 Comment cmnt(masm_, "[ FunctionDeclaration"); |
| 802 VisitForAccumulatorValue(declaration->fun()); | 802 VisitForAccumulatorValue(declaration->fun()); |
| 803 __ movq(StackOperand(variable), result_register()); | 803 __ movq(StackOperand(variable), result_register()); |
| 804 break; | 804 break; |
| 805 } | 805 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 831 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 831 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
| 832 break; | 832 break; |
| 833 } | 833 } |
| 834 } | 834 } |
| 835 } | 835 } |
| 836 | 836 |
| 837 | 837 |
| 838 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 838 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
| 839 VariableProxy* proxy = declaration->proxy(); | 839 VariableProxy* proxy = declaration->proxy(); |
| 840 Variable* variable = proxy->var(); | 840 Variable* variable = proxy->var(); |
| 841 Handle<JSModule> instance = declaration->module()->interface()->Instance(); |
| 842 // TODO(rossberg): temporary hack until URL import is implemented: |
| 843 if (instance.is_null()) return; |
| 844 ASSERT(!instance.is_null()); |
| 845 |
| 841 switch (variable->location()) { | 846 switch (variable->location()) { |
| 842 case Variable::UNALLOCATED: | 847 case Variable::UNALLOCATED: { |
| 843 // TODO(rossberg): initialize module instance object | 848 Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 849 globals_->Add(variable->name()); |
| 850 globals_->Add(instance); |
| 851 Visit(declaration->module()); |
| 844 break; | 852 break; |
| 853 } |
| 845 | 854 |
| 846 case Variable::CONTEXT: { | 855 case Variable::CONTEXT: { |
| 847 Comment cmnt(masm_, "[ ModuleDeclaration"); | 856 Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 848 EmitDebugCheckDeclarationContext(variable); | 857 EmitDebugCheckDeclarationContext(variable); |
| 849 // TODO(rossberg): initialize module instance object | 858 __ Move(ContextOperand(rsi, variable->index()), instance); |
| 859 Visit(declaration->module()); |
| 850 break; | 860 break; |
| 851 } | 861 } |
| 852 | 862 |
| 853 case Variable::PARAMETER: | 863 case Variable::PARAMETER: |
| 854 case Variable::LOCAL: | 864 case Variable::LOCAL: |
| 855 case Variable::LOOKUP: | 865 case Variable::LOOKUP: |
| 856 UNREACHABLE(); | 866 UNREACHABLE(); |
| 857 } | 867 } |
| 858 } | 868 } |
| 859 | 869 |
| (...skipping 3563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4423 } | 4433 } |
| 4424 | 4434 |
| 4425 | 4435 |
| 4426 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4436 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 4427 __ movq(dst, ContextOperand(rsi, context_index)); | 4437 __ movq(dst, ContextOperand(rsi, context_index)); |
| 4428 } | 4438 } |
| 4429 | 4439 |
| 4430 | 4440 |
| 4431 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4441 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 4432 Scope* declaration_scope = scope()->DeclarationScope(); | 4442 Scope* declaration_scope = scope()->DeclarationScope(); |
| 4433 if (declaration_scope->is_global_scope()) { | 4443 if (declaration_scope->is_global_scope() || |
| 4444 declaration_scope->is_module_scope()) { |
| 4434 // Contexts nested in the global context have a canonical empty function | 4445 // Contexts nested in the global context have a canonical empty function |
| 4435 // as their closure, not the anonymous closure containing the global | 4446 // as their closure, not the anonymous closure containing the global |
| 4436 // code. Pass a smi sentinel and let the runtime look up the empty | 4447 // code. Pass a smi sentinel and let the runtime look up the empty |
| 4437 // function. | 4448 // function. |
| 4438 __ Push(Smi::FromInt(0)); | 4449 __ Push(Smi::FromInt(0)); |
| 4439 } else if (declaration_scope->is_eval_scope()) { | 4450 } else if (declaration_scope->is_eval_scope()) { |
| 4440 // Contexts created by a call to eval have the same closure as the | 4451 // Contexts created by a call to eval have the same closure as the |
| 4441 // context calling eval, not the anonymous closure containing the eval | 4452 // context calling eval, not the anonymous closure containing the eval |
| 4442 // code. Fetch it from the context. | 4453 // code. Fetch it from the context. |
| 4443 __ push(ContextOperand(rsi, Context::CLOSURE_INDEX)); | 4454 __ push(ContextOperand(rsi, Context::CLOSURE_INDEX)); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4505 *context_length = 0; | 4516 *context_length = 0; |
| 4506 return previous_; | 4517 return previous_; |
| 4507 } | 4518 } |
| 4508 | 4519 |
| 4509 | 4520 |
| 4510 #undef __ | 4521 #undef __ |
| 4511 | 4522 |
| 4512 } } // namespace v8::internal | 4523 } } // namespace v8::internal |
| 4513 | 4524 |
| 4514 #endif // V8_TARGET_ARCH_X64 | 4525 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |