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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 if (scope()->HasIllegalRedeclaration()) { | 288 if (scope()->HasIllegalRedeclaration()) { |
289 Comment cmnt(masm_, "[ Declarations"); | 289 Comment cmnt(masm_, "[ Declarations"); |
290 scope()->VisitIllegalRedeclaration(this); | 290 scope()->VisitIllegalRedeclaration(this); |
291 | 291 |
292 } else { | 292 } else { |
293 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); | 293 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); |
294 { Comment cmnt(masm_, "[ Declarations"); | 294 { Comment cmnt(masm_, "[ Declarations"); |
295 // For named function expressions, declare the function name as a | 295 // For named function expressions, declare the function name as a |
296 // constant. | 296 // constant. |
297 if (scope()->is_function_scope() && scope()->function() != NULL) { | 297 if (scope()->is_function_scope() && scope()->function() != NULL) { |
298 int ignored = 0; | |
299 VariableProxy* proxy = scope()->function(); | 298 VariableProxy* proxy = scope()->function(); |
300 ASSERT(proxy->var()->mode() == CONST || | 299 ASSERT(proxy->var()->mode() == CONST || |
301 proxy->var()->mode() == CONST_HARMONY); | 300 proxy->var()->mode() == CONST_HARMONY); |
302 EmitDeclaration(proxy, proxy->var()->mode(), NULL, &ignored); | 301 ASSERT(proxy->var()->location() != Variable::UNALLOCATED); |
| 302 EmitDeclaration(proxy, proxy->var()->mode(), NULL); |
303 } | 303 } |
304 VisitDeclarations(scope()->declarations()); | 304 VisitDeclarations(scope()->declarations()); |
305 } | 305 } |
306 | 306 |
307 { Comment cmnt(masm_, "[ Stack check"); | 307 { Comment cmnt(masm_, "[ Stack check"); |
308 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); | 308 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); |
309 Label ok; | 309 Label ok; |
310 __ LoadRoot(t0, Heap::kStackLimitRootIndex); | 310 __ LoadRoot(t0, Heap::kStackLimitRootIndex); |
311 __ Branch(&ok, hs, sp, Operand(t0)); | 311 __ Branch(&ok, hs, sp, Operand(t0)); |
312 StackCheckStub stub; | 312 StackCheckStub stub; |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 if (should_normalize) { | 731 if (should_normalize) { |
732 __ LoadRoot(t0, Heap::kTrueValueRootIndex); | 732 __ LoadRoot(t0, Heap::kTrueValueRootIndex); |
733 Split(eq, a0, Operand(t0), if_true, if_false, NULL); | 733 Split(eq, a0, Operand(t0), if_true, if_false, NULL); |
734 __ bind(&skip); | 734 __ bind(&skip); |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 | 738 |
739 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, | 739 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, |
740 VariableMode mode, | 740 VariableMode mode, |
741 FunctionLiteral* function, | 741 FunctionLiteral* function) { |
742 int* global_count) { | |
743 // If it was not possible to allocate the variable at compile time, we | 742 // If it was not possible to allocate the variable at compile time, we |
744 // need to "declare" it at runtime to make sure it actually exists in the | 743 // need to "declare" it at runtime to make sure it actually exists in the |
745 // local context. | 744 // local context. |
746 Variable* variable = proxy->var(); | 745 Variable* variable = proxy->var(); |
747 bool binding_needs_init = (function == NULL) && | 746 bool binding_needs_init = (function == NULL) && |
748 (mode == CONST || mode == CONST_HARMONY || mode == LET); | 747 (mode == CONST || mode == CONST_HARMONY || mode == LET); |
749 switch (variable->location()) { | 748 switch (variable->location()) { |
750 case Variable::UNALLOCATED: | 749 case Variable::UNALLOCATED: |
751 ++(*global_count); | 750 ++global_count_; |
752 break; | 751 break; |
753 | 752 |
754 case Variable::PARAMETER: | 753 case Variable::PARAMETER: |
755 case Variable::LOCAL: | 754 case Variable::LOCAL: |
756 if (function != NULL) { | 755 if (function != NULL) { |
757 Comment cmnt(masm_, "[ Declaration"); | 756 Comment cmnt(masm_, "[ Declaration"); |
758 VisitForAccumulatorValue(function); | 757 VisitForAccumulatorValue(function); |
759 __ sw(result_register(), StackOperand(variable)); | 758 __ sw(result_register(), StackOperand(variable)); |
760 } else if (binding_needs_init) { | 759 } else if (binding_needs_init) { |
761 Comment cmnt(masm_, "[ Declaration"); | 760 Comment cmnt(masm_, "[ Declaration"); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. | 828 __ mov(a0, zero_reg); // Smi::FromInt(0) indicates no initial value. |
830 __ Push(cp, a2, a1, a0); | 829 __ Push(cp, a2, a1, a0); |
831 } | 830 } |
832 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 831 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
833 break; | 832 break; |
834 } | 833 } |
835 } | 834 } |
836 } | 835 } |
837 | 836 |
838 | 837 |
839 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { } | |
840 | |
841 | |
842 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 838 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
843 // Call the runtime to declare the globals. | 839 // Call the runtime to declare the globals. |
844 // The context is the first argument. | 840 // The context is the first argument. |
845 __ li(a1, Operand(pairs)); | 841 __ li(a1, Operand(pairs)); |
846 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 842 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
847 __ Push(cp, a1, a0); | 843 __ Push(cp, a1, a0); |
848 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 844 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
849 // Return value is ignored. | 845 // Return value is ignored. |
850 } | 846 } |
851 | 847 |
(...skipping 3609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4461 *context_length = 0; | 4457 *context_length = 0; |
4462 return previous_; | 4458 return previous_; |
4463 } | 4459 } |
4464 | 4460 |
4465 | 4461 |
4466 #undef __ | 4462 #undef __ |
4467 | 4463 |
4468 } } // namespace v8::internal | 4464 } } // namespace v8::internal |
4469 | 4465 |
4470 #endif // V8_TARGET_ARCH_MIPS | 4466 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |