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

Side by Side Diff: src/a64/lithium-gap-resolver-a64.cc

Issue 185653004: Experimental parser: merge to r19637 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 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
« no previous file with comments | « src/a64/lithium-gap-resolver-a64.h ('k') | src/a64/macro-assembler-a64.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 2013 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #include "arm/lithium-gap-resolver-arm.h" 30 #include "a64/lithium-gap-resolver-a64.h"
31 #include "arm/lithium-codegen-arm.h" 31 #include "a64/lithium-codegen-a64.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 static const Register kSavedValueRegister = { 9 }; 36 // We use the root register to spill a value while breaking a cycle in parallel
37 // moves. We don't need access to roots while resolving the move list and using
38 // the root register has two advantages:
39 // - It is not in crankshaft allocatable registers list, so it can't interfere
40 // with any of the moves we are resolving.
41 // - We don't need to push it on the stack, as we can reload it with its value
42 // once we have resolved a cycle.
43 #define kSavedValue root
37 44
38 LGapResolver::LGapResolver(LCodeGen* owner) 45 LGapResolver::LGapResolver(LCodeGen* owner)
39 : cgen_(owner), moves_(32, owner->zone()), root_index_(0), in_cycle_(false), 46 : cgen_(owner), moves_(32, owner->zone()), root_index_(0), in_cycle_(false),
40 saved_destination_(NULL) { } 47 saved_destination_(NULL), need_to_restore_root_(false) { }
41 48
42 49
50 #define __ ACCESS_MASM(cgen_->masm())
51
43 void LGapResolver::Resolve(LParallelMove* parallel_move) { 52 void LGapResolver::Resolve(LParallelMove* parallel_move) {
44 ASSERT(moves_.is_empty()); 53 ASSERT(moves_.is_empty());
54
45 // Build up a worklist of moves. 55 // Build up a worklist of moves.
46 BuildInitialMoveList(parallel_move); 56 BuildInitialMoveList(parallel_move);
47 57
48 for (int i = 0; i < moves_.length(); ++i) { 58 for (int i = 0; i < moves_.length(); ++i) {
49 LMoveOperands move = moves_[i]; 59 LMoveOperands move = moves_[i];
50 // Skip constants to perform them last. They don't block other moves 60
61 // Skip constants to perform them last. They don't block other moves
51 // and skipping such moves with register destinations keeps those 62 // and skipping such moves with register destinations keeps those
52 // registers free for the whole algorithm. 63 // registers free for the whole algorithm.
53 if (!move.IsEliminated() && !move.source()->IsConstantOperand()) { 64 if (!move.IsEliminated() && !move.source()->IsConstantOperand()) {
54 root_index_ = i; // Any cycle is found when by reaching this move again. 65 root_index_ = i; // Any cycle is found when we reach this move again.
55 PerformMove(i); 66 PerformMove(i);
56 if (in_cycle_) { 67 if (in_cycle_) RestoreValue();
57 RestoreValue();
58 }
59 } 68 }
60 } 69 }
61 70
62 // Perform the moves with constant sources. 71 // Perform the moves with constant sources.
63 for (int i = 0; i < moves_.length(); ++i) { 72 for (int i = 0; i < moves_.length(); ++i) {
64 if (!moves_[i].IsEliminated()) { 73 LMoveOperands move = moves_[i];
65 ASSERT(moves_[i].source()->IsConstantOperand()); 74
75 if (!move.IsEliminated()) {
76 ASSERT(move.source()->IsConstantOperand());
66 EmitMove(i); 77 EmitMove(i);
67 } 78 }
68 } 79 }
69 80
81 if (need_to_restore_root_) {
82 ASSERT(kSavedValue.Is(root));
83 __ InitializeRootRegister();
84 need_to_restore_root_ = false;
85 }
86
70 moves_.Rewind(0); 87 moves_.Rewind(0);
71 } 88 }
72 89
73 90
74 void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) { 91 void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) {
75 // Perform a linear sweep of the moves to add them to the initial list of 92 // Perform a linear sweep of the moves to add them to the initial list of
76 // moves to perform, ignoring any move that is redundant (the source is 93 // moves to perform, ignoring any move that is redundant (the source is
77 // the same as the destination, the destination is ignored and 94 // the same as the destination, the destination is ignored and
78 // unallocated, or the move was already eliminated). 95 // unallocated, or the move was already eliminated).
79 const ZoneList<LMoveOperands>* moves = parallel_move->move_operands(); 96 const ZoneList<LMoveOperands>* moves = parallel_move->move_operands();
80 for (int i = 0; i < moves->length(); ++i) { 97 for (int i = 0; i < moves->length(); ++i) {
81 LMoveOperands move = moves->at(i); 98 LMoveOperands move = moves->at(i);
82 if (!move.IsRedundant()) moves_.Add(move, cgen_->zone()); 99 if (!move.IsRedundant()) moves_.Add(move, cgen_->zone());
83 } 100 }
84 Verify(); 101 Verify();
85 } 102 }
86 103
87 104
88 void LGapResolver::PerformMove(int index) { 105 void LGapResolver::PerformMove(int index) {
89 // Each call to this function performs a move and deletes it from the move 106 // Each call to this function performs a move and deletes it from the move
90 // graph. We first recursively perform any move blocking this one. We 107 // graph. We first recursively perform any move blocking this one. We
91 // mark a move as "pending" on entry to PerformMove in order to detect 108 // mark a move as "pending" on entry to PerformMove in order to detect
92 // cycles in the move graph. 109 // cycles in the move graph.
110 LMoveOperands& current_move = moves_[index];
93 111
94 // We can only find a cycle, when doing a depth-first traversal of moves, 112 ASSERT(!current_move.IsPending());
95 // be encountering the starting move again. So by spilling the source of 113 ASSERT(!current_move.IsRedundant());
96 // the starting move, we break the cycle. All moves are then unblocked,
97 // and the starting move is completed by writing the spilled value to
98 // its destination. All other moves from the spilled source have been
99 // completed prior to breaking the cycle.
100 // An additional complication is that moves to MemOperands with large
101 // offsets (more than 1K or 4K) require us to spill this spilled value to
102 // the stack, to free up the register.
103 ASSERT(!moves_[index].IsPending());
104 ASSERT(!moves_[index].IsRedundant());
105 114
106 // Clear this move's destination to indicate a pending move. The actual 115 // Clear this move's destination to indicate a pending move. The actual
107 // destination is saved in a stack allocated local. Multiple moves can 116 // destination is saved in a stack allocated local. Multiple moves can
108 // be pending because this function is recursive. 117 // be pending because this function is recursive.
109 ASSERT(moves_[index].source() != NULL); // Or else it will look eliminated. 118 ASSERT(current_move.source() != NULL); // Otherwise it will look eliminated.
110 LOperand* destination = moves_[index].destination(); 119 LOperand* destination = current_move.destination();
111 moves_[index].set_destination(NULL); 120 current_move.set_destination(NULL);
112 121
113 // Perform a depth-first traversal of the move graph to resolve 122 // Perform a depth-first traversal of the move graph to resolve
114 // dependencies. Any unperformed, unpending move with a source the same 123 // dependencies. Any unperformed, unpending move with a source the same
115 // as this one's destination blocks this one so recursively perform all 124 // as this one's destination blocks this one so recursively perform all
116 // such moves. 125 // such moves.
117 for (int i = 0; i < moves_.length(); ++i) { 126 for (int i = 0; i < moves_.length(); ++i) {
118 LMoveOperands other_move = moves_[i]; 127 LMoveOperands other_move = moves_[i];
119 if (other_move.Blocks(destination) && !other_move.IsPending()) { 128 if (other_move.Blocks(destination) && !other_move.IsPending()) {
120 PerformMove(i); 129 PerformMove(i);
121 // If there is a blocking, pending move it must be moves_[root_index_] 130 // If there is a blocking, pending move it must be moves_[root_index_]
122 // and all other moves with the same source as moves_[root_index_] are 131 // and all other moves with the same source as moves_[root_index_] are
123 // sucessfully executed (because they are cycle-free) by this loop. 132 // sucessfully executed (because they are cycle-free) by this loop.
124 } 133 }
125 } 134 }
126 135
127 // We are about to resolve this move and don't need it marked as 136 // We are about to resolve this move and don't need it marked as
128 // pending, so restore its destination. 137 // pending, so restore its destination.
129 moves_[index].set_destination(destination); 138 current_move.set_destination(destination);
130 139
131 // The move may be blocked on a pending move, which must be the starting move. 140 // The move may be blocked on a pending move, which must be the starting move.
132 // In this case, we have a cycle, and we save the source of this move to 141 // In this case, we have a cycle, and we save the source of this move to
133 // a scratch register to break it. 142 // a scratch register to break it.
134 LMoveOperands other_move = moves_[root_index_]; 143 LMoveOperands other_move = moves_[root_index_];
135 if (other_move.Blocks(destination)) { 144 if (other_move.Blocks(destination)) {
136 ASSERT(other_move.IsPending()); 145 ASSERT(other_move.IsPending());
137 BreakCycle(index); 146 BreakCycle(index);
138 return; 147 return;
139 } 148 }
140 149
141 // This move is no longer blocked. 150 // This move is no longer blocked.
142 EmitMove(index); 151 EmitMove(index);
143 } 152 }
144 153
145 154
146 void LGapResolver::Verify() { 155 void LGapResolver::Verify() {
147 #ifdef ENABLE_SLOW_ASSERTS 156 #ifdef ENABLE_SLOW_ASSERTS
148 // No operand should be the destination for more than one move. 157 // No operand should be the destination for more than one move.
149 for (int i = 0; i < moves_.length(); ++i) { 158 for (int i = 0; i < moves_.length(); ++i) {
150 LOperand* destination = moves_[i].destination(); 159 LOperand* destination = moves_[i].destination();
151 for (int j = i + 1; j < moves_.length(); ++j) { 160 for (int j = i + 1; j < moves_.length(); ++j) {
152 SLOW_ASSERT(!destination->Equals(moves_[j].destination())); 161 SLOW_ASSERT(!destination->Equals(moves_[j].destination()));
153 } 162 }
154 } 163 }
155 #endif 164 #endif
156 } 165 }
157 166
158 #define __ ACCESS_MASM(cgen_->masm())
159 167
160 void LGapResolver::BreakCycle(int index) { 168 void LGapResolver::BreakCycle(int index) {
161 // We save in a register the value that should end up in the source of
162 // moves_[root_index]. After performing all moves in the tree rooted
163 // in that move, we save the value to that source.
164 ASSERT(moves_[index].destination()->Equals(moves_[root_index_].source())); 169 ASSERT(moves_[index].destination()->Equals(moves_[root_index_].source()));
165 ASSERT(!in_cycle_); 170 ASSERT(!in_cycle_);
171
172 // We use a register which is not allocatable by crankshaft to break the cycle
173 // to be sure it doesn't interfere with the moves we are resolving.
174 ASSERT(!kSavedValue.IsAllocatable());
175 need_to_restore_root_ = true;
176
177 // We save in a register the source of that move and we remember its
178 // destination. Then we mark this move as resolved so the cycle is
179 // broken and we can perform the other moves.
166 in_cycle_ = true; 180 in_cycle_ = true;
167 LOperand* source = moves_[index].source(); 181 LOperand* source = moves_[index].source();
168 saved_destination_ = moves_[index].destination(); 182 saved_destination_ = moves_[index].destination();
183
169 if (source->IsRegister()) { 184 if (source->IsRegister()) {
170 __ mov(kSavedValueRegister, cgen_->ToRegister(source)); 185 __ Mov(kSavedValue, cgen_->ToRegister(source));
171 } else if (source->IsStackSlot()) { 186 } else if (source->IsStackSlot()) {
172 __ ldr(kSavedValueRegister, cgen_->ToMemOperand(source)); 187 __ Ldr(kSavedValue, cgen_->ToMemOperand(source));
173 } else if (source->IsDoubleRegister()) { 188 } else if (source->IsDoubleRegister()) {
174 __ vmov(kScratchDoubleReg, cgen_->ToDoubleRegister(source)); 189 // TODO(all): We should use a double register to store the value to avoid
190 // the penalty of the mov across register banks. We are going to reserve
191 // d31 to hold 0.0 value. We could clobber this register while breaking the
192 // cycle and restore it after like we do with the root register.
193 // LGapResolver::RestoreValue() will need to be updated as well when we'll
194 // do that.
195 __ Fmov(kSavedValue, cgen_->ToDoubleRegister(source));
175 } else if (source->IsDoubleStackSlot()) { 196 } else if (source->IsDoubleStackSlot()) {
176 __ vldr(kScratchDoubleReg, cgen_->ToMemOperand(source)); 197 __ Ldr(kSavedValue, cgen_->ToMemOperand(source));
177 } else { 198 } else {
178 UNREACHABLE(); 199 UNREACHABLE();
179 } 200 }
180 // This move will be done by restoring the saved value to the destination. 201
202 // Mark this move as resolved.
203 // This move will be actually performed by moving the saved value to this
204 // move's destination in LGapResolver::RestoreValue().
181 moves_[index].Eliminate(); 205 moves_[index].Eliminate();
182 } 206 }
183 207
184 208
185 void LGapResolver::RestoreValue() { 209 void LGapResolver::RestoreValue() {
186 ASSERT(in_cycle_); 210 ASSERT(in_cycle_);
187 ASSERT(saved_destination_ != NULL); 211 ASSERT(saved_destination_ != NULL);
188 212
189 // Spilled value is in kSavedValueRegister or kSavedDoubleValueRegister.
190 if (saved_destination_->IsRegister()) { 213 if (saved_destination_->IsRegister()) {
191 __ mov(cgen_->ToRegister(saved_destination_), kSavedValueRegister); 214 __ Mov(cgen_->ToRegister(saved_destination_), kSavedValue);
192 } else if (saved_destination_->IsStackSlot()) { 215 } else if (saved_destination_->IsStackSlot()) {
193 __ str(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_)); 216 __ Str(kSavedValue, cgen_->ToMemOperand(saved_destination_));
194 } else if (saved_destination_->IsDoubleRegister()) { 217 } else if (saved_destination_->IsDoubleRegister()) {
195 __ vmov(cgen_->ToDoubleRegister(saved_destination_), kScratchDoubleReg); 218 __ Fmov(cgen_->ToDoubleRegister(saved_destination_), kSavedValue);
196 } else if (saved_destination_->IsDoubleStackSlot()) { 219 } else if (saved_destination_->IsDoubleStackSlot()) {
197 __ vstr(kScratchDoubleReg, cgen_->ToMemOperand(saved_destination_)); 220 __ Str(kSavedValue, cgen_->ToMemOperand(saved_destination_));
198 } else { 221 } else {
199 UNREACHABLE(); 222 UNREACHABLE();
200 } 223 }
201 224
202 in_cycle_ = false; 225 in_cycle_ = false;
203 saved_destination_ = NULL; 226 saved_destination_ = NULL;
204 } 227 }
205 228
206 229
207 void LGapResolver::EmitMove(int index) { 230 void LGapResolver::EmitMove(int index) {
208 LOperand* source = moves_[index].source(); 231 LOperand* source = moves_[index].source();
209 LOperand* destination = moves_[index].destination(); 232 LOperand* destination = moves_[index].destination();
210 233
211 // Dispatch on the source and destination operand kinds. Not all 234 // Dispatch on the source and destination operand kinds. Not all
212 // combinations are possible. 235 // combinations are possible.
213 236
214 if (source->IsRegister()) { 237 if (source->IsRegister()) {
215 Register source_register = cgen_->ToRegister(source); 238 Register source_register = cgen_->ToRegister(source);
216 if (destination->IsRegister()) { 239 if (destination->IsRegister()) {
217 __ mov(cgen_->ToRegister(destination), source_register); 240 __ Mov(cgen_->ToRegister(destination), source_register);
218 } else { 241 } else {
219 ASSERT(destination->IsStackSlot()); 242 ASSERT(destination->IsStackSlot());
220 __ str(source_register, cgen_->ToMemOperand(destination)); 243 __ Str(source_register, cgen_->ToMemOperand(destination));
221 } 244 }
245
222 } else if (source->IsStackSlot()) { 246 } else if (source->IsStackSlot()) {
223 MemOperand source_operand = cgen_->ToMemOperand(source); 247 MemOperand source_operand = cgen_->ToMemOperand(source);
224 if (destination->IsRegister()) { 248 if (destination->IsRegister()) {
225 __ ldr(cgen_->ToRegister(destination), source_operand); 249 __ Ldr(cgen_->ToRegister(destination), source_operand);
226 } else { 250 } else {
227 ASSERT(destination->IsStackSlot()); 251 ASSERT(destination->IsStackSlot());
228 MemOperand destination_operand = cgen_->ToMemOperand(destination); 252 EmitStackSlotMove(index);
229 if (in_cycle_) {
230 if (!destination_operand.OffsetIsUint12Encodable()) {
231 // ip is overwritten while saving the value to the destination.
232 // Therefore we can't use ip. It is OK if the read from the source
233 // destroys ip, since that happens before the value is read.
234 __ vldr(kScratchDoubleReg.low(), source_operand);
235 __ vstr(kScratchDoubleReg.low(), destination_operand);
236 } else {
237 __ ldr(ip, source_operand);
238 __ str(ip, destination_operand);
239 }
240 } else {
241 __ ldr(kSavedValueRegister, source_operand);
242 __ str(kSavedValueRegister, destination_operand);
243 }
244 } 253 }
245 254
246 } else if (source->IsConstantOperand()) { 255 } else if (source->IsConstantOperand()) {
247 LConstantOperand* constant_source = LConstantOperand::cast(source); 256 LConstantOperand* constant_source = LConstantOperand::cast(source);
248 if (destination->IsRegister()) { 257 if (destination->IsRegister()) {
249 Register dst = cgen_->ToRegister(destination); 258 Register dst = cgen_->ToRegister(destination);
250 Representation r = cgen_->IsSmi(constant_source) 259 if (cgen_->IsSmi(constant_source)) {
251 ? Representation::Smi() : Representation::Integer32(); 260 __ Mov(dst, Operand(cgen_->ToSmi(constant_source)));
252 if (cgen_->IsInteger32(constant_source)) { 261 } else if (cgen_->IsInteger32Constant(constant_source)) {
253 __ mov(dst, Operand(cgen_->ToRepresentation(constant_source, r))); 262 __ Mov(dst, cgen_->ToInteger32(constant_source));
254 } else { 263 } else {
255 __ Move(dst, cgen_->ToHandle(constant_source)); 264 __ LoadObject(dst, cgen_->ToHandle(constant_source));
256 } 265 }
257 } else if (destination->IsDoubleRegister()) { 266 } else if (destination->IsDoubleRegister()) {
258 DwVfpRegister result = cgen_->ToDoubleRegister(destination); 267 DoubleRegister result = cgen_->ToDoubleRegister(destination);
259 double v = cgen_->ToDouble(constant_source); 268 __ Fmov(result, cgen_->ToDouble(constant_source));
260 __ Vmov(result, v, ip);
261 } else { 269 } else {
262 ASSERT(destination->IsStackSlot()); 270 ASSERT(destination->IsStackSlot());
263 ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone. 271 ASSERT(!in_cycle_); // Constant moves happen after all cycles are gone.
264 Representation r = cgen_->IsSmi(constant_source) 272 need_to_restore_root_ = true;
265 ? Representation::Smi() : Representation::Integer32(); 273 if (cgen_->IsSmi(constant_source)) {
266 if (cgen_->IsInteger32(constant_source)) { 274 __ Mov(kSavedValue, Operand(cgen_->ToSmi(constant_source)));
267 __ mov(kSavedValueRegister, 275 } else if (cgen_->IsInteger32Constant(constant_source)) {
268 Operand(cgen_->ToRepresentation(constant_source, r))); 276 __ Mov(kSavedValue, cgen_->ToInteger32(constant_source));
269 } else { 277 } else {
270 __ Move(kSavedValueRegister, 278 __ LoadObject(kSavedValue, cgen_->ToHandle(constant_source));
271 cgen_->ToHandle(constant_source));
272 } 279 }
273 __ str(kSavedValueRegister, cgen_->ToMemOperand(destination)); 280 __ Str(kSavedValue, cgen_->ToMemOperand(destination));
274 } 281 }
275 282
276 } else if (source->IsDoubleRegister()) { 283 } else if (source->IsDoubleRegister()) {
277 DwVfpRegister source_register = cgen_->ToDoubleRegister(source); 284 DoubleRegister src = cgen_->ToDoubleRegister(source);
278 if (destination->IsDoubleRegister()) { 285 if (destination->IsDoubleRegister()) {
279 __ vmov(cgen_->ToDoubleRegister(destination), source_register); 286 __ Fmov(cgen_->ToDoubleRegister(destination), src);
280 } else { 287 } else {
281 ASSERT(destination->IsDoubleStackSlot()); 288 ASSERT(destination->IsDoubleStackSlot());
282 __ vstr(source_register, cgen_->ToMemOperand(destination)); 289 __ Str(src, cgen_->ToMemOperand(destination));
283 } 290 }
284 291
285 } else if (source->IsDoubleStackSlot()) { 292 } else if (source->IsDoubleStackSlot()) {
286 MemOperand source_operand = cgen_->ToMemOperand(source); 293 MemOperand src = cgen_->ToMemOperand(source);
287 if (destination->IsDoubleRegister()) { 294 if (destination->IsDoubleRegister()) {
288 __ vldr(cgen_->ToDoubleRegister(destination), source_operand); 295 __ Ldr(cgen_->ToDoubleRegister(destination), src);
289 } else { 296 } else {
290 ASSERT(destination->IsDoubleStackSlot()); 297 ASSERT(destination->IsDoubleStackSlot());
291 MemOperand destination_operand = cgen_->ToMemOperand(destination); 298 EmitStackSlotMove(index);
292 if (in_cycle_) {
293 // kSavedDoubleValueRegister was used to break the cycle,
294 // but kSavedValueRegister is free.
295 MemOperand source_high_operand =
296 cgen_->ToHighMemOperand(source);
297 MemOperand destination_high_operand =
298 cgen_->ToHighMemOperand(destination);
299 __ ldr(kSavedValueRegister, source_operand);
300 __ str(kSavedValueRegister, destination_operand);
301 __ ldr(kSavedValueRegister, source_high_operand);
302 __ str(kSavedValueRegister, destination_high_operand);
303 } else {
304 __ vldr(kScratchDoubleReg, source_operand);
305 __ vstr(kScratchDoubleReg, destination_operand);
306 }
307 } 299 }
300
308 } else { 301 } else {
309 UNREACHABLE(); 302 UNREACHABLE();
310 } 303 }
311 304
305 // The move has been emitted, we can eliminate it.
312 moves_[index].Eliminate(); 306 moves_[index].Eliminate();
313 } 307 }
314 308
315 309
316 #undef __ 310 void LGapResolver::EmitStackSlotMove(int index) {
311 // We need a temp register to perform a stack slot to stack slot move, and
312 // the register must not be involved in breaking cycles.
313
314 // Use the Crankshaft double scratch register as the temporary.
315 DoubleRegister temp = crankshaft_fp_scratch;
316
317 LOperand* src = moves_[index].source();
318 LOperand* dst = moves_[index].destination();
319
320 ASSERT(src->IsStackSlot());
321 ASSERT(dst->IsStackSlot());
322 __ Ldr(temp, cgen_->ToMemOperand(src));
323 __ Str(temp, cgen_->ToMemOperand(dst));
324 }
317 325
318 } } // namespace v8::internal 326 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/a64/lithium-gap-resolver-a64.h ('k') | src/a64/macro-assembler-a64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698