OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS | 7 #if V8_TARGET_ARCH_MIPS |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 4362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4373 SmiCheckType smi_check_type) { | 4373 SmiCheckType smi_check_type) { |
4374 if (smi_check_type == DO_SMI_CHECK) { | 4374 if (smi_check_type == DO_SMI_CHECK) { |
4375 JumpIfSmi(obj, fail); | 4375 JumpIfSmi(obj, fail); |
4376 } | 4376 } |
4377 Label success; | 4377 Label success; |
4378 CompareMapAndBranch(obj, scratch, map, &success, ne, fail); | 4378 CompareMapAndBranch(obj, scratch, map, &success, ne, fail); |
4379 bind(&success); | 4379 bind(&success); |
4380 } | 4380 } |
4381 | 4381 |
4382 | 4382 |
4383 void MacroAssembler::DispatchWeakMap(Register obj, Register scratch1, | |
4384 Register scratch2, Handle<WeakCell> cell, | |
4385 Handle<Code> success, | |
4386 SmiCheckType smi_check_type) { | |
4387 Label fail; | |
4388 if (smi_check_type == DO_SMI_CHECK) { | |
4389 JumpIfSmi(obj, &fail); | |
4390 } | |
4391 lw(scratch1, FieldMemOperand(obj, HeapObject::kMapOffset)); | |
4392 GetWeakValue(scratch2, cell); | |
4393 Jump(success, RelocInfo::CODE_TARGET, eq, scratch1, Operand(scratch2)); | |
4394 bind(&fail); | |
4395 } | |
4396 | |
4397 | |
4398 void MacroAssembler::CheckMap(Register obj, | 4383 void MacroAssembler::CheckMap(Register obj, |
4399 Register scratch, | 4384 Register scratch, |
4400 Heap::RootListIndex index, | 4385 Heap::RootListIndex index, |
4401 Label* fail, | 4386 Label* fail, |
4402 SmiCheckType smi_check_type) { | 4387 SmiCheckType smi_check_type) { |
4403 if (smi_check_type == DO_SMI_CHECK) { | 4388 if (smi_check_type == DO_SMI_CHECK) { |
4404 JumpIfSmi(obj, fail); | 4389 JumpIfSmi(obj, fail); |
4405 } | 4390 } |
4406 lw(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); | 4391 lw(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
4407 LoadRoot(at, index); | 4392 LoadRoot(at, index); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4773 Label* fail) { | 4758 Label* fail) { |
4774 DCHECK(kNotStringTag != 0); | 4759 DCHECK(kNotStringTag != 0); |
4775 | 4760 |
4776 lw(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 4761 lw(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); |
4777 lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | 4762 lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); |
4778 And(scratch, scratch, Operand(kIsNotStringMask)); | 4763 And(scratch, scratch, Operand(kIsNotStringMask)); |
4779 Branch(fail, ne, scratch, Operand(zero_reg)); | 4764 Branch(fail, ne, scratch, Operand(zero_reg)); |
4780 } | 4765 } |
4781 | 4766 |
4782 | 4767 |
4783 void MacroAssembler::IsObjectNameType(Register object, | |
4784 Register scratch, | |
4785 Label* fail) { | |
4786 lw(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | |
4787 lbu(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | |
4788 Branch(fail, hi, scratch, Operand(LAST_NAME_TYPE)); | |
4789 } | |
4790 | |
4791 | |
4792 // --------------------------------------------------------------------------- | 4768 // --------------------------------------------------------------------------- |
4793 // Support functions. | 4769 // Support functions. |
4794 | 4770 |
4795 void MacroAssembler::GetObjectType(Register object, | 4771 void MacroAssembler::GetObjectType(Register object, |
4796 Register map, | 4772 Register map, |
4797 Register type_reg) { | 4773 Register type_reg) { |
4798 lw(map, FieldMemOperand(object, HeapObject::kMapOffset)); | 4774 lw(map, FieldMemOperand(object, HeapObject::kMapOffset)); |
4799 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 4775 lbu(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
4800 } | 4776 } |
4801 | 4777 |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5220 // ----------------------------------------------------------------------------- | 5196 // ----------------------------------------------------------------------------- |
5221 // Debugging. | 5197 // Debugging. |
5222 | 5198 |
5223 void MacroAssembler::Assert(Condition cc, BailoutReason reason, | 5199 void MacroAssembler::Assert(Condition cc, BailoutReason reason, |
5224 Register rs, Operand rt) { | 5200 Register rs, Operand rt) { |
5225 if (emit_debug_code()) | 5201 if (emit_debug_code()) |
5226 Check(cc, reason, rs, rt); | 5202 Check(cc, reason, rs, rt); |
5227 } | 5203 } |
5228 | 5204 |
5229 | 5205 |
5230 void MacroAssembler::AssertFastElements(Register elements) { | |
5231 if (emit_debug_code()) { | |
5232 DCHECK(!elements.is(at)); | |
5233 Label ok; | |
5234 push(elements); | |
5235 lw(elements, FieldMemOperand(elements, HeapObject::kMapOffset)); | |
5236 LoadRoot(at, Heap::kFixedArrayMapRootIndex); | |
5237 Branch(&ok, eq, elements, Operand(at)); | |
5238 LoadRoot(at, Heap::kFixedDoubleArrayMapRootIndex); | |
5239 Branch(&ok, eq, elements, Operand(at)); | |
5240 LoadRoot(at, Heap::kFixedCOWArrayMapRootIndex); | |
5241 Branch(&ok, eq, elements, Operand(at)); | |
5242 Abort(kJSObjectWithFastElementsMapHasSlowElements); | |
5243 bind(&ok); | |
5244 pop(elements); | |
5245 } | |
5246 } | |
5247 | |
5248 | 5206 |
5249 void MacroAssembler::Check(Condition cc, BailoutReason reason, | 5207 void MacroAssembler::Check(Condition cc, BailoutReason reason, |
5250 Register rs, Operand rt) { | 5208 Register rs, Operand rt) { |
5251 Label L; | 5209 Label L; |
5252 Branch(&L, cc, rs, rt); | 5210 Branch(&L, cc, rs, rt); |
5253 Abort(reason); | 5211 Abort(reason); |
5254 // Will not return here. | 5212 // Will not return here. |
5255 bind(&L); | 5213 bind(&L); |
5256 } | 5214 } |
5257 | 5215 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5665 void MacroAssembler::JumpIfEitherSmi(Register reg1, | 5623 void MacroAssembler::JumpIfEitherSmi(Register reg1, |
5666 Register reg2, | 5624 Register reg2, |
5667 Label* on_either_smi) { | 5625 Label* on_either_smi) { |
5668 STATIC_ASSERT(kSmiTag == 0); | 5626 STATIC_ASSERT(kSmiTag == 0); |
5669 DCHECK_EQ(1, kSmiTagMask); | 5627 DCHECK_EQ(1, kSmiTagMask); |
5670 // Both Smi tags must be 1 (not Smi). | 5628 // Both Smi tags must be 1 (not Smi). |
5671 and_(at, reg1, reg2); | 5629 and_(at, reg1, reg2); |
5672 JumpIfSmi(at, on_either_smi); | 5630 JumpIfSmi(at, on_either_smi); |
5673 } | 5631 } |
5674 | 5632 |
5675 void MacroAssembler::AssertNotNumber(Register object) { | |
5676 if (emit_debug_code()) { | |
5677 STATIC_ASSERT(kSmiTag == 0); | |
5678 andi(at, object, kSmiTagMask); | |
5679 Check(ne, kOperandIsANumber, at, Operand(zero_reg)); | |
5680 GetObjectType(object, t8, t8); | |
5681 Check(ne, kOperandIsNotANumber, t8, Operand(HEAP_NUMBER_TYPE)); | |
5682 } | |
5683 } | |
5684 | |
5685 void MacroAssembler::AssertNotSmi(Register object) { | 5633 void MacroAssembler::AssertNotSmi(Register object) { |
5686 if (emit_debug_code()) { | 5634 if (emit_debug_code()) { |
5687 STATIC_ASSERT(kSmiTag == 0); | 5635 STATIC_ASSERT(kSmiTag == 0); |
5688 andi(at, object, kSmiTagMask); | 5636 andi(at, object, kSmiTagMask); |
5689 Check(ne, kOperandIsASmi, at, Operand(zero_reg)); | 5637 Check(ne, kOperandIsASmi, at, Operand(zero_reg)); |
5690 } | 5638 } |
5691 } | 5639 } |
5692 | 5640 |
5693 | 5641 |
5694 void MacroAssembler::AssertSmi(Register object) { | 5642 void MacroAssembler::AssertSmi(Register object) { |
5695 if (emit_debug_code()) { | 5643 if (emit_debug_code()) { |
5696 STATIC_ASSERT(kSmiTag == 0); | 5644 STATIC_ASSERT(kSmiTag == 0); |
5697 andi(at, object, kSmiTagMask); | 5645 andi(at, object, kSmiTagMask); |
5698 Check(eq, kOperandIsASmi, at, Operand(zero_reg)); | 5646 Check(eq, kOperandIsASmi, at, Operand(zero_reg)); |
5699 } | 5647 } |
5700 } | 5648 } |
5701 | 5649 |
5702 | 5650 |
5703 void MacroAssembler::AssertString(Register object) { | |
5704 if (emit_debug_code()) { | |
5705 STATIC_ASSERT(kSmiTag == 0); | |
5706 SmiTst(object, t8); | |
5707 Check(ne, kOperandIsASmiAndNotAString, t8, Operand(zero_reg)); | |
5708 GetObjectType(object, t8, t8); | |
5709 Check(lo, kOperandIsNotAString, t8, Operand(FIRST_NONSTRING_TYPE)); | |
5710 } | |
5711 } | |
5712 | |
5713 | |
5714 void MacroAssembler::AssertName(Register object) { | |
5715 if (emit_debug_code()) { | |
5716 STATIC_ASSERT(kSmiTag == 0); | |
5717 SmiTst(object, t8); | |
5718 Check(ne, kOperandIsASmiAndNotAName, t8, Operand(zero_reg)); | |
5719 GetObjectType(object, t8, t8); | |
5720 Check(le, kOperandIsNotAName, t8, Operand(LAST_NAME_TYPE)); | |
5721 } | |
5722 } | |
5723 | |
5724 | |
5725 void MacroAssembler::AssertFunction(Register object) { | 5651 void MacroAssembler::AssertFunction(Register object) { |
5726 if (emit_debug_code()) { | 5652 if (emit_debug_code()) { |
5727 STATIC_ASSERT(kSmiTag == 0); | 5653 STATIC_ASSERT(kSmiTag == 0); |
5728 SmiTst(object, t8); | 5654 SmiTst(object, t8); |
5729 Check(ne, kOperandIsASmiAndNotAFunction, t8, Operand(zero_reg)); | 5655 Check(ne, kOperandIsASmiAndNotAFunction, t8, Operand(zero_reg)); |
5730 GetObjectType(object, t8, t8); | 5656 GetObjectType(object, t8, t8); |
5731 Check(eq, kOperandIsNotAFunction, t8, Operand(JS_FUNCTION_TYPE)); | 5657 Check(eq, kOperandIsNotAFunction, t8, Operand(JS_FUNCTION_TYPE)); |
5732 } | 5658 } |
5733 } | 5659 } |
5734 | 5660 |
(...skipping 12 matching lines...) Expand all Loading... |
5747 if (emit_debug_code()) { | 5673 if (emit_debug_code()) { |
5748 STATIC_ASSERT(kSmiTag == 0); | 5674 STATIC_ASSERT(kSmiTag == 0); |
5749 SmiTst(object, t8); | 5675 SmiTst(object, t8); |
5750 Check(ne, kOperandIsASmiAndNotAGeneratorObject, t8, Operand(zero_reg)); | 5676 Check(ne, kOperandIsASmiAndNotAGeneratorObject, t8, Operand(zero_reg)); |
5751 GetObjectType(object, t8, t8); | 5677 GetObjectType(object, t8, t8); |
5752 Check(eq, kOperandIsNotAGeneratorObject, t8, | 5678 Check(eq, kOperandIsNotAGeneratorObject, t8, |
5753 Operand(JS_GENERATOR_OBJECT_TYPE)); | 5679 Operand(JS_GENERATOR_OBJECT_TYPE)); |
5754 } | 5680 } |
5755 } | 5681 } |
5756 | 5682 |
5757 void MacroAssembler::AssertReceiver(Register object) { | |
5758 if (emit_debug_code()) { | |
5759 STATIC_ASSERT(kSmiTag == 0); | |
5760 SmiTst(object, t8); | |
5761 Check(ne, kOperandIsASmiAndNotAReceiver, t8, Operand(zero_reg)); | |
5762 GetObjectType(object, t8, t8); | |
5763 Check(ge, kOperandIsNotAReceiver, t8, Operand(FIRST_JS_RECEIVER_TYPE)); | |
5764 } | |
5765 } | |
5766 | |
5767 | 5683 |
5768 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, | 5684 void MacroAssembler::AssertUndefinedOrAllocationSite(Register object, |
5769 Register scratch) { | 5685 Register scratch) { |
5770 if (emit_debug_code()) { | 5686 if (emit_debug_code()) { |
5771 Label done_checking; | 5687 Label done_checking; |
5772 AssertNotSmi(object); | 5688 AssertNotSmi(object); |
5773 LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 5689 LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
5774 Branch(&done_checking, eq, object, Operand(scratch)); | 5690 Branch(&done_checking, eq, object, Operand(scratch)); |
5775 lw(t8, FieldMemOperand(object, HeapObject::kMapOffset)); | 5691 lw(t8, FieldMemOperand(object, HeapObject::kMapOffset)); |
5776 LoadRoot(scratch, Heap::kAllocationSiteMapRootIndex); | 5692 LoadRoot(scratch, Heap::kAllocationSiteMapRootIndex); |
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6539 if (mag.shift > 0) sra(result, result, mag.shift); | 6455 if (mag.shift > 0) sra(result, result, mag.shift); |
6540 srl(at, dividend, 31); | 6456 srl(at, dividend, 31); |
6541 Addu(result, result, Operand(at)); | 6457 Addu(result, result, Operand(at)); |
6542 } | 6458 } |
6543 | 6459 |
6544 | 6460 |
6545 } // namespace internal | 6461 } // namespace internal |
6546 } // namespace v8 | 6462 } // namespace v8 |
6547 | 6463 |
6548 #endif // V8_TARGET_ARCH_MIPS | 6464 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |