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

Side by Side Diff: src/a64/macro-assembler-a64.cc

Issue 164793003: A64: Use a scope utility to allocate scratch registers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Modify Printf (as discussed) and remove Exclude(). 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
OLDNEW
1 // Copyright 2013 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
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 MacroAssembler::MacroAssembler(Isolate* arg_isolate, 46 MacroAssembler::MacroAssembler(Isolate* arg_isolate,
47 byte * buffer, 47 byte * buffer,
48 unsigned buffer_size) 48 unsigned buffer_size)
49 : Assembler(arg_isolate, buffer, buffer_size), 49 : Assembler(arg_isolate, buffer, buffer_size),
50 generating_stub_(false), 50 generating_stub_(false),
51 #if DEBUG 51 #if DEBUG
52 allow_macro_instructions_(true), 52 allow_macro_instructions_(true),
53 #endif 53 #endif
54 has_frame_(false), 54 has_frame_(false),
55 use_real_aborts_(true), 55 use_real_aborts_(true),
56 sp_(jssp), tmp0_(ip0), tmp1_(ip1), fptmp0_(fp_scratch) { 56 sp_(jssp), tmp_list_(ip0, ip1), fptmp_list_(fp_scratch) {
57 if (isolate() != NULL) { 57 if (isolate() != NULL) {
58 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(), 58 code_object_ = Handle<Object>(isolate()->heap()->undefined_value(),
59 isolate()); 59 isolate());
60 } 60 }
61 } 61 }
62 62
63 63
64 void MacroAssembler::LogicalMacro(const Register& rd, 64 void MacroAssembler::LogicalMacro(const Register& rd,
65 const Register& rn, 65 const Register& rn,
66 const Operand& operand, 66 const Operand& operand,
67 LogicalOp op) { 67 LogicalOp op) {
68 UseScratchRegisterScope temps(this);
69
68 if (operand.NeedsRelocation()) { 70 if (operand.NeedsRelocation()) {
69 LoadRelocated(Tmp0(), operand); 71 Register temp = temps.AcquireX();
70 Logical(rd, rn, Tmp0(), op); 72 LoadRelocated(temp, operand);
73 Logical(rd, rn, temp, op);
71 74
72 } else if (operand.IsImmediate()) { 75 } else if (operand.IsImmediate()) {
73 int64_t immediate = operand.immediate(); 76 int64_t immediate = operand.immediate();
74 unsigned reg_size = rd.SizeInBits(); 77 unsigned reg_size = rd.SizeInBits();
75 ASSERT(rd.Is64Bits() || is_uint32(immediate)); 78 ASSERT(rd.Is64Bits() || is_uint32(immediate));
76 79
77 // If the operation is NOT, invert the operation and immediate. 80 // If the operation is NOT, invert the operation and immediate.
78 if ((op & NOT) == NOT) { 81 if ((op & NOT) == NOT) {
79 op = static_cast<LogicalOp>(op & ~NOT); 82 op = static_cast<LogicalOp>(op & ~NOT);
80 immediate = ~immediate; 83 immediate = ~immediate;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 UNREACHABLE(); 121 UNREACHABLE();
119 } 122 }
120 } 123 }
121 124
122 unsigned n, imm_s, imm_r; 125 unsigned n, imm_s, imm_r;
123 if (IsImmLogical(immediate, reg_size, &n, &imm_s, &imm_r)) { 126 if (IsImmLogical(immediate, reg_size, &n, &imm_s, &imm_r)) {
124 // Immediate can be encoded in the instruction. 127 // Immediate can be encoded in the instruction.
125 LogicalImmediate(rd, rn, n, imm_s, imm_r, op); 128 LogicalImmediate(rd, rn, n, imm_s, imm_r, op);
126 } else { 129 } else {
127 // Immediate can't be encoded: synthesize using move immediate. 130 // Immediate can't be encoded: synthesize using move immediate.
128 Register temp = AppropriateTempFor(rn); 131 Register temp = temps.AcquireSameSizeAs(rn);
129 Mov(temp, immediate); 132 Mov(temp, immediate);
130 if (rd.Is(csp)) { 133 if (rd.Is(csp)) {
131 // If rd is the stack pointer we cannot use it as the destination 134 // If rd is the stack pointer we cannot use it as the destination
132 // register so we use the temp register as an intermediate again. 135 // register so we use the temp register as an intermediate again.
133 Logical(temp, rn, temp, op); 136 Logical(temp, rn, temp, op);
134 Mov(csp, temp); 137 Mov(csp, temp);
135 } else { 138 } else {
136 Logical(rd, rn, temp, op); 139 Logical(rd, rn, temp, op);
137 } 140 }
138 } 141 }
139 142
140 } else if (operand.IsExtendedRegister()) { 143 } else if (operand.IsExtendedRegister()) {
141 ASSERT(operand.reg().SizeInBits() <= rd.SizeInBits()); 144 ASSERT(operand.reg().SizeInBits() <= rd.SizeInBits());
142 // Add/sub extended supports shift <= 4. We want to support exactly the 145 // Add/sub extended supports shift <= 4. We want to support exactly the
143 // same modes here. 146 // same modes here.
144 ASSERT(operand.shift_amount() <= 4); 147 ASSERT(operand.shift_amount() <= 4);
145 ASSERT(operand.reg().Is64Bits() || 148 ASSERT(operand.reg().Is64Bits() ||
146 ((operand.extend() != UXTX) && (operand.extend() != SXTX))); 149 ((operand.extend() != UXTX) && (operand.extend() != SXTX)));
147 Register temp = AppropriateTempFor(rn, operand.reg()); 150 Register temp = temps.AcquireSameSizeAs(rn);
148 EmitExtendShift(temp, operand.reg(), operand.extend(), 151 EmitExtendShift(temp, operand.reg(), operand.extend(),
149 operand.shift_amount()); 152 operand.shift_amount());
150 Logical(rd, rn, temp, op); 153 Logical(rd, rn, temp, op);
151 154
152 } else { 155 } else {
153 // The operand can be encoded in the instruction. 156 // The operand can be encoded in the instruction.
154 ASSERT(operand.IsShiftedRegister()); 157 ASSERT(operand.IsShiftedRegister());
155 Logical(rd, rn, operand, op); 158 Logical(rd, rn, operand, op);
156 } 159 }
157 } 160 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 uint64_t ignored_halfword = 0; 204 uint64_t ignored_halfword = 0;
202 bool invert_move = false; 205 bool invert_move = false;
203 // If the number of 0xffff halfwords is greater than the number of 0x0000 206 // If the number of 0xffff halfwords is greater than the number of 0x0000
204 // halfwords, it's more efficient to use move-inverted. 207 // halfwords, it's more efficient to use move-inverted.
205 if (CountClearHalfWords(~imm, reg_size) > 208 if (CountClearHalfWords(~imm, reg_size) >
206 CountClearHalfWords(imm, reg_size)) { 209 CountClearHalfWords(imm, reg_size)) {
207 ignored_halfword = 0xffffL; 210 ignored_halfword = 0xffffL;
208 invert_move = true; 211 invert_move = true;
209 } 212 }
210 213
211 // Mov instructions can't move value into the stack pointer, so set up a 214 // Mov instructions can't move immediate values into the stack pointer, so
212 // temporary register, if needed. 215 // set up a temporary register, if needed.
213 Register temp = rd.IsSP() ? AppropriateTempFor(rd) : rd; 216 UseScratchRegisterScope temps(this);
217 Register temp = rd.IsSP() ? temps.AcquireSameSizeAs(rd) : rd;
214 218
215 // Iterate through the halfwords. Use movn/movz for the first non-ignored 219 // Iterate through the halfwords. Use movn/movz for the first non-ignored
216 // halfword, and movk for subsequent halfwords. 220 // halfword, and movk for subsequent halfwords.
217 ASSERT((reg_size % 16) == 0); 221 ASSERT((reg_size % 16) == 0);
218 bool first_mov_done = false; 222 bool first_mov_done = false;
219 for (unsigned i = 0; i < (rd.SizeInBits() / 16); i++) { 223 for (unsigned i = 0; i < (rd.SizeInBits() / 16); i++) {
220 uint64_t imm16 = (imm >> (16 * i)) & 0xffffL; 224 uint64_t imm16 = (imm >> (16 * i)) & 0xffffL;
221 if (imm16 != ignored_halfword) { 225 if (imm16 != ignored_halfword) {
222 if (!first_mov_done) { 226 if (!first_mov_done) {
223 if (invert_move) { 227 if (invert_move) {
(...skipping 17 matching lines...) Expand all
241 } 245 }
242 } 246 }
243 } 247 }
244 248
245 249
246 void MacroAssembler::Mov(const Register& rd, 250 void MacroAssembler::Mov(const Register& rd,
247 const Operand& operand, 251 const Operand& operand,
248 DiscardMoveMode discard_mode) { 252 DiscardMoveMode discard_mode) {
249 ASSERT(allow_macro_instructions_); 253 ASSERT(allow_macro_instructions_);
250 ASSERT(!rd.IsZero()); 254 ASSERT(!rd.IsZero());
255
251 // Provide a swap register for instructions that need to write into the 256 // Provide a swap register for instructions that need to write into the
252 // system stack pointer (and can't do this inherently). 257 // system stack pointer (and can't do this inherently).
253 Register dst = (rd.Is(csp)) ? (Tmp1()) : (rd); 258 UseScratchRegisterScope temps(this);
259 Register dst = (rd.IsSP()) ? temps.AcquireSameSizeAs(rd) : rd;
254 260
255 if (operand.NeedsRelocation()) { 261 if (operand.NeedsRelocation()) {
256 LoadRelocated(dst, operand); 262 LoadRelocated(dst, operand);
257 263
258 } else if (operand.IsImmediate()) { 264 } else if (operand.IsImmediate()) {
259 // Call the macro assembler for generic immediates. 265 // Call the macro assembler for generic immediates.
260 Mov(dst, operand.immediate()); 266 Mov(dst, operand.immediate());
261 267
262 } else if (operand.IsShiftedRegister() && (operand.shift_amount() != 0)) { 268 } else if (operand.IsShiftedRegister() && (operand.shift_amount() != 0)) {
263 // Emit a shift instruction if moving a shifted register. This operation 269 // Emit a shift instruction if moving a shifted register. This operation
(...skipping 20 matching lines...) Expand all
284 if (!rd.Is(operand.reg()) || (rd.Is32Bits() && 290 if (!rd.Is(operand.reg()) || (rd.Is32Bits() &&
285 (discard_mode == kDontDiscardForSameWReg))) { 291 (discard_mode == kDontDiscardForSameWReg))) {
286 Assembler::mov(rd, operand.reg()); 292 Assembler::mov(rd, operand.reg());
287 } 293 }
288 // This case can handle writes into the system stack pointer directly. 294 // This case can handle writes into the system stack pointer directly.
289 dst = rd; 295 dst = rd;
290 } 296 }
291 297
292 // Copy the result to the system stack pointer. 298 // Copy the result to the system stack pointer.
293 if (!dst.Is(rd)) { 299 if (!dst.Is(rd)) {
294 ASSERT(rd.IsZero()); 300 ASSERT(rd.IsSP());
295 ASSERT(dst.Is(Tmp1()));
296 Assembler::mov(rd, dst); 301 Assembler::mov(rd, dst);
297 } 302 }
298 } 303 }
299 304
300 305
301 void MacroAssembler::Mvn(const Register& rd, const Operand& operand) { 306 void MacroAssembler::Mvn(const Register& rd, const Operand& operand) {
302 ASSERT(allow_macro_instructions_); 307 ASSERT(allow_macro_instructions_);
303 308
304 if (operand.NeedsRelocation()) { 309 if (operand.NeedsRelocation()) {
305 LoadRelocated(Tmp0(), operand); 310 LoadRelocated(rd, operand);
306 Mvn(rd, Tmp0()); 311 mvn(rd, rd);
307 312
308 } else if (operand.IsImmediate()) { 313 } else if (operand.IsImmediate()) {
309 // Call the macro assembler for generic immediates. 314 // Call the macro assembler for generic immediates.
310 Mov(rd, ~operand.immediate()); 315 Mov(rd, ~operand.immediate());
311 316
312 } else if (operand.IsExtendedRegister()) { 317 } else if (operand.IsExtendedRegister()) {
313 // Emit two instructions for the extend case. This differs from Mov, as 318 // Emit two instructions for the extend case. This differs from Mov, as
314 // the extend and invert can't be achieved in one instruction. 319 // the extend and invert can't be achieved in one instruction.
315 Register temp = AppropriateTempFor(rd, operand.reg()); 320 EmitExtendShift(rd, operand.reg(), operand.extend(),
316 EmitExtendShift(temp, operand.reg(), operand.extend(),
317 operand.shift_amount()); 321 operand.shift_amount());
318 mvn(rd, temp); 322 mvn(rd, rd);
319 323
320 } else { 324 } else {
321 // Otherwise, emit a register move only if the registers are distinct.
322 // If the jssp is an operand, add #0 is emitted, otherwise, orr #0.
323 mvn(rd, operand); 325 mvn(rd, operand);
324 } 326 }
325 } 327 }
326 328
327 329
328 unsigned MacroAssembler::CountClearHalfWords(uint64_t imm, unsigned reg_size) { 330 unsigned MacroAssembler::CountClearHalfWords(uint64_t imm, unsigned reg_size) {
329 ASSERT((reg_size % 8) == 0); 331 ASSERT((reg_size % 8) == 0);
330 int count = 0; 332 int count = 0;
331 for (unsigned i = 0; i < (reg_size / 16); i++) { 333 for (unsigned i = 0; i < (reg_size / 16); i++) {
332 if ((imm & 0xffff) == 0) { 334 if ((imm & 0xffff) == 0) {
(...skipping 20 matching lines...) Expand all
353 } 355 }
354 356
355 357
356 void MacroAssembler::ConditionalCompareMacro(const Register& rn, 358 void MacroAssembler::ConditionalCompareMacro(const Register& rn,
357 const Operand& operand, 359 const Operand& operand,
358 StatusFlags nzcv, 360 StatusFlags nzcv,
359 Condition cond, 361 Condition cond,
360 ConditionalCompareOp op) { 362 ConditionalCompareOp op) {
361 ASSERT((cond != al) && (cond != nv)); 363 ASSERT((cond != al) && (cond != nv));
362 if (operand.NeedsRelocation()) { 364 if (operand.NeedsRelocation()) {
363 LoadRelocated(Tmp0(), operand); 365 UseScratchRegisterScope temps(this);
364 ConditionalCompareMacro(rn, Tmp0(), nzcv, cond, op); 366 Register temp = temps.AcquireX();
367 LoadRelocated(temp, operand);
368 ConditionalCompareMacro(rn, temp, nzcv, cond, op);
365 369
366 } else if ((operand.IsShiftedRegister() && (operand.shift_amount() == 0)) || 370 } else if ((operand.IsShiftedRegister() && (operand.shift_amount() == 0)) ||
367 (operand.IsImmediate() && IsImmConditionalCompare(operand.immediate()))) { 371 (operand.IsImmediate() && IsImmConditionalCompare(operand.immediate()))) {
368 // The immediate can be encoded in the instruction, or the operand is an 372 // The immediate can be encoded in the instruction, or the operand is an
369 // unshifted register: call the assembler. 373 // unshifted register: call the assembler.
370 ConditionalCompare(rn, operand, nzcv, cond, op); 374 ConditionalCompare(rn, operand, nzcv, cond, op);
371 375
372 } else { 376 } else {
373 // The operand isn't directly supported by the instruction: perform the 377 // The operand isn't directly supported by the instruction: perform the
374 // operation on a temporary register. 378 // operation on a temporary register.
375 Register temp = AppropriateTempFor(rn); 379 UseScratchRegisterScope temps(this);
380 Register temp = temps.AcquireSameSizeAs(rn);
376 Mov(temp, operand); 381 Mov(temp, operand);
377 ConditionalCompare(rn, temp, nzcv, cond, op); 382 ConditionalCompare(rn, temp, nzcv, cond, op);
378 } 383 }
379 } 384 }
380 385
381 386
382 void MacroAssembler::Csel(const Register& rd, 387 void MacroAssembler::Csel(const Register& rd,
383 const Register& rn, 388 const Register& rn,
384 const Operand& operand, 389 const Operand& operand,
385 Condition cond) { 390 Condition cond) {
386 ASSERT(allow_macro_instructions_); 391 ASSERT(allow_macro_instructions_);
387 ASSERT(!rd.IsZero()); 392 ASSERT(!rd.IsZero());
388 ASSERT((cond != al) && (cond != nv)); 393 ASSERT((cond != al) && (cond != nv));
389 if (operand.IsImmediate()) { 394 if (operand.IsImmediate()) {
390 // Immediate argument. Handle special cases of 0, 1 and -1 using zero 395 // Immediate argument. Handle special cases of 0, 1 and -1 using zero
391 // register. 396 // register.
392 int64_t imm = operand.immediate(); 397 int64_t imm = operand.immediate();
393 Register zr = AppropriateZeroRegFor(rn); 398 Register zr = AppropriateZeroRegFor(rn);
394 if (imm == 0) { 399 if (imm == 0) {
395 csel(rd, rn, zr, cond); 400 csel(rd, rn, zr, cond);
396 } else if (imm == 1) { 401 } else if (imm == 1) {
397 csinc(rd, rn, zr, cond); 402 csinc(rd, rn, zr, cond);
398 } else if (imm == -1) { 403 } else if (imm == -1) {
399 csinv(rd, rn, zr, cond); 404 csinv(rd, rn, zr, cond);
400 } else { 405 } else {
401 Register temp = AppropriateTempFor(rn); 406 UseScratchRegisterScope temps(this);
407 Register temp = temps.AcquireSameSizeAs(rn);
402 Mov(temp, operand.immediate()); 408 Mov(temp, operand.immediate());
403 csel(rd, rn, temp, cond); 409 csel(rd, rn, temp, cond);
404 } 410 }
405 } else if (operand.IsShiftedRegister() && (operand.shift_amount() == 0)) { 411 } else if (operand.IsShiftedRegister() && (operand.shift_amount() == 0)) {
406 // Unshifted register argument. 412 // Unshifted register argument.
407 csel(rd, rn, operand.reg(), cond); 413 csel(rd, rn, operand.reg(), cond);
408 } else { 414 } else {
409 // All other arguments. 415 // All other arguments.
410 Register temp = AppropriateTempFor(rn); 416 UseScratchRegisterScope temps(this);
417 Register temp = temps.AcquireSameSizeAs(rn);
411 Mov(temp, operand); 418 Mov(temp, operand);
412 csel(rd, rn, temp, cond); 419 csel(rd, rn, temp, cond);
413 } 420 }
414 } 421 }
415 422
416 423
417 void MacroAssembler::AddSubMacro(const Register& rd, 424 void MacroAssembler::AddSubMacro(const Register& rd,
418 const Register& rn, 425 const Register& rn,
419 const Operand& operand, 426 const Operand& operand,
420 FlagsUpdate S, 427 FlagsUpdate S,
421 AddSubOp op) { 428 AddSubOp op) {
422 if (operand.IsZero() && rd.Is(rn) && rd.Is64Bits() && rn.Is64Bits() && 429 if (operand.IsZero() && rd.Is(rn) && rd.Is64Bits() && rn.Is64Bits() &&
423 !operand.NeedsRelocation() && (S == LeaveFlags)) { 430 !operand.NeedsRelocation() && (S == LeaveFlags)) {
424 // The instruction would be a nop. Avoid generating useless code. 431 // The instruction would be a nop. Avoid generating useless code.
425 return; 432 return;
426 } 433 }
427 434
428 if (operand.NeedsRelocation()) { 435 if (operand.NeedsRelocation()) {
429 LoadRelocated(Tmp0(), operand); 436 UseScratchRegisterScope temps(this);
430 AddSubMacro(rd, rn, Tmp0(), S, op); 437 Register temp = temps.AcquireX();
438 LoadRelocated(temp, operand);
439 AddSubMacro(rd, rn, temp, S, op);
431 } else if ((operand.IsImmediate() && !IsImmAddSub(operand.immediate())) || 440 } else if ((operand.IsImmediate() && !IsImmAddSub(operand.immediate())) ||
432 (rn.IsZero() && !operand.IsShiftedRegister()) || 441 (rn.IsZero() && !operand.IsShiftedRegister()) ||
433 (operand.IsShiftedRegister() && (operand.shift() == ROR))) { 442 (operand.IsShiftedRegister() && (operand.shift() == ROR))) {
434 Register temp = AppropriateTempFor(rn); 443 UseScratchRegisterScope temps(this);
444 Register temp = temps.AcquireSameSizeAs(rn);
435 Mov(temp, operand); 445 Mov(temp, operand);
436 AddSub(rd, rn, temp, S, op); 446 AddSub(rd, rn, temp, S, op);
437 } else { 447 } else {
438 AddSub(rd, rn, operand, S, op); 448 AddSub(rd, rn, operand, S, op);
439 } 449 }
440 } 450 }
441 451
442 452
443 void MacroAssembler::AddSubWithCarryMacro(const Register& rd, 453 void MacroAssembler::AddSubWithCarryMacro(const Register& rd,
444 const Register& rn, 454 const Register& rn,
445 const Operand& operand, 455 const Operand& operand,
446 FlagsUpdate S, 456 FlagsUpdate S,
447 AddSubWithCarryOp op) { 457 AddSubWithCarryOp op) {
448 ASSERT(rd.SizeInBits() == rn.SizeInBits()); 458 ASSERT(rd.SizeInBits() == rn.SizeInBits());
459 UseScratchRegisterScope temps(this);
449 460
450 if (operand.NeedsRelocation()) { 461 if (operand.NeedsRelocation()) {
451 LoadRelocated(Tmp0(), operand); 462 Register temp = temps.AcquireX();
452 AddSubWithCarryMacro(rd, rn, Tmp0(), S, op); 463 LoadRelocated(temp, operand);
464 AddSubWithCarryMacro(rd, rn, temp, S, op);
453 465
454 } else if (operand.IsImmediate() || 466 } else if (operand.IsImmediate() ||
455 (operand.IsShiftedRegister() && (operand.shift() == ROR))) { 467 (operand.IsShiftedRegister() && (operand.shift() == ROR))) {
456 // Add/sub with carry (immediate or ROR shifted register.) 468 // Add/sub with carry (immediate or ROR shifted register.)
457 Register temp = AppropriateTempFor(rn); 469 Register temp = temps.AcquireSameSizeAs(rn);
458 Mov(temp, operand); 470 Mov(temp, operand);
459 AddSubWithCarry(rd, rn, temp, S, op); 471 AddSubWithCarry(rd, rn, temp, S, op);
472
460 } else if (operand.IsShiftedRegister() && (operand.shift_amount() != 0)) { 473 } else if (operand.IsShiftedRegister() && (operand.shift_amount() != 0)) {
461 // Add/sub with carry (shifted register). 474 // Add/sub with carry (shifted register).
462 ASSERT(operand.reg().SizeInBits() == rd.SizeInBits()); 475 ASSERT(operand.reg().SizeInBits() == rd.SizeInBits());
463 ASSERT(operand.shift() != ROR); 476 ASSERT(operand.shift() != ROR);
464 ASSERT(is_uintn(operand.shift_amount(), 477 ASSERT(
465 rd.SizeInBits() == kXRegSize ? kXRegSizeLog2 : kWRegSizeLog2)); 478 is_uintn(operand.shift_amount(),
466 Register temp = AppropriateTempFor(rn, operand.reg()); 479 rd.SizeInBits() == kXRegSize ? kXRegSizeLog2 : kWRegSizeLog2));
480 Register temp = temps.AcquireSameSizeAs(rn);
467 EmitShift(temp, operand.reg(), operand.shift(), operand.shift_amount()); 481 EmitShift(temp, operand.reg(), operand.shift(), operand.shift_amount());
468 AddSubWithCarry(rd, rn, temp, S, op); 482 AddSubWithCarry(rd, rn, temp, S, op);
469 483
470 } else if (operand.IsExtendedRegister()) { 484 } else if (operand.IsExtendedRegister()) {
471 // Add/sub with carry (extended register). 485 // Add/sub with carry (extended register).
472 ASSERT(operand.reg().SizeInBits() <= rd.SizeInBits()); 486 ASSERT(operand.reg().SizeInBits() <= rd.SizeInBits());
473 // Add/sub extended supports a shift <= 4. We want to support exactly the 487 // Add/sub extended supports a shift <= 4. We want to support exactly the
474 // same modes. 488 // same modes.
475 ASSERT(operand.shift_amount() <= 4); 489 ASSERT(operand.shift_amount() <= 4);
476 ASSERT(operand.reg().Is64Bits() || 490 ASSERT(operand.reg().Is64Bits() ||
477 ((operand.extend() != UXTX) && (operand.extend() != SXTX))); 491 ((operand.extend() != UXTX) && (operand.extend() != SXTX)));
478 Register temp = AppropriateTempFor(rn, operand.reg()); 492 Register temp = temps.AcquireSameSizeAs(rn);
479 EmitExtendShift(temp, operand.reg(), operand.extend(), 493 EmitExtendShift(temp, operand.reg(), operand.extend(),
480 operand.shift_amount()); 494 operand.shift_amount());
481 AddSubWithCarry(rd, rn, temp, S, op); 495 AddSubWithCarry(rd, rn, temp, S, op);
482 496
483 } else { 497 } else {
484 // The addressing mode is directly supported by the instruction. 498 // The addressing mode is directly supported by the instruction.
485 AddSubWithCarry(rd, rn, operand, S, op); 499 AddSubWithCarry(rd, rn, operand, S, op);
486 } 500 }
487 } 501 }
488 502
489 503
490 void MacroAssembler::LoadStoreMacro(const CPURegister& rt, 504 void MacroAssembler::LoadStoreMacro(const CPURegister& rt,
491 const MemOperand& addr, 505 const MemOperand& addr,
492 LoadStoreOp op) { 506 LoadStoreOp op) {
493 int64_t offset = addr.offset(); 507 int64_t offset = addr.offset();
494 LSDataSize size = CalcLSDataSize(op); 508 LSDataSize size = CalcLSDataSize(op);
495 509
496 // Check if an immediate offset fits in the immediate field of the 510 // Check if an immediate offset fits in the immediate field of the
497 // appropriate instruction. If not, emit two instructions to perform 511 // appropriate instruction. If not, emit two instructions to perform
498 // the operation. 512 // the operation.
499 if (addr.IsImmediateOffset() && !IsImmLSScaled(offset, size) && 513 if (addr.IsImmediateOffset() && !IsImmLSScaled(offset, size) &&
500 !IsImmLSUnscaled(offset)) { 514 !IsImmLSUnscaled(offset)) {
501 // Immediate offset that can't be encoded using unsigned or unscaled 515 // Immediate offset that can't be encoded using unsigned or unscaled
502 // addressing modes. 516 // addressing modes.
503 Register temp = AppropriateTempFor(addr.base()); 517 UseScratchRegisterScope temps(this);
518 Register temp = temps.AcquireSameSizeAs(addr.base());
504 Mov(temp, addr.offset()); 519 Mov(temp, addr.offset());
505 LoadStore(rt, MemOperand(addr.base(), temp), op); 520 LoadStore(rt, MemOperand(addr.base(), temp), op);
506 } else if (addr.IsPostIndex() && !IsImmLSUnscaled(offset)) { 521 } else if (addr.IsPostIndex() && !IsImmLSUnscaled(offset)) {
507 // Post-index beyond unscaled addressing range. 522 // Post-index beyond unscaled addressing range.
508 LoadStore(rt, MemOperand(addr.base()), op); 523 LoadStore(rt, MemOperand(addr.base()), op);
509 add(addr.base(), addr.base(), offset); 524 add(addr.base(), addr.base(), offset);
510 } else if (addr.IsPreIndex() && !IsImmLSUnscaled(offset)) { 525 } else if (addr.IsPreIndex() && !IsImmLSUnscaled(offset)) {
511 // Pre-index beyond unscaled addressing range. 526 // Pre-index beyond unscaled addressing range.
512 add(addr.base(), addr.base(), offset); 527 add(addr.base(), addr.base(), offset);
513 LoadStore(rt, MemOperand(addr.base()), op); 528 LoadStore(rt, MemOperand(addr.base()), op);
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 } 951 }
937 } 952 }
938 953
939 954
940 void MacroAssembler::PushMultipleTimes(CPURegister src, int count) { 955 void MacroAssembler::PushMultipleTimes(CPURegister src, int count) {
941 int size = src.SizeInBytes(); 956 int size = src.SizeInBytes();
942 957
943 PrepareForPush(count, size); 958 PrepareForPush(count, size);
944 959
945 if (FLAG_optimize_for_size && count > 8) { 960 if (FLAG_optimize_for_size && count > 8) {
961 UseScratchRegisterScope temps(this);
962 Register temp = temps.AcquireX();
963
946 Label loop; 964 Label loop;
947 __ Mov(Tmp0(), count / 2); 965 __ Mov(temp, count / 2);
948 __ Bind(&loop); 966 __ Bind(&loop);
949 PushHelper(2, size, src, src, NoReg, NoReg); 967 PushHelper(2, size, src, src, NoReg, NoReg);
950 __ Subs(Tmp0(), Tmp0(), 1); 968 __ Subs(temp, temp, 1);
951 __ B(ne, &loop); 969 __ B(ne, &loop);
952 970
953 count %= 2; 971 count %= 2;
954 } 972 }
955 973
956 // Push up to four registers at a time if possible because if the current 974 // Push up to four registers at a time if possible because if the current
957 // stack pointer is csp and the register size is 32, registers must be pushed 975 // stack pointer is csp and the register size is 32, registers must be pushed
958 // in blocks of four in order to maintain the 16-byte alignment for csp. 976 // in blocks of four in order to maintain the 16-byte alignment for csp.
959 while (count >= 4) { 977 while (count >= 4) {
960 PushHelper(4, size, src, src, src, src); 978 PushHelper(4, size, src, src, src, src);
961 count -= 4; 979 count -= 4;
962 } 980 }
963 if (count >= 2) { 981 if (count >= 2) {
964 PushHelper(2, size, src, src, NoReg, NoReg); 982 PushHelper(2, size, src, src, NoReg, NoReg);
965 count -= 2; 983 count -= 2;
966 } 984 }
967 if (count == 1) { 985 if (count == 1) {
968 PushHelper(1, size, src, NoReg, NoReg, NoReg); 986 PushHelper(1, size, src, NoReg, NoReg, NoReg);
969 count -= 1; 987 count -= 1;
970 } 988 }
971 ASSERT(count == 0); 989 ASSERT(count == 0);
972 } 990 }
973 991
974 992
975 void MacroAssembler::PushMultipleTimes(CPURegister src, Register count) { 993 void MacroAssembler::PushMultipleTimes(CPURegister src, Register count) {
976 PrepareForPush(Operand(count, UXTW, WhichPowerOf2(src.SizeInBytes()))); 994 PrepareForPush(Operand(count, UXTW, WhichPowerOf2(src.SizeInBytes())));
977 995
978 Register temp = AppropriateTempFor(count); 996 UseScratchRegisterScope temps(this);
997 Register temp = temps.AcquireSameSizeAs(count);
979 998
980 if (FLAG_optimize_for_size) { 999 if (FLAG_optimize_for_size) {
981 Label loop, done; 1000 Label loop, done;
982 1001
983 Subs(temp, count, 1); 1002 Subs(temp, count, 1);
984 B(mi, &done); 1003 B(mi, &done);
985 1004
986 // Push all registers individually, to save code size. 1005 // Push all registers individually, to save code size.
987 Bind(&loop); 1006 Bind(&loop);
988 Subs(temp, temp, 1); 1007 Subs(temp, temp, 1);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 Add(scratch1, object, Code::kHeaderSize - kHeapObjectTag); 1431 Add(scratch1, object, Code::kHeaderSize - kHeapObjectTag);
1413 Add(scratch1, scratch1, Operand::UntagSmi(scratch2)); 1432 Add(scratch1, scratch1, Operand::UntagSmi(scratch2));
1414 Br(scratch1); 1433 Br(scratch1);
1415 } 1434 }
1416 1435
1417 1436
1418 void MacroAssembler::InNewSpace(Register object, 1437 void MacroAssembler::InNewSpace(Register object,
1419 Condition cond, 1438 Condition cond,
1420 Label* branch) { 1439 Label* branch) {
1421 ASSERT(cond == eq || cond == ne); 1440 ASSERT(cond == eq || cond == ne);
1422 // Use Tmp1() to have a different destination register, as Tmp0() will be used 1441 UseScratchRegisterScope temps(this);
1423 // for relocation. 1442 Register temp = temps.AcquireX();
1424 And(Tmp1(), object, Operand(ExternalReference::new_space_mask(isolate()))); 1443 And(temp, object, Operand(ExternalReference::new_space_mask(isolate())));
1425 Cmp(Tmp1(), Operand(ExternalReference::new_space_start(isolate()))); 1444 Cmp(temp, Operand(ExternalReference::new_space_start(isolate())));
1426 B(cond, branch); 1445 B(cond, branch);
1427 } 1446 }
1428 1447
1429 1448
1430 void MacroAssembler::Throw(Register value, 1449 void MacroAssembler::Throw(Register value,
1431 Register scratch1, 1450 Register scratch1,
1432 Register scratch2, 1451 Register scratch2,
1433 Register scratch3, 1452 Register scratch3,
1434 Register scratch4) { 1453 Register scratch4) {
1435 // Adjust this code if not the case. 1454 // Adjust this code if not the case.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 1603
1585 void MacroAssembler::AssertName(Register object) { 1604 void MacroAssembler::AssertName(Register object) {
1586 if (emit_debug_code()) { 1605 if (emit_debug_code()) {
1587 STATIC_ASSERT(kSmiTag == 0); 1606 STATIC_ASSERT(kSmiTag == 0);
1588 // TODO(jbramley): Add AbortIfSmi and related functions. 1607 // TODO(jbramley): Add AbortIfSmi and related functions.
1589 Label not_smi; 1608 Label not_smi;
1590 JumpIfNotSmi(object, &not_smi); 1609 JumpIfNotSmi(object, &not_smi);
1591 Abort(kOperandIsASmiAndNotAName); 1610 Abort(kOperandIsASmiAndNotAName);
1592 Bind(&not_smi); 1611 Bind(&not_smi);
1593 1612
1594 Ldr(Tmp1(), FieldMemOperand(object, HeapObject::kMapOffset)); 1613 UseScratchRegisterScope temps(this);
1595 CompareInstanceType(Tmp1(), Tmp1(), LAST_NAME_TYPE); 1614 Register temp = temps.AcquireX();
1615
1616 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
1617 CompareInstanceType(temp, temp, LAST_NAME_TYPE);
1596 Check(ls, kOperandIsNotAName); 1618 Check(ls, kOperandIsNotAName);
1597 } 1619 }
1598 } 1620 }
1599 1621
1600 1622
1601 void MacroAssembler::AssertString(Register object) { 1623 void MacroAssembler::AssertString(Register object) {
1602 if (emit_debug_code()) { 1624 if (emit_debug_code()) {
1603 Register temp = Tmp1(); 1625 UseScratchRegisterScope temps(this);
1626 Register temp = temps.AcquireX();
1604 STATIC_ASSERT(kSmiTag == 0); 1627 STATIC_ASSERT(kSmiTag == 0);
1605 Tst(object, kSmiTagMask); 1628 Tst(object, kSmiTagMask);
1606 Check(ne, kOperandIsASmiAndNotAString); 1629 Check(ne, kOperandIsASmiAndNotAString);
1607 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); 1630 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
1608 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE); 1631 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE);
1609 Check(lo, kOperandIsNotAString); 1632 Check(lo, kOperandIsNotAString);
1610 } 1633 }
1611 } 1634 }
1612 1635
1613 1636
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1910 1933
1911 void MacroAssembler::CallCFunction(ExternalReference function, 1934 void MacroAssembler::CallCFunction(ExternalReference function,
1912 int num_of_reg_args) { 1935 int num_of_reg_args) {
1913 CallCFunction(function, num_of_reg_args, 0); 1936 CallCFunction(function, num_of_reg_args, 0);
1914 } 1937 }
1915 1938
1916 1939
1917 void MacroAssembler::CallCFunction(ExternalReference function, 1940 void MacroAssembler::CallCFunction(ExternalReference function,
1918 int num_of_reg_args, 1941 int num_of_reg_args,
1919 int num_of_double_args) { 1942 int num_of_double_args) {
1920 Mov(Tmp0(), Operand(function)); 1943 UseScratchRegisterScope temps(this);
1921 CallCFunction(Tmp0(), num_of_reg_args, num_of_double_args); 1944 Register temp = temps.AcquireX();
1945 Mov(temp, Operand(function));
1946 CallCFunction(temp, num_of_reg_args, num_of_double_args);
1922 } 1947 }
1923 1948
1924 1949
1925 void MacroAssembler::CallCFunction(Register function, 1950 void MacroAssembler::CallCFunction(Register function,
1926 int num_of_reg_args, 1951 int num_of_reg_args,
1927 int num_of_double_args) { 1952 int num_of_double_args) {
1928 ASSERT(has_frame()); 1953 ASSERT(has_frame());
1929 // We can pass 8 integer arguments in registers. If we need to pass more than 1954 // We can pass 8 integer arguments in registers. If we need to pass more than
1930 // that, we'll need to implement support for passing them on the stack. 1955 // that, we'll need to implement support for passing them on the stack.
1931 ASSERT(num_of_reg_args <= 8); 1956 ASSERT(num_of_reg_args <= 8);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 1989
1965 // Call directly. The function called cannot cause a GC, or allow preemption, 1990 // Call directly. The function called cannot cause a GC, or allow preemption,
1966 // so the return address in the link register stays correct. 1991 // so the return address in the link register stays correct.
1967 Call(function); 1992 Call(function);
1968 1993
1969 if (!csp.Is(old_stack_pointer)) { 1994 if (!csp.Is(old_stack_pointer)) {
1970 if (emit_debug_code()) { 1995 if (emit_debug_code()) {
1971 // Because the stack pointer must be aligned on a 16-byte boundary, the 1996 // Because the stack pointer must be aligned on a 16-byte boundary, the
1972 // aligned csp can be up to 12 bytes below the jssp. This is the case 1997 // aligned csp can be up to 12 bytes below the jssp. This is the case
1973 // where we only pushed one W register on top of an aligned jssp. 1998 // where we only pushed one W register on top of an aligned jssp.
1974 Register temp = Tmp1(); 1999 UseScratchRegisterScope temps(this);
2000 Register temp = temps.AcquireX();
1975 ASSERT(ActivationFrameAlignment() == 16); 2001 ASSERT(ActivationFrameAlignment() == 16);
1976 Sub(temp, csp, old_stack_pointer); 2002 Sub(temp, csp, old_stack_pointer);
1977 // We want temp <= 0 && temp >= -12. 2003 // We want temp <= 0 && temp >= -12.
1978 Cmp(temp, 0); 2004 Cmp(temp, 0);
1979 Ccmp(temp, -12, NFlag, le); 2005 Ccmp(temp, -12, NFlag, le);
1980 Check(ge, kTheStackWasCorruptedByMacroAssemblerCall); 2006 Check(ge, kTheStackWasCorruptedByMacroAssemblerCall);
1981 } 2007 }
1982 SetStackPointer(old_stack_pointer); 2008 SetStackPointer(old_stack_pointer);
1983 } 2009 }
1984 } 2010 }
1985 2011
1986 2012
1987 void MacroAssembler::Jump(Register target) { 2013 void MacroAssembler::Jump(Register target) {
1988 Br(target); 2014 Br(target);
1989 } 2015 }
1990 2016
1991 2017
1992 void MacroAssembler::Jump(intptr_t target, RelocInfo::Mode rmode) { 2018 void MacroAssembler::Jump(intptr_t target, RelocInfo::Mode rmode) {
1993 Mov(Tmp0(), Operand(target, rmode)); 2019 UseScratchRegisterScope temps(this);
1994 Br(Tmp0()); 2020 Register temp = temps.AcquireX();
2021 Mov(temp, Operand(target, rmode));
2022 Br(temp);
1995 } 2023 }
1996 2024
1997 2025
1998 void MacroAssembler::Jump(Address target, RelocInfo::Mode rmode) { 2026 void MacroAssembler::Jump(Address target, RelocInfo::Mode rmode) {
1999 ASSERT(!RelocInfo::IsCodeTarget(rmode)); 2027 ASSERT(!RelocInfo::IsCodeTarget(rmode));
2000 Jump(reinterpret_cast<intptr_t>(target), rmode); 2028 Jump(reinterpret_cast<intptr_t>(target), rmode);
2001 } 2029 }
2002 2030
2003 2031
2004 void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode) { 2032 void MacroAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 Label start_call; 2074 Label start_call;
2047 Bind(&start_call); 2075 Bind(&start_call);
2048 #endif 2076 #endif
2049 // Statement positions are expected to be recorded when the target 2077 // Statement positions are expected to be recorded when the target
2050 // address is loaded. 2078 // address is loaded.
2051 positions_recorder()->WriteRecordedPositions(); 2079 positions_recorder()->WriteRecordedPositions();
2052 2080
2053 // Addresses always have 64 bits, so we shouldn't encounter NONE32. 2081 // Addresses always have 64 bits, so we shouldn't encounter NONE32.
2054 ASSERT(rmode != RelocInfo::NONE32); 2082 ASSERT(rmode != RelocInfo::NONE32);
2055 2083
2084 UseScratchRegisterScope temps(this);
2085 Register temp = temps.AcquireX();
2086
2056 if (rmode == RelocInfo::NONE64) { 2087 if (rmode == RelocInfo::NONE64) {
2057 uint64_t imm = reinterpret_cast<uint64_t>(target); 2088 uint64_t imm = reinterpret_cast<uint64_t>(target);
2058 movz(Tmp0(), (imm >> 0) & 0xffff, 0); 2089 movz(temp, (imm >> 0) & 0xffff, 0);
2059 movk(Tmp0(), (imm >> 16) & 0xffff, 16); 2090 movk(temp, (imm >> 16) & 0xffff, 16);
2060 movk(Tmp0(), (imm >> 32) & 0xffff, 32); 2091 movk(temp, (imm >> 32) & 0xffff, 32);
2061 movk(Tmp0(), (imm >> 48) & 0xffff, 48); 2092 movk(temp, (imm >> 48) & 0xffff, 48);
2062 } else { 2093 } else {
2063 LoadRelocated(Tmp0(), Operand(reinterpret_cast<intptr_t>(target), rmode)); 2094 LoadRelocated(temp, Operand(reinterpret_cast<intptr_t>(target), rmode));
2064 } 2095 }
2065 Blr(Tmp0()); 2096 Blr(temp);
2066 #ifdef DEBUG 2097 #ifdef DEBUG
2067 AssertSizeOfCodeGeneratedSince(&start_call, CallSize(target, rmode)); 2098 AssertSizeOfCodeGeneratedSince(&start_call, CallSize(target, rmode));
2068 #endif 2099 #endif
2069 } 2100 }
2070 2101
2071 2102
2072 void MacroAssembler::Call(Handle<Code> code, 2103 void MacroAssembler::Call(Handle<Code> code,
2073 RelocInfo::Mode rmode, 2104 RelocInfo::Mode rmode,
2074 TypeFeedbackId ast_id) { 2105 TypeFeedbackId ast_id) {
2075 #ifdef DEBUG 2106 #ifdef DEBUG
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 2167
2137 2168
2138 2169
2139 2170
2140 2171
2141 void MacroAssembler::JumpForHeapNumber(Register object, 2172 void MacroAssembler::JumpForHeapNumber(Register object,
2142 Register heap_number_map, 2173 Register heap_number_map,
2143 Label* on_heap_number, 2174 Label* on_heap_number,
2144 Label* on_not_heap_number) { 2175 Label* on_not_heap_number) {
2145 ASSERT(on_heap_number || on_not_heap_number); 2176 ASSERT(on_heap_number || on_not_heap_number);
2146 // Tmp0() is used as a scratch register.
2147 ASSERT(!AreAliased(Tmp0(), heap_number_map));
2148 AssertNotSmi(object); 2177 AssertNotSmi(object);
2149 2178
2179 UseScratchRegisterScope temps(this);
2180 Register temp = temps.AcquireX();
2181
2150 // Load the HeapNumber map if it is not passed. 2182 // Load the HeapNumber map if it is not passed.
2151 if (heap_number_map.Is(NoReg)) { 2183 if (heap_number_map.Is(NoReg)) {
2152 heap_number_map = Tmp1(); 2184 heap_number_map = temps.AcquireX();
2153 LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 2185 LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
2154 } else { 2186 } else {
2155 // This assert clobbers Tmp0(), so do it before loading Tmp0() with the map.
2156 AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex); 2187 AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
2157 } 2188 }
2158 2189
2159 Ldr(Tmp0(), FieldMemOperand(object, HeapObject::kMapOffset)); 2190 ASSERT(!AreAliased(temp, heap_number_map));
2160 Cmp(Tmp0(), heap_number_map); 2191
2192 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
2193 Cmp(temp, heap_number_map);
2161 2194
2162 if (on_heap_number) { 2195 if (on_heap_number) {
2163 B(eq, on_heap_number); 2196 B(eq, on_heap_number);
2164 } 2197 }
2165 if (on_not_heap_number) { 2198 if (on_not_heap_number) {
2166 B(ne, on_not_heap_number); 2199 B(ne, on_not_heap_number);
2167 } 2200 }
2168 } 2201 }
2169 2202
2170 2203
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 B(on_successful_conversion, eq); 2309 B(on_successful_conversion, eq);
2277 } 2310 }
2278 if (on_failed_conversion) { 2311 if (on_failed_conversion) {
2279 B(on_failed_conversion, ne); 2312 B(on_failed_conversion, ne);
2280 } 2313 }
2281 } 2314 }
2282 2315
2283 2316
2284 void MacroAssembler::JumpIfMinusZero(DoubleRegister input, 2317 void MacroAssembler::JumpIfMinusZero(DoubleRegister input,
2285 Label* on_negative_zero) { 2318 Label* on_negative_zero) {
2319 UseScratchRegisterScope temps(this);
2320 Register temp = temps.AcquireX();
2286 // Floating point -0.0 is kMinInt as an integer, so subtracting 1 (cmp) will 2321 // Floating point -0.0 is kMinInt as an integer, so subtracting 1 (cmp) will
2287 // cause overflow. 2322 // cause overflow.
2288 Fmov(Tmp0(), input); 2323 Fmov(temp, input);
2289 Cmp(Tmp0(), 1); 2324 Cmp(temp, 1);
2290 B(vs, on_negative_zero); 2325 B(vs, on_negative_zero);
2291 } 2326 }
2292 2327
2293 2328
2294 void MacroAssembler::ClampInt32ToUint8(Register output, Register input) { 2329 void MacroAssembler::ClampInt32ToUint8(Register output, Register input) {
2295 // Clamp the value to [0..255]. 2330 // Clamp the value to [0..255].
2296 Cmp(input.W(), Operand(input.W(), UXTB)); 2331 Cmp(input.W(), Operand(input.W(), UXTB));
2297 // If input < input & 0xff, it must be < 0, so saturate to 0. 2332 // If input < input & 0xff, it must be < 0, so saturate to 0.
2298 Csel(output.W(), wzr, input.W(), lt); 2333 Csel(output.W(), wzr, input.W(), lt);
2299 // Create a constant 0xff. 2334 // If input <= input & 0xff, it must be <= 255. Otherwise, saturate to 255.
2300 Mov(WTmp0(), 255); 2335 Csel(output.W(), output.W(), 255, le);
2301 // If input > input & 0xff, it must be > 255, so saturate to 255.
2302 Csel(output.W(), WTmp0(), output.W(), gt);
2303 } 2336 }
2304 2337
2305 2338
2306 void MacroAssembler::ClampInt32ToUint8(Register in_out) { 2339 void MacroAssembler::ClampInt32ToUint8(Register in_out) {
2307 ClampInt32ToUint8(in_out, in_out); 2340 ClampInt32ToUint8(in_out, in_out);
2308 } 2341 }
2309 2342
2310 2343
2311 void MacroAssembler::ClampDoubleToUint8(Register output, 2344 void MacroAssembler::ClampDoubleToUint8(Register output,
2312 DoubleRegister input, 2345 DoubleRegister input,
(...skipping 13 matching lines...) Expand all
2326 // Values greater than 255 have already been clamped to 255. 2359 // Values greater than 255 have already been clamped to 255.
2327 Fcvtnu(output, dbl_scratch); 2360 Fcvtnu(output, dbl_scratch);
2328 } 2361 }
2329 2362
2330 2363
2331 void MacroAssembler::CopyFieldsLoopPairsHelper(Register dst, 2364 void MacroAssembler::CopyFieldsLoopPairsHelper(Register dst,
2332 Register src, 2365 Register src,
2333 unsigned count, 2366 unsigned count,
2334 Register scratch1, 2367 Register scratch1,
2335 Register scratch2, 2368 Register scratch2,
2336 Register scratch3) { 2369 Register scratch3,
2370 Register scratch4,
2371 Register scratch5) {
2337 // Untag src and dst into scratch registers. 2372 // Untag src and dst into scratch registers.
2338 // Copy src->dst in a tight loop. 2373 // Copy src->dst in a tight loop.
2339 ASSERT(!AreAliased(dst, src, scratch1, scratch2, scratch3, Tmp0(), Tmp1())); 2374 ASSERT(!AreAliased(dst, src,
2375 scratch1, scratch2, scratch3, scratch4, scratch5));
2340 ASSERT(count >= 2); 2376 ASSERT(count >= 2);
2341 2377
2342 const Register& remaining = scratch3; 2378 const Register& remaining = scratch3;
2343 Mov(remaining, count / 2); 2379 Mov(remaining, count / 2);
2344 2380
2345 // Only use the Assembler, so we can use Tmp0() and Tmp1().
2346 InstructionAccurateScope scope(this);
2347
2348 const Register& dst_untagged = scratch1; 2381 const Register& dst_untagged = scratch1;
2349 const Register& src_untagged = scratch2; 2382 const Register& src_untagged = scratch2;
2350 sub(dst_untagged, dst, kHeapObjectTag); 2383 Sub(dst_untagged, dst, kHeapObjectTag);
2351 sub(src_untagged, src, kHeapObjectTag); 2384 Sub(src_untagged, src, kHeapObjectTag);
2352 2385
2353 // Copy fields in pairs. 2386 // Copy fields in pairs.
2354 Label loop; 2387 Label loop;
2355 bind(&loop); 2388 Bind(&loop);
2356 ldp(Tmp0(), Tmp1(), MemOperand(src_untagged, kXRegSizeInBytes * 2, 2389 Ldp(scratch4, scratch5,
2357 PostIndex)); 2390 MemOperand(src_untagged, kXRegSizeInBytes * 2, PostIndex));
2358 stp(Tmp0(), Tmp1(), MemOperand(dst_untagged, kXRegSizeInBytes * 2, 2391 Stp(scratch4, scratch5,
2359 PostIndex)); 2392 MemOperand(dst_untagged, kXRegSizeInBytes * 2, PostIndex));
2360 sub(remaining, remaining, 1); 2393 Sub(remaining, remaining, 1);
2361 cbnz(remaining, &loop); 2394 Cbnz(remaining, &loop);
2362 2395
2363 // Handle the leftovers. 2396 // Handle the leftovers.
2364 if (count & 1) { 2397 if (count & 1) {
2365 ldr(Tmp0(), MemOperand(src_untagged)); 2398 Ldr(scratch4, MemOperand(src_untagged));
2366 str(Tmp0(), MemOperand(dst_untagged)); 2399 Str(scratch4, MemOperand(dst_untagged));
2367 } 2400 }
2368 } 2401 }
2369 2402
2370 2403
2371 void MacroAssembler::CopyFieldsUnrolledPairsHelper(Register dst, 2404 void MacroAssembler::CopyFieldsUnrolledPairsHelper(Register dst,
2372 Register src, 2405 Register src,
2373 unsigned count, 2406 unsigned count,
2374 Register scratch1, 2407 Register scratch1,
2375 Register scratch2) { 2408 Register scratch2,
2409 Register scratch3,
2410 Register scratch4) {
2376 // Untag src and dst into scratch registers. 2411 // Untag src and dst into scratch registers.
2377 // Copy src->dst in an unrolled loop. 2412 // Copy src->dst in an unrolled loop.
2378 ASSERT(!AreAliased(dst, src, scratch1, scratch2, Tmp0(), Tmp1())); 2413 ASSERT(!AreAliased(dst, src, scratch1, scratch2, scratch3, scratch4));
2379
2380 // Only use the Assembler, so we can use Tmp0() and Tmp1().
2381 InstructionAccurateScope scope(this);
2382 2414
2383 const Register& dst_untagged = scratch1; 2415 const Register& dst_untagged = scratch1;
2384 const Register& src_untagged = scratch2; 2416 const Register& src_untagged = scratch2;
2385 sub(dst_untagged, dst, kHeapObjectTag); 2417 sub(dst_untagged, dst, kHeapObjectTag);
2386 sub(src_untagged, src, kHeapObjectTag); 2418 sub(src_untagged, src, kHeapObjectTag);
2387 2419
2388 // Copy fields in pairs. 2420 // Copy fields in pairs.
2389 for (unsigned i = 0; i < count / 2; i++) { 2421 for (unsigned i = 0; i < count / 2; i++) {
2390 ldp(Tmp0(), Tmp1(), MemOperand(src_untagged, kXRegSizeInBytes * 2, 2422 Ldp(scratch3, scratch4,
2391 PostIndex)); 2423 MemOperand(src_untagged, kXRegSizeInBytes * 2, PostIndex));
2392 stp(Tmp0(), Tmp1(), MemOperand(dst_untagged, kXRegSizeInBytes * 2, 2424 Stp(scratch3, scratch4,
2393 PostIndex)); 2425 MemOperand(dst_untagged, kXRegSizeInBytes * 2, PostIndex));
2394 } 2426 }
2395 2427
2396 // Handle the leftovers. 2428 // Handle the leftovers.
2397 if (count & 1) { 2429 if (count & 1) {
2398 ldr(Tmp0(), MemOperand(src_untagged)); 2430 Ldr(scratch3, MemOperand(src_untagged));
2399 str(Tmp0(), MemOperand(dst_untagged)); 2431 Str(scratch3, MemOperand(dst_untagged));
2400 } 2432 }
2401 } 2433 }
2402 2434
2403 2435
2404 void MacroAssembler::CopyFieldsUnrolledHelper(Register dst, 2436 void MacroAssembler::CopyFieldsUnrolledHelper(Register dst,
2405 Register src, 2437 Register src,
2406 unsigned count, 2438 unsigned count,
2407 Register scratch1) { 2439 Register scratch1,
2440 Register scratch2,
2441 Register scratch3) {
2408 // Untag src and dst into scratch registers. 2442 // Untag src and dst into scratch registers.
2409 // Copy src->dst in an unrolled loop. 2443 // Copy src->dst in an unrolled loop.
2410 ASSERT(!AreAliased(dst, src, scratch1, Tmp0(), Tmp1())); 2444 ASSERT(!AreAliased(dst, src, scratch1, scratch2, scratch3));
2411
2412 // Only use the Assembler, so we can use Tmp0() and Tmp1().
2413 InstructionAccurateScope scope(this);
2414 2445
2415 const Register& dst_untagged = scratch1; 2446 const Register& dst_untagged = scratch1;
2416 const Register& src_untagged = Tmp1(); 2447 const Register& src_untagged = scratch2;
2417 sub(dst_untagged, dst, kHeapObjectTag); 2448 Sub(dst_untagged, dst, kHeapObjectTag);
2418 sub(src_untagged, src, kHeapObjectTag); 2449 Sub(src_untagged, src, kHeapObjectTag);
2419 2450
2420 // Copy fields one by one. 2451 // Copy fields one by one.
2421 for (unsigned i = 0; i < count; i++) { 2452 for (unsigned i = 0; i < count; i++) {
2422 ldr(Tmp0(), MemOperand(src_untagged, kXRegSizeInBytes, PostIndex)); 2453 Ldr(scratch3, MemOperand(src_untagged, kXRegSizeInBytes, PostIndex));
2423 str(Tmp0(), MemOperand(dst_untagged, kXRegSizeInBytes, PostIndex)); 2454 Str(scratch3, MemOperand(dst_untagged, kXRegSizeInBytes, PostIndex));
2424 } 2455 }
2425 } 2456 }
2426 2457
2427 2458
2428 void MacroAssembler::CopyFields(Register dst, Register src, CPURegList temps, 2459 void MacroAssembler::CopyFields(Register dst, Register src, CPURegList temps,
2429 unsigned count) { 2460 unsigned count) {
2430 // One of two methods is used: 2461 // One of two methods is used:
2431 // 2462 //
2432 // For high 'count' values where many scratch registers are available: 2463 // For high 'count' values where many scratch registers are available:
2433 // Untag src and dst into scratch registers. 2464 // Untag src and dst into scratch registers.
2434 // Copy src->dst in a tight loop. 2465 // Copy src->dst in a tight loop.
2435 // 2466 //
2436 // For low 'count' values or where few scratch registers are available: 2467 // For low 'count' values or where few scratch registers are available:
2437 // Untag src and dst into scratch registers. 2468 // Untag src and dst into scratch registers.
2438 // Copy src->dst in an unrolled loop. 2469 // Copy src->dst in an unrolled loop.
2439 // 2470 //
2440 // In both cases, fields are copied in pairs if possible, and left-overs are 2471 // In both cases, fields are copied in pairs if possible, and left-overs are
2441 // handled separately. 2472 // handled separately.
2473 ASSERT(!AreAliased(dst, src));
2442 ASSERT(!temps.IncludesAliasOf(dst)); 2474 ASSERT(!temps.IncludesAliasOf(dst));
2443 ASSERT(!temps.IncludesAliasOf(src)); 2475 ASSERT(!temps.IncludesAliasOf(src));
2444 ASSERT(!temps.IncludesAliasOf(Tmp0()));
2445 ASSERT(!temps.IncludesAliasOf(Tmp1()));
2446 ASSERT(!temps.IncludesAliasOf(xzr)); 2476 ASSERT(!temps.IncludesAliasOf(xzr));
2447 ASSERT(!AreAliased(dst, src, Tmp0(), Tmp1()));
2448 2477
2449 if (emit_debug_code()) { 2478 if (emit_debug_code()) {
2450 Cmp(dst, src); 2479 Cmp(dst, src);
2451 Check(ne, kTheSourceAndDestinationAreTheSame); 2480 Check(ne, kTheSourceAndDestinationAreTheSame);
2452 } 2481 }
2453 2482
2454 // The value of 'count' at which a loop will be generated (if there are 2483 // The value of 'count' at which a loop will be generated (if there are
2455 // enough scratch registers). 2484 // enough scratch registers).
2456 static const unsigned kLoopThreshold = 8; 2485 static const unsigned kLoopThreshold = 8;
2457 2486
2458 ASSERT(!temps.IsEmpty()); 2487 UseScratchRegisterScope masm_temps(this);
2459 Register scratch1 = Register(temps.PopLowestIndex()); 2488 if ((temps.Count() >= 3) && (count >= kLoopThreshold)) {
2460 Register scratch2 = Register(temps.PopLowestIndex()); 2489 CopyFieldsLoopPairsHelper(dst, src, count,
2461 Register scratch3 = Register(temps.PopLowestIndex()); 2490 Register(temps.PopLowestIndex()),
2462 2491 Register(temps.PopLowestIndex()),
2463 if (scratch3.IsValid() && (count >= kLoopThreshold)) { 2492 Register(temps.PopLowestIndex()),
2464 CopyFieldsLoopPairsHelper(dst, src, count, scratch1, scratch2, scratch3); 2493 masm_temps.AcquireX(),
2465 } else if (scratch2.IsValid()) { 2494 masm_temps.AcquireX());
2466 CopyFieldsUnrolledPairsHelper(dst, src, count, scratch1, scratch2); 2495 } else if (temps.Count() >= 2) {
2467 } else if (scratch1.IsValid()) { 2496 CopyFieldsUnrolledPairsHelper(dst, src, count,
2468 CopyFieldsUnrolledHelper(dst, src, count, scratch1); 2497 Register(temps.PopLowestIndex()),
2498 Register(temps.PopLowestIndex()),
2499 masm_temps.AcquireX(),
2500 masm_temps.AcquireX());
2501 } else if (temps.Count() == 1) {
2502 CopyFieldsUnrolledHelper(dst, src, count,
2503 Register(temps.PopLowestIndex()),
2504 masm_temps.AcquireX(),
2505 masm_temps.AcquireX());
2469 } else { 2506 } else {
2470 UNREACHABLE(); 2507 UNREACHABLE();
2471 } 2508 }
2472 } 2509 }
2473 2510
2474 2511
2475 void MacroAssembler::CopyBytes(Register dst, 2512 void MacroAssembler::CopyBytes(Register dst,
2476 Register src, 2513 Register src,
2477 Register length, 2514 Register length,
2478 Register scratch, 2515 Register scratch,
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 2925
2889 // TODO(rmcilroy): Remove this Sxtw once the following bug is fixed: 2926 // TODO(rmcilroy): Remove this Sxtw once the following bug is fixed:
2890 // https://code.google.com/p/v8/issues/detail?id=3149 2927 // https://code.google.com/p/v8/issues/detail?id=3149
2891 Sxtw(result, result.W()); 2928 Sxtw(result, result.W());
2892 } 2929 }
2893 2930
2894 2931
2895 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { 2932 void MacroAssembler::Prologue(PrologueFrameMode frame_mode) {
2896 if (frame_mode == BUILD_STUB_FRAME) { 2933 if (frame_mode == BUILD_STUB_FRAME) {
2897 ASSERT(StackPointer().Is(jssp)); 2934 ASSERT(StackPointer().Is(jssp));
2935 UseScratchRegisterScope temps(this);
2936 Register temp = temps.AcquireX();
2898 // TODO(jbramley): Does x1 contain a JSFunction here, or does it already 2937 // TODO(jbramley): Does x1 contain a JSFunction here, or does it already
2899 // have the special STUB smi? 2938 // have the special STUB smi?
2900 __ Mov(Tmp0(), Operand(Smi::FromInt(StackFrame::STUB))); 2939 __ Mov(temp, Operand(Smi::FromInt(StackFrame::STUB)));
2901 // Compiled stubs don't age, and so they don't need the predictable code 2940 // Compiled stubs don't age, and so they don't need the predictable code
2902 // ageing sequence. 2941 // ageing sequence.
2903 __ Push(lr, fp, cp, Tmp0()); 2942 __ Push(lr, fp, cp, temp);
2904 __ Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp); 2943 __ Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp);
2905 } else { 2944 } else {
2906 if (isolate()->IsCodePreAgingActive()) { 2945 if (isolate()->IsCodePreAgingActive()) {
2907 Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); 2946 Code* stub = Code::GetPreAgedCodeAgeStub(isolate());
2908 __ EmitCodeAgeSequence(stub); 2947 __ EmitCodeAgeSequence(stub);
2909 } else { 2948 } else {
2910 __ EmitFrameSetupForCodeAgePatching(); 2949 __ EmitFrameSetupForCodeAgePatching();
2911 } 2950 }
2912 } 2951 }
2913 } 2952 }
2914 2953
2915 2954
2916 void MacroAssembler::EnterFrame(StackFrame::Type type) { 2955 void MacroAssembler::EnterFrame(StackFrame::Type type) {
2917 ASSERT(jssp.Is(StackPointer())); 2956 ASSERT(jssp.Is(StackPointer()));
2957 UseScratchRegisterScope temps(this);
2958 Register type_reg = temps.AcquireX();
2959 Register code_reg = temps.AcquireX();
2960
2918 Push(lr, fp, cp); 2961 Push(lr, fp, cp);
2919 Mov(Tmp1(), Operand(Smi::FromInt(type))); 2962 Mov(type_reg, Operand(Smi::FromInt(type)));
2920 Mov(Tmp0(), Operand(CodeObject())); 2963 Mov(code_reg, Operand(CodeObject()));
2921 Push(Tmp1(), Tmp0()); 2964 Push(type_reg, code_reg);
2922 // jssp[4] : lr 2965 // jssp[4] : lr
2923 // jssp[3] : fp 2966 // jssp[3] : fp
2924 // jssp[2] : cp 2967 // jssp[2] : cp
2925 // jssp[1] : type 2968 // jssp[1] : type
2926 // jssp[0] : code object 2969 // jssp[0] : code object
2927 2970
2928 // Adjust FP to point to saved FP. 2971 // Adjust FP to point to saved FP.
2929 add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); 2972 Add(fp, jssp, StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize);
2930 } 2973 }
2931 2974
2932 2975
2933 void MacroAssembler::LeaveFrame(StackFrame::Type type) { 2976 void MacroAssembler::LeaveFrame(StackFrame::Type type) {
2934 ASSERT(jssp.Is(StackPointer())); 2977 ASSERT(jssp.Is(StackPointer()));
2935 // Drop the execution stack down to the frame pointer and restore 2978 // Drop the execution stack down to the frame pointer and restore
2936 // the caller frame pointer and return address. 2979 // the caller frame pointer and return address.
2937 Mov(jssp, fp); 2980 Mov(jssp, fp);
2938 AssertStackConsistency(); 2981 AssertStackConsistency();
2939 Pop(fp, lr); 2982 Pop(fp, lr);
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 // Trash the registers to simulate an allocation failure. 3228 // Trash the registers to simulate an allocation failure.
3186 // We apply salt to the original zap value to easily spot the values. 3229 // We apply salt to the original zap value to easily spot the values.
3187 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L); 3230 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L);
3188 Mov(scratch1, (kDebugZapValue & ~0xffL) | 0x21L); 3231 Mov(scratch1, (kDebugZapValue & ~0xffL) | 0x21L);
3189 Mov(scratch2, (kDebugZapValue & ~0xffL) | 0x21L); 3232 Mov(scratch2, (kDebugZapValue & ~0xffL) | 0x21L);
3190 } 3233 }
3191 B(gc_required); 3234 B(gc_required);
3192 return; 3235 return;
3193 } 3236 }
3194 3237
3195 ASSERT(!AreAliased(result, scratch1, scratch2, Tmp0(), Tmp1())); 3238 UseScratchRegisterScope temps(this);
3196 ASSERT(result.Is64Bits() && scratch1.Is64Bits() && scratch2.Is64Bits() && 3239 Register scratch3 = temps.AcquireX();
3197 Tmp0().Is64Bits() && Tmp1().Is64Bits()); 3240
3241 ASSERT(!AreAliased(result, scratch1, scratch2, scratch3));
3242 ASSERT(result.Is64Bits() && scratch1.Is64Bits() && scratch2.Is64Bits());
3198 3243
3199 // Make object size into bytes. 3244 // Make object size into bytes.
3200 if ((flags & SIZE_IN_WORDS) != 0) { 3245 if ((flags & SIZE_IN_WORDS) != 0) {
3201 object_size *= kPointerSize; 3246 object_size *= kPointerSize;
3202 } 3247 }
3203 ASSERT(0 == (object_size & kObjectAlignmentMask)); 3248 ASSERT(0 == (object_size & kObjectAlignmentMask));
3204 3249
3205 // Check relative positions of allocation top and limit addresses. 3250 // Check relative positions of allocation top and limit addresses.
3206 // The values must be adjacent in memory to allow the use of LDP. 3251 // The values must be adjacent in memory to allow the use of LDP.
3207 ExternalReference heap_allocation_top = 3252 ExternalReference heap_allocation_top =
3208 AllocationUtils::GetAllocationTopReference(isolate(), flags); 3253 AllocationUtils::GetAllocationTopReference(isolate(), flags);
3209 ExternalReference heap_allocation_limit = 3254 ExternalReference heap_allocation_limit =
3210 AllocationUtils::GetAllocationLimitReference(isolate(), flags); 3255 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
3211 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address()); 3256 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address());
3212 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); 3257 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address());
3213 ASSERT((limit - top) == kPointerSize); 3258 ASSERT((limit - top) == kPointerSize);
3214 3259
3215 // Set up allocation top address and object size registers. 3260 // Set up allocation top address and object size registers.
3216 Register top_address = scratch1; 3261 Register top_address = scratch1;
3217 Register allocation_limit = scratch2; 3262 Register allocation_limit = scratch2;
3218 Mov(top_address, Operand(heap_allocation_top)); 3263 Mov(top_address, Operand(heap_allocation_top));
3219 3264
3220 if ((flags & RESULT_CONTAINS_TOP) == 0) { 3265 if ((flags & RESULT_CONTAINS_TOP) == 0) {
3221 // Load allocation top into result and the allocation limit. 3266 // Load allocation top into result and the allocation limit.
3222 Ldp(result, allocation_limit, MemOperand(top_address)); 3267 Ldp(result, allocation_limit, MemOperand(top_address));
3223 } else { 3268 } else {
3224 if (emit_debug_code()) { 3269 if (emit_debug_code()) {
3225 // Assert that result actually contains top on entry. 3270 // Assert that result actually contains top on entry.
3226 Ldr(Tmp0(), MemOperand(top_address)); 3271 Ldr(scratch3, MemOperand(top_address));
3227 Cmp(result, Tmp0()); 3272 Cmp(result, scratch3);
3228 Check(eq, kUnexpectedAllocationTop); 3273 Check(eq, kUnexpectedAllocationTop);
3229 } 3274 }
3230 // Load the allocation limit. 'result' already contains the allocation top. 3275 // Load the allocation limit. 'result' already contains the allocation top.
3231 Ldr(allocation_limit, MemOperand(top_address, limit - top)); 3276 Ldr(allocation_limit, MemOperand(top_address, limit - top));
3232 } 3277 }
3233 3278
3234 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have 3279 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have
3235 // the same alignment on A64. 3280 // the same alignment on A64.
3236 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); 3281 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment);
3237 3282
3238 // Calculate new top and bail out if new space is exhausted. 3283 // Calculate new top and bail out if new space is exhausted.
3239 Adds(Tmp1(), result, object_size); 3284 Adds(scratch3, result, object_size);
3240 B(vs, gc_required); 3285 B(vs, gc_required);
3241 Cmp(Tmp1(), allocation_limit); 3286 Cmp(scratch3, allocation_limit);
3242 B(hi, gc_required); 3287 B(hi, gc_required);
3243 Str(Tmp1(), MemOperand(top_address)); 3288 Str(scratch3, MemOperand(top_address));
3244 3289
3245 // Tag the object if requested. 3290 // Tag the object if requested.
3246 if ((flags & TAG_OBJECT) != 0) { 3291 if ((flags & TAG_OBJECT) != 0) {
3247 Orr(result, result, kHeapObjectTag); 3292 Orr(result, result, kHeapObjectTag);
3248 } 3293 }
3249 } 3294 }
3250 3295
3251 3296
3252 void MacroAssembler::Allocate(Register object_size, 3297 void MacroAssembler::Allocate(Register object_size,
3253 Register result, 3298 Register result,
3254 Register scratch1, 3299 Register scratch1,
3255 Register scratch2, 3300 Register scratch2,
3256 Label* gc_required, 3301 Label* gc_required,
3257 AllocationFlags flags) { 3302 AllocationFlags flags) {
3258 if (!FLAG_inline_new) { 3303 if (!FLAG_inline_new) {
3259 if (emit_debug_code()) { 3304 if (emit_debug_code()) {
3260 // Trash the registers to simulate an allocation failure. 3305 // Trash the registers to simulate an allocation failure.
3261 // We apply salt to the original zap value to easily spot the values. 3306 // We apply salt to the original zap value to easily spot the values.
3262 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L); 3307 Mov(result, (kDebugZapValue & ~0xffL) | 0x11L);
3263 Mov(scratch1, (kDebugZapValue & ~0xffL) | 0x21L); 3308 Mov(scratch1, (kDebugZapValue & ~0xffL) | 0x21L);
3264 Mov(scratch2, (kDebugZapValue & ~0xffL) | 0x21L); 3309 Mov(scratch2, (kDebugZapValue & ~0xffL) | 0x21L);
3265 } 3310 }
3266 B(gc_required); 3311 B(gc_required);
3267 return; 3312 return;
3268 } 3313 }
3269 3314
3270 ASSERT(!AreAliased(object_size, result, scratch1, scratch2, Tmp0(), Tmp1())); 3315 UseScratchRegisterScope temps(this);
3271 ASSERT(object_size.Is64Bits() && result.Is64Bits() && scratch1.Is64Bits() && 3316 Register scratch3 = temps.AcquireX();
3272 scratch2.Is64Bits() && Tmp0().Is64Bits() && Tmp1().Is64Bits()); 3317
3318 ASSERT(!AreAliased(object_size, result, scratch1, scratch2, scratch3));
3319 ASSERT(object_size.Is64Bits() && result.Is64Bits() &&
3320 scratch1.Is64Bits() && scratch2.Is64Bits());
3273 3321
3274 // Check relative positions of allocation top and limit addresses. 3322 // Check relative positions of allocation top and limit addresses.
3275 // The values must be adjacent in memory to allow the use of LDP. 3323 // The values must be adjacent in memory to allow the use of LDP.
3276 ExternalReference heap_allocation_top = 3324 ExternalReference heap_allocation_top =
3277 AllocationUtils::GetAllocationTopReference(isolate(), flags); 3325 AllocationUtils::GetAllocationTopReference(isolate(), flags);
3278 ExternalReference heap_allocation_limit = 3326 ExternalReference heap_allocation_limit =
3279 AllocationUtils::GetAllocationLimitReference(isolate(), flags); 3327 AllocationUtils::GetAllocationLimitReference(isolate(), flags);
3280 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address()); 3328 intptr_t top = reinterpret_cast<intptr_t>(heap_allocation_top.address());
3281 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address()); 3329 intptr_t limit = reinterpret_cast<intptr_t>(heap_allocation_limit.address());
3282 ASSERT((limit - top) == kPointerSize); 3330 ASSERT((limit - top) == kPointerSize);
3283 3331
3284 // Set up allocation top address and object size registers. 3332 // Set up allocation top address and object size registers.
3285 Register top_address = scratch1; 3333 Register top_address = scratch1;
3286 Register allocation_limit = scratch2; 3334 Register allocation_limit = scratch2;
3287 Mov(top_address, Operand(heap_allocation_top)); 3335 Mov(top_address, Operand(heap_allocation_top));
3288 3336
3289 if ((flags & RESULT_CONTAINS_TOP) == 0) { 3337 if ((flags & RESULT_CONTAINS_TOP) == 0) {
3290 // Load allocation top into result and the allocation limit. 3338 // Load allocation top into result and the allocation limit.
3291 Ldp(result, allocation_limit, MemOperand(top_address)); 3339 Ldp(result, allocation_limit, MemOperand(top_address));
3292 } else { 3340 } else {
3293 if (emit_debug_code()) { 3341 if (emit_debug_code()) {
3294 // Assert that result actually contains top on entry. 3342 // Assert that result actually contains top on entry.
3295 Ldr(Tmp0(), MemOperand(top_address)); 3343 Ldr(scratch3, MemOperand(top_address));
3296 Cmp(result, Tmp0()); 3344 Cmp(result, scratch3);
3297 Check(eq, kUnexpectedAllocationTop); 3345 Check(eq, kUnexpectedAllocationTop);
3298 } 3346 }
3299 // Load the allocation limit. 'result' already contains the allocation top. 3347 // Load the allocation limit. 'result' already contains the allocation top.
3300 Ldr(allocation_limit, MemOperand(top_address, limit - top)); 3348 Ldr(allocation_limit, MemOperand(top_address, limit - top));
3301 } 3349 }
3302 3350
3303 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have 3351 // We can ignore DOUBLE_ALIGNMENT flags here because doubles and pointers have
3304 // the same alignment on A64. 3352 // the same alignment on A64.
3305 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment); 3353 STATIC_ASSERT(kPointerAlignment == kDoubleAlignment);
3306 3354
3307 // Calculate new top and bail out if new space is exhausted 3355 // Calculate new top and bail out if new space is exhausted
3308 if ((flags & SIZE_IN_WORDS) != 0) { 3356 if ((flags & SIZE_IN_WORDS) != 0) {
3309 Adds(Tmp1(), result, Operand(object_size, LSL, kPointerSizeLog2)); 3357 Adds(scratch3, result, Operand(object_size, LSL, kPointerSizeLog2));
3310 } else { 3358 } else {
3311 Adds(Tmp1(), result, object_size); 3359 Adds(scratch3, result, object_size);
3312 } 3360 }
3313 3361
3314 if (emit_debug_code()) { 3362 if (emit_debug_code()) {
3315 Tst(Tmp1(), kObjectAlignmentMask); 3363 Tst(scratch3, kObjectAlignmentMask);
3316 Check(eq, kUnalignedAllocationInNewSpace); 3364 Check(eq, kUnalignedAllocationInNewSpace);
3317 } 3365 }
3318 3366
3319 B(vs, gc_required); 3367 B(vs, gc_required);
3320 Cmp(Tmp1(), allocation_limit); 3368 Cmp(scratch3, allocation_limit);
3321 B(hi, gc_required); 3369 B(hi, gc_required);
3322 Str(Tmp1(), MemOperand(top_address)); 3370 Str(scratch3, MemOperand(top_address));
3323 3371
3324 // Tag the object if requested. 3372 // Tag the object if requested.
3325 if ((flags & TAG_OBJECT) != 0) { 3373 if ((flags & TAG_OBJECT) != 0) {
3326 Orr(result, result, kHeapObjectTag); 3374 Orr(result, result, kHeapObjectTag);
3327 } 3375 }
3328 } 3376 }
3329 3377
3330 3378
3331 void MacroAssembler::UndoAllocationInNewSpace(Register object, 3379 void MacroAssembler::UndoAllocationInNewSpace(Register object,
3332 Register scratch) { 3380 Register scratch) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3640 } 3688 }
3641 Ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); 3689 Ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset));
3642 Cmp(scratch, Operand(map)); 3690 Cmp(scratch, Operand(map));
3643 B(ne, &fail); 3691 B(ne, &fail);
3644 Jump(success, RelocInfo::CODE_TARGET); 3692 Jump(success, RelocInfo::CODE_TARGET);
3645 Bind(&fail); 3693 Bind(&fail);
3646 } 3694 }
3647 3695
3648 3696
3649 void MacroAssembler::TestMapBitfield(Register object, uint64_t mask) { 3697 void MacroAssembler::TestMapBitfield(Register object, uint64_t mask) {
3650 Ldr(Tmp0(), FieldMemOperand(object, HeapObject::kMapOffset)); 3698 UseScratchRegisterScope temps(this);
3651 Ldrb(Tmp0(), FieldMemOperand(Tmp0(), Map::kBitFieldOffset)); 3699 Register temp = temps.AcquireX();
3652 Tst(Tmp0(), mask); 3700 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
3701 Ldrb(temp, FieldMemOperand(temp, Map::kBitFieldOffset));
3702 Tst(temp, mask);
3653 } 3703 }
3654 3704
3655 3705
3656 void MacroAssembler::LoadElementsKind(Register result, Register object) { 3706 void MacroAssembler::LoadElementsKind(Register result, Register object) {
3657 // Load map. 3707 // Load map.
3658 __ Ldr(result, FieldMemOperand(object, HeapObject::kMapOffset)); 3708 __ Ldr(result, FieldMemOperand(object, HeapObject::kMapOffset));
3659 // Load the map's "bit field 2". 3709 // Load the map's "bit field 2".
3660 __ Ldrb(result, FieldMemOperand(result, Map::kBitField2Offset)); 3710 __ Ldrb(result, FieldMemOperand(result, Map::kBitField2Offset));
3661 // Retrieve elements_kind from bit field 2. 3711 // Retrieve elements_kind from bit field 2.
3662 __ Ubfx(result, result, Map::kElementsKindShift, Map::kElementsKindBitCount); 3712 __ Ubfx(result, result, Map::kElementsKindShift, Map::kElementsKindBitCount);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 Bind(&non_instance); 3764 Bind(&non_instance);
3715 Ldr(result, FieldMemOperand(result, Map::kConstructorOffset)); 3765 Ldr(result, FieldMemOperand(result, Map::kConstructorOffset));
3716 3766
3717 // All done. 3767 // All done.
3718 Bind(&done); 3768 Bind(&done);
3719 } 3769 }
3720 3770
3721 3771
3722 void MacroAssembler::CompareRoot(const Register& obj, 3772 void MacroAssembler::CompareRoot(const Register& obj,
3723 Heap::RootListIndex index) { 3773 Heap::RootListIndex index) {
3724 ASSERT(!AreAliased(obj, Tmp0())); 3774 UseScratchRegisterScope temps(this);
3725 LoadRoot(Tmp0(), index); 3775 Register temp = temps.AcquireX();
3726 Cmp(obj, Tmp0()); 3776 ASSERT(!AreAliased(obj, temp));
3777 LoadRoot(temp, index);
3778 Cmp(obj, temp);
3727 } 3779 }
3728 3780
3729 3781
3730 void MacroAssembler::JumpIfRoot(const Register& obj, 3782 void MacroAssembler::JumpIfRoot(const Register& obj,
3731 Heap::RootListIndex index, 3783 Heap::RootListIndex index,
3732 Label* if_equal) { 3784 Label* if_equal) {
3733 CompareRoot(obj, index); 3785 CompareRoot(obj, index);
3734 B(eq, if_equal); 3786 B(eq, if_equal);
3735 } 3787 }
3736 3788
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
3913 Cmp(index, index_type == kIndexIsSmi ? scratch : Operand::UntagSmi(scratch)); 3965 Cmp(index, index_type == kIndexIsSmi ? scratch : Operand::UntagSmi(scratch));
3914 Check(lt, kIndexIsTooLarge); 3966 Check(lt, kIndexIsTooLarge);
3915 3967
3916 ASSERT_EQ(0, Smi::FromInt(0)); 3968 ASSERT_EQ(0, Smi::FromInt(0));
3917 Cmp(index, 0); 3969 Cmp(index, 0);
3918 Check(ge, kIndexIsNegative); 3970 Check(ge, kIndexIsNegative);
3919 } 3971 }
3920 3972
3921 3973
3922 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg, 3974 void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
3923 Register scratch, 3975 Register scratch1,
3976 Register scratch2,
3924 Label* miss) { 3977 Label* miss) {
3925 // TODO(jbramley): Sort out the uses of Tmp0() and Tmp1() in this function. 3978 ASSERT(!AreAliased(holder_reg, scratch1, scratch2));
3926 // The ARM version takes two scratch registers, and that should be enough for
3927 // all of the checks.
3928
3929 Label same_contexts; 3979 Label same_contexts;
3930 3980
3931 ASSERT(!AreAliased(holder_reg, scratch));
3932
3933 // Load current lexical context from the stack frame. 3981 // Load current lexical context from the stack frame.
3934 Ldr(scratch, MemOperand(fp, StandardFrameConstants::kContextOffset)); 3982 Ldr(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset));
3935 // In debug mode, make sure the lexical context is set. 3983 // In debug mode, make sure the lexical context is set.
3936 #ifdef DEBUG 3984 #ifdef DEBUG
3937 Cmp(scratch, 0); 3985 Cmp(scratch1, 0);
3938 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext); 3986 Check(ne, kWeShouldNotHaveAnEmptyLexicalContext);
3939 #endif 3987 #endif
3940 3988
3941 // Load the native context of the current context. 3989 // Load the native context of the current context.
3942 int offset = 3990 int offset =
3943 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize; 3991 Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize;
3944 Ldr(scratch, FieldMemOperand(scratch, offset)); 3992 Ldr(scratch1, FieldMemOperand(scratch1, offset));
3945 Ldr(scratch, FieldMemOperand(scratch, GlobalObject::kNativeContextOffset)); 3993 Ldr(scratch1, FieldMemOperand(scratch1, GlobalObject::kNativeContextOffset));
3946 3994
3947 // Check the context is a native context. 3995 // Check the context is a native context.
3948 if (emit_debug_code()) { 3996 if (emit_debug_code()) {
3949 // Read the first word and compare to the global_context_map. 3997 // Read the first word and compare to the global_context_map.
3950 Register temp = Tmp1(); 3998 Ldr(scratch2, FieldMemOperand(scratch1, HeapObject::kMapOffset));
3951 Ldr(temp, FieldMemOperand(scratch, HeapObject::kMapOffset)); 3999 CompareRoot(scratch2, Heap::kNativeContextMapRootIndex);
3952 CompareRoot(temp, Heap::kNativeContextMapRootIndex);
3953 Check(eq, kExpectedNativeContext); 4000 Check(eq, kExpectedNativeContext);
3954 } 4001 }
3955 4002
3956 // Check if both contexts are the same. 4003 // Check if both contexts are the same.
3957 ldr(Tmp0(), FieldMemOperand(holder_reg, JSGlobalProxy::kNativeContextOffset)); 4004 Ldr(scratch2, FieldMemOperand(holder_reg,
3958 cmp(scratch, Tmp0()); 4005 JSGlobalProxy::kNativeContextOffset));
3959 b(&same_contexts, eq); 4006 Cmp(scratch1, scratch2);
4007 B(&same_contexts, eq);
3960 4008
3961 // Check the context is a native context. 4009 // Check the context is a native context.
3962 if (emit_debug_code()) { 4010 if (emit_debug_code()) {
3963 // Move Tmp0() into a different register, as CompareRoot will use it. 4011 // We're short on scratch registers here, so use holder_reg as a scratch.
3964 Register temp = Tmp1(); 4012 Push(holder_reg);
3965 mov(temp, Tmp0()); 4013 Register scratch3 = holder_reg;
3966 CompareRoot(temp, Heap::kNullValueRootIndex); 4014
4015 CompareRoot(scratch2, Heap::kNullValueRootIndex);
3967 Check(ne, kExpectedNonNullContext); 4016 Check(ne, kExpectedNonNullContext);
3968 4017
3969 Ldr(temp, FieldMemOperand(temp, HeapObject::kMapOffset)); 4018 Ldr(scratch3, FieldMemOperand(scratch2, HeapObject::kMapOffset));
3970 CompareRoot(temp, Heap::kNativeContextMapRootIndex); 4019 CompareRoot(scratch3, Heap::kNativeContextMapRootIndex);
3971 Check(eq, kExpectedNativeContext); 4020 Check(eq, kExpectedNativeContext);
3972 4021 Pop(holder_reg);
3973 // Let's consider that Tmp0() has been cloberred by the MacroAssembler.
3974 // We reload it with its value.
3975 ldr(Tmp0(), FieldMemOperand(holder_reg,
3976 JSGlobalProxy::kNativeContextOffset));
3977 } 4022 }
3978 4023
3979 // Check that the security token in the calling global object is 4024 // Check that the security token in the calling global object is
3980 // compatible with the security token in the receiving global 4025 // compatible with the security token in the receiving global
3981 // object. 4026 // object.
3982 int token_offset = Context::kHeaderSize + 4027 int token_offset = Context::kHeaderSize +
3983 Context::SECURITY_TOKEN_INDEX * kPointerSize; 4028 Context::SECURITY_TOKEN_INDEX * kPointerSize;
3984 4029
3985 ldr(scratch, FieldMemOperand(scratch, token_offset)); 4030 Ldr(scratch1, FieldMemOperand(scratch1, token_offset));
3986 ldr(Tmp0(), FieldMemOperand(Tmp0(), token_offset)); 4031 Ldr(scratch2, FieldMemOperand(scratch2, token_offset));
3987 cmp(scratch, Tmp0()); 4032 Cmp(scratch1, scratch2);
3988 b(miss, ne); 4033 B(miss, ne);
3989 4034
3990 bind(&same_contexts); 4035 Bind(&same_contexts);
3991 } 4036 }
3992 4037
3993 4038
3994 // Compute the hash code from the untagged key. This must be kept in sync with 4039 // Compute the hash code from the untagged key. This must be kept in sync with
3995 // ComputeIntegerHash in utils.h and KeyedLoadGenericElementStub in 4040 // ComputeIntegerHash in utils.h and KeyedLoadGenericElementStub in
3996 // code-stub-hydrogen.cc 4041 // code-stub-hydrogen.cc
3997 void MacroAssembler::GetNumberHash(Register key, Register scratch) { 4042 void MacroAssembler::GetNumberHash(Register key, Register scratch) {
3998 ASSERT(!AreAliased(key, scratch)); 4043 ASSERT(!AreAliased(key, scratch));
3999 4044
4000 // Xor original key with a seed. 4045 // Xor original key with a seed.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4083 4128
4084 // Get the value at the masked, scaled index and return. 4129 // Get the value at the masked, scaled index and return.
4085 const int kValueOffset = 4130 const int kValueOffset =
4086 SeededNumberDictionary::kElementsStartOffset + kPointerSize; 4131 SeededNumberDictionary::kElementsStartOffset + kPointerSize;
4087 Ldr(result, FieldMemOperand(scratch2, kValueOffset)); 4132 Ldr(result, FieldMemOperand(scratch2, kValueOffset));
4088 } 4133 }
4089 4134
4090 4135
4091 void MacroAssembler::RememberedSetHelper(Register object, // For debug tests. 4136 void MacroAssembler::RememberedSetHelper(Register object, // For debug tests.
4092 Register address, 4137 Register address,
4093 Register scratch, 4138 Register scratch1,
4094 SaveFPRegsMode fp_mode, 4139 SaveFPRegsMode fp_mode,
4095 RememberedSetFinalAction and_then) { 4140 RememberedSetFinalAction and_then) {
4096 ASSERT(!AreAliased(object, address, scratch)); 4141 ASSERT(!AreAliased(object, address, scratch1));
4097 Label done, store_buffer_overflow; 4142 Label done, store_buffer_overflow;
4098 if (emit_debug_code()) { 4143 if (emit_debug_code()) {
4099 Label ok; 4144 Label ok;
4100 JumpIfNotInNewSpace(object, &ok); 4145 JumpIfNotInNewSpace(object, &ok);
4101 Abort(kRememberedSetPointerInNewSpace); 4146 Abort(kRememberedSetPointerInNewSpace);
4102 bind(&ok); 4147 bind(&ok);
4103 } 4148 }
4149 UseScratchRegisterScope temps(this);
4150 Register scratch2 = temps.AcquireX();
4151
4104 // Load store buffer top. 4152 // Load store buffer top.
4105 Mov(Tmp0(), Operand(ExternalReference::store_buffer_top(isolate()))); 4153 Mov(scratch2, Operand(ExternalReference::store_buffer_top(isolate())));
4106 Ldr(scratch, MemOperand(Tmp0())); 4154 Ldr(scratch1, MemOperand(scratch2));
4107 // Store pointer to buffer and increment buffer top. 4155 // Store pointer to buffer and increment buffer top.
4108 Str(address, MemOperand(scratch, kPointerSize, PostIndex)); 4156 Str(address, MemOperand(scratch1, kPointerSize, PostIndex));
4109 // Write back new top of buffer. 4157 // Write back new top of buffer.
4110 Str(scratch, MemOperand(Tmp0())); 4158 Str(scratch1, MemOperand(scratch2));
4111 // Call stub on end of buffer. 4159 // Call stub on end of buffer.
4112 // Check for end of buffer. 4160 // Check for end of buffer.
4113 ASSERT(StoreBuffer::kStoreBufferOverflowBit == 4161 ASSERT(StoreBuffer::kStoreBufferOverflowBit ==
4114 (1 << (14 + kPointerSizeLog2))); 4162 (1 << (14 + kPointerSizeLog2)));
4115 if (and_then == kFallThroughAtEnd) { 4163 if (and_then == kFallThroughAtEnd) {
4116 Tbz(scratch, (14 + kPointerSizeLog2), &done); 4164 Tbz(scratch1, (14 + kPointerSizeLog2), &done);
4117 } else { 4165 } else {
4118 ASSERT(and_then == kReturnAtEnd); 4166 ASSERT(and_then == kReturnAtEnd);
4119 Tbnz(scratch, (14 + kPointerSizeLog2), &store_buffer_overflow); 4167 Tbnz(scratch1, (14 + kPointerSizeLog2), &store_buffer_overflow);
4120 Ret(); 4168 Ret();
4121 } 4169 }
4122 4170
4123 Bind(&store_buffer_overflow); 4171 Bind(&store_buffer_overflow);
4124 Push(lr); 4172 Push(lr);
4125 StoreBufferOverflowStub store_buffer_overflow_stub = 4173 StoreBufferOverflowStub store_buffer_overflow_stub =
4126 StoreBufferOverflowStub(fp_mode); 4174 StoreBufferOverflowStub(fp_mode);
4127 CallStub(&store_buffer_overflow_stub); 4175 CallStub(&store_buffer_overflow_stub);
4128 Pop(lr); 4176 Pop(lr);
4129 4177
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 4305
4258 // Clobber clobbered input registers when running with the debug-code flag 4306 // Clobber clobbered input registers when running with the debug-code flag
4259 // turned on to provoke errors. 4307 // turned on to provoke errors.
4260 if (emit_debug_code()) { 4308 if (emit_debug_code()) {
4261 Mov(value, Operand(BitCast<int64_t>(kZapValue + 4))); 4309 Mov(value, Operand(BitCast<int64_t>(kZapValue + 4)));
4262 Mov(scratch, Operand(BitCast<int64_t>(kZapValue + 8))); 4310 Mov(scratch, Operand(BitCast<int64_t>(kZapValue + 8)));
4263 } 4311 }
4264 } 4312 }
4265 4313
4266 4314
4267 // Will clobber: object, address, value, Tmp0(), Tmp1(). 4315 // Will clobber: object, address, value.
4268 // If lr_status is kLRHasBeenSaved, lr will also be clobbered. 4316 // If lr_status is kLRHasBeenSaved, lr will also be clobbered.
4269 // 4317 //
4270 // The register 'object' contains a heap object pointer. The heap object tag is 4318 // The register 'object' contains a heap object pointer. The heap object tag is
4271 // shifted away. 4319 // shifted away.
4272 void MacroAssembler::RecordWrite(Register object, 4320 void MacroAssembler::RecordWrite(Register object,
4273 Register address, 4321 Register address,
4274 Register value, 4322 Register value,
4275 LinkRegisterStatus lr_status, 4323 LinkRegisterStatus lr_status,
4276 SaveFPRegsMode fp_mode, 4324 SaveFPRegsMode fp_mode,
4277 RememberedSetAction remembered_set_action, 4325 RememberedSetAction remembered_set_action,
4278 SmiCheck smi_check) { 4326 SmiCheck smi_check) {
4279 ASM_LOCATION("MacroAssembler::RecordWrite"); 4327 ASM_LOCATION("MacroAssembler::RecordWrite");
4280 ASSERT(!AreAliased(object, value)); 4328 ASSERT(!AreAliased(object, value));
4281 4329
4282 if (emit_debug_code()) { 4330 if (emit_debug_code()) {
4283 Ldr(Tmp0(), MemOperand(address)); 4331 UseScratchRegisterScope temps(this);
4284 Cmp(Tmp0(), value); 4332 Register temp = temps.AcquireX();
4333
4334 Ldr(temp, MemOperand(address));
4335 Cmp(temp, value);
4285 Check(eq, kWrongAddressOrValuePassedToRecordWrite); 4336 Check(eq, kWrongAddressOrValuePassedToRecordWrite);
4286 } 4337 }
4287 4338
4288 // Count number of write barriers in generated code. 4339 // Count number of write barriers in generated code.
4289 isolate()->counters()->write_barriers_static()->Increment(); 4340 isolate()->counters()->write_barriers_static()->Increment();
4290 // TODO(mstarzinger): Dynamic counter missing. 4341 // TODO(mstarzinger): Dynamic counter missing.
4291 4342
4292 // First, check if a write barrier is even needed. The tests below 4343 // First, check if a write barrier is even needed. The tests below
4293 // catch stores of smis and stores into the young generation. 4344 // catch stores of smis and stores into the young generation.
4294 Label done; 4345 Label done;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4339 Tbz(reg, 1, &color_is_valid); 4390 Tbz(reg, 1, &color_is_valid);
4340 Abort(kUnexpectedColorFound); 4391 Abort(kUnexpectedColorFound);
4341 Bind(&color_is_valid); 4392 Bind(&color_is_valid);
4342 } 4393 }
4343 } 4394 }
4344 4395
4345 4396
4346 void MacroAssembler::GetMarkBits(Register addr_reg, 4397 void MacroAssembler::GetMarkBits(Register addr_reg,
4347 Register bitmap_reg, 4398 Register bitmap_reg,
4348 Register shift_reg) { 4399 Register shift_reg) {
4349 ASSERT(!AreAliased(addr_reg, bitmap_reg, shift_reg, no_reg)); 4400 ASSERT(!AreAliased(addr_reg, bitmap_reg, shift_reg));
4401 ASSERT(addr_reg.Is64Bits() && bitmap_reg.Is64Bits() && shift_reg.Is64Bits());
4350 // addr_reg is divided into fields: 4402 // addr_reg is divided into fields:
4351 // |63 page base 20|19 high 8|7 shift 3|2 0| 4403 // |63 page base 20|19 high 8|7 shift 3|2 0|
4352 // 'high' gives the index of the cell holding color bits for the object. 4404 // 'high' gives the index of the cell holding color bits for the object.
4353 // 'shift' gives the offset in the cell for this object's color. 4405 // 'shift' gives the offset in the cell for this object's color.
4354 const int kShiftBits = kPointerSizeLog2 + Bitmap::kBitsPerCellLog2; 4406 const int kShiftBits = kPointerSizeLog2 + Bitmap::kBitsPerCellLog2;
4355 Ubfx(Tmp0(), addr_reg, kShiftBits, kPageSizeBits - kShiftBits); 4407 UseScratchRegisterScope temps(this);
4408 Register temp = temps.AcquireX();
4409 Ubfx(temp, addr_reg, kShiftBits, kPageSizeBits - kShiftBits);
4356 Bic(bitmap_reg, addr_reg, Page::kPageAlignmentMask); 4410 Bic(bitmap_reg, addr_reg, Page::kPageAlignmentMask);
4357 Add(bitmap_reg, bitmap_reg, Operand(Tmp0(), LSL, Bitmap::kBytesPerCellLog2)); 4411 Add(bitmap_reg, bitmap_reg, Operand(temp, LSL, Bitmap::kBytesPerCellLog2));
4358 // bitmap_reg: 4412 // bitmap_reg:
4359 // |63 page base 20|19 zeros 15|14 high 3|2 0| 4413 // |63 page base 20|19 zeros 15|14 high 3|2 0|
4360 Ubfx(shift_reg, addr_reg, kPointerSizeLog2, Bitmap::kBitsPerCellLog2); 4414 Ubfx(shift_reg, addr_reg, kPointerSizeLog2, Bitmap::kBitsPerCellLog2);
4361 } 4415 }
4362 4416
4363 4417
4364 void MacroAssembler::HasColor(Register object, 4418 void MacroAssembler::HasColor(Register object,
4365 Register bitmap_scratch, 4419 Register bitmap_scratch,
4366 Register shift_scratch, 4420 Register shift_scratch,
4367 Label* has_color, 4421 Label* has_color,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
4571 void MacroAssembler::AssertRegisterIsClear(Register reg, BailoutReason reason) { 4625 void MacroAssembler::AssertRegisterIsClear(Register reg, BailoutReason reason) {
4572 if (emit_debug_code()) { 4626 if (emit_debug_code()) {
4573 CheckRegisterIsClear(reg, reason); 4627 CheckRegisterIsClear(reg, reason);
4574 } 4628 }
4575 } 4629 }
4576 4630
4577 4631
4578 void MacroAssembler::AssertRegisterIsRoot(Register reg, 4632 void MacroAssembler::AssertRegisterIsRoot(Register reg,
4579 Heap::RootListIndex index, 4633 Heap::RootListIndex index,
4580 BailoutReason reason) { 4634 BailoutReason reason) {
4581 // CompareRoot uses Tmp0().
4582 ASSERT(!reg.Is(Tmp0()));
4583 if (emit_debug_code()) { 4635 if (emit_debug_code()) {
4584 CompareRoot(reg, index); 4636 CompareRoot(reg, index);
4585 Check(eq, reason); 4637 Check(eq, reason);
4586 } 4638 }
4587 } 4639 }
4588 4640
4589 4641
4590 void MacroAssembler::AssertFastElements(Register elements) { 4642 void MacroAssembler::AssertFastElements(Register elements) {
4591 if (emit_debug_code()) { 4643 if (emit_debug_code()) {
4592 Register temp = Tmp1(); 4644 UseScratchRegisterScope temps(this);
4645 Register temp = temps.AcquireX();
4593 Label ok; 4646 Label ok;
4594 Ldr(temp, FieldMemOperand(elements, HeapObject::kMapOffset)); 4647 Ldr(temp, FieldMemOperand(elements, HeapObject::kMapOffset));
4595 JumpIfRoot(temp, Heap::kFixedArrayMapRootIndex, &ok); 4648 JumpIfRoot(temp, Heap::kFixedArrayMapRootIndex, &ok);
4596 JumpIfRoot(temp, Heap::kFixedDoubleArrayMapRootIndex, &ok); 4649 JumpIfRoot(temp, Heap::kFixedDoubleArrayMapRootIndex, &ok);
4597 JumpIfRoot(temp, Heap::kFixedCOWArrayMapRootIndex, &ok); 4650 JumpIfRoot(temp, Heap::kFixedCOWArrayMapRootIndex, &ok);
4598 Abort(kJSObjectWithFastElementsMapHasSlowElements); 4651 Abort(kJSObjectWithFastElementsMapHasSlowElements);
4599 Bind(&ok); 4652 Bind(&ok);
4600 } 4653 }
4601 } 4654 }
4602 4655
4603 4656
4604 void MacroAssembler::AssertIsString(const Register& object) { 4657 void MacroAssembler::AssertIsString(const Register& object) {
4605 if (emit_debug_code()) { 4658 if (emit_debug_code()) {
4606 Register temp = Tmp1(); 4659 UseScratchRegisterScope temps(this);
4660 Register temp = temps.AcquireX();
4607 STATIC_ASSERT(kSmiTag == 0); 4661 STATIC_ASSERT(kSmiTag == 0);
4608 Tst(object, Operand(kSmiTagMask)); 4662 Tst(object, Operand(kSmiTagMask));
4609 Check(ne, kOperandIsNotAString); 4663 Check(ne, kOperandIsNotAString);
4610 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset)); 4664 Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
4611 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE); 4665 CompareInstanceType(temp, temp, FIRST_NONSTRING_TYPE);
4612 Check(lo, kOperandIsNotAString); 4666 Check(lo, kOperandIsNotAString);
4613 } 4667 }
4614 } 4668 }
4615 4669
4616 4670
(...skipping 26 matching lines...) Expand all
4643 } 4697 }
4644 #endif 4698 #endif
4645 4699
4646 // Abort is used in some contexts where csp is the stack pointer. In order to 4700 // Abort is used in some contexts where csp is the stack pointer. In order to
4647 // simplify the CallRuntime code, make sure that jssp is the stack pointer. 4701 // simplify the CallRuntime code, make sure that jssp is the stack pointer.
4648 // There is no risk of register corruption here because Abort doesn't return. 4702 // There is no risk of register corruption here because Abort doesn't return.
4649 Register old_stack_pointer = StackPointer(); 4703 Register old_stack_pointer = StackPointer();
4650 SetStackPointer(jssp); 4704 SetStackPointer(jssp);
4651 Mov(jssp, old_stack_pointer); 4705 Mov(jssp, old_stack_pointer);
4652 4706
4707 // We need some scratch registers for the MacroAssembler, so make sure we have
4708 // some. This is safe here because Abort never returns.
4709 RegList old_tmp_list = TmpList()->list();
4710 TmpList()->Combine(ip0);
4711 TmpList()->Combine(ip1);
4712
4653 if (use_real_aborts()) { 4713 if (use_real_aborts()) {
4654 // Avoid infinite recursion; Push contains some assertions that use Abort. 4714 // Avoid infinite recursion; Push contains some assertions that use Abort.
4655 NoUseRealAbortsScope no_real_aborts(this); 4715 NoUseRealAbortsScope no_real_aborts(this);
4656 4716
4657 Mov(x0, Operand(Smi::FromInt(reason))); 4717 Mov(x0, Operand(Smi::FromInt(reason)));
4658 Push(x0); 4718 Push(x0);
4659 4719
4660 if (!has_frame_) { 4720 if (!has_frame_) {
4661 // We don't actually want to generate a pile of code for this, so just 4721 // We don't actually want to generate a pile of code for this, so just
4662 // claim there is a stack frame, without generating one. 4722 // claim there is a stack frame, without generating one.
(...skipping 16 matching lines...) Expand all
4679 4739
4680 // Emit the message string directly in the instruction stream. 4740 // Emit the message string directly in the instruction stream.
4681 { 4741 {
4682 BlockConstPoolScope scope(this); 4742 BlockConstPoolScope scope(this);
4683 Bind(&msg_address); 4743 Bind(&msg_address);
4684 EmitStringData(GetBailoutReason(reason)); 4744 EmitStringData(GetBailoutReason(reason));
4685 } 4745 }
4686 } 4746 }
4687 4747
4688 SetStackPointer(old_stack_pointer); 4748 SetStackPointer(old_stack_pointer);
4749 TmpList()->set_list(old_tmp_list);
4689 } 4750 }
4690 4751
4691 4752
4692 void MacroAssembler::LoadTransitionedArrayMapConditional( 4753 void MacroAssembler::LoadTransitionedArrayMapConditional(
4693 ElementsKind expected_kind, 4754 ElementsKind expected_kind,
4694 ElementsKind transitioned_kind, 4755 ElementsKind transitioned_kind,
4695 Register map_in_out, 4756 Register map_in_out,
4696 Register scratch, 4757 Register scratch1,
4758 Register scratch2,
4697 Label* no_map_match) { 4759 Label* no_map_match) {
4698 // Load the global or builtins object from the current context. 4760 // Load the global or builtins object from the current context.
4699 Ldr(scratch, GlobalObjectMemOperand()); 4761 Ldr(scratch1, GlobalObjectMemOperand());
4700 Ldr(scratch, FieldMemOperand(scratch, GlobalObject::kNativeContextOffset)); 4762 Ldr(scratch1, FieldMemOperand(scratch1, GlobalObject::kNativeContextOffset));
4701 4763
4702 // Check that the function's map is the same as the expected cached map. 4764 // Check that the function's map is the same as the expected cached map.
4703 Ldr(scratch, ContextMemOperand(scratch, Context::JS_ARRAY_MAPS_INDEX)); 4765 Ldr(scratch1, ContextMemOperand(scratch1, Context::JS_ARRAY_MAPS_INDEX));
4704 size_t offset = (expected_kind * kPointerSize) + FixedArrayBase::kHeaderSize; 4766 size_t offset = (expected_kind * kPointerSize) + FixedArrayBase::kHeaderSize;
4705 Ldr(Tmp0(), FieldMemOperand(scratch, offset)); 4767 Ldr(scratch2, FieldMemOperand(scratch1, offset));
4706 Cmp(map_in_out, Tmp0()); 4768 Cmp(map_in_out, scratch2);
4707 B(ne, no_map_match); 4769 B(ne, no_map_match);
4708 4770
4709 // Use the transitioned cached map. 4771 // Use the transitioned cached map.
4710 offset = (transitioned_kind * kPointerSize) + FixedArrayBase::kHeaderSize; 4772 offset = (transitioned_kind * kPointerSize) + FixedArrayBase::kHeaderSize;
4711 Ldr(map_in_out, FieldMemOperand(scratch, offset)); 4773 Ldr(map_in_out, FieldMemOperand(scratch1, offset));
4712 } 4774 }
4713 4775
4714 4776
4715 void MacroAssembler::LoadArrayFunction(Register function) { 4777 void MacroAssembler::LoadArrayFunction(Register function) {
4716 // Load the global or builtins object from the current context. 4778 // Load the global or builtins object from the current context.
4717 Ldr(function, GlobalObjectMemOperand()); 4779 Ldr(function, GlobalObjectMemOperand());
4718 // Load the global context from the global or builtins object. 4780 // Load the global context from the global or builtins object.
4719 Ldr(function, 4781 Ldr(function,
4720 FieldMemOperand(function, GlobalObject::kGlobalContextOffset)); 4782 FieldMemOperand(function, GlobalObject::kGlobalContextOffset));
4721 // Load the array function from the native context. 4783 // Load the array function from the native context.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4754 // PrintfNoPreserve after setting up one or more PreserveRegisterScopes. 4816 // PrintfNoPreserve after setting up one or more PreserveRegisterScopes.
4755 void MacroAssembler::PrintfNoPreserve(const char * format, 4817 void MacroAssembler::PrintfNoPreserve(const char * format,
4756 const CPURegister& arg0, 4818 const CPURegister& arg0,
4757 const CPURegister& arg1, 4819 const CPURegister& arg1,
4758 const CPURegister& arg2, 4820 const CPURegister& arg2,
4759 const CPURegister& arg3) { 4821 const CPURegister& arg3) {
4760 // We cannot handle a caller-saved stack pointer. It doesn't make much sense 4822 // We cannot handle a caller-saved stack pointer. It doesn't make much sense
4761 // in most cases anyway, so this restriction shouldn't be too serious. 4823 // in most cases anyway, so this restriction shouldn't be too serious.
4762 ASSERT(!kCallerSaved.IncludesAliasOf(__ StackPointer())); 4824 ASSERT(!kCallerSaved.IncludesAliasOf(__ StackPointer()));
4763 4825
4764 // We cannot print Tmp0() or Tmp1() as they're used internally by the macro 4826 // Make sure that the macro assembler doesn't try to use any of our arguments
4765 // assembler. We cannot print the stack pointer because it is typically used 4827 // as scratch registers.
4766 // to preserve caller-saved registers (using other Printf variants which 4828 ASSERT(!TmpList()->IncludesAliasOf(arg0));
rmcilroy 2014/02/28 13:44:30 nit - ASSERT(!(TmpList()->IncludesAliasOf(arg0) |
jbramley 2014/02/28 16:56:37 Fixed, though they won't fit on one line so I just
4767 // depend on this helper). 4829 ASSERT(!TmpList()->IncludesAliasOf(arg1));
4768 ASSERT(!AreAliased(Tmp0(), Tmp1(), StackPointer(), arg0)); 4830 ASSERT(!TmpList()->IncludesAliasOf(arg2));
4769 ASSERT(!AreAliased(Tmp0(), Tmp1(), StackPointer(), arg1)); 4831 ASSERT(!TmpList()->IncludesAliasOf(arg3));
4770 ASSERT(!AreAliased(Tmp0(), Tmp1(), StackPointer(), arg2)); 4832
4771 ASSERT(!AreAliased(Tmp0(), Tmp1(), StackPointer(), arg3)); 4833 // We cannot print the stack pointer because it is typically used to preserve
4834 // caller-saved registers (using other Printf variants which depend on this
4835 // helper).
4836 ASSERT(!AreAliased(arg0, StackPointer()));
4837 ASSERT(!AreAliased(arg1, StackPointer()));
4838 ASSERT(!AreAliased(arg2, StackPointer()));
4839 ASSERT(!AreAliased(arg3, StackPointer()));
4772 4840
4773 static const int kMaxArgCount = 4; 4841 static const int kMaxArgCount = 4;
4774 // Assume that we have the maximum number of arguments until we know 4842 // Assume that we have the maximum number of arguments until we know
4775 // otherwise. 4843 // otherwise.
4776 int arg_count = kMaxArgCount; 4844 int arg_count = kMaxArgCount;
4777 4845
4778 // The provided arguments. 4846 // The provided arguments.
4779 CPURegister args[kMaxArgCount] = {arg0, arg1, arg2, arg3}; 4847 CPURegister args[kMaxArgCount] = {arg0, arg1, arg2, arg3};
4780 4848
4781 // The PCS registers where the arguments need to end up. 4849 // The PCS registers where the arguments need to end up.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4903 Call(FUNCTION_ADDR(printf), RelocInfo::EXTERNAL_REFERENCE); 4971 Call(FUNCTION_ADDR(printf), RelocInfo::EXTERNAL_REFERENCE);
4904 #endif 4972 #endif
4905 } 4973 }
4906 4974
4907 4975
4908 void MacroAssembler::Printf(const char * format, 4976 void MacroAssembler::Printf(const char * format,
4909 const CPURegister& arg0, 4977 const CPURegister& arg0,
4910 const CPURegister& arg1, 4978 const CPURegister& arg1,
4911 const CPURegister& arg2, 4979 const CPURegister& arg2,
4912 const CPURegister& arg3) { 4980 const CPURegister& arg3) {
4981 // Printf is expected to preserve all registers, so make sure that none are
4982 // available as scratch registers until we've preserved them.
4983 RegList old_tmp_list = TmpList()->list();
4984 RegList old_fptmp_list = FPTmpList()->list();
rmcilroy 2014/02/28 13:44:30 nit - old_fp_tmp_list (not old_fptmp_list)
jbramley 2014/02/28 16:56:37 Done.
4985 TmpList()->set_list(0);
4986 FPTmpList()->set_list(0);
4987
4913 // Preserve all caller-saved registers as well as NZCV. 4988 // Preserve all caller-saved registers as well as NZCV.
4914 // If csp is the stack pointer, PushCPURegList asserts that the size of each 4989 // If csp is the stack pointer, PushCPURegList asserts that the size of each
4915 // list is a multiple of 16 bytes. 4990 // list is a multiple of 16 bytes.
4916 PushCPURegList(kCallerSaved); 4991 PushCPURegList(kCallerSaved);
4917 PushCPURegList(kCallerSavedFP); 4992 PushCPURegList(kCallerSavedFP);
4918 // Use Tmp0() as a scratch register. It is not accepted by Printf so it will 4993
4919 // never overlap an argument register. 4994 // We can use caller-saved registers as scratch values (except for argN).
4920 Mrs(Tmp0(), NZCV); 4995 CPURegList tmp_list = kCallerSaved;
4921 Push(Tmp0(), xzr); 4996 CPURegList fptmp_list = kCallerSavedFP;
rmcilroy 2014/02/28 13:44:30 nit - fp_tmp_list (not fptmp_list)
jbramley 2014/02/28 16:56:37 Done.
4997 tmp_list.Remove(arg0, arg1, arg2, arg3);
4998 fptmp_list.Remove(arg0, arg1, arg2, arg3);
4999 TmpList()->set_list(tmp_list.list());
5000 FPTmpList()->set_list(fptmp_list.list());
5001
5002 // Preserve NZCV.
5003 { UseScratchRegisterScope temps(this);
5004 Register tmp = temps.AcquireX();
5005 Mrs(tmp, NZCV);
5006 Push(tmp, xzr);
5007 }
4922 5008
4923 PrintfNoPreserve(format, arg0, arg1, arg2, arg3); 5009 PrintfNoPreserve(format, arg0, arg1, arg2, arg3);
4924 5010
4925 Pop(xzr, Tmp0()); 5011 { UseScratchRegisterScope temps(this);
4926 Msr(NZCV, Tmp0()); 5012 Register tmp = temps.AcquireX();
5013 Pop(xzr, tmp);
5014 Msr(NZCV, tmp);
5015 }
5016
4927 PopCPURegList(kCallerSavedFP); 5017 PopCPURegList(kCallerSavedFP);
4928 PopCPURegList(kCallerSaved); 5018 PopCPURegList(kCallerSaved);
5019
5020 TmpList()->set_list(old_tmp_list);
5021 FPTmpList()->set_list(old_fptmp_list);
4929 } 5022 }
4930 5023
4931 5024
4932 void MacroAssembler::EmitFrameSetupForCodeAgePatching() { 5025 void MacroAssembler::EmitFrameSetupForCodeAgePatching() {
4933 // TODO(jbramley): Other architectures use the internal memcpy to copy the 5026 // TODO(jbramley): Other architectures use the internal memcpy to copy the
4934 // sequence. If this is a performance bottleneck, we should consider caching 5027 // sequence. If this is a performance bottleneck, we should consider caching
4935 // the sequence and copying it in the same way. 5028 // the sequence and copying it in the same way.
4936 InstructionAccurateScope scope(this, kCodeAgeSequenceSize / kInstructionSize); 5029 InstructionAccurateScope scope(this, kCodeAgeSequenceSize / kInstructionSize);
4937 ASSERT(jssp.Is(StackPointer())); 5030 ASSERT(jssp.Is(StackPointer()));
4938 EmitFrameSetupForCodeAgePatching(this); 5031 EmitFrameSetupForCodeAgePatching(this);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
5024 PatchingAssembler patcher(old, length); 5117 PatchingAssembler patcher(old, length);
5025 MacroAssembler::EmitCodeAgeSequence(&patcher, NULL); 5118 MacroAssembler::EmitCodeAgeSequence(&patcher, NULL);
5026 initialized = true; 5119 initialized = true;
5027 } 5120 }
5028 return memcmp(sequence, old, kCodeAgeStubEntryOffset) == 0; 5121 return memcmp(sequence, old, kCodeAgeStubEntryOffset) == 0;
5029 } 5122 }
5030 #endif 5123 #endif
5031 5124
5032 5125
5033 #undef __ 5126 #undef __
5127
5128
5129 UseScratchRegisterScope::~UseScratchRegisterScope() {
5130 available_->set_list(old_available_);
5131 availablefp_->set_list(old_availablefp_);
5132 }
5133
5134
5135 Register UseScratchRegisterScope::AcquireSameSizeAs(const Register& reg) {
5136 int code = AcquireNextAvailable(available_).code();
5137 return Register::Create(code, reg.SizeInBits());
5138 }
5139
5140
5141 FPRegister UseScratchRegisterScope::AcquireSameSizeAs(const FPRegister& reg) {
5142 int code = AcquireNextAvailable(availablefp_).code();
5143 return FPRegister::Create(code, reg.SizeInBits());
5144 }
5145
5146
5147 CPURegister UseScratchRegisterScope::AcquireNextAvailable(
5148 CPURegList* available) {
5149 CHECK(!available->IsEmpty());
5150 CPURegister result = available->PopLowestIndex();
5151 ASSERT(!AreAliased(result, xzr, csp));
5152 return result;
5153 }
5154
5155
5156 void UseScratchRegisterScope::ReleaseByCode(CPURegList* available, int code) {
5157 ReleaseByRegList(available, static_cast<RegList>(1) << code);
5158 }
5159
5160
5161 void UseScratchRegisterScope::ReleaseByRegList(CPURegList* available,
5162 RegList regs) {
5163 available->set_list(available->list() | regs);
5164 }
5165
5166
5167 void UseScratchRegisterScope::IncludeByRegList(CPURegList* available,
5168 RegList regs) {
5169 available->set_list(available->list() | regs);
5170 }
5171
5172
5173 void UseScratchRegisterScope::ExcludeByRegList(CPURegList* available,
5174 RegList exclude) {
5175 available->set_list(available->list() & ~exclude);
5176 }
5177
5178
5034 #define __ masm-> 5179 #define __ masm->
5035 5180
5036 5181
5037 void InlineSmiCheckInfo::Emit(MacroAssembler* masm, const Register& reg, 5182 void InlineSmiCheckInfo::Emit(MacroAssembler* masm, const Register& reg,
5038 const Label* smi_check) { 5183 const Label* smi_check) {
5039 Assembler::BlockConstPoolScope scope(masm); 5184 Assembler::BlockConstPoolScope scope(masm);
5040 if (reg.IsValid()) { 5185 if (reg.IsValid()) {
5041 ASSERT(smi_check->is_bound()); 5186 ASSERT(smi_check->is_bound());
5042 ASSERT(reg.Is64Bits()); 5187 ASSERT(reg.Is64Bits());
5043 5188
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
5075 } 5220 }
5076 } 5221 }
5077 5222
5078 5223
5079 #undef __ 5224 #undef __
5080 5225
5081 5226
5082 } } // namespace v8::internal 5227 } } // namespace v8::internal
5083 5228
5084 #endif // V8_TARGET_ARCH_A64 5229 #endif // V8_TARGET_ARCH_A64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698