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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (scope()->HasIllegalRedeclaration()) { | 249 if (scope()->HasIllegalRedeclaration()) { |
250 Comment cmnt(masm_, "[ Declarations"); | 250 Comment cmnt(masm_, "[ Declarations"); |
251 scope()->VisitIllegalRedeclaration(this); | 251 scope()->VisitIllegalRedeclaration(this); |
252 | 252 |
253 } else { | 253 } else { |
254 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); | 254 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); |
255 { Comment cmnt(masm_, "[ Declarations"); | 255 { Comment cmnt(masm_, "[ Declarations"); |
256 // For named function expressions, declare the function name as a | 256 // For named function expressions, declare the function name as a |
257 // constant. | 257 // constant. |
258 if (scope()->is_function_scope() && scope()->function() != NULL) { | 258 if (scope()->is_function_scope() && scope()->function() != NULL) { |
259 int ignored = 0; | |
260 VariableProxy* proxy = scope()->function(); | 259 VariableProxy* proxy = scope()->function(); |
261 ASSERT(proxy->var()->mode() == CONST || | 260 ASSERT(proxy->var()->mode() == CONST || |
262 proxy->var()->mode() == CONST_HARMONY); | 261 proxy->var()->mode() == CONST_HARMONY); |
263 EmitDeclaration(proxy, proxy->var()->mode(), NULL, &ignored); | 262 ASSERT(proxy->var()->location() != Variable::UNALLOCATED); |
| 263 EmitDeclaration(proxy, proxy->var()->mode(), NULL); |
264 } | 264 } |
265 VisitDeclarations(scope()->declarations()); | 265 VisitDeclarations(scope()->declarations()); |
266 } | 266 } |
267 | 267 |
268 { Comment cmnt(masm_, "[ Stack check"); | 268 { Comment cmnt(masm_, "[ Stack check"); |
269 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); | 269 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); |
270 Label ok; | 270 Label ok; |
271 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 271 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
272 __ j(above_equal, &ok, Label::kNear); | 272 __ j(above_equal, &ok, Label::kNear); |
273 StackCheckStub stub; | 273 StackCheckStub stub; |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 if (should_normalize) { | 671 if (should_normalize) { |
672 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 672 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
673 Split(equal, if_true, if_false, NULL); | 673 Split(equal, if_true, if_false, NULL); |
674 __ bind(&skip); | 674 __ bind(&skip); |
675 } | 675 } |
676 } | 676 } |
677 | 677 |
678 | 678 |
679 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, | 679 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, |
680 VariableMode mode, | 680 VariableMode mode, |
681 FunctionLiteral* function, | 681 FunctionLiteral* function) { |
682 int* global_count) { | |
683 // If it was not possible to allocate the variable at compile time, we | 682 // If it was not possible to allocate the variable at compile time, we |
684 // need to "declare" it at runtime to make sure it actually exists in the | 683 // need to "declare" it at runtime to make sure it actually exists in the |
685 // local context. | 684 // local context. |
686 Variable* variable = proxy->var(); | 685 Variable* variable = proxy->var(); |
687 bool binding_needs_init = (function == NULL) && | 686 bool binding_needs_init = (function == NULL) && |
688 (mode == CONST || mode == CONST_HARMONY || mode == LET); | 687 (mode == CONST || mode == CONST_HARMONY || mode == LET); |
689 switch (variable->location()) { | 688 switch (variable->location()) { |
690 case Variable::UNALLOCATED: | 689 case Variable::UNALLOCATED: |
691 ++(*global_count); | 690 ++global_count_; |
692 break; | 691 break; |
693 | 692 |
694 case Variable::PARAMETER: | 693 case Variable::PARAMETER: |
695 case Variable::LOCAL: | 694 case Variable::LOCAL: |
696 if (function != NULL) { | 695 if (function != NULL) { |
697 Comment cmnt(masm_, "[ Declaration"); | 696 Comment cmnt(masm_, "[ Declaration"); |
698 VisitForAccumulatorValue(function); | 697 VisitForAccumulatorValue(function); |
699 __ movq(StackOperand(variable), result_register()); | 698 __ movq(StackOperand(variable), result_register()); |
700 } else if (binding_needs_init) { | 699 } else if (binding_needs_init) { |
701 Comment cmnt(masm_, "[ Declaration"); | 700 Comment cmnt(masm_, "[ Declaration"); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 } else { | 761 } else { |
763 __ Push(Smi::FromInt(0)); // Indicates no initial value. | 762 __ Push(Smi::FromInt(0)); // Indicates no initial value. |
764 } | 763 } |
765 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 764 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
766 break; | 765 break; |
767 } | 766 } |
768 } | 767 } |
769 } | 768 } |
770 | 769 |
771 | 770 |
772 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { } | |
773 | |
774 | |
775 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 771 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
776 // Call the runtime to declare the globals. | 772 // Call the runtime to declare the globals. |
777 __ push(rsi); // The context is the first argument. | 773 __ push(rsi); // The context is the first argument. |
778 __ Push(pairs); | 774 __ Push(pairs); |
779 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 775 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
780 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 776 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
781 // Return value is ignored. | 777 // Return value is ignored. |
782 } | 778 } |
783 | 779 |
784 | 780 |
(...skipping 3580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4365 *context_length = 0; | 4361 *context_length = 0; |
4366 return previous_; | 4362 return previous_; |
4367 } | 4363 } |
4368 | 4364 |
4369 | 4365 |
4370 #undef __ | 4366 #undef __ |
4371 | 4367 |
4372 } } // namespace v8::internal | 4368 } } // namespace v8::internal |
4373 | 4369 |
4374 #endif // V8_TARGET_ARCH_X64 | 4370 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |