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

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

Issue 9844002: Implement rudimentary module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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
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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 VariableDeclaration* declaration) { 769 VariableDeclaration* declaration) {
770 // If it was not possible to allocate the variable at compile time, we 770 // If it was not possible to allocate the variable at compile time, we
771 // need to "declare" it at runtime to make sure it actually exists in the 771 // need to "declare" it at runtime to make sure it actually exists in the
772 // local context. 772 // local context.
773 VariableProxy* proxy = declaration->proxy(); 773 VariableProxy* proxy = declaration->proxy();
774 VariableMode mode = declaration->mode(); 774 VariableMode mode = declaration->mode();
775 Variable* variable = proxy->var(); 775 Variable* variable = proxy->var();
776 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET; 776 bool hole_init = mode == CONST || mode == CONST_HARMONY || mode == LET;
777 switch (variable->location()) { 777 switch (variable->location()) {
778 case Variable::UNALLOCATED: 778 case Variable::UNALLOCATED:
779 globals_.Add(variable->name()); 779 globals_->Add(variable->name());
780 globals_.Add(variable->binding_needs_init() 780 globals_->Add(variable->binding_needs_init()
781 ? isolate()->factory()->the_hole_value() 781 ? isolate()->factory()->the_hole_value()
782 : isolate()->factory()->undefined_value()); 782 : isolate()->factory()->undefined_value());
783 break; 783 break;
784 784
785 case Variable::PARAMETER: 785 case Variable::PARAMETER:
786 case Variable::LOCAL: 786 case Variable::LOCAL:
787 if (hole_init) { 787 if (hole_init) {
788 Comment cmnt(masm_, "[ VariableDeclaration"); 788 Comment cmnt(masm_, "[ VariableDeclaration");
789 __ mov(StackOperand(variable), 789 __ mov(StackOperand(variable),
790 Immediate(isolate()->factory()->the_hole_value())); 790 Immediate(isolate()->factory()->the_hole_value()));
791 } 791 }
792 break; 792 break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 } 827 }
828 } 828 }
829 829
830 830
831 void FullCodeGenerator::VisitFunctionDeclaration( 831 void FullCodeGenerator::VisitFunctionDeclaration(
832 FunctionDeclaration* declaration) { 832 FunctionDeclaration* declaration) {
833 VariableProxy* proxy = declaration->proxy(); 833 VariableProxy* proxy = declaration->proxy();
834 Variable* variable = proxy->var(); 834 Variable* variable = proxy->var();
835 switch (variable->location()) { 835 switch (variable->location()) {
836 case Variable::UNALLOCATED: { 836 case Variable::UNALLOCATED: {
837 globals_.Add(variable->name()); 837 globals_->Add(variable->name());
838 Handle<SharedFunctionInfo> function = 838 Handle<SharedFunctionInfo> function =
839 Compiler::BuildFunctionInfo(declaration->fun(), script()); 839 Compiler::BuildFunctionInfo(declaration->fun(), script());
840 // Check for stack-overflow exception. 840 // Check for stack-overflow exception.
841 if (function.is_null()) return SetStackOverflow(); 841 if (function.is_null()) return SetStackOverflow();
842 globals_.Add(function); 842 globals_->Add(function);
843 break; 843 break;
844 } 844 }
845 845
846 case Variable::PARAMETER: 846 case Variable::PARAMETER:
847 case Variable::LOCAL: { 847 case Variable::LOCAL: {
848 Comment cmnt(masm_, "[ FunctionDeclaration"); 848 Comment cmnt(masm_, "[ FunctionDeclaration");
849 VisitForAccumulatorValue(declaration->fun()); 849 VisitForAccumulatorValue(declaration->fun());
850 __ mov(StackOperand(variable), result_register()); 850 __ mov(StackOperand(variable), result_register());
851 break; 851 break;
852 } 852 }
(...skipping 24 matching lines...) Expand all
877 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 877 __ CallRuntime(Runtime::kDeclareContextSlot, 4);
878 break; 878 break;
879 } 879 }
880 } 880 }
881 } 881 }
882 882
883 883
884 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 884 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
885 VariableProxy* proxy = declaration->proxy(); 885 VariableProxy* proxy = declaration->proxy();
886 Variable* variable = proxy->var(); 886 Variable* variable = proxy->var();
887 Handle<JSModule> instance = declaration->module()->interface()->Instance();
888 // TODO(rossberg): temporary hack until URL import is implemented:
889 if (instance.is_null()) return;
890 ASSERT(!instance.is_null());
891
887 switch (variable->location()) { 892 switch (variable->location()) {
888 case Variable::UNALLOCATED: 893 case Variable::UNALLOCATED: {
889 // TODO(rossberg): initialize module instance object 894 Comment cmnt(masm_, "[ ModuleDeclaration");
895 globals_->Add(variable->name());
896 globals_->Add(instance);
897 Visit(declaration->module());
890 break; 898 break;
899 }
891 900
892 case Variable::CONTEXT: { 901 case Variable::CONTEXT: {
893 Comment cmnt(masm_, "[ ModuleDeclaration"); 902 Comment cmnt(masm_, "[ ModuleDeclaration");
894 EmitDebugCheckDeclarationContext(variable); 903 EmitDebugCheckDeclarationContext(variable);
895 // TODO(rossberg): initialize module instance object 904 __ mov(ContextOperand(esi, variable->index()), Immediate(instance));
905 Visit(declaration->module());
896 break; 906 break;
897 } 907 }
898 908
899 case Variable::PARAMETER: 909 case Variable::PARAMETER:
900 case Variable::LOCAL: 910 case Variable::LOCAL:
901 case Variable::LOOKUP: 911 case Variable::LOOKUP:
902 UNREACHABLE(); 912 UNREACHABLE();
903 } 913 }
904 } 914 }
905 915
(...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after
4492 } 4502 }
4493 4503
4494 4504
4495 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { 4505 void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
4496 __ mov(dst, ContextOperand(esi, context_index)); 4506 __ mov(dst, ContextOperand(esi, context_index));
4497 } 4507 }
4498 4508
4499 4509
4500 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { 4510 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
4501 Scope* declaration_scope = scope()->DeclarationScope(); 4511 Scope* declaration_scope = scope()->DeclarationScope();
4502 if (declaration_scope->is_global_scope()) { 4512 if (declaration_scope->is_global_scope() ||
4513 declaration_scope->is_module_scope()) {
4503 // Contexts nested in the global context have a canonical empty function 4514 // Contexts nested in the global context have a canonical empty function
4504 // as their closure, not the anonymous closure containing the global 4515 // as their closure, not the anonymous closure containing the global
4505 // code. Pass a smi sentinel and let the runtime look up the empty 4516 // code. Pass a smi sentinel and let the runtime look up the empty
4506 // function. 4517 // function.
4507 __ push(Immediate(Smi::FromInt(0))); 4518 __ push(Immediate(Smi::FromInt(0)));
4508 } else if (declaration_scope->is_eval_scope()) { 4519 } else if (declaration_scope->is_eval_scope()) {
4509 // Contexts nested inside eval code have the same closure as the context 4520 // Contexts nested inside eval code have the same closure as the context
4510 // calling eval, not the anonymous closure containing the eval code. 4521 // calling eval, not the anonymous closure containing the eval code.
4511 // Fetch it from the context. 4522 // Fetch it from the context.
4512 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); 4523 __ push(ContextOperand(esi, Context::CLOSURE_INDEX));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
4571 *context_length = 0; 4582 *context_length = 0;
4572 return previous_; 4583 return previous_;
4573 } 4584 }
4574 4585
4575 4586
4576 #undef __ 4587 #undef __
4577 4588
4578 } } // namespace v8::internal 4589 } } // namespace v8::internal
4579 4590
4580 #endif // V8_TARGET_ARCH_IA32 4591 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/heap.cc ('K') | « src/hydrogen.cc ('k') | src/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698