OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (scope()->HasIllegalRedeclaration()) { | 258 if (scope()->HasIllegalRedeclaration()) { |
259 Comment cmnt(masm_, "[ Declarations"); | 259 Comment cmnt(masm_, "[ Declarations"); |
260 scope()->VisitIllegalRedeclaration(this); | 260 scope()->VisitIllegalRedeclaration(this); |
261 | 261 |
262 } else { | 262 } else { |
263 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); | 263 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); |
264 { Comment cmnt(masm_, "[ Declarations"); | 264 { Comment cmnt(masm_, "[ Declarations"); |
265 // For named function expressions, declare the function name as a | 265 // For named function expressions, declare the function name as a |
266 // constant. | 266 // constant. |
267 if (scope()->is_function_scope() && scope()->function() != NULL) { | 267 if (scope()->is_function_scope() && scope()->function() != NULL) { |
268 int ignored = 0; | |
269 VariableProxy* proxy = scope()->function(); | 268 VariableProxy* proxy = scope()->function(); |
270 ASSERT(proxy->var()->mode() == CONST || | 269 ASSERT(proxy->var()->mode() == CONST || |
271 proxy->var()->mode() == CONST_HARMONY); | 270 proxy->var()->mode() == CONST_HARMONY); |
272 EmitDeclaration(proxy, proxy->var()->mode(), NULL, &ignored); | 271 ASSERT(proxy->var()->location() != Variable::UNALLOCATED); |
| 272 EmitDeclaration(proxy, proxy->var()->mode(), NULL); |
273 } | 273 } |
274 VisitDeclarations(scope()->declarations()); | 274 VisitDeclarations(scope()->declarations()); |
275 } | 275 } |
276 | 276 |
277 { Comment cmnt(masm_, "[ Stack check"); | 277 { Comment cmnt(masm_, "[ Stack check"); |
278 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); | 278 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); |
279 Label ok; | 279 Label ok; |
280 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 280 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
281 __ cmp(sp, Operand(ip)); | 281 __ cmp(sp, Operand(ip)); |
282 __ b(hs, &ok); | 282 __ b(hs, &ok); |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 699 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
700 __ cmp(r0, ip); | 700 __ cmp(r0, ip); |
701 Split(eq, if_true, if_false, NULL); | 701 Split(eq, if_true, if_false, NULL); |
702 __ bind(&skip); | 702 __ bind(&skip); |
703 } | 703 } |
704 } | 704 } |
705 | 705 |
706 | 706 |
707 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, | 707 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, |
708 VariableMode mode, | 708 VariableMode mode, |
709 FunctionLiteral* function, | 709 FunctionLiteral* function) { |
710 int* global_count) { | |
711 // If it was not possible to allocate the variable at compile time, we | 710 // If it was not possible to allocate the variable at compile time, we |
712 // need to "declare" it at runtime to make sure it actually exists in the | 711 // need to "declare" it at runtime to make sure it actually exists in the |
713 // local context. | 712 // local context. |
714 Variable* variable = proxy->var(); | 713 Variable* variable = proxy->var(); |
715 bool binding_needs_init = (function == NULL) && | 714 bool binding_needs_init = (function == NULL) && |
716 (mode == CONST || mode == CONST_HARMONY || mode == LET); | 715 (mode == CONST || mode == CONST_HARMONY || mode == LET); |
717 switch (variable->location()) { | 716 switch (variable->location()) { |
718 case Variable::UNALLOCATED: | 717 case Variable::UNALLOCATED: |
719 ++(*global_count); | 718 ++global_count_; |
720 break; | 719 break; |
721 | 720 |
722 case Variable::PARAMETER: | 721 case Variable::PARAMETER: |
723 case Variable::LOCAL: | 722 case Variable::LOCAL: |
724 if (function != NULL) { | 723 if (function != NULL) { |
725 Comment cmnt(masm_, "[ Declaration"); | 724 Comment cmnt(masm_, "[ Declaration"); |
726 VisitForAccumulatorValue(function); | 725 VisitForAccumulatorValue(function); |
727 __ str(result_register(), StackOperand(variable)); | 726 __ str(result_register(), StackOperand(variable)); |
728 } else if (binding_needs_init) { | 727 } else if (binding_needs_init) { |
729 Comment cmnt(masm_, "[ Declaration"); | 728 Comment cmnt(masm_, "[ Declaration"); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 __ mov(r0, Operand(Smi::FromInt(0))); // Indicates no initial value. | 793 __ mov(r0, Operand(Smi::FromInt(0))); // Indicates no initial value. |
795 __ Push(cp, r2, r1, r0); | 794 __ Push(cp, r2, r1, r0); |
796 } | 795 } |
797 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 796 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
798 break; | 797 break; |
799 } | 798 } |
800 } | 799 } |
801 } | 800 } |
802 | 801 |
803 | 802 |
804 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { } | |
805 | |
806 | |
807 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 803 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
808 // Call the runtime to declare the globals. | 804 // Call the runtime to declare the globals. |
809 // The context is the first argument. | 805 // The context is the first argument. |
810 __ mov(r1, Operand(pairs)); | 806 __ mov(r1, Operand(pairs)); |
811 __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 807 __ mov(r0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
812 __ Push(cp, r1, r0); | 808 __ Push(cp, r1, r0); |
813 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 809 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
814 // Return value is ignored. | 810 // Return value is ignored. |
815 } | 811 } |
816 | 812 |
(...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4403 *context_length = 0; | 4399 *context_length = 0; |
4404 return previous_; | 4400 return previous_; |
4405 } | 4401 } |
4406 | 4402 |
4407 | 4403 |
4408 #undef __ | 4404 #undef __ |
4409 | 4405 |
4410 } } // namespace v8::internal | 4406 } } // namespace v8::internal |
4411 | 4407 |
4412 #endif // V8_TARGET_ARCH_ARM | 4408 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |