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

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

Issue 9844002: Implement rudimentary module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased Created 8 years, 8 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 | « no previous file | src/ast.h » ('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 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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 VariableDeclaration* declaration) { 799 VariableDeclaration* declaration) {
800 // If it was not possible to allocate the variable at compile time, we 800 // If it was not possible to allocate the variable at compile time, we
801 // need to "declare" it at runtime to make sure it actually exists in the 801 // need to "declare" it at runtime to make sure it actually exists in the
802 // local context. 802 // local context.
803 VariableProxy* proxy = declaration->proxy(); 803 VariableProxy* proxy = declaration->proxy();
804 VariableMode mode = declaration->mode(); 804 VariableMode mode = declaration->mode();
805 Variable* variable = proxy->var(); 805 Variable* variable = proxy->var();
806 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; 806 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
807 switch (variable->location()) { 807 switch (variable->location()) {
808 case Variable::UNALLOCATED: 808 case Variable::UNALLOCATED:
809 globals_.Add(variable->name()); 809 globals_->Add(variable->name());
810 globals_.Add(variable->binding_needs_init() 810 globals_->Add(variable->binding_needs_init()
811 ? isolate()->factory()->the_hole_value() 811 ? isolate()->factory()->the_hole_value()
812 : isolate()->factory()->undefined_value()); 812 : isolate()->factory()->undefined_value());
813 break; 813 break;
814 814
815 case Variable::PARAMETER: 815 case Variable::PARAMETER:
816 case Variable::LOCAL: 816 case Variable::LOCAL:
817 if (hole_init) { 817 if (hole_init) {
818 Comment cmnt(masm_, "[ VariableDeclaration"); 818 Comment cmnt(masm_, "[ VariableDeclaration");
819 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); 819 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex);
820 __ str(ip, StackOperand(variable)); 820 __ str(ip, StackOperand(variable));
821 } 821 }
822 break; 822 break;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 } 858 }
859 } 859 }
860 860
861 861
862 void FullCodeGenerator::VisitFunctionDeclaration( 862 void FullCodeGenerator::VisitFunctionDeclaration(
863 FunctionDeclaration* declaration) { 863 FunctionDeclaration* declaration) {
864 VariableProxy* proxy = declaration->proxy(); 864 VariableProxy* proxy = declaration->proxy();
865 Variable* variable = proxy->var(); 865 Variable* variable = proxy->var();
866 switch (variable->location()) { 866 switch (variable->location()) {
867 case Variable::UNALLOCATED: { 867 case Variable::UNALLOCATED: {
868 globals_.Add(variable->name()); 868 globals_->Add(variable->name());
869 Handle<SharedFunctionInfo> function = 869 Handle<SharedFunctionInfo> function =
870 Compiler::BuildFunctionInfo(declaration->fun(), script()); 870 Compiler::BuildFunctionInfo(declaration->fun(), script());
871 // Check for stack-overflow exception. 871 // Check for stack-overflow exception.
872 if (function.is_null()) return SetStackOverflow(); 872 if (function.is_null()) return SetStackOverflow();
873 globals_.Add(function); 873 globals_->Add(function);
874 break; 874 break;
875 } 875 }
876 876
877 case Variable::PARAMETER: 877 case Variable::PARAMETER:
878 case Variable::LOCAL: { 878 case Variable::LOCAL: {
879 Comment cmnt(masm_, "[ FunctionDeclaration"); 879 Comment cmnt(masm_, "[ FunctionDeclaration");
880 VisitForAccumulatorValue(declaration->fun()); 880 VisitForAccumulatorValue(declaration->fun());
881 __ str(result_register(), StackOperand(variable)); 881 __ str(result_register(), StackOperand(variable));
882 break; 882 break;
883 } 883 }
(...skipping 27 matching lines...) Expand all
911 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 911 __ CallRuntime(Runtime::kDeclareContextSlot, 4);
912 break; 912 break;
913 } 913 }
914 } 914 }
915 } 915 }
916 916
917 917
918 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 918 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
919 VariableProxy* proxy = declaration->proxy(); 919 VariableProxy* proxy = declaration->proxy();
920 Variable* variable = proxy->var(); 920 Variable* variable = proxy->var();
921 Handle<JSModule> instance = declaration->module()->interface()->Instance();
922 ASSERT(!instance.is_null());
923
921 switch (variable->location()) { 924 switch (variable->location()) {
922 case Variable::UNALLOCATED: 925 case Variable::UNALLOCATED: {
923 // TODO(rossberg): initialize module instance object 926 Comment cmnt(masm_, "[ ModuleDeclaration");
927 globals_->Add(variable->name());
928 globals_->Add(instance);
929 Visit(declaration->module());
924 break; 930 break;
931 }
925 932
926 case Variable::CONTEXT: { 933 case Variable::CONTEXT: {
927 Comment cmnt(masm_, "[ ModuleDeclaration"); 934 Comment cmnt(masm_, "[ ModuleDeclaration");
928 EmitDebugCheckDeclarationContext(variable); 935 EmitDebugCheckDeclarationContext(variable);
929 // TODO(rossberg): initialize module instance object 936 __ mov(r1, Operand(instance));
937 __ str(r1, ContextOperand(cp, variable->index()));
938 Visit(declaration->module());
930 break; 939 break;
931 } 940 }
932 941
933 case Variable::PARAMETER: 942 case Variable::PARAMETER:
934 case Variable::LOCAL: 943 case Variable::LOCAL:
935 case Variable::LOOKUP: 944 case Variable::LOOKUP:
936 UNREACHABLE(); 945 UNREACHABLE();
937 } 946 }
938 } 947 }
939 948
(...skipping 3589 matching lines...) Expand 10 before | Expand all | Expand 10 after
4529 } 4538 }
4530 4539
4531 4540
4532 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { 4541 void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
4533 __ ldr(dst, ContextOperand(cp, context_index)); 4542 __ ldr(dst, ContextOperand(cp, context_index));
4534 } 4543 }
4535 4544
4536 4545
4537 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { 4546 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
4538 Scope* declaration_scope = scope()->DeclarationScope(); 4547 Scope* declaration_scope = scope()->DeclarationScope();
4539 if (declaration_scope->is_global_scope()) { 4548 if (declaration_scope->is_global_scope() ||
4549 declaration_scope->is_module_scope()) {
4540 // Contexts nested in the global context have a canonical empty function 4550 // Contexts nested in the global context have a canonical empty function
4541 // as their closure, not the anonymous closure containing the global 4551 // as their closure, not the anonymous closure containing the global
4542 // code. Pass a smi sentinel and let the runtime look up the empty 4552 // code. Pass a smi sentinel and let the runtime look up the empty
4543 // function. 4553 // function.
4544 __ mov(ip, Operand(Smi::FromInt(0))); 4554 __ mov(ip, Operand(Smi::FromInt(0)));
4545 } else if (declaration_scope->is_eval_scope()) { 4555 } else if (declaration_scope->is_eval_scope()) {
4546 // Contexts created by a call to eval have the same closure as the 4556 // Contexts created by a call to eval have the same closure as the
4547 // context calling eval, not the anonymous closure containing the eval 4557 // context calling eval, not the anonymous closure containing the eval
4548 // code. Fetch it from the context. 4558 // code. Fetch it from the context.
4549 __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX)); 4559 __ ldr(ip, ContextOperand(cp, Context::CLOSURE_INDEX));
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4609 *context_length = 0; 4619 *context_length = 0;
4610 return previous_; 4620 return previous_;
4611 } 4621 }
4612 4622
4613 4623
4614 #undef __ 4624 #undef __
4615 4625
4616 } } // namespace v8::internal 4626 } } // namespace v8::internal
4617 4627
4618 #endif // V8_TARGET_ARCH_ARM 4628 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/ast.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698