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: runtime/vm/flow_graph_compiler_x64.cc

Issue 678763004: Make CTX allocatable by the register allocator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64.
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/flow_graph_compiler.h" 8 #include "vm/flow_graph_compiler.h"
9 9
10 #include "vm/ast_printer.h" 10 #include "vm/ast_printer.h"
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 // The noSuchMethod call may return to the caller, but not here. 1106 // The noSuchMethod call may return to the caller, but not here.
1107 } else { 1107 } else {
1108 __ Stop("Wrong number of arguments"); 1108 __ Stop("Wrong number of arguments");
1109 } 1109 }
1110 __ Bind(&correct_num_arguments); 1110 __ Bind(&correct_num_arguments);
1111 } 1111 }
1112 } else if (!flow_graph().IsCompiledForOsr()) { 1112 } else if (!flow_graph().IsCompiledForOsr()) {
1113 CopyParameters(); 1113 CopyParameters();
1114 } 1114 }
1115 1115
1116 if (function.IsClosureFunction() && !flow_graph().IsCompiledForOsr()) {
1117 // Load context from the closure object (first argument).
1118 LocalScope* scope = parsed_function().node_sequence()->scope();
1119 LocalVariable* closure_parameter = scope->VariableAt(0);
1120 __ movq(CTX, Address(RBP, closure_parameter->index() * kWordSize));
1121 __ movq(CTX, FieldAddress(CTX, Closure::context_offset()));
1122 #ifdef dEBUG
1123 Label ok;
1124 __ LoadClassId(RAX, CTX);
1125 __ cmpq(RAX, Immediate(kContextCid));
1126 __ j(EQUAL, &ok, Assembler::kNearJump);
1127 __ Stop("Incorrect context at entry");
1128 __ Bind(&ok);
1129 #endif
1130 }
1131
1116 // In unoptimized code, initialize (non-argument) stack allocated slots to 1132 // In unoptimized code, initialize (non-argument) stack allocated slots to
1117 // null. 1133 // null.
1118 if (!is_optimizing() && (num_locals > 0)) { 1134 if (!is_optimizing()) {
1135 ASSERT(num_locals > 0); // There is always at least context_var.
1119 __ Comment("Initialize spill slots"); 1136 __ Comment("Initialize spill slots");
1120 const intptr_t slot_base = parsed_function().first_stack_local_index(); 1137 const intptr_t slot_base = parsed_function().first_stack_local_index();
1121 __ LoadObject(RAX, Object::null_object(), PP); 1138 const intptr_t context_index =
1139 parsed_function().current_context_var()->index();
1140 if (num_locals > 1) {
1141 __ LoadObject(RAX, Object::null_object(), PP);
1142 }
1122 for (intptr_t i = 0; i < num_locals; ++i) { 1143 for (intptr_t i = 0; i < num_locals; ++i) {
1123 // Subtract index i (locals lie at lower addresses than RBP). 1144 // Subtract index i (locals lie at lower addresses than RBP).
1124 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX); 1145 if (((slot_base - i) == context_index)) {
1146 if (function.IsClosureFunction()) {
1147 __ movq(Address(RBP, (slot_base - i) * kWordSize), CTX);
1148 } else {
1149 const Context& empty_context = Context::ZoneHandle(
1150 isolate(), isolate()->object_store()->empty_context());
1151 __ StoreObject(
1152 Address(RBP, (slot_base - i) * kWordSize), empty_context, PP);
1153 }
1154 } else {
1155 ASSERT(num_locals > 1);
1156 __ movq(Address(RBP, (slot_base - i) * kWordSize), RAX);
1157 }
1125 } 1158 }
1126 } 1159 }
1127 1160
1128 ASSERT(!block_order().is_empty()); 1161 ASSERT(!block_order().is_empty());
1129 VisitBlocks(); 1162 VisitBlocks();
1130 1163
1131 __ int3(); 1164 __ int3();
1132 GenerateDeferredCode(); 1165 GenerateDeferredCode();
1133 // Emit function patching code. This will be swapped with the first 13 bytes 1166 // Emit function patching code. This will be swapped with the first 13 bytes
1134 // at entry point. 1167 // at entry point.
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 __ movups(reg, Address(RSP, 0)); 1758 __ movups(reg, Address(RSP, 0));
1726 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP); 1759 __ AddImmediate(RSP, Immediate(kFpuRegisterSize), PP);
1727 } 1760 }
1728 1761
1729 1762
1730 #undef __ 1763 #undef __
1731 1764
1732 } // namespace dart 1765 } // namespace dart
1733 1766
1734 #endif // defined TARGET_ARCH_X64 1767 #endif // defined TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698