blob: 454fe9ee5106f39396ca24fff745598b5e45c2e2 [file] [log] [blame]
Ben Murdoch257744e2011-11-30 15:57:28 +00001// Copyright 2011 the V8 project authors. All rights reserved.
Andrei Popescu31002712010-02-23 13:46:05 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#ifndef V8_MIPS_MACRO_ASSEMBLER_MIPS_H_
29#define V8_MIPS_MACRO_ASSEMBLER_MIPS_H_
30
31#include "assembler.h"
32#include "mips/assembler-mips.h"
Ben Murdoch257744e2011-11-30 15:57:28 +000033#include "v8globals.h"
Andrei Popescu31002712010-02-23 13:46:05 +000034
35namespace v8 {
36namespace internal {
37
38// Forward declaration.
39class JumpTarget;
40
Steve Block44f0eee2011-05-26 01:26:41 +010041// Reserved Register Usage Summary.
42//
43// Registers t8, t9, and at are reserved for use by the MacroAssembler.
44//
45// The programmer should know that the MacroAssembler may clobber these three,
46// but won't touch other registers except in special cases.
47//
48// Per the MIPS ABI, register t9 must be used for indirect function call
49// via 'jalr t9' or 'jr t9' instructions. This is relied upon by gcc when
50// trying to update gp register for position-independent-code. Whenever
51// MIPS generated code calls C code, it must be via t9 register.
Andrei Popescu31002712010-02-23 13:46:05 +000052
Ben Murdoch592a9fc2012-03-05 11:04:45 +000053
54// Register aliases.
Steve Block6ded16b2010-05-10 14:33:55 +010055// cp is assumed to be a callee saved register.
Ben Murdoch592a9fc2012-03-05 11:04:45 +000056const Register lithiumScratchReg = s3; // Scratch register.
57const Register lithiumScratchReg2 = s4; // Scratch register.
58const Register condReg = s5; // Simulated (partial) condition code for mips.
Steve Block44f0eee2011-05-26 01:26:41 +010059const Register roots = s6; // Roots array pointer.
Ben Murdoch257744e2011-11-30 15:57:28 +000060const Register cp = s7; // JavaScript context pointer.
61const Register fp = s8_fp; // Alias for fp.
Ben Murdoch592a9fc2012-03-05 11:04:45 +000062const DoubleRegister lithiumScratchDouble = f30; // Double scratch register.
Steve Block44f0eee2011-05-26 01:26:41 +010063
64// Flags used for the AllocateInNewSpace functions.
65enum AllocationFlags {
66 // No special flags.
67 NO_ALLOCATION_FLAGS = 0,
68 // Return the pointer to the allocated already tagged as a heap object.
69 TAG_OBJECT = 1 << 0,
70 // The content of the result register already contains the allocation top in
71 // new space.
72 RESULT_CONTAINS_TOP = 1 << 1,
73 // Specify that the requested size of the space to allocate is specified in
74 // words instead of bytes.
75 SIZE_IN_WORDS = 1 << 2
76};
77
78// Flags used for the ObjectToDoubleFPURegister function.
79enum ObjectToDoubleFlags {
80 // No special flags.
81 NO_OBJECT_TO_DOUBLE_FLAGS = 0,
82 // Object is known to be a non smi.
83 OBJECT_NOT_SMI = 1 << 0,
84 // Don't load NaNs or infinities, branch to the non number case instead.
85 AVOID_NANS_AND_INFINITIES = 1 << 1
86};
87
88// Allow programmer to use Branch Delay Slot of Branches, Jumps, Calls.
89enum BranchDelaySlot {
90 USE_DELAY_SLOT,
91 PROTECT
92};
93
Ben Murdoch592a9fc2012-03-05 11:04:45 +000094
95enum RememberedSetAction { EMIT_REMEMBERED_SET, OMIT_REMEMBERED_SET };
96enum SmiCheck { INLINE_SMI_CHECK, OMIT_SMI_CHECK };
97enum RAStatus { kRAHasNotBeenSaved, kRAHasBeenSaved };
98
99bool AreAliased(Register r1, Register r2, Register r3, Register r4);
100
101
102// -----------------------------------------------------------------------------
103// Static helper functions.
104
105inline MemOperand ContextOperand(Register context, int index) {
106 return MemOperand(context, Context::SlotOffset(index));
107}
108
109
110inline MemOperand GlobalObjectOperand() {
111 return ContextOperand(cp, Context::GLOBAL_INDEX);
112}
113
114
115// Generate a MemOperand for loading a field from an object.
116inline MemOperand FieldMemOperand(Register object, int offset) {
117 return MemOperand(object, offset - kHeapObjectTag);
118}
119
120
121// Generate a MemOperand for storing arguments 5..N on the stack
122// when calling CallCFunction().
123inline MemOperand CFunctionArgumentOperand(int index) {
124 ASSERT(index > kCArgSlotCount);
125 // Argument 5 takes the slot just past the four Arg-slots.
126 int offset = (index - 5) * kPointerSize + kCArgsSlotsSize;
127 return MemOperand(sp, offset);
128}
129
130
Andrei Popescu31002712010-02-23 13:46:05 +0000131// MacroAssembler implements a collection of frequently used macros.
132class MacroAssembler: public Assembler {
133 public:
Ben Murdoch257744e2011-11-30 15:57:28 +0000134 // The isolate parameter can be NULL if the macro assembler should
135 // not use isolate-dependent functionality. In this case, it's the
136 // responsibility of the caller to never invoke such function on the
137 // macro assembler.
138 MacroAssembler(Isolate* isolate, void* buffer, int size);
Andrei Popescu31002712010-02-23 13:46:05 +0000139
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000140 // Arguments macros.
Steve Block44f0eee2011-05-26 01:26:41 +0100141#define COND_TYPED_ARGS Condition cond, Register r1, const Operand& r2
142#define COND_ARGS cond, r1, r2
143
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000144 // Cases when relocation is not needed.
Steve Block44f0eee2011-05-26 01:26:41 +0100145#define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \
146 void Name(target_type target, BranchDelaySlot bd = PROTECT); \
147 inline void Name(BranchDelaySlot bd, target_type target) { \
148 Name(target, bd); \
149 } \
150 void Name(target_type target, \
151 COND_TYPED_ARGS, \
152 BranchDelaySlot bd = PROTECT); \
153 inline void Name(BranchDelaySlot bd, \
154 target_type target, \
155 COND_TYPED_ARGS) { \
156 Name(target, COND_ARGS, bd); \
157 }
158
Steve Block44f0eee2011-05-26 01:26:41 +0100159#define DECLARE_BRANCH_PROTOTYPES(Name) \
160 DECLARE_NORELOC_PROTOTYPE(Name, Label*) \
161 DECLARE_NORELOC_PROTOTYPE(Name, int16_t)
162
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000163 DECLARE_BRANCH_PROTOTYPES(Branch)
164 DECLARE_BRANCH_PROTOTYPES(BranchAndLink)
Steve Block44f0eee2011-05-26 01:26:41 +0100165
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000166#undef DECLARE_BRANCH_PROTOTYPES
Steve Block44f0eee2011-05-26 01:26:41 +0100167#undef COND_TYPED_ARGS
168#undef COND_ARGS
Andrei Popescu31002712010-02-23 13:46:05 +0000169
Ben Murdoch257744e2011-11-30 15:57:28 +0000170
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000171 // Jump, Call, and Ret pseudo instructions implementing inter-working.
172#define COND_ARGS Condition cond = al, Register rs = zero_reg, \
173 const Operand& rt = Operand(zero_reg), BranchDelaySlot bd = PROTECT
174
175 void Jump(Register target, COND_ARGS);
176 void Jump(intptr_t target, RelocInfo::Mode rmode, COND_ARGS);
177 void Jump(Address target, RelocInfo::Mode rmode, COND_ARGS);
178 void Jump(Handle<Code> code, RelocInfo::Mode rmode, COND_ARGS);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000179 static int CallSize(Register target, COND_ARGS);
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000180 void Call(Register target, COND_ARGS);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000181 static int CallSize(Address target, RelocInfo::Mode rmode, COND_ARGS);
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000182 void Call(Address target, RelocInfo::Mode rmode, COND_ARGS);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000183 static int CallSize(Handle<Code> code,
184 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
185 unsigned ast_id = kNoASTId,
186 COND_ARGS);
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000187 void Call(Handle<Code> code,
188 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET,
189 unsigned ast_id = kNoASTId,
190 COND_ARGS);
191 void Ret(COND_ARGS);
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000192 inline void Ret(BranchDelaySlot bd, Condition cond = al,
193 Register rs = zero_reg, const Operand& rt = Operand(zero_reg)) {
194 Ret(cond, rs, rt, bd);
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000195 }
196
197#undef COND_ARGS
Ben Murdoch257744e2011-11-30 15:57:28 +0000198
Andrei Popescu31002712010-02-23 13:46:05 +0000199 // Emit code to discard a non-negative number of pointer-sized elements
200 // from the stack, clobbering only the sp register.
Steve Block44f0eee2011-05-26 01:26:41 +0100201 void Drop(int count,
202 Condition cond = cc_always,
203 Register reg = no_reg,
204 const Operand& op = Operand(no_reg));
205
206 void DropAndRet(int drop = 0,
207 Condition cond = cc_always,
208 Register reg = no_reg,
209 const Operand& op = Operand(no_reg));
210
211 // Swap two registers. If the scratch register is omitted then a slightly
212 // less efficient form using xor instead of mov is emitted.
213 void Swap(Register reg1, Register reg2, Register scratch = no_reg);
Andrei Popescu31002712010-02-23 13:46:05 +0000214
215 void Call(Label* target);
Steve Block44f0eee2011-05-26 01:26:41 +0100216
Ben Murdoch257744e2011-11-30 15:57:28 +0000217 inline void Move(Register dst, Register src) {
218 if (!dst.is(src)) {
219 mov(dst, src);
220 }
221 }
222
223 inline void Move(FPURegister dst, FPURegister src) {
224 if (!dst.is(src)) {
225 mov_d(dst, src);
226 }
227 }
228
229 inline void Move(Register dst_low, Register dst_high, FPURegister src) {
230 mfc1(dst_low, src);
231 mfc1(dst_high, FPURegister::from_code(src.code() + 1));
232 }
233
234 inline void Move(FPURegister dst, Register src_low, Register src_high) {
235 mtc1(src_low, dst);
236 mtc1(src_high, FPURegister::from_code(dst.code() + 1));
237 }
Andrei Popescu31002712010-02-23 13:46:05 +0000238
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000239 void Move(FPURegister dst, double imm);
240
Andrei Popescu31002712010-02-23 13:46:05 +0000241 // Jump unconditionally to given label.
242 // We NEED a nop in the branch delay slot, as it used by v8, for example in
243 // CodeGenerator::ProcessDeferred().
Steve Block6ded16b2010-05-10 14:33:55 +0100244 // Currently the branch delay slot is filled by the MacroAssembler.
Andrei Popescu31002712010-02-23 13:46:05 +0000245 // Use rather b(Label) for code generation.
246 void jmp(Label* L) {
Steve Block44f0eee2011-05-26 01:26:41 +0100247 Branch(L);
Andrei Popescu31002712010-02-23 13:46:05 +0000248 }
249
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000250
Andrei Popescu31002712010-02-23 13:46:05 +0000251 // Load an object from the root table.
252 void LoadRoot(Register destination,
253 Heap::RootListIndex index);
254 void LoadRoot(Register destination,
255 Heap::RootListIndex index,
256 Condition cond, Register src1, const Operand& src2);
257
Steve Block44f0eee2011-05-26 01:26:41 +0100258 // Store an object to the root table.
259 void StoreRoot(Register source,
260 Heap::RootListIndex index);
261 void StoreRoot(Register source,
262 Heap::RootListIndex index,
263 Condition cond, Register src1, const Operand& src2);
264
265
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000266 // ---------------------------------------------------------------------------
267 // GC Support
268
269 void IncrementalMarkingRecordWriteHelper(Register object,
270 Register value,
271 Register address);
272
273 enum RememberedSetFinalAction {
274 kReturnAtEnd,
275 kFallThroughAtEnd
276 };
Steve Block44f0eee2011-05-26 01:26:41 +0100277
278
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000279 // Record in the remembered set the fact that we have a pointer to new space
280 // at the address pointed to by the addr register. Only works if addr is not
281 // in new space.
282 void RememberedSetHelper(Register object, // Used for debug code.
283 Register addr,
284 Register scratch,
285 SaveFPRegsMode save_fp,
286 RememberedSetFinalAction and_then);
Steve Block44f0eee2011-05-26 01:26:41 +0100287
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000288 void CheckPageFlag(Register object,
289 Register scratch,
290 int mask,
291 Condition cc,
292 Label* condition_met);
293
294 // Check if object is in new space. Jumps if the object is not in new space.
295 // The register scratch can be object itself, but it will be clobbered.
296 void JumpIfNotInNewSpace(Register object,
297 Register scratch,
298 Label* branch) {
299 InNewSpace(object, scratch, ne, branch);
300 }
301
302 // Check if object is in new space. Jumps if the object is in new space.
303 // The register scratch can be object itself, but scratch will be clobbered.
304 void JumpIfInNewSpace(Register object,
305 Register scratch,
306 Label* branch) {
307 InNewSpace(object, scratch, eq, branch);
308 }
309
310 // Check if an object has a given incremental marking color.
311 void HasColor(Register object,
312 Register scratch0,
313 Register scratch1,
314 Label* has_color,
315 int first_bit,
316 int second_bit);
317
318 void JumpIfBlack(Register object,
Steve Block44f0eee2011-05-26 01:26:41 +0100319 Register scratch0,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000320 Register scratch1,
321 Label* on_black);
Steve Block44f0eee2011-05-26 01:26:41 +0100322
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000323 // Checks the color of an object. If the object is already grey or black
324 // then we just fall through, since it is already live. If it is white and
325 // we can determine that it doesn't need to be scanned, then we just mark it
326 // black and fall through. For the rest we jump to the label so the
327 // incremental marker can fix its assumptions.
328 void EnsureNotWhite(Register object,
329 Register scratch1,
330 Register scratch2,
331 Register scratch3,
332 Label* object_is_white_and_not_data);
333
334 // Detects conservatively whether an object is data-only, ie it does need to
335 // be scanned by the garbage collector.
336 void JumpIfDataObject(Register value,
337 Register scratch,
338 Label* not_data_object);
339
340 // Notify the garbage collector that we wrote a pointer into an object.
341 // |object| is the object being stored into, |value| is the object being
342 // stored. value and scratch registers are clobbered by the operation.
343 // The offset is the offset from the start of the object, not the offset from
344 // the tagged HeapObject pointer. For use with FieldOperand(reg, off).
345 void RecordWriteField(
346 Register object,
347 int offset,
348 Register value,
349 Register scratch,
350 RAStatus ra_status,
351 SaveFPRegsMode save_fp,
352 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
353 SmiCheck smi_check = INLINE_SMI_CHECK);
354
355 // As above, but the offset has the tag presubtracted. For use with
356 // MemOperand(reg, off).
357 inline void RecordWriteContextSlot(
358 Register context,
359 int offset,
360 Register value,
361 Register scratch,
362 RAStatus ra_status,
363 SaveFPRegsMode save_fp,
364 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
365 SmiCheck smi_check = INLINE_SMI_CHECK) {
366 RecordWriteField(context,
367 offset + kHeapObjectTag,
368 value,
369 scratch,
370 ra_status,
371 save_fp,
372 remembered_set_action,
373 smi_check);
374 }
375
376 // For a given |object| notify the garbage collector that the slot |address|
377 // has been written. |value| is the object being stored. The value and
378 // address registers are clobbered by the operation.
379 void RecordWrite(
380 Register object,
381 Register address,
382 Register value,
383 RAStatus ra_status,
384 SaveFPRegsMode save_fp,
385 RememberedSetAction remembered_set_action = EMIT_REMEMBERED_SET,
386 SmiCheck smi_check = INLINE_SMI_CHECK);
Steve Block44f0eee2011-05-26 01:26:41 +0100387
388
389 // ---------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000390 // Inline caching support.
Steve Block44f0eee2011-05-26 01:26:41 +0100391
392 // Generate code for checking access rights - used for security checks
393 // on access to global objects across environments. The holder register
394 // is left untouched, whereas both scratch registers are clobbered.
395 void CheckAccessGlobalProxy(Register holder_reg,
396 Register scratch,
397 Label* miss);
398
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000399
400 void LoadFromNumberDictionary(Label* miss,
401 Register elements,
402 Register key,
403 Register result,
404 Register reg0,
405 Register reg1,
406 Register reg2);
407
408
Steve Block44f0eee2011-05-26 01:26:41 +0100409 inline void MarkCode(NopMarkerTypes type) {
410 nop(type);
Steve Block6ded16b2010-05-10 14:33:55 +0100411 }
412
Steve Block44f0eee2011-05-26 01:26:41 +0100413 // Check if the given instruction is a 'type' marker.
414 // ie. check if it is a sll zero_reg, zero_reg, <type> (referenced as
415 // nop(type)). These instructions are generated to mark special location in
416 // the code, like some special IC code.
417 static inline bool IsMarkedCode(Instr instr, int type) {
418 ASSERT((FIRST_IC_MARKER <= type) && (type < LAST_CODE_MARKER));
419 return IsNop(instr, type);
420 }
Andrei Popescu31002712010-02-23 13:46:05 +0000421
422
Steve Block44f0eee2011-05-26 01:26:41 +0100423 static inline int GetCodeMarker(Instr instr) {
424 uint32_t opcode = ((instr & kOpcodeMask));
425 uint32_t rt = ((instr & kRtFieldMask) >> kRtShift);
426 uint32_t rs = ((instr & kRsFieldMask) >> kRsShift);
427 uint32_t sa = ((instr & kSaFieldMask) >> kSaShift);
428
429 // Return <n> if we have a sll zero_reg, zero_reg, n
430 // else return -1.
431 bool sllzz = (opcode == SLL &&
432 rt == static_cast<uint32_t>(ToNumber(zero_reg)) &&
433 rs == static_cast<uint32_t>(ToNumber(zero_reg)));
434 int type =
435 (sllzz && FIRST_IC_MARKER <= sa && sa < LAST_CODE_MARKER) ? sa : -1;
436 ASSERT((type == -1) ||
437 ((FIRST_IC_MARKER <= type) && (type < LAST_CODE_MARKER)));
438 return type;
439 }
440
441
442
443 // ---------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000444 // Allocation support.
Steve Block44f0eee2011-05-26 01:26:41 +0100445
446 // Allocate an object in new space. The object_size is specified
447 // either in bytes or in words if the allocation flag SIZE_IN_WORDS
448 // is passed. If the new space is exhausted control continues at the
449 // gc_required label. The allocated object is returned in result. If
450 // the flag tag_allocated_object is true the result is tagged as as
451 // a heap object. All registers are clobbered also when control
452 // continues at the gc_required label.
453 void AllocateInNewSpace(int object_size,
454 Register result,
455 Register scratch1,
456 Register scratch2,
457 Label* gc_required,
458 AllocationFlags flags);
459 void AllocateInNewSpace(Register object_size,
460 Register result,
461 Register scratch1,
462 Register scratch2,
463 Label* gc_required,
464 AllocationFlags flags);
465
466 // Undo allocation in new space. The object passed and objects allocated after
467 // it will no longer be allocated. The caller must make sure that no pointers
468 // are left to the object(s) no longer allocated as they would be invalid when
469 // allocation is undone.
470 void UndoAllocationInNewSpace(Register object, Register scratch);
471
472
473 void AllocateTwoByteString(Register result,
474 Register length,
475 Register scratch1,
476 Register scratch2,
477 Register scratch3,
478 Label* gc_required);
479 void AllocateAsciiString(Register result,
480 Register length,
481 Register scratch1,
482 Register scratch2,
483 Register scratch3,
484 Label* gc_required);
485 void AllocateTwoByteConsString(Register result,
486 Register length,
487 Register scratch1,
488 Register scratch2,
489 Label* gc_required);
490 void AllocateAsciiConsString(Register result,
491 Register length,
492 Register scratch1,
493 Register scratch2,
494 Label* gc_required);
Ben Murdoch589d6972011-11-30 16:04:58 +0000495 void AllocateTwoByteSlicedString(Register result,
496 Register length,
497 Register scratch1,
498 Register scratch2,
499 Label* gc_required);
500 void AllocateAsciiSlicedString(Register result,
501 Register length,
502 Register scratch1,
503 Register scratch2,
504 Label* gc_required);
Steve Block44f0eee2011-05-26 01:26:41 +0100505
506 // Allocates a heap number or jumps to the gc_required label if the young
507 // space is full and a scavenge is needed. All registers are clobbered also
508 // when control continues at the gc_required label.
509 void AllocateHeapNumber(Register result,
510 Register scratch1,
511 Register scratch2,
512 Register heap_number_map,
513 Label* gc_required);
514 void AllocateHeapNumberWithValue(Register result,
515 FPURegister value,
516 Register scratch1,
517 Register scratch2,
518 Label* gc_required);
519
Andrei Popescu31002712010-02-23 13:46:05 +0000520 // ---------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000521 // Instruction macros.
Andrei Popescu31002712010-02-23 13:46:05 +0000522
Steve Block44f0eee2011-05-26 01:26:41 +0100523#define DEFINE_INSTRUCTION(instr) \
Andrei Popescu31002712010-02-23 13:46:05 +0000524 void instr(Register rd, Register rs, const Operand& rt); \
525 void instr(Register rd, Register rs, Register rt) { \
526 instr(rd, rs, Operand(rt)); \
527 } \
528 void instr(Register rs, Register rt, int32_t j) { \
529 instr(rs, rt, Operand(j)); \
530 }
531
Steve Block44f0eee2011-05-26 01:26:41 +0100532#define DEFINE_INSTRUCTION2(instr) \
Andrei Popescu31002712010-02-23 13:46:05 +0000533 void instr(Register rs, const Operand& rt); \
534 void instr(Register rs, Register rt) { \
535 instr(rs, Operand(rt)); \
536 } \
537 void instr(Register rs, int32_t j) { \
538 instr(rs, Operand(j)); \
539 }
540
Andrei Popescu31002712010-02-23 13:46:05 +0000541 DEFINE_INSTRUCTION(Addu);
Steve Block44f0eee2011-05-26 01:26:41 +0100542 DEFINE_INSTRUCTION(Subu);
Andrei Popescu31002712010-02-23 13:46:05 +0000543 DEFINE_INSTRUCTION(Mul);
544 DEFINE_INSTRUCTION2(Mult);
545 DEFINE_INSTRUCTION2(Multu);
546 DEFINE_INSTRUCTION2(Div);
547 DEFINE_INSTRUCTION2(Divu);
548
549 DEFINE_INSTRUCTION(And);
550 DEFINE_INSTRUCTION(Or);
551 DEFINE_INSTRUCTION(Xor);
552 DEFINE_INSTRUCTION(Nor);
Ben Murdoch257744e2011-11-30 15:57:28 +0000553 DEFINE_INSTRUCTION2(Neg);
Andrei Popescu31002712010-02-23 13:46:05 +0000554
555 DEFINE_INSTRUCTION(Slt);
556 DEFINE_INSTRUCTION(Sltu);
557
Steve Block44f0eee2011-05-26 01:26:41 +0100558 // MIPS32 R2 instruction macro.
559 DEFINE_INSTRUCTION(Ror);
560
Andrei Popescu31002712010-02-23 13:46:05 +0000561#undef DEFINE_INSTRUCTION
562#undef DEFINE_INSTRUCTION2
563
564
Ben Murdoch257744e2011-11-30 15:57:28 +0000565 // ---------------------------------------------------------------------------
566 // Pseudo-instructions.
Andrei Popescu31002712010-02-23 13:46:05 +0000567
568 void mov(Register rd, Register rt) { or_(rd, rt, zero_reg); }
Andrei Popescu31002712010-02-23 13:46:05 +0000569
Ben Murdoch257744e2011-11-30 15:57:28 +0000570 // Load int32 in the rd register.
Andrei Popescu31002712010-02-23 13:46:05 +0000571 void li(Register rd, Operand j, bool gen2instr = false);
572 inline void li(Register rd, int32_t j, bool gen2instr = false) {
573 li(rd, Operand(j), gen2instr);
574 }
Steve Block44f0eee2011-05-26 01:26:41 +0100575 inline void li(Register dst, Handle<Object> value, bool gen2instr = false) {
576 li(dst, Operand(value), gen2instr);
577 }
Andrei Popescu31002712010-02-23 13:46:05 +0000578
Andrei Popescu31002712010-02-23 13:46:05 +0000579 // Push multiple registers on the stack.
Steve Block6ded16b2010-05-10 14:33:55 +0100580 // Registers are saved in numerical order, with higher numbered registers
Ben Murdoch257744e2011-11-30 15:57:28 +0000581 // saved in higher memory addresses.
Andrei Popescu31002712010-02-23 13:46:05 +0000582 void MultiPush(RegList regs);
583 void MultiPushReversed(RegList regs);
Steve Block44f0eee2011-05-26 01:26:41 +0100584
Ben Murdoch589d6972011-11-30 16:04:58 +0000585 void MultiPushFPU(RegList regs);
586 void MultiPushReversedFPU(RegList regs);
587
Ben Murdoch257744e2011-11-30 15:57:28 +0000588 // Lower case push() for compatibility with arch-independent code.
589 void push(Register src) {
Andrei Popescu31002712010-02-23 13:46:05 +0000590 Addu(sp, sp, Operand(-kPointerSize));
591 sw(src, MemOperand(sp, 0));
592 }
Steve Block44f0eee2011-05-26 01:26:41 +0100593
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000594 // Push a handle.
595 void Push(Handle<Object> handle);
596
Ben Murdoch257744e2011-11-30 15:57:28 +0000597 // Push two registers. Pushes leftmost register first (to highest address).
598 void Push(Register src1, Register src2) {
Steve Block44f0eee2011-05-26 01:26:41 +0100599 Subu(sp, sp, Operand(2 * kPointerSize));
600 sw(src1, MemOperand(sp, 1 * kPointerSize));
601 sw(src2, MemOperand(sp, 0 * kPointerSize));
602 }
603
Ben Murdoch257744e2011-11-30 15:57:28 +0000604 // Push three registers. Pushes leftmost register first (to highest address).
605 void Push(Register src1, Register src2, Register src3) {
606 Subu(sp, sp, Operand(3 * kPointerSize));
Steve Block44f0eee2011-05-26 01:26:41 +0100607 sw(src1, MemOperand(sp, 2 * kPointerSize));
608 sw(src2, MemOperand(sp, 1 * kPointerSize));
609 sw(src3, MemOperand(sp, 0 * kPointerSize));
610 }
611
Ben Murdoch257744e2011-11-30 15:57:28 +0000612 // Push four registers. Pushes leftmost register first (to highest address).
613 void Push(Register src1, Register src2, Register src3, Register src4) {
614 Subu(sp, sp, Operand(4 * kPointerSize));
Steve Block44f0eee2011-05-26 01:26:41 +0100615 sw(src1, MemOperand(sp, 3 * kPointerSize));
616 sw(src2, MemOperand(sp, 2 * kPointerSize));
617 sw(src3, MemOperand(sp, 1 * kPointerSize));
618 sw(src4, MemOperand(sp, 0 * kPointerSize));
619 }
620
Andrei Popescu31002712010-02-23 13:46:05 +0000621 void Push(Register src, Condition cond, Register tst1, Register tst2) {
Ben Murdoch257744e2011-11-30 15:57:28 +0000622 // Since we don't have conditional execution we use a Branch.
Steve Block44f0eee2011-05-26 01:26:41 +0100623 Branch(3, cond, tst1, Operand(tst2));
Ben Murdoch257744e2011-11-30 15:57:28 +0000624 Subu(sp, sp, Operand(kPointerSize));
Andrei Popescu31002712010-02-23 13:46:05 +0000625 sw(src, MemOperand(sp, 0));
626 }
627
628 // Pops multiple values from the stack and load them in the
629 // registers specified in regs. Pop order is the opposite as in MultiPush.
630 void MultiPop(RegList regs);
631 void MultiPopReversed(RegList regs);
Ben Murdoch257744e2011-11-30 15:57:28 +0000632
Ben Murdoch589d6972011-11-30 16:04:58 +0000633 void MultiPopFPU(RegList regs);
634 void MultiPopReversedFPU(RegList regs);
635
Ben Murdoch257744e2011-11-30 15:57:28 +0000636 // Lower case pop() for compatibility with arch-independent code.
637 void pop(Register dst) {
Andrei Popescu31002712010-02-23 13:46:05 +0000638 lw(dst, MemOperand(sp, 0));
639 Addu(sp, sp, Operand(kPointerSize));
640 }
Ben Murdoch257744e2011-11-30 15:57:28 +0000641
642 // Pop two registers. Pops rightmost register first (from lower address).
643 void Pop(Register src1, Register src2) {
644 ASSERT(!src1.is(src2));
645 lw(src2, MemOperand(sp, 0 * kPointerSize));
646 lw(src1, MemOperand(sp, 1 * kPointerSize));
647 Addu(sp, sp, 2 * kPointerSize);
648 }
649
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000650 // Pop three registers. Pops rightmost register first (from lower address).
651 void Pop(Register src1, Register src2, Register src3) {
652 lw(src3, MemOperand(sp, 0 * kPointerSize));
653 lw(src2, MemOperand(sp, 1 * kPointerSize));
654 lw(src1, MemOperand(sp, 2 * kPointerSize));
655 Addu(sp, sp, 3 * kPointerSize);
656 }
657
Steve Block44f0eee2011-05-26 01:26:41 +0100658 void Pop(uint32_t count = 1) {
659 Addu(sp, sp, Operand(count * kPointerSize));
Andrei Popescu31002712010-02-23 13:46:05 +0000660 }
661
Steve Block44f0eee2011-05-26 01:26:41 +0100662 // Push and pop the registers that can hold pointers, as defined by the
663 // RegList constant kSafepointSavedRegisters.
Ben Murdoch257744e2011-11-30 15:57:28 +0000664 void PushSafepointRegisters();
665 void PopSafepointRegisters();
666 void PushSafepointRegistersAndDoubles();
667 void PopSafepointRegistersAndDoubles();
668 // Store value in register src in the safepoint stack slot for
669 // register dst.
670 void StoreToSafepointRegisterSlot(Register src, Register dst);
671 void StoreToSafepointRegistersAndDoublesSlot(Register src, Register dst);
672 // Load the value of the src register from its safepoint stack slot
673 // into register dst.
674 void LoadFromSafepointRegisterSlot(Register dst, Register src);
Steve Block44f0eee2011-05-26 01:26:41 +0100675
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000676 // Flush the I-cache from asm code. You should use CPU::FlushICache from C.
677 // Does not handle errors.
678 void FlushICache(Register address, unsigned instructions);
679
Steve Block44f0eee2011-05-26 01:26:41 +0100680 // MIPS32 R2 instruction macro.
681 void Ins(Register rt, Register rs, uint16_t pos, uint16_t size);
682 void Ext(Register rt, Register rs, uint16_t pos, uint16_t size);
683
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000684 // ---------------------------------------------------------------------------
685 // FPU macros. These do not handle special cases like NaN or +- inf.
686
Steve Block44f0eee2011-05-26 01:26:41 +0100687 // Convert unsigned word to double.
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000688 void Cvt_d_uw(FPURegister fd, FPURegister fs, FPURegister scratch);
689 void Cvt_d_uw(FPURegister fd, Register rs, FPURegister scratch);
Steve Block44f0eee2011-05-26 01:26:41 +0100690
691 // Convert double to unsigned word.
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000692 void Trunc_uw_d(FPURegister fd, FPURegister fs, FPURegister scratch);
693 void Trunc_uw_d(FPURegister fd, Register rs, FPURegister scratch);
Steve Block44f0eee2011-05-26 01:26:41 +0100694
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000695 // Wrapper function for the different cmp/branch types.
696 void BranchF(Label* target,
697 Label* nan,
698 Condition cc,
699 FPURegister cmp1,
700 FPURegister cmp2,
701 BranchDelaySlot bd = PROTECT);
702
703 // Alternate (inline) version for better readability with USE_DELAY_SLOT.
704 inline void BranchF(BranchDelaySlot bd,
705 Label* target,
706 Label* nan,
707 Condition cc,
708 FPURegister cmp1,
709 FPURegister cmp2) {
710 BranchF(target, nan, cc, cmp1, cmp2, bd);
711 };
712
Steve Block44f0eee2011-05-26 01:26:41 +0100713 // Convert the HeapNumber pointed to by source to a 32bits signed integer
714 // dest. If the HeapNumber does not fit into a 32bits signed integer branch
715 // to not_int32 label. If FPU is available double_scratch is used but not
716 // scratch2.
717 void ConvertToInt32(Register source,
718 Register dest,
719 Register scratch,
720 Register scratch2,
721 FPURegister double_scratch,
722 Label *not_int32);
723
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000724 // Truncates a double using a specific rounding mode.
725 // The except_flag will contain any exceptions caused by the instruction.
726 // If check_inexact is kDontCheckForInexactConversion, then the inexacat
727 // exception is masked.
728 void EmitFPUTruncate(FPURoundingMode rounding_mode,
729 FPURegister result,
730 DoubleRegister double_input,
731 Register scratch1,
732 Register except_flag,
733 CheckForInexactConversion check_inexact
734 = kDontCheckForInexactConversion);
735
Ben Murdoch257744e2011-11-30 15:57:28 +0000736 // Helper for EmitECMATruncate.
737 // This will truncate a floating-point value outside of the singed 32bit
738 // integer range to a 32bit signed integer.
739 // Expects the double value loaded in input_high and input_low.
740 // Exits with the answer in 'result'.
741 // Note that this code does not work for values in the 32bit range!
742 void EmitOutOfInt32RangeTruncate(Register result,
743 Register input_high,
744 Register input_low,
745 Register scratch);
746
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000747 // Performs a truncating conversion of a floating point number as used by
748 // the JS bitwise operations. See ECMA-262 9.5: ToInt32.
749 // Exits with 'result' holding the answer and all other registers clobbered.
750 void EmitECMATruncate(Register result,
751 FPURegister double_input,
752 FPURegister single_scratch,
753 Register scratch,
754 Register scratch2,
755 Register scratch3);
756
Steve Block44f0eee2011-05-26 01:26:41 +0100757 // Enter exit frame.
Ben Murdoch257744e2011-11-30 15:57:28 +0000758 // argc - argument count to be dropped by LeaveExitFrame.
759 // save_doubles - saves FPU registers on stack, currently disabled.
760 // stack_space - extra stack space.
761 void EnterExitFrame(bool save_doubles,
762 int stack_space = 0);
Steve Block6ded16b2010-05-10 14:33:55 +0100763
Ben Murdoch257744e2011-11-30 15:57:28 +0000764 // Leave the current exit frame.
765 void LeaveExitFrame(bool save_doubles, Register arg_count);
Steve Block6ded16b2010-05-10 14:33:55 +0100766
Steve Block44f0eee2011-05-26 01:26:41 +0100767 // Get the actual activation frame alignment for target environment.
768 static int ActivationFrameAlignment();
Steve Block6ded16b2010-05-10 14:33:55 +0100769
Ben Murdoch257744e2011-11-30 15:57:28 +0000770 // Make sure the stack is aligned. Only emits code in debug mode.
771 void AssertStackIsAligned();
772
Steve Block44f0eee2011-05-26 01:26:41 +0100773 void LoadContext(Register dst, int context_chain_length);
Steve Block6ded16b2010-05-10 14:33:55 +0100774
Steve Block44f0eee2011-05-26 01:26:41 +0100775 void LoadGlobalFunction(int index, Register function);
776
777 // Load the initial map from the global function. The registers
778 // function and map can be the same, function is then overwritten.
779 void LoadGlobalFunctionInitialMap(Register function,
780 Register map,
781 Register scratch);
782
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000783
Steve Block44f0eee2011-05-26 01:26:41 +0100784 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000785 // JavaScript invokes.
786
787 // Setup call kind marking in t1. The method takes t1 as an
788 // explicit first parameter to make the code more readable at the
789 // call sites.
790 void SetCallKind(Register dst, CallKind kind);
Steve Block6ded16b2010-05-10 14:33:55 +0100791
792 // Invoke the JavaScript function code by either calling or jumping.
793 void InvokeCode(Register code,
794 const ParameterCount& expected,
795 const ParameterCount& actual,
Steve Block44f0eee2011-05-26 01:26:41 +0100796 InvokeFlag flag,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000797 const CallWrapper& call_wrapper,
798 CallKind call_kind);
Steve Block6ded16b2010-05-10 14:33:55 +0100799
800 void InvokeCode(Handle<Code> code,
801 const ParameterCount& expected,
802 const ParameterCount& actual,
803 RelocInfo::Mode rmode,
Ben Murdoch257744e2011-11-30 15:57:28 +0000804 InvokeFlag flag,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000805 CallKind call_kind);
Steve Block6ded16b2010-05-10 14:33:55 +0100806
807 // Invoke the JavaScript function in the given register. Changes the
808 // current context to the context in the function before invoking.
809 void InvokeFunction(Register function,
810 const ParameterCount& actual,
Steve Block44f0eee2011-05-26 01:26:41 +0100811 InvokeFlag flag,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000812 const CallWrapper& call_wrapper,
813 CallKind call_kind);
Steve Block44f0eee2011-05-26 01:26:41 +0100814
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000815 void InvokeFunction(Handle<JSFunction> function,
Steve Block44f0eee2011-05-26 01:26:41 +0100816 const ParameterCount& actual,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000817 InvokeFlag flag,
818 CallKind call_kind);
Steve Block6ded16b2010-05-10 14:33:55 +0100819
820
Steve Block44f0eee2011-05-26 01:26:41 +0100821 void IsObjectJSObjectType(Register heap_object,
822 Register map,
823 Register scratch,
824 Label* fail);
825
826 void IsInstanceJSObjectType(Register map,
827 Register scratch,
828 Label* fail);
829
830 void IsObjectJSStringType(Register object,
831 Register scratch,
832 Label* fail);
833
Steve Block6ded16b2010-05-10 14:33:55 +0100834#ifdef ENABLE_DEBUGGER_SUPPORT
Steve Block44f0eee2011-05-26 01:26:41 +0100835 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000836 // Debugger Support.
Steve Block6ded16b2010-05-10 14:33:55 +0100837
Steve Block6ded16b2010-05-10 14:33:55 +0100838 void DebugBreak();
839#endif
840
841
Steve Block44f0eee2011-05-26 01:26:41 +0100842 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +0000843 // Exception handling.
Andrei Popescu31002712010-02-23 13:46:05 +0000844
845 // Push a new try handler and link into try handler chain.
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000846 void PushTryHandler(CodeLocation try_location,
847 HandlerType type,
848 int handler_index);
Andrei Popescu31002712010-02-23 13:46:05 +0000849
850 // Unlink the stack handler on top of the stack from the try handler chain.
851 // Must preserve the result register.
852 void PopTryHandler();
853
Ben Murdoch257744e2011-11-30 15:57:28 +0000854 // Passes thrown value (in v0) to the handler of top of the try handler chain.
855 void Throw(Register value);
856
857 // Propagates an uncatchable exception to the top of the current JS stack's
858 // handler chain.
859 void ThrowUncatchable(UncatchableExceptionType type, Register value);
860
Steve Block44f0eee2011-05-26 01:26:41 +0100861 // Copies a fixed number of fields of heap objects from src to dst.
862 void CopyFields(Register dst, Register src, RegList temps, int field_count);
Andrei Popescu31002712010-02-23 13:46:05 +0000863
Ben Murdoch257744e2011-11-30 15:57:28 +0000864 // Copies a number of bytes from src to dst. All registers are clobbered. On
865 // exit src and dst will point to the place just after where the last byte was
866 // read or written and length will be zero.
867 void CopyBytes(Register src,
868 Register dst,
869 Register length,
870 Register scratch);
871
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000872 // Initialize fields with filler values. Fields starting at |start_offset|
873 // not including end_offset are overwritten with the value in |filler|. At
874 // the end the loop, |start_offset| takes the value of |end_offset|.
875 void InitializeFieldsWithFiller(Register start_offset,
876 Register end_offset,
877 Register filler);
878
Steve Block44f0eee2011-05-26 01:26:41 +0100879 // -------------------------------------------------------------------------
Andrei Popescu31002712010-02-23 13:46:05 +0000880 // Support functions.
881
Steve Block44f0eee2011-05-26 01:26:41 +0100882 // Try to get function prototype of a function and puts the value in
883 // the result register. Checks that the function really is a
884 // function and jumps to the miss label if the fast checks fail. The
885 // function register will be untouched; the other registers may be
886 // clobbered.
887 void TryGetFunctionPrototype(Register function,
888 Register result,
889 Register scratch,
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000890 Label* miss,
891 bool miss_on_bound_function = false);
Steve Block44f0eee2011-05-26 01:26:41 +0100892
Steve Block6ded16b2010-05-10 14:33:55 +0100893 void GetObjectType(Register function,
894 Register map,
895 Register type_reg);
896
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000897 // Check if a map for a JSObject indicates that the object has fast elements.
898 // Jump to the specified label if it does not.
899 void CheckFastElements(Register map,
900 Register scratch,
901 Label* fail);
902
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000903 // Check if a map for a JSObject indicates that the object can have both smi
904 // and HeapObject elements. Jump to the specified label if it does not.
905 void CheckFastObjectElements(Register map,
906 Register scratch,
907 Label* fail);
908
909 // Check if a map for a JSObject indicates that the object has fast smi only
910 // elements. Jump to the specified label if it does not.
911 void CheckFastSmiOnlyElements(Register map,
912 Register scratch,
913 Label* fail);
914
915 // Check to see if maybe_number can be stored as a double in
916 // FastDoubleElements. If it can, store it at the index specified by key in
917 // the FastDoubleElements array elements, otherwise jump to fail.
918 void StoreNumberToDoubleElements(Register value_reg,
919 Register key_reg,
920 Register receiver_reg,
921 Register elements_reg,
922 Register scratch1,
923 Register scratch2,
924 Register scratch3,
925 Register scratch4,
926 Label* fail);
927
Steve Block44f0eee2011-05-26 01:26:41 +0100928 // Check if the map of an object is equal to a specified map (either
929 // given directly or as an index into the root list) and branch to
930 // label if not. Skip the smi check if not required (object is known
Ben Murdoch257744e2011-11-30 15:57:28 +0000931 // to be a heap object).
Steve Block44f0eee2011-05-26 01:26:41 +0100932 void CheckMap(Register obj,
933 Register scratch,
934 Handle<Map> map,
935 Label* fail,
Ben Murdoch257744e2011-11-30 15:57:28 +0000936 SmiCheckType smi_check_type);
Andrei Popescu31002712010-02-23 13:46:05 +0000937
Steve Block44f0eee2011-05-26 01:26:41 +0100938 void CheckMap(Register obj,
939 Register scratch,
940 Heap::RootListIndex index,
941 Label* fail,
Ben Murdoch257744e2011-11-30 15:57:28 +0000942 SmiCheckType smi_check_type);
943
944 // Check if the map of an object is equal to a specified map and branch to a
945 // specified target if equal. Skip the smi check if not required (object is
946 // known to be a heap object)
947 void DispatchMap(Register obj,
948 Register scratch,
949 Handle<Map> map,
950 Handle<Code> success,
951 SmiCheckType smi_check_type);
Steve Block6ded16b2010-05-10 14:33:55 +0100952
953 // Generates code for reporting that an illegal operation has
954 // occurred.
955 void IllegalOperation(int num_arguments);
956
Ben Murdoch592a9fc2012-03-05 11:04:45 +0000957
958 // Load and check the instance type of an object for being a string.
959 // Loads the type into the second argument register.
960 // Returns a condition that will be enabled if the object was a string.
961 Condition IsObjectStringType(Register obj,
962 Register type,
963 Register result) {
964 lw(type, FieldMemOperand(obj, HeapObject::kMapOffset));
965 lbu(type, FieldMemOperand(type, Map::kInstanceTypeOffset));
966 And(type, type, Operand(kIsNotStringMask));
967 ASSERT_EQ(0, kStringTag);
968 return eq;
969 }
970
971
Steve Block44f0eee2011-05-26 01:26:41 +0100972 // Picks out an array index from the hash field.
973 // Register use:
974 // hash - holds the index's hash. Clobbered.
975 // index - holds the overwritten index on exit.
976 void IndexFromHash(Register hash, Register index);
Andrei Popescu31002712010-02-23 13:46:05 +0000977
Ben Murdoch257744e2011-11-30 15:57:28 +0000978 // Get the number of least significant bits from a register.
979 void GetLeastBitsFromSmi(Register dst, Register src, int num_least_bits);
980 void GetLeastBitsFromInt32(Register dst, Register src, int mun_least_bits);
981
Steve Block44f0eee2011-05-26 01:26:41 +0100982 // Load the value of a number object into a FPU double register. If the
983 // object is not a number a jump to the label not_number is performed
984 // and the FPU double register is unchanged.
985 void ObjectToDoubleFPURegister(
986 Register object,
987 FPURegister value,
988 Register scratch1,
989 Register scratch2,
990 Register heap_number_map,
991 Label* not_number,
992 ObjectToDoubleFlags flags = NO_OBJECT_TO_DOUBLE_FLAGS);
993
994 // Load the value of a smi object into a FPU double register. The register
995 // scratch1 can be the same register as smi in which case smi will hold the
996 // untagged value afterwards.
997 void SmiToDoubleFPURegister(Register smi,
998 FPURegister value,
999 Register scratch1);
1000
1001 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001002 // Overflow handling functions.
1003 // Usage: first call the appropriate arithmetic function, then call one of the
1004 // jump functions with the overflow_dst register as the second parameter.
1005
1006 void AdduAndCheckForOverflow(Register dst,
1007 Register left,
1008 Register right,
1009 Register overflow_dst,
1010 Register scratch = at);
1011
1012 void SubuAndCheckForOverflow(Register dst,
1013 Register left,
1014 Register right,
1015 Register overflow_dst,
1016 Register scratch = at);
1017
1018 void BranchOnOverflow(Label* label,
1019 Register overflow_check,
1020 BranchDelaySlot bd = PROTECT) {
1021 Branch(label, lt, overflow_check, Operand(zero_reg), bd);
1022 }
1023
1024 void BranchOnNoOverflow(Label* label,
1025 Register overflow_check,
1026 BranchDelaySlot bd = PROTECT) {
1027 Branch(label, ge, overflow_check, Operand(zero_reg), bd);
1028 }
1029
1030 void RetOnOverflow(Register overflow_check, BranchDelaySlot bd = PROTECT) {
1031 Ret(lt, overflow_check, Operand(zero_reg), bd);
1032 }
1033
1034 void RetOnNoOverflow(Register overflow_check, BranchDelaySlot bd = PROTECT) {
1035 Ret(ge, overflow_check, Operand(zero_reg), bd);
1036 }
1037
1038 // -------------------------------------------------------------------------
1039 // Runtime calls.
Andrei Popescu31002712010-02-23 13:46:05 +00001040
1041 // Call a code stub.
1042 void CallStub(CodeStub* stub, Condition cond = cc_always,
1043 Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
Steve Block44f0eee2011-05-26 01:26:41 +01001044
1045 // Tail call a code stub (jump).
1046 void TailCallStub(CodeStub* stub);
1047
Andrei Popescu31002712010-02-23 13:46:05 +00001048 void CallJSExitStub(CodeStub* stub);
1049
Andrei Popescu31002712010-02-23 13:46:05 +00001050 // Call a runtime routine.
Steve Block44f0eee2011-05-26 01:26:41 +01001051 void CallRuntime(const Runtime::Function* f, int num_arguments);
1052 void CallRuntimeSaveDoubles(Runtime::FunctionId id);
Andrei Popescu31002712010-02-23 13:46:05 +00001053
1054 // Convenience function: Same as above, but takes the fid instead.
1055 void CallRuntime(Runtime::FunctionId fid, int num_arguments);
1056
Steve Block44f0eee2011-05-26 01:26:41 +01001057 // Convenience function: call an external reference.
1058 void CallExternalReference(const ExternalReference& ext,
1059 int num_arguments);
1060
Andrei Popescu31002712010-02-23 13:46:05 +00001061 // Tail call of a runtime routine (jump).
Steve Block6ded16b2010-05-10 14:33:55 +01001062 // Like JumpToExternalReference, but also takes care of passing the number
Andrei Popescu31002712010-02-23 13:46:05 +00001063 // of parameters.
Steve Block6ded16b2010-05-10 14:33:55 +01001064 void TailCallExternalReference(const ExternalReference& ext,
1065 int num_arguments,
1066 int result_size);
1067
1068 // Convenience function: tail call a runtime routine (jump).
1069 void TailCallRuntime(Runtime::FunctionId fid,
Andrei Popescu31002712010-02-23 13:46:05 +00001070 int num_arguments,
1071 int result_size);
1072
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001073 int CalculateStackPassedWords(int num_reg_arguments,
1074 int num_double_arguments);
1075
Steve Block44f0eee2011-05-26 01:26:41 +01001076 // Before calling a C-function from generated code, align arguments on stack
1077 // and add space for the four mips argument slots.
1078 // After aligning the frame, non-register arguments must be stored on the
1079 // stack, after the argument-slots using helper: CFunctionArgumentOperand().
1080 // The argument count assumes all arguments are word sized.
1081 // Some compilers/platforms require the stack to be aligned when calling
1082 // C++ code.
1083 // Needs a scratch register to do some arithmetic. This register will be
1084 // trashed.
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001085 void PrepareCallCFunction(int num_reg_arguments,
1086 int num_double_registers,
1087 Register scratch);
1088 void PrepareCallCFunction(int num_reg_arguments,
1089 Register scratch);
Steve Block44f0eee2011-05-26 01:26:41 +01001090
1091 // Arguments 1-4 are placed in registers a0 thru a3 respectively.
1092 // Arguments 5..n are stored to stack using following:
1093 // sw(t0, CFunctionArgumentOperand(5));
1094
1095 // Calls a C function and cleans up the space for arguments allocated
1096 // by PrepareCallCFunction. The called function is not allowed to trigger a
1097 // garbage collection, since that might move the code and invalidate the
1098 // return address (unless this is somehow accounted for by the called
1099 // function).
1100 void CallCFunction(ExternalReference function, int num_arguments);
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001101 void CallCFunction(Register function, int num_arguments);
1102 void CallCFunction(ExternalReference function,
1103 int num_reg_arguments,
1104 int num_double_arguments);
1105 void CallCFunction(Register function,
1106 int num_reg_arguments,
1107 int num_double_arguments);
Ben Murdoch257744e2011-11-30 15:57:28 +00001108 void GetCFunctionDoubleResult(const DoubleRegister dst);
1109
1110 // There are two ways of passing double arguments on MIPS, depending on
1111 // whether soft or hard floating point ABI is used. These functions
1112 // abstract parameter passing for the three different ways we call
1113 // C functions from generated code.
1114 void SetCallCDoubleArguments(DoubleRegister dreg);
1115 void SetCallCDoubleArguments(DoubleRegister dreg1, DoubleRegister dreg2);
1116 void SetCallCDoubleArguments(DoubleRegister dreg, Register reg);
1117
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001118 // Calls an API function. Allocates HandleScope, extracts returned value
1119 // from handle and propagates exceptions. Restores context. stack_space
1120 // - space to be unwound on exit (includes the call js arguments space and
1121 // the additional space allocated for the fast call).
1122 void CallApiFunctionAndReturn(ExternalReference function, int stack_space);
Steve Block44f0eee2011-05-26 01:26:41 +01001123
Andrei Popescu31002712010-02-23 13:46:05 +00001124 // Jump to the builtin routine.
Steve Block6ded16b2010-05-10 14:33:55 +01001125 void JumpToExternalReference(const ExternalReference& builtin);
Andrei Popescu31002712010-02-23 13:46:05 +00001126
1127 // Invoke specified builtin JavaScript function. Adds an entry to
1128 // the unresolved list if the name does not resolve.
Steve Block44f0eee2011-05-26 01:26:41 +01001129 void InvokeBuiltin(Builtins::JavaScript id,
Ben Murdoch257744e2011-11-30 15:57:28 +00001130 InvokeFlag flag,
1131 const CallWrapper& call_wrapper = NullCallWrapper());
Andrei Popescu31002712010-02-23 13:46:05 +00001132
1133 // Store the code object for the given builtin in the target register and
Steve Block44f0eee2011-05-26 01:26:41 +01001134 // setup the function in a1.
Andrei Popescu31002712010-02-23 13:46:05 +00001135 void GetBuiltinEntry(Register target, Builtins::JavaScript id);
1136
Steve Block44f0eee2011-05-26 01:26:41 +01001137 // Store the function for the given builtin in the target register.
1138 void GetBuiltinFunction(Register target, Builtins::JavaScript id);
1139
Andrei Popescu31002712010-02-23 13:46:05 +00001140 struct Unresolved {
1141 int pc;
Ben Murdoch257744e2011-11-30 15:57:28 +00001142 uint32_t flags; // See Bootstrapper::FixupFlags decoders/encoders.
Andrei Popescu31002712010-02-23 13:46:05 +00001143 const char* name;
1144 };
Andrei Popescu31002712010-02-23 13:46:05 +00001145
Ben Murdoch257744e2011-11-30 15:57:28 +00001146 Handle<Object> CodeObject() {
1147 ASSERT(!code_object_.is_null());
1148 return code_object_;
1149 }
Andrei Popescu31002712010-02-23 13:46:05 +00001150
Steve Block44f0eee2011-05-26 01:26:41 +01001151 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001152 // StatsCounter support.
Andrei Popescu31002712010-02-23 13:46:05 +00001153
1154 void SetCounter(StatsCounter* counter, int value,
1155 Register scratch1, Register scratch2);
1156 void IncrementCounter(StatsCounter* counter, int value,
1157 Register scratch1, Register scratch2);
1158 void DecrementCounter(StatsCounter* counter, int value,
1159 Register scratch1, Register scratch2);
1160
1161
Steve Block44f0eee2011-05-26 01:26:41 +01001162 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001163 // Debugging.
Andrei Popescu31002712010-02-23 13:46:05 +00001164
1165 // Calls Abort(msg) if the condition cc is not satisfied.
1166 // Use --debug_code to enable.
1167 void Assert(Condition cc, const char* msg, Register rs, Operand rt);
Steve Block44f0eee2011-05-26 01:26:41 +01001168 void AssertRegisterIsRoot(Register reg, Heap::RootListIndex index);
1169 void AssertFastElements(Register elements);
Andrei Popescu31002712010-02-23 13:46:05 +00001170
1171 // Like Assert(), but always enabled.
1172 void Check(Condition cc, const char* msg, Register rs, Operand rt);
1173
1174 // Print a message to stdout and abort execution.
1175 void Abort(const char* msg);
1176
1177 // Verify restrictions about code generated in stubs.
1178 void set_generating_stub(bool value) { generating_stub_ = value; }
1179 bool generating_stub() { return generating_stub_; }
1180 void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; }
1181 bool allow_stub_calls() { return allow_stub_calls_; }
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001182 void set_has_frame(bool value) { has_frame_ = value; }
1183 bool has_frame() { return has_frame_; }
1184 inline bool AllowThisStubCall(CodeStub* stub);
Andrei Popescu31002712010-02-23 13:46:05 +00001185
Steve Block44f0eee2011-05-26 01:26:41 +01001186 // ---------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001187 // Number utilities.
Steve Block6ded16b2010-05-10 14:33:55 +01001188
Steve Block44f0eee2011-05-26 01:26:41 +01001189 // Check whether the value of reg is a power of two and not zero. If not
1190 // control continues at the label not_power_of_two. If reg is a power of two
1191 // the register scratch contains the value of (reg - 1) when control falls
1192 // through.
1193 void JumpIfNotPowerOfTwoOrZero(Register reg,
1194 Register scratch,
1195 Label* not_power_of_two_or_zero);
1196
1197 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001198 // Smi utilities.
Steve Block44f0eee2011-05-26 01:26:41 +01001199
1200 // Try to convert int32 to smi. If the value is to large, preserve
1201 // the original value and jump to not_a_smi. Destroys scratch and
1202 // sets flags.
1203 // This is only used by crankshaft atm so it is unimplemented on MIPS.
1204 void TrySmiTag(Register reg, Label* not_a_smi, Register scratch) {
1205 UNIMPLEMENTED_MIPS();
1206 }
1207
1208 void SmiTag(Register reg) {
1209 Addu(reg, reg, reg);
1210 }
1211
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001212 // Test for overflow < 0: use BranchOnOverflow() or BranchOnNoOverflow().
1213 void SmiTagCheckOverflow(Register reg, Register overflow) {
1214 mov(overflow, reg); // Save original value.
1215 addu(reg, reg, reg);
1216 xor_(overflow, overflow, reg); // Overflow if (value ^ 2 * value) < 0.
1217 }
1218
Steve Block44f0eee2011-05-26 01:26:41 +01001219 void SmiTag(Register dst, Register src) {
1220 Addu(dst, src, src);
1221 }
1222
1223 void SmiUntag(Register reg) {
1224 sra(reg, reg, kSmiTagSize);
1225 }
1226
1227 void SmiUntag(Register dst, Register src) {
1228 sra(dst, src, kSmiTagSize);
1229 }
1230
1231 // Jump the register contains a smi.
1232 inline void JumpIfSmi(Register value, Label* smi_label,
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001233 Register scratch = at,
1234 BranchDelaySlot bd = PROTECT) {
Steve Block44f0eee2011-05-26 01:26:41 +01001235 ASSERT_EQ(0, kSmiTag);
1236 andi(scratch, value, kSmiTagMask);
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001237 Branch(bd, smi_label, eq, scratch, Operand(zero_reg));
Steve Block44f0eee2011-05-26 01:26:41 +01001238 }
1239
1240 // Jump if the register contains a non-smi.
1241 inline void JumpIfNotSmi(Register value, Label* not_smi_label,
1242 Register scratch = at) {
1243 ASSERT_EQ(0, kSmiTag);
1244 andi(scratch, value, kSmiTagMask);
1245 Branch(not_smi_label, ne, scratch, Operand(zero_reg));
1246 }
1247
1248 // Jump if either of the registers contain a non-smi.
1249 void JumpIfNotBothSmi(Register reg1, Register reg2, Label* on_not_both_smi);
1250 // Jump if either of the registers contain a smi.
1251 void JumpIfEitherSmi(Register reg1, Register reg2, Label* on_either_smi);
1252
1253 // Abort execution if argument is a smi. Used in debug code.
1254 void AbortIfSmi(Register object);
1255 void AbortIfNotSmi(Register object);
1256
Ben Murdoch257744e2011-11-30 15:57:28 +00001257 // Abort execution if argument is a string. Used in debug code.
1258 void AbortIfNotString(Register object);
1259
Steve Block44f0eee2011-05-26 01:26:41 +01001260 // Abort execution if argument is not the root value with the given index.
1261 void AbortIfNotRootValue(Register src,
1262 Heap::RootListIndex root_value_index,
1263 const char* message);
1264
1265 // ---------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001266 // HeapNumber utilities.
Steve Block44f0eee2011-05-26 01:26:41 +01001267
1268 void JumpIfNotHeapNumber(Register object,
1269 Register heap_number_map,
1270 Register scratch,
1271 Label* on_not_heap_number);
1272
1273 // -------------------------------------------------------------------------
Ben Murdoch257744e2011-11-30 15:57:28 +00001274 // String utilities.
Steve Block44f0eee2011-05-26 01:26:41 +01001275
1276 // Checks if both instance types are sequential ASCII strings and jumps to
1277 // label if either is not.
1278 void JumpIfBothInstanceTypesAreNotSequentialAscii(
1279 Register first_object_instance_type,
1280 Register second_object_instance_type,
1281 Register scratch1,
1282 Register scratch2,
1283 Label* failure);
1284
1285 // Check if instance type is sequential ASCII string and jump to label if
1286 // it is not.
1287 void JumpIfInstanceTypeIsNotSequentialAscii(Register type,
1288 Register scratch,
1289 Label* failure);
1290
1291 // Test that both first and second are sequential ASCII strings.
1292 // Assume that they are non-smis.
1293 void JumpIfNonSmisNotBothSequentialAsciiStrings(Register first,
1294 Register second,
1295 Register scratch1,
1296 Register scratch2,
1297 Label* failure);
1298
1299 // Test that both first and second are sequential ASCII strings.
1300 // Check that they are non-smis.
1301 void JumpIfNotBothSequentialAsciiStrings(Register first,
1302 Register second,
1303 Register scratch1,
1304 Register scratch2,
1305 Label* failure);
1306
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001307 void ClampUint8(Register output_reg, Register input_reg);
1308
1309 void ClampDoubleToUint8(Register result_reg,
1310 DoubleRegister input_reg,
1311 DoubleRegister temp_double_reg);
1312
1313
Ben Murdoch257744e2011-11-30 15:57:28 +00001314 void LoadInstanceDescriptors(Register map, Register descriptors);
1315
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001316
1317 // Activation support.
1318 void EnterFrame(StackFrame::Type type);
1319 void LeaveFrame(StackFrame::Type type);
1320
1321 // Patch the relocated value (lui/ori pair).
1322 void PatchRelocatedValue(Register li_location,
1323 Register scratch,
1324 Register new_value);
1325 // Get the relocatad value (loaded data) from the lui/ori pair.
1326 void GetRelocatedValue(Register li_location,
1327 Register value,
1328 Register scratch);
1329
Steve Block44f0eee2011-05-26 01:26:41 +01001330 private:
1331 void CallCFunctionHelper(Register function,
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001332 int num_reg_arguments,
1333 int num_double_arguments);
Steve Block44f0eee2011-05-26 01:26:41 +01001334
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001335 void BranchShort(int16_t offset, BranchDelaySlot bdslot = PROTECT);
1336 void BranchShort(int16_t offset, Condition cond, Register rs,
1337 const Operand& rt,
1338 BranchDelaySlot bdslot = PROTECT);
1339 void BranchShort(Label* L, BranchDelaySlot bdslot = PROTECT);
1340 void BranchShort(Label* L, Condition cond, Register rs,
1341 const Operand& rt,
1342 BranchDelaySlot bdslot = PROTECT);
1343 void BranchAndLinkShort(int16_t offset, BranchDelaySlot bdslot = PROTECT);
1344 void BranchAndLinkShort(int16_t offset, Condition cond, Register rs,
1345 const Operand& rt,
1346 BranchDelaySlot bdslot = PROTECT);
1347 void BranchAndLinkShort(Label* L, BranchDelaySlot bdslot = PROTECT);
1348 void BranchAndLinkShort(Label* L, Condition cond, Register rs,
1349 const Operand& rt,
1350 BranchDelaySlot bdslot = PROTECT);
1351 void J(Label* L, BranchDelaySlot bdslot);
1352 void Jr(Label* L, BranchDelaySlot bdslot);
1353 void Jalr(Label* L, BranchDelaySlot bdslot);
Steve Block6ded16b2010-05-10 14:33:55 +01001354
1355 // Helper functions for generating invokes.
1356 void InvokePrologue(const ParameterCount& expected,
1357 const ParameterCount& actual,
1358 Handle<Code> code_constant,
1359 Register code_reg,
1360 Label* done,
Steve Block44f0eee2011-05-26 01:26:41 +01001361 InvokeFlag flag,
Ben Murdoch3fb3ca82011-12-02 17:19:32 +00001362 const CallWrapper& call_wrapper,
1363 CallKind call_kind);
Steve Block6ded16b2010-05-10 14:33:55 +01001364
1365 // Get the code for the given builtin. Returns if able to resolve
1366 // the function in the 'resolved' flag.
1367 Handle<Code> ResolveBuiltin(Builtins::JavaScript id, bool* resolved);
1368
Steve Block44f0eee2011-05-26 01:26:41 +01001369 void InitializeNewString(Register string,
1370 Register length,
1371 Heap::RootListIndex map_index,
1372 Register scratch1,
1373 Register scratch2);
1374
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001375 // Helper for implementing JumpIfNotInNewSpace and JumpIfInNewSpace.
1376 void InNewSpace(Register object,
1377 Register scratch,
1378 Condition cond, // eq for new space, ne otherwise.
1379 Label* branch);
1380
1381 // Helper for finding the mark bits for an address. Afterwards, the
1382 // bitmap register points at the word with the mark bits and the mask
1383 // the position of the first bit. Leaves addr_reg unchanged.
1384 inline void GetMarkBits(Register addr_reg,
1385 Register bitmap_reg,
1386 Register mask_reg);
1387
1388 // Helper for throwing exceptions. Compute a handler address and jump to
1389 // it. See the implementation for register usage.
1390 void JumpToHandlerEntry();
1391
Ben Murdoch257744e2011-11-30 15:57:28 +00001392 // Compute memory operands for safepoint stack slots.
1393 static int SafepointRegisterStackIndex(int reg_code);
1394 MemOperand SafepointRegisterSlot(Register reg);
1395 MemOperand SafepointRegistersAndDoublesSlot(Register reg);
Steve Block44f0eee2011-05-26 01:26:41 +01001396
1397 bool generating_stub_;
1398 bool allow_stub_calls_;
Ben Murdoch592a9fc2012-03-05 11:04:45 +00001399 bool has_frame_;
Steve Block44f0eee2011-05-26 01:26:41 +01001400 // This handle will be patched with the code object on installation.
1401 Handle<Object> code_object_;
Ben Murdoch257744e2011-11-30 15:57:28 +00001402
1403 // Needs access to SafepointRegisterStackIndex for optimized frame
1404 // traversal.
1405 friend class OptimizedFrame;
Steve Block44f0eee2011-05-26 01:26:41 +01001406};
1407
1408
Steve Block44f0eee2011-05-26 01:26:41 +01001409// The code patcher is used to patch (typically) small parts of code e.g. for
1410// debugging and other types of instrumentation. When using the code patcher
1411// the exact number of bytes specified must be emitted. It is not legal to emit
1412// relocation information. If any of these constraints are violated it causes
1413// an assertion to fail.
1414class CodePatcher {
1415 public:
1416 CodePatcher(byte* address, int instructions);
1417 virtual ~CodePatcher();
1418
1419 // Macro assembler to emit code.
1420 MacroAssembler* masm() { return &masm_; }
1421
1422 // Emit an instruction directly.
Ben Murdoch257744e2011-11-30 15:57:28 +00001423 void Emit(Instr instr);
Steve Block44f0eee2011-05-26 01:26:41 +01001424
1425 // Emit an address directly.
1426 void Emit(Address addr);
1427
Ben Murdoch257744e2011-11-30 15:57:28 +00001428 // Change the condition part of an instruction leaving the rest of the current
1429 // instruction unchanged.
1430 void ChangeBranchCondition(Condition cond);
1431
Steve Block44f0eee2011-05-26 01:26:41 +01001432 private:
1433 byte* address_; // The address of the code being patched.
1434 int instructions_; // Number of instructions of the expected patch size.
1435 int size_; // Number of bytes of the expected patch size.
1436 MacroAssembler masm_; // Macro assembler used to generate the code.
1437};
Andrei Popescu31002712010-02-23 13:46:05 +00001438
1439
Andrei Popescu31002712010-02-23 13:46:05 +00001440
1441#ifdef GENERATED_CODE_COVERAGE
1442#define CODE_COVERAGE_STRINGIFY(x) #x
1443#define CODE_COVERAGE_TOSTRING(x) CODE_COVERAGE_STRINGIFY(x)
1444#define __FILE_LINE__ __FILE__ ":" CODE_COVERAGE_TOSTRING(__LINE__)
1445#define ACCESS_MASM(masm) masm->stop(__FILE_LINE__); masm->
1446#else
1447#define ACCESS_MASM(masm) masm->
1448#endif
1449
1450} } // namespace v8::internal
1451
1452#endif // V8_MIPS_MACRO_ASSEMBLER_MIPS_H_