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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
772 VariableDeclaration* declaration) { | 772 VariableDeclaration* declaration) { |
773 // If it was not possible to allocate the variable at compile time, we | 773 // If it was not possible to allocate the variable at compile time, we |
774 // need to "declare" it at runtime to make sure it actually exists in the | 774 // need to "declare" it at runtime to make sure it actually exists in the |
775 // local context. | 775 // local context. |
776 VariableProxy* proxy = declaration->proxy(); | 776 VariableProxy* proxy = declaration->proxy(); |
777 VariableMode mode = declaration->mode(); | 777 VariableMode mode = declaration->mode(); |
778 Variable* variable = proxy->var(); | 778 Variable* variable = proxy->var(); |
779 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; | 779 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; |
780 switch (variable->location()) { | 780 switch (variable->location()) { |
781 case Variable::UNALLOCATED: | 781 case Variable::UNALLOCATED: |
782 globals_->Add(variable->name()); | 782 globals_->Add(variable->name(), zone()); |
783 globals_->Add(variable->binding_needs_init() | 783 globals_->Add(variable->binding_needs_init() |
784 ? isolate()->factory()->the_hole_value() | 784 ? isolate()->factory()->the_hole_value() |
785 : isolate()->factory()->undefined_value()); | 785 : isolate()->factory()->undefined_value(), |
| 786 zone()); |
786 break; | 787 break; |
787 | 788 |
788 case Variable::PARAMETER: | 789 case Variable::PARAMETER: |
789 case Variable::LOCAL: | 790 case Variable::LOCAL: |
790 if (hole_init) { | 791 if (hole_init) { |
791 Comment cmnt(masm_, "[ VariableDeclaration"); | 792 Comment cmnt(masm_, "[ VariableDeclaration"); |
792 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 793 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
793 __ movq(StackOperand(variable), kScratchRegister); | 794 __ movq(StackOperand(variable), kScratchRegister); |
794 } | 795 } |
795 break; | 796 break; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 } | 831 } |
831 } | 832 } |
832 | 833 |
833 | 834 |
834 void FullCodeGenerator::VisitFunctionDeclaration( | 835 void FullCodeGenerator::VisitFunctionDeclaration( |
835 FunctionDeclaration* declaration) { | 836 FunctionDeclaration* declaration) { |
836 VariableProxy* proxy = declaration->proxy(); | 837 VariableProxy* proxy = declaration->proxy(); |
837 Variable* variable = proxy->var(); | 838 Variable* variable = proxy->var(); |
838 switch (variable->location()) { | 839 switch (variable->location()) { |
839 case Variable::UNALLOCATED: { | 840 case Variable::UNALLOCATED: { |
840 globals_->Add(variable->name()); | 841 globals_->Add(variable->name(), zone()); |
841 Handle<SharedFunctionInfo> function = | 842 Handle<SharedFunctionInfo> function = |
842 Compiler::BuildFunctionInfo(declaration->fun(), script()); | 843 Compiler::BuildFunctionInfo(declaration->fun(), script()); |
843 // Check for stack-overflow exception. | 844 // Check for stack-overflow exception. |
844 if (function.is_null()) return SetStackOverflow(); | 845 if (function.is_null()) return SetStackOverflow(); |
845 globals_->Add(function); | 846 globals_->Add(function, zone()); |
846 break; | 847 break; |
847 } | 848 } |
848 | 849 |
849 case Variable::PARAMETER: | 850 case Variable::PARAMETER: |
850 case Variable::LOCAL: { | 851 case Variable::LOCAL: { |
851 Comment cmnt(masm_, "[ FunctionDeclaration"); | 852 Comment cmnt(masm_, "[ FunctionDeclaration"); |
852 VisitForAccumulatorValue(declaration->fun()); | 853 VisitForAccumulatorValue(declaration->fun()); |
853 __ movq(StackOperand(variable), result_register()); | 854 __ movq(StackOperand(variable), result_register()); |
854 break; | 855 break; |
855 } | 856 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 888 |
888 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 889 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
889 VariableProxy* proxy = declaration->proxy(); | 890 VariableProxy* proxy = declaration->proxy(); |
890 Variable* variable = proxy->var(); | 891 Variable* variable = proxy->var(); |
891 Handle<JSModule> instance = declaration->module()->interface()->Instance(); | 892 Handle<JSModule> instance = declaration->module()->interface()->Instance(); |
892 ASSERT(!instance.is_null()); | 893 ASSERT(!instance.is_null()); |
893 | 894 |
894 switch (variable->location()) { | 895 switch (variable->location()) { |
895 case Variable::UNALLOCATED: { | 896 case Variable::UNALLOCATED: { |
896 Comment cmnt(masm_, "[ ModuleDeclaration"); | 897 Comment cmnt(masm_, "[ ModuleDeclaration"); |
897 globals_->Add(variable->name()); | 898 globals_->Add(variable->name(), zone()); |
898 globals_->Add(instance); | 899 globals_->Add(instance, zone()); |
899 Visit(declaration->module()); | 900 Visit(declaration->module()); |
900 break; | 901 break; |
901 } | 902 } |
902 | 903 |
903 case Variable::CONTEXT: { | 904 case Variable::CONTEXT: { |
904 Comment cmnt(masm_, "[ ModuleDeclaration"); | 905 Comment cmnt(masm_, "[ ModuleDeclaration"); |
905 EmitDebugCheckDeclarationContext(variable); | 906 EmitDebugCheckDeclarationContext(variable); |
906 __ Move(ContextOperand(rsi, variable->index()), instance); | 907 __ Move(ContextOperand(rsi, variable->index()), instance); |
907 Visit(declaration->module()); | 908 Visit(declaration->module()); |
908 break; | 909 break; |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 __ CallStub(&stub); | 1561 __ CallStub(&stub); |
1561 } | 1562 } |
1562 | 1563 |
1563 // If result_saved is true the result is on top of the stack. If | 1564 // If result_saved is true the result is on top of the stack. If |
1564 // result_saved is false the result is in rax. | 1565 // result_saved is false the result is in rax. |
1565 bool result_saved = false; | 1566 bool result_saved = false; |
1566 | 1567 |
1567 // Mark all computed expressions that are bound to a key that | 1568 // Mark all computed expressions that are bound to a key that |
1568 // is shadowed by a later occurrence of the same key. For the | 1569 // is shadowed by a later occurrence of the same key. For the |
1569 // marked expressions, no store code is emitted. | 1570 // marked expressions, no store code is emitted. |
1570 expr->CalculateEmitStore(); | 1571 expr->CalculateEmitStore(zone()); |
1571 | 1572 |
1572 AccessorTable accessor_table(isolate()->zone()); | 1573 AccessorTable accessor_table(isolate()->zone()); |
1573 for (int i = 0; i < expr->properties()->length(); i++) { | 1574 for (int i = 0; i < expr->properties()->length(); i++) { |
1574 ObjectLiteral::Property* property = expr->properties()->at(i); | 1575 ObjectLiteral::Property* property = expr->properties()->at(i); |
1575 if (property->IsCompileTimeValue()) continue; | 1576 if (property->IsCompileTimeValue()) continue; |
1576 | 1577 |
1577 Literal* key = property->key(); | 1578 Literal* key = property->key(); |
1578 Expression* value = property->value(); | 1579 Expression* value = property->value(); |
1579 if (!result_saved) { | 1580 if (!result_saved) { |
1580 __ push(rax); // Save result on the stack | 1581 __ push(rax); // Save result on the stack |
(...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4503 *context_length = 0; | 4504 *context_length = 0; |
4504 return previous_; | 4505 return previous_; |
4505 } | 4506 } |
4506 | 4507 |
4507 | 4508 |
4508 #undef __ | 4509 #undef __ |
4509 | 4510 |
4510 } } // namespace v8::internal | 4511 } } // namespace v8::internal |
4511 | 4512 |
4512 #endif // V8_TARGET_ARCH_X64 | 4513 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |