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

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

Issue 11093074: Get rid of static module allocation, do it in code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed last comments; added other back-ends Created 8 years, 1 month 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/ia32/macro-assembler-ia32.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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 PrepareForBailout(expr, TOS_REG); 747 PrepareForBailout(expr, TOS_REG);
748 if (should_normalize) { 748 if (should_normalize) {
749 __ cmp(eax, isolate()->factory()->true_value()); 749 __ cmp(eax, isolate()->factory()->true_value());
750 Split(equal, if_true, if_false, NULL); 750 Split(equal, if_true, if_false, NULL);
751 __ bind(&skip); 751 __ bind(&skip);
752 } 752 }
753 } 753 }
754 754
755 755
756 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) { 756 void FullCodeGenerator::EmitDebugCheckDeclarationContext(Variable* variable) {
757 // The variable in the declaration always resides in the current function 757 // The variable in the declaration always resides in the current context.
758 // context.
759 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); 758 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
760 if (generate_debug_code_) { 759 if (generate_debug_code_) {
761 // Check that we're not inside a with or catch context. 760 // Check that we're not inside a with or catch context.
762 __ mov(ebx, FieldOperand(esi, HeapObject::kMapOffset)); 761 __ mov(ebx, FieldOperand(esi, HeapObject::kMapOffset));
763 __ cmp(ebx, isolate()->factory()->with_context_map()); 762 __ cmp(ebx, isolate()->factory()->with_context_map());
764 __ Check(not_equal, "Declaration in with context."); 763 __ Check(not_equal, "Declaration in with context.");
765 __ cmp(ebx, isolate()->factory()->catch_context_map()); 764 __ cmp(ebx, isolate()->factory()->catch_context_map());
766 __ Check(not_equal, "Declaration in catch context."); 765 __ Check(not_equal, "Declaration in catch context.");
767 } 766 }
768 } 767 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 __ push(Immediate(Smi::FromInt(NONE))); 876 __ push(Immediate(Smi::FromInt(NONE)));
878 VisitForStackValue(declaration->fun()); 877 VisitForStackValue(declaration->fun());
879 __ CallRuntime(Runtime::kDeclareContextSlot, 4); 878 __ CallRuntime(Runtime::kDeclareContextSlot, 4);
880 break; 879 break;
881 } 880 }
882 } 881 }
883 } 882 }
884 883
885 884
886 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { 885 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) {
887 VariableProxy* proxy = declaration->proxy(); 886 Variable* variable = declaration->proxy()->var();
888 Variable* variable = proxy->var(); 887 ASSERT(variable->location() == Variable::CONTEXT);
889 Handle<JSModule> instance = declaration->module()->interface()->Instance(); 888 ASSERT(variable->interface()->IsFrozen());
890 ASSERT(!instance.is_null());
891 889
892 switch (variable->location()) { 890 Comment cmnt(masm_, "[ ModuleDeclaration");
893 case Variable::UNALLOCATED: { 891 EmitDebugCheckDeclarationContext(variable);
894 Comment cmnt(masm_, "[ ModuleDeclaration");
895 globals_->Add(variable->name(), zone());
896 globals_->Add(instance, zone());
897 Visit(declaration->module());
898 break;
899 }
900 892
901 case Variable::CONTEXT: { 893 // Load instance object.
902 Comment cmnt(masm_, "[ ModuleDeclaration"); 894 __ LoadContext(eax, scope_->ContextChainLength(scope_->GlobalScope()));
903 EmitDebugCheckDeclarationContext(variable); 895 __ mov(eax, ContextOperand(eax, variable->interface()->Index()));
904 __ mov(ContextOperand(esi, variable->index()), Immediate(instance)); 896 __ mov(eax, ContextOperand(eax, Context::EXTENSION_INDEX));
905 Visit(declaration->module());
906 break;
907 }
908 897
909 case Variable::PARAMETER: 898 // Assign it.
910 case Variable::LOCAL: 899 __ mov(ContextOperand(esi, variable->index()), eax);
911 case Variable::LOOKUP: 900 // We know that we have written a module, which is not a smi.
912 UNREACHABLE(); 901 __ RecordWriteContextSlot(esi,
913 } 902 Context::SlotOffset(variable->index()),
903 eax,
904 ecx,
905 kDontSaveFPRegs,
906 EMIT_REMEMBERED_SET,
907 OMIT_SMI_CHECK);
908 PrepareForBailoutForId(declaration->proxy()->id(), NO_REGISTERS);
909
910 // Traverse into body.
911 Visit(declaration->module());
914 } 912 }
915 913
916 914
917 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) { 915 void FullCodeGenerator::VisitImportDeclaration(ImportDeclaration* declaration) {
918 VariableProxy* proxy = declaration->proxy(); 916 VariableProxy* proxy = declaration->proxy();
919 Variable* variable = proxy->var(); 917 Variable* variable = proxy->var();
920 switch (variable->location()) { 918 switch (variable->location()) {
921 case Variable::UNALLOCATED: 919 case Variable::UNALLOCATED:
922 // TODO(rossberg) 920 // TODO(rossberg)
923 break; 921 break;
(...skipping 14 matching lines...) Expand all
938 936
939 937
940 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) { 938 void FullCodeGenerator::VisitExportDeclaration(ExportDeclaration* declaration) {
941 // TODO(rossberg) 939 // TODO(rossberg)
942 } 940 }
943 941
944 942
945 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { 943 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
946 // Call the runtime to declare the globals. 944 // Call the runtime to declare the globals.
947 __ push(esi); // The context is the first argument. 945 __ push(esi); // The context is the first argument.
948 __ push(Immediate(pairs)); 946 __ Push(pairs);
949 __ push(Immediate(Smi::FromInt(DeclareGlobalsFlags()))); 947 __ Push(Smi::FromInt(DeclareGlobalsFlags()));
950 __ CallRuntime(Runtime::kDeclareGlobals, 3); 948 __ CallRuntime(Runtime::kDeclareGlobals, 3);
951 // Return value is ignored. 949 // Return value is ignored.
952 } 950 }
953 951
954 952
953 void FullCodeGenerator::DeclareModules(Handle<FixedArray> descriptions) {
954 // Call the runtime to declare the modules.
955 __ Push(descriptions);
956 __ CallRuntime(Runtime::kDeclareModules, 1);
957 // Return value is ignored.
958 }
959
960
955 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) { 961 void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
956 Comment cmnt(masm_, "[ SwitchStatement"); 962 Comment cmnt(masm_, "[ SwitchStatement");
957 Breakable nested_statement(this, stmt); 963 Breakable nested_statement(this, stmt);
958 SetStatementPosition(stmt); 964 SetStatementPosition(stmt);
959 965
960 // Keep the switch value on the stack until a case matches. 966 // Keep the switch value on the stack until a case matches.
961 VisitForStackValue(stmt->tag()); 967 VisitForStackValue(stmt->tag());
962 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); 968 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
963 969
964 ZoneList<CaseClause*>* clauses = stmt->cases(); 970 ZoneList<CaseClause*>* clauses = stmt->cases();
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 // eval-introduced variables. Eval is used a lot without 1345 // eval-introduced variables. Eval is used a lot without
1340 // introducing variables. In those cases, we do not want to 1346 // introducing variables. In those cases, we do not want to
1341 // perform a runtime call for all variables in the scope 1347 // perform a runtime call for all variables in the scope
1342 // containing the eval. 1348 // containing the eval.
1343 if (var->mode() == DYNAMIC_GLOBAL) { 1349 if (var->mode() == DYNAMIC_GLOBAL) {
1344 EmitLoadGlobalCheckExtensions(var, typeof_state, slow); 1350 EmitLoadGlobalCheckExtensions(var, typeof_state, slow);
1345 __ jmp(done); 1351 __ jmp(done);
1346 } else if (var->mode() == DYNAMIC_LOCAL) { 1352 } else if (var->mode() == DYNAMIC_LOCAL) {
1347 Variable* local = var->local_if_not_shadowed(); 1353 Variable* local = var->local_if_not_shadowed();
1348 __ mov(eax, ContextSlotOperandCheckExtensions(local, slow)); 1354 __ mov(eax, ContextSlotOperandCheckExtensions(local, slow));
1349 if (local->mode() == CONST || 1355 if (local->mode() == LET ||
1350 local->mode() == CONST_HARMONY || 1356 local->mode() == CONST ||
1351 local->mode() == LET) { 1357 local->mode() == CONST_HARMONY) {
1352 __ cmp(eax, isolate()->factory()->the_hole_value()); 1358 __ cmp(eax, isolate()->factory()->the_hole_value());
1353 __ j(not_equal, done); 1359 __ j(not_equal, done);
1354 if (local->mode() == CONST) { 1360 if (local->mode() == CONST) {
1355 __ mov(eax, isolate()->factory()->undefined_value()); 1361 __ mov(eax, isolate()->factory()->undefined_value());
1356 } else { // LET || CONST_HARMONY 1362 } else { // LET || CONST_HARMONY
1357 __ push(Immediate(var->name())); 1363 __ push(Immediate(var->name()));
1358 __ CallRuntime(Runtime::kThrowReferenceError, 1); 1364 __ CallRuntime(Runtime::kThrowReferenceError, 1);
1359 } 1365 }
1360 } 1366 }
1361 __ jmp(done); 1367 __ jmp(done);
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4517 *stack_depth = 0; 4523 *stack_depth = 0;
4518 *context_length = 0; 4524 *context_length = 0;
4519 return previous_; 4525 return previous_;
4520 } 4526 }
4521 4527
4522 #undef __ 4528 #undef __
4523 4529
4524 } } // namespace v8::internal 4530 } } // namespace v8::internal
4525 4531
4526 #endif // V8_TARGET_ARCH_IA32 4532 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/hydrogen.cc ('k') | src/ia32/macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698