Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: src/ia32/full-codegen-ia32.cc

Issue 9348057: Split AST Declaration class, in preparation for new module declaration forms. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Jakob's comments. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (scope()->HasIllegalRedeclaration()) { 254 if (scope()->HasIllegalRedeclaration()) {
255 Comment cmnt(masm_, "[ Declarations"); 255 Comment cmnt(masm_, "[ Declarations");
256 scope()->VisitIllegalRedeclaration(this); 256 scope()->VisitIllegalRedeclaration(this);
257 257
258 } else { 258 } else {
259 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS); 259 PrepareForBailoutForId(AstNode::kFunctionEntryId, NO_REGISTERS);
260 { Comment cmnt(masm_, "[ Declarations"); 260 { Comment cmnt(masm_, "[ Declarations");
261 // For named function expressions, declare the function name as a 261 // For named function expressions, declare the function name as a
262 // constant. 262 // constant.
263 if (scope()->is_function_scope() && scope()->function() != NULL) { 263 if (scope()->is_function_scope() && scope()->function() != NULL) {
264 int ignored = 0;
265 VariableProxy* proxy = scope()->function(); 264 VariableProxy* proxy = scope()->function();
266 ASSERT(proxy->var()->mode() == CONST || 265 ASSERT(proxy->var()->mode() == CONST ||
267 proxy->var()->mode() == CONST_HARMONY); 266 proxy->var()->mode() == CONST_HARMONY);
268 EmitDeclaration(proxy, proxy->var()->mode(), NULL, &ignored); 267 ASSERT(proxy->var()->location() != Variable::UNALLOCATED);
268 EmitDeclaration(proxy, proxy->var()->mode(), NULL);
269 } 269 }
270 VisitDeclarations(scope()->declarations()); 270 VisitDeclarations(scope()->declarations());
271 } 271 }
272 272
273 { Comment cmnt(masm_, "[ Stack check"); 273 { Comment cmnt(masm_, "[ Stack check");
274 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS); 274 PrepareForBailoutForId(AstNode::kDeclarationsId, NO_REGISTERS);
275 Label ok; 275 Label ok;
276 ExternalReference stack_limit = 276 ExternalReference stack_limit =
277 ExternalReference::address_of_stack_limit(isolate()); 277 ExternalReference::address_of_stack_limit(isolate());
278 __ cmp(esp, Operand::StaticVariable(stack_limit)); 278 __ cmp(esp, Operand::StaticVariable(stack_limit));
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (should_normalize) { 674 if (should_normalize) {
675 __ cmp(eax, isolate()->factory()->true_value()); 675 __ cmp(eax, isolate()->factory()->true_value());
676 Split(equal, if_true, if_false, NULL); 676 Split(equal, if_true, if_false, NULL);
677 __ bind(&skip); 677 __ bind(&skip);
678 } 678 }
679 } 679 }
680 680
681 681
682 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, 682 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy,
683 VariableMode mode, 683 VariableMode mode,
684 FunctionLiteral* function, 684 FunctionLiteral* function) {
685 int* global_count) {
686 // If it was not possible to allocate the variable at compile time, we 685 // If it was not possible to allocate the variable at compile time, we
687 // need to "declare" it at runtime to make sure it actually exists in the 686 // need to "declare" it at runtime to make sure it actually exists in the
688 // local context. 687 // local context.
689 Variable* variable = proxy->var(); 688 Variable* variable = proxy->var();
690 bool binding_needs_init = (function == NULL) && 689 bool binding_needs_init = (function == NULL) &&
691 (mode == CONST || mode == CONST_HARMONY || mode == LET); 690 (mode == CONST || mode == CONST_HARMONY || mode == LET);
692 switch (variable->location()) { 691 switch (variable->location()) {
693 case Variable::UNALLOCATED: 692 case Variable::UNALLOCATED:
694 ++(*global_count); 693 ++global_count_;
695 break; 694 break;
696 695
697 case Variable::PARAMETER: 696 case Variable::PARAMETER:
698 case Variable::LOCAL: 697 case Variable::LOCAL:
699 if (function != NULL) { 698 if (function != NULL) {
700 Comment cmnt(masm_, "[ Declaration"); 699 Comment cmnt(masm_, "[ Declaration");
701 VisitForAccumulatorValue(function); 700 VisitForAccumulatorValue(function);
702 __ mov(StackOperand(variable), result_register()); 701 __ mov(StackOperand(variable), result_register());
703 } else if (binding_needs_init) { 702 } else if (binding_needs_init) {
704 Comment cmnt(masm_, "[ Declaration"); 703 Comment cmnt(masm_, "[ Declaration");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 } else { 763 } else {
765 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value. 764 __ push(Immediate(Smi::FromInt(0))); // Indicates no initial value.
766 } 765 }
767 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 766 __ CallRuntime(Runtime::kDeclareContextSlot, 4);
768 break; 767 break;
769 } 768 }
770 } 769 }
771 } 770 }
772 771
773 772
774 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { }
775
776
777 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { 773 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
778 // Call the runtime to declare the globals. 774 // Call the runtime to declare the globals.
779 __ push(esi); // The context is the first argument. 775 __ push(esi); // The context is the first argument.
780 __ push(Immediate(pairs)); 776 __ push(Immediate(pairs));
781 __ push(Immediate(Smi::FromInt(DeclareGlobalsFlags()))); 777 __ push(Immediate(Smi::FromInt(DeclareGlobalsFlags())));
782 __ CallRuntime(Runtime::kDeclareGlobals, 3); 778 __ CallRuntime(Runtime::kDeclareGlobals, 3);
783 // Return value is ignored. 779 // Return value is ignored.
784 } 780 }
785 781
786 782
(...skipping 3598 matching lines...) Expand 10 before | Expand all | Expand 10 after
4385 *context_length = 0; 4381 *context_length = 0;
4386 return previous_; 4382 return previous_;
4387 } 4383 }
4388 4384
4389 4385
4390 #undef __ 4386 #undef __
4391 4387
4392 } } // namespace v8::internal 4388 } } // namespace v8::internal
4393 4389
4394 #endif // V8_TARGET_ARCH_IA32 4390 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698