| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 srl(rd, rs, 0); | 761 srl(rd, rs, 0); |
| 762 } else { | 762 } else { |
| 763 srl(at, rs, rt.imm32_); | 763 srl(at, rs, rt.imm32_); |
| 764 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f); | 764 sll(rd, rs, (0x20 - rt.imm32_) & 0x1f); |
| 765 or_(rd, rd, at); | 765 or_(rd, rd, at); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 } | 768 } |
| 769 } | 769 } |
| 770 | 770 |
| 771 | |
| 772 //------------Pseudo-instructions------------- | 771 //------------Pseudo-instructions------------- |
| 773 | 772 |
| 774 void MacroAssembler::li(Register rd, Operand j, bool gen2instr) { | 773 void MacroAssembler::li(Register rd, Operand j, LiFlags mode) { |
| 775 ASSERT(!j.is_reg()); | 774 ASSERT(!j.is_reg()); |
| 776 BlockTrampolinePoolScope block_trampoline_pool(this); | 775 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 777 if (!MustUseReg(j.rmode_) && !gen2instr) { | 776 if (!MustUseReg(j.rmode_) && mode == OPTIMIZE_SIZE) { |
| 778 // Normal load of an immediate value which does not need Relocation Info. | 777 // Normal load of an immediate value which does not need Relocation Info. |
| 779 if (is_int16(j.imm32_)) { | 778 if (is_int16(j.imm32_)) { |
| 780 addiu(rd, zero_reg, j.imm32_); | 779 addiu(rd, zero_reg, j.imm32_); |
| 781 } else if (!(j.imm32_ & kHiMask)) { | 780 } else if (!(j.imm32_ & kHiMask)) { |
| 782 ori(rd, zero_reg, j.imm32_); | 781 ori(rd, zero_reg, j.imm32_); |
| 783 } else if (!(j.imm32_ & kImm16Mask)) { | 782 } else if (!(j.imm32_ & kImm16Mask)) { |
| 784 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); | 783 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); |
| 785 } else { | 784 } else { |
| 786 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); | 785 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); |
| 787 ori(rd, rd, (j.imm32_ & kImm16Mask)); | 786 ori(rd, rd, (j.imm32_ & kImm16Mask)); |
| 788 } | 787 } |
| 789 } else if (MustUseReg(j.rmode_) || gen2instr) { | 788 } else { |
| 790 if (MustUseReg(j.rmode_)) { | 789 if (MustUseReg(j.rmode_)) { |
| 791 RecordRelocInfo(j.rmode_, j.imm32_); | 790 RecordRelocInfo(j.rmode_, j.imm32_); |
| 792 } | 791 } |
| 793 // We always need the same number of instructions as we may need to patch | 792 // We always need the same number of instructions as we may need to patch |
| 794 // this code to load another value which may need 2 instructions to load. | 793 // this code to load another value which may need 2 instructions to load. |
| 795 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); | 794 lui(rd, (j.imm32_ >> kLuiShift) & kImm16Mask); |
| 796 ori(rd, rd, (j.imm32_ & kImm16Mask)); | 795 ori(rd, rd, (j.imm32_ & kImm16Mask)); |
| 797 } | 796 } |
| 798 } | 797 } |
| 799 | 798 |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1640 BranchShort(&skip, neg_cond, rs, rt); | 1639 BranchShort(&skip, neg_cond, rs, rt); |
| 1641 Jr(L, bdslot); | 1640 Jr(L, bdslot); |
| 1642 bind(&skip); | 1641 bind(&skip); |
| 1643 } else { | 1642 } else { |
| 1644 BranchShort(L, cond, rs, rt, bdslot); | 1643 BranchShort(L, cond, rs, rt, bdslot); |
| 1645 } | 1644 } |
| 1646 } | 1645 } |
| 1647 } | 1646 } |
| 1648 | 1647 |
| 1649 | 1648 |
| 1649 void MacroAssembler::Branch(Label* L, |
| 1650 Condition cond, |
| 1651 Register rs, |
| 1652 Heap::RootListIndex index, |
| 1653 BranchDelaySlot bdslot) { |
| 1654 LoadRoot(at, index); |
| 1655 Branch(L, cond, rs, Operand(at), bdslot); |
| 1656 } |
| 1657 |
| 1658 |
| 1650 void MacroAssembler::BranchShort(int16_t offset, BranchDelaySlot bdslot) { | 1659 void MacroAssembler::BranchShort(int16_t offset, BranchDelaySlot bdslot) { |
| 1651 b(offset); | 1660 b(offset); |
| 1652 | 1661 |
| 1653 // Emit a nop in the branch delay slot if required. | 1662 // Emit a nop in the branch delay slot if required. |
| 1654 if (bdslot == PROTECT) | 1663 if (bdslot == PROTECT) |
| 1655 nop(); | 1664 nop(); |
| 1656 } | 1665 } |
| 1657 | 1666 |
| 1658 | 1667 |
| 1659 void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, | 1668 void MacroAssembler::BranchShort(int16_t offset, Condition cond, Register rs, |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2527 Register rs, | 2536 Register rs, |
| 2528 const Operand& rt, | 2537 const Operand& rt, |
| 2529 BranchDelaySlot bd) { | 2538 BranchDelaySlot bd) { |
| 2530 BlockTrampolinePoolScope block_trampoline_pool(this); | 2539 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 2531 Label start; | 2540 Label start; |
| 2532 bind(&start); | 2541 bind(&start); |
| 2533 int32_t target_int = reinterpret_cast<int32_t>(target); | 2542 int32_t target_int = reinterpret_cast<int32_t>(target); |
| 2534 // Must record previous source positions before the | 2543 // Must record previous source positions before the |
| 2535 // li() generates a new code target. | 2544 // li() generates a new code target. |
| 2536 positions_recorder()->WriteRecordedPositions(); | 2545 positions_recorder()->WriteRecordedPositions(); |
| 2537 li(t9, Operand(target_int, rmode), true); | 2546 li(t9, Operand(target_int, rmode), CONSTANT_SIZE); |
| 2538 Call(t9, cond, rs, rt, bd); | 2547 Call(t9, cond, rs, rt, bd); |
| 2539 ASSERT_EQ(CallSize(target, rmode, cond, rs, rt, bd), | 2548 ASSERT_EQ(CallSize(target, rmode, cond, rs, rt, bd), |
| 2540 SizeOfCodeGeneratedSince(&start)); | 2549 SizeOfCodeGeneratedSince(&start)); |
| 2541 } | 2550 } |
| 2542 | 2551 |
| 2543 | 2552 |
| 2544 int MacroAssembler::CallSize(Handle<Code> code, | 2553 int MacroAssembler::CallSize(Handle<Code> code, |
| 2545 RelocInfo::Mode rmode, | 2554 RelocInfo::Mode rmode, |
| 2546 unsigned ast_id, | 2555 unsigned ast_id, |
| 2547 Condition cond, | 2556 Condition cond, |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2736 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); | 2745 STATIC_ASSERT(StackHandlerConstants::kContextOffset == 3 * kPointerSize); |
| 2737 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); | 2746 STATIC_ASSERT(StackHandlerConstants::kFPOffset == 4 * kPointerSize); |
| 2738 | 2747 |
| 2739 // For the JSEntry handler, we must preserve a0-a3 and s0. | 2748 // For the JSEntry handler, we must preserve a0-a3 and s0. |
| 2740 // t1-t3 are available. We will build up the handler from the bottom by | 2749 // t1-t3 are available. We will build up the handler from the bottom by |
| 2741 // pushing on the stack. | 2750 // pushing on the stack. |
| 2742 // Set up the code object (t1) and the state (t2) for pushing. | 2751 // Set up the code object (t1) and the state (t2) for pushing. |
| 2743 unsigned state = | 2752 unsigned state = |
| 2744 StackHandler::IndexField::encode(handler_index) | | 2753 StackHandler::IndexField::encode(handler_index) | |
| 2745 StackHandler::KindField::encode(kind); | 2754 StackHandler::KindField::encode(kind); |
| 2746 li(t1, Operand(CodeObject())); | 2755 li(t1, Operand(CodeObject()), CONSTANT_SIZE); |
| 2747 li(t2, Operand(state)); | 2756 li(t2, Operand(state)); |
| 2748 | 2757 |
| 2749 // Push the frame pointer, context, state, and code object. | 2758 // Push the frame pointer, context, state, and code object. |
| 2750 if (kind == StackHandler::JS_ENTRY) { | 2759 if (kind == StackHandler::JS_ENTRY) { |
| 2751 ASSERT_EQ(Smi::FromInt(0), 0); | 2760 ASSERT_EQ(Smi::FromInt(0), 0); |
| 2752 // The second zero_reg indicates no context. | 2761 // The second zero_reg indicates no context. |
| 2753 // The first zero_reg is the NULL frame pointer. | 2762 // The first zero_reg is the NULL frame pointer. |
| 2754 // The operands are reversed to match the order of MultiPush/Pop. | 2763 // The operands are reversed to match the order of MultiPush/Pop. |
| 2755 Push(zero_reg, zero_reg, t2, t1); | 2764 Push(zero_reg, zero_reg, t2, t1); |
| 2756 } else { | 2765 } else { |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3365 Label smi_value, maybe_nan, have_double_value, is_nan, done; | 3374 Label smi_value, maybe_nan, have_double_value, is_nan, done; |
| 3366 Register mantissa_reg = scratch2; | 3375 Register mantissa_reg = scratch2; |
| 3367 Register exponent_reg = scratch3; | 3376 Register exponent_reg = scratch3; |
| 3368 | 3377 |
| 3369 // Handle smi values specially. | 3378 // Handle smi values specially. |
| 3370 JumpIfSmi(value_reg, &smi_value); | 3379 JumpIfSmi(value_reg, &smi_value); |
| 3371 | 3380 |
| 3372 // Ensure that the object is a heap number | 3381 // Ensure that the object is a heap number |
| 3373 CheckMap(value_reg, | 3382 CheckMap(value_reg, |
| 3374 scratch1, | 3383 scratch1, |
| 3375 isolate()->factory()->heap_number_map(), | 3384 Heap::kHeapNumberMapRootIndex, |
| 3376 fail, | 3385 fail, |
| 3377 DONT_DO_SMI_CHECK); | 3386 DONT_DO_SMI_CHECK); |
| 3378 | 3387 |
| 3379 // Check for nan: all NaN values have a value greater (signed) than 0x7ff00000 | 3388 // Check for nan: all NaN values have a value greater (signed) than 0x7ff00000 |
| 3380 // in the exponent. | 3389 // in the exponent. |
| 3381 li(scratch1, Operand(kNaNOrInfinityLowerBoundUpper32)); | 3390 li(scratch1, Operand(kNaNOrInfinityLowerBoundUpper32)); |
| 3382 lw(exponent_reg, FieldMemOperand(value_reg, HeapNumber::kExponentOffset)); | 3391 lw(exponent_reg, FieldMemOperand(value_reg, HeapNumber::kExponentOffset)); |
| 3383 Branch(&maybe_nan, ge, exponent_reg, Operand(scratch1)); | 3392 Branch(&maybe_nan, ge, exponent_reg, Operand(scratch1)); |
| 3384 | 3393 |
| 3385 lw(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset)); | 3394 lw(mantissa_reg, FieldMemOperand(value_reg, HeapNumber::kMantissaOffset)); |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4468 bind(&fail); | 4477 bind(&fail); |
| 4469 Abort("Global functions must have initial map"); | 4478 Abort("Global functions must have initial map"); |
| 4470 bind(&ok); | 4479 bind(&ok); |
| 4471 } | 4480 } |
| 4472 } | 4481 } |
| 4473 | 4482 |
| 4474 | 4483 |
| 4475 void MacroAssembler::EnterFrame(StackFrame::Type type) { | 4484 void MacroAssembler::EnterFrame(StackFrame::Type type) { |
| 4476 addiu(sp, sp, -5 * kPointerSize); | 4485 addiu(sp, sp, -5 * kPointerSize); |
| 4477 li(t8, Operand(Smi::FromInt(type))); | 4486 li(t8, Operand(Smi::FromInt(type))); |
| 4478 li(t9, Operand(CodeObject())); | 4487 li(t9, Operand(CodeObject()), CONSTANT_SIZE); |
| 4479 sw(ra, MemOperand(sp, 4 * kPointerSize)); | 4488 sw(ra, MemOperand(sp, 4 * kPointerSize)); |
| 4480 sw(fp, MemOperand(sp, 3 * kPointerSize)); | 4489 sw(fp, MemOperand(sp, 3 * kPointerSize)); |
| 4481 sw(cp, MemOperand(sp, 2 * kPointerSize)); | 4490 sw(cp, MemOperand(sp, 2 * kPointerSize)); |
| 4482 sw(t8, MemOperand(sp, 1 * kPointerSize)); | 4491 sw(t8, MemOperand(sp, 1 * kPointerSize)); |
| 4483 sw(t9, MemOperand(sp, 0 * kPointerSize)); | 4492 sw(t9, MemOperand(sp, 0 * kPointerSize)); |
| 4484 addiu(fp, sp, 3 * kPointerSize); | 4493 addiu(fp, sp, 3 * kPointerSize); |
| 4485 } | 4494 } |
| 4486 | 4495 |
| 4487 | 4496 |
| 4488 void MacroAssembler::LeaveFrame(StackFrame::Type type) { | 4497 void MacroAssembler::LeaveFrame(StackFrame::Type type) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 4512 // Save registers. | 4521 // Save registers. |
| 4513 addiu(sp, sp, -4 * kPointerSize); | 4522 addiu(sp, sp, -4 * kPointerSize); |
| 4514 sw(ra, MemOperand(sp, 3 * kPointerSize)); | 4523 sw(ra, MemOperand(sp, 3 * kPointerSize)); |
| 4515 sw(fp, MemOperand(sp, 2 * kPointerSize)); | 4524 sw(fp, MemOperand(sp, 2 * kPointerSize)); |
| 4516 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer. | 4525 addiu(fp, sp, 2 * kPointerSize); // Set up new frame pointer. |
| 4517 | 4526 |
| 4518 if (emit_debug_code()) { | 4527 if (emit_debug_code()) { |
| 4519 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 4528 sw(zero_reg, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
| 4520 } | 4529 } |
| 4521 | 4530 |
| 4522 li(t8, Operand(CodeObject())); // Accessed from ExitFrame::code_slot. | 4531 // Accessed from ExitFrame::code_slot. |
| 4532 li(t8, Operand(CodeObject()), CONSTANT_SIZE); |
| 4523 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); | 4533 sw(t8, MemOperand(fp, ExitFrameConstants::kCodeOffset)); |
| 4524 | 4534 |
| 4525 // Save the frame pointer and the context in top. | 4535 // Save the frame pointer and the context in top. |
| 4526 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 4536 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
| 4527 sw(fp, MemOperand(t8)); | 4537 sw(fp, MemOperand(t8)); |
| 4528 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 4538 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
| 4529 sw(cp, MemOperand(t8)); | 4539 sw(cp, MemOperand(t8)); |
| 4530 | 4540 |
| 4531 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); | 4541 const int frame_alignment = MacroAssembler::ActivationFrameAlignment(); |
| 4532 if (save_doubles) { | 4542 if (save_doubles) { |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 bind(&done); | 5241 bind(&done); |
| 5232 } | 5242 } |
| 5233 | 5243 |
| 5234 | 5244 |
| 5235 void MacroAssembler::LoadInstanceDescriptors(Register map, | 5245 void MacroAssembler::LoadInstanceDescriptors(Register map, |
| 5236 Register descriptors) { | 5246 Register descriptors) { |
| 5237 lw(descriptors, | 5247 lw(descriptors, |
| 5238 FieldMemOperand(map, Map::kInstanceDescriptorsOrBitField3Offset)); | 5248 FieldMemOperand(map, Map::kInstanceDescriptorsOrBitField3Offset)); |
| 5239 Label not_smi; | 5249 Label not_smi; |
| 5240 JumpIfNotSmi(descriptors, ¬_smi); | 5250 JumpIfNotSmi(descriptors, ¬_smi); |
| 5241 li(descriptors, Operand(FACTORY->empty_descriptor_array())); | 5251 LoadRoot(descriptors, Heap::kEmptyDescriptorArrayRootIndex); |
| 5242 bind(¬_smi); | 5252 bind(¬_smi); |
| 5243 } | 5253 } |
| 5244 | 5254 |
| 5245 | 5255 |
| 5246 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) { | 5256 void MacroAssembler::CheckEnumCache(Register null_value, Label* call_runtime) { |
| 5247 Label next; | 5257 Label next; |
| 5248 // Preload a couple of values used in the loop. | 5258 // Preload a couple of values used in the loop. |
| 5249 Register empty_fixed_array_value = t2; | 5259 Register empty_fixed_array_value = t2; |
| 5250 LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex); | 5260 LoadRoot(empty_fixed_array_value, Heap::kEmptyFixedArrayRootIndex); |
| 5251 Register empty_descriptor_array_value = t3; | 5261 Register empty_descriptor_array_value = t3; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5389 opcode == BGTZL); | 5399 opcode == BGTZL); |
| 5390 opcode = (cond == eq) ? BEQ : BNE; | 5400 opcode = (cond == eq) ? BEQ : BNE; |
| 5391 instr = (instr & ~kOpcodeMask) | opcode; | 5401 instr = (instr & ~kOpcodeMask) | opcode; |
| 5392 masm_.emit(instr); | 5402 masm_.emit(instr); |
| 5393 } | 5403 } |
| 5394 | 5404 |
| 5395 | 5405 |
| 5396 } } // namespace v8::internal | 5406 } } // namespace v8::internal |
| 5397 | 5407 |
| 5398 #endif // V8_TARGET_ARCH_MIPS | 5408 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |