| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 virtual InlineCacheState GetICState() { | 136 virtual InlineCacheState GetICState() { |
| 137 return UnaryOpIC::ToState(operand_type_); | 137 return UnaryOpIC::ToState(operand_type_); |
| 138 } | 138 } |
| 139 | 139 |
| 140 virtual void FinishCode(Handle<Code> code) { | 140 virtual void FinishCode(Handle<Code> code) { |
| 141 code->set_unary_op_type(operand_type_); | 141 code->set_unary_op_type(operand_type_); |
| 142 } | 142 } |
| 143 }; | 143 }; |
| 144 | 144 |
| 145 | 145 |
| 146 class BinaryOpStub: public CodeStub { | |
| 147 public: | |
| 148 BinaryOpStub(Token::Value op, OverwriteMode mode) | |
| 149 : op_(op), | |
| 150 mode_(mode), | |
| 151 operands_type_(BinaryOpIC::UNINITIALIZED), | |
| 152 result_type_(BinaryOpIC::UNINITIALIZED) { | |
| 153 use_fpu_ = CpuFeatures::IsSupported(FPU); | |
| 154 ASSERT(OpBits::is_valid(Token::NUM_TOKENS)); | |
| 155 } | |
| 156 | |
| 157 BinaryOpStub( | |
| 158 int key, | |
| 159 BinaryOpIC::TypeInfo operands_type, | |
| 160 BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED) | |
| 161 : op_(OpBits::decode(key)), | |
| 162 mode_(ModeBits::decode(key)), | |
| 163 use_fpu_(FPUBits::decode(key)), | |
| 164 operands_type_(operands_type), | |
| 165 result_type_(result_type) { } | |
| 166 | |
| 167 private: | |
| 168 enum SmiCodeGenerateHeapNumberResults { | |
| 169 ALLOW_HEAPNUMBER_RESULTS, | |
| 170 NO_HEAPNUMBER_RESULTS | |
| 171 }; | |
| 172 | |
| 173 Token::Value op_; | |
| 174 OverwriteMode mode_; | |
| 175 bool use_fpu_; | |
| 176 | |
| 177 // Operand type information determined at runtime. | |
| 178 BinaryOpIC::TypeInfo operands_type_; | |
| 179 BinaryOpIC::TypeInfo result_type_; | |
| 180 | |
| 181 virtual void PrintName(StringStream* stream); | |
| 182 | |
| 183 // Minor key encoding in 16 bits RRRTTTVOOOOOOOMM. | |
| 184 class ModeBits: public BitField<OverwriteMode, 0, 2> {}; | |
| 185 class OpBits: public BitField<Token::Value, 2, 7> {}; | |
| 186 class FPUBits: public BitField<bool, 9, 1> {}; | |
| 187 class OperandTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 10, 3> {}; | |
| 188 class ResultTypeInfoBits: public BitField<BinaryOpIC::TypeInfo, 13, 3> {}; | |
| 189 | |
| 190 Major MajorKey() { return BinaryOp; } | |
| 191 int MinorKey() { | |
| 192 return OpBits::encode(op_) | |
| 193 | ModeBits::encode(mode_) | |
| 194 | FPUBits::encode(use_fpu_) | |
| 195 | OperandTypeInfoBits::encode(operands_type_) | |
| 196 | ResultTypeInfoBits::encode(result_type_); | |
| 197 } | |
| 198 | |
| 199 void Generate(MacroAssembler* masm); | |
| 200 void GenerateGeneric(MacroAssembler* masm); | |
| 201 void GenerateSmiSmiOperation(MacroAssembler* masm); | |
| 202 void GenerateFPOperation(MacroAssembler* masm, | |
| 203 bool smi_operands, | |
| 204 Label* not_numbers, | |
| 205 Label* gc_required); | |
| 206 void GenerateSmiCode(MacroAssembler* masm, | |
| 207 Label* use_runtime, | |
| 208 Label* gc_required, | |
| 209 SmiCodeGenerateHeapNumberResults heapnumber_results); | |
| 210 void GenerateLoadArguments(MacroAssembler* masm); | |
| 211 void GenerateReturn(MacroAssembler* masm); | |
| 212 void GenerateUninitializedStub(MacroAssembler* masm); | |
| 213 void GenerateSmiStub(MacroAssembler* masm); | |
| 214 void GenerateInt32Stub(MacroAssembler* masm); | |
| 215 void GenerateHeapNumberStub(MacroAssembler* masm); | |
| 216 void GenerateOddballStub(MacroAssembler* masm); | |
| 217 void GenerateStringStub(MacroAssembler* masm); | |
| 218 void GenerateBothStringStub(MacroAssembler* masm); | |
| 219 void GenerateGenericStub(MacroAssembler* masm); | |
| 220 void GenerateAddStrings(MacroAssembler* masm); | |
| 221 void GenerateCallRuntime(MacroAssembler* masm); | |
| 222 | |
| 223 void GenerateHeapResultAllocation(MacroAssembler* masm, | |
| 224 Register result, | |
| 225 Register heap_number_map, | |
| 226 Register scratch1, | |
| 227 Register scratch2, | |
| 228 Label* gc_required); | |
| 229 void GenerateRegisterArgsPush(MacroAssembler* masm); | |
| 230 void GenerateTypeTransition(MacroAssembler* masm); | |
| 231 void GenerateTypeTransitionWithSavedArgs(MacroAssembler* masm); | |
| 232 | |
| 233 virtual int GetCodeKind() { return Code::BINARY_OP_IC; } | |
| 234 | |
| 235 virtual InlineCacheState GetICState() { | |
| 236 return BinaryOpIC::ToState(operands_type_); | |
| 237 } | |
| 238 | |
| 239 virtual void FinishCode(Handle<Code> code) { | |
| 240 code->set_binary_op_type(operands_type_); | |
| 241 code->set_binary_op_result_type(result_type_); | |
| 242 } | |
| 243 | |
| 244 friend class CodeGenerator; | |
| 245 }; | |
| 246 | |
| 247 | |
| 248 class StringHelper : public AllStatic { | 146 class StringHelper : public AllStatic { |
| 249 public: | 147 public: |
| 250 // Generate code for copying characters using a simple loop. This should only | 148 // Generate code for copying characters using a simple loop. This should only |
| 251 // be used in places where the number of characters is small and the | 149 // be used in places where the number of characters is small and the |
| 252 // additional setup and checking in GenerateCopyCharactersLong adds too much | 150 // additional setup and checking in GenerateCopyCharactersLong adds too much |
| 253 // overhead. Copying of overlapping regions is not supported. | 151 // overhead. Copying of overlapping regions is not supported. |
| 254 // Dest register ends at the position after the last character written. | 152 // Dest register ends at the position after the last character written. |
| 255 static void GenerateCopyCharacters(MacroAssembler* masm, | 153 static void GenerateCopyCharacters(MacroAssembler* masm, |
| 256 Register dest, | 154 Register dest, |
| 257 Register src, | 155 Register src, |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 // Loads smis from a0 and a1 (right and left in binary operations) into | 615 // Loads smis from a0 and a1 (right and left in binary operations) into |
| 718 // floating point registers. Depending on the destination the values ends up | 616 // floating point registers. Depending on the destination the values ends up |
| 719 // either f14 and f12 or in a2/a3 and a0/a1 respectively. If the destination | 617 // either f14 and f12 or in a2/a3 and a0/a1 respectively. If the destination |
| 720 // is floating point registers FPU must be supported. If core registers are | 618 // is floating point registers FPU must be supported. If core registers are |
| 721 // requested when FPU is supported f12 and f14 will be scratched. | 619 // requested when FPU is supported f12 and f14 will be scratched. |
| 722 static void LoadSmis(MacroAssembler* masm, | 620 static void LoadSmis(MacroAssembler* masm, |
| 723 Destination destination, | 621 Destination destination, |
| 724 Register scratch1, | 622 Register scratch1, |
| 725 Register scratch2); | 623 Register scratch2); |
| 726 | 624 |
| 727 // Loads objects from a0 and a1 (right and left in binary operations) into | |
| 728 // floating point registers. Depending on the destination the values ends up | |
| 729 // either f14 and f12 or in a2/a3 and a0/a1 respectively. If the destination | |
| 730 // is floating point registers FPU must be supported. If core registers are | |
| 731 // requested when FPU is supported f12 and f14 will still be scratched. If | |
| 732 // either a0 or a1 is not a number (not smi and not heap number object) the | |
| 733 // not_number label is jumped to with a0 and a1 intact. | |
| 734 static void LoadOperands(MacroAssembler* masm, | |
| 735 FloatingPointHelper::Destination destination, | |
| 736 Register heap_number_map, | |
| 737 Register scratch1, | |
| 738 Register scratch2, | |
| 739 Label* not_number); | |
| 740 | |
| 741 // Convert the smi or heap number in object to an int32 using the rules | 625 // Convert the smi or heap number in object to an int32 using the rules |
| 742 // for ToInt32 as described in ECMAScript 9.5.: the value is truncated | 626 // for ToInt32 as described in ECMAScript 9.5.: the value is truncated |
| 743 // and brought into the range -2^31 .. +2^31 - 1. | 627 // and brought into the range -2^31 .. +2^31 - 1. |
| 744 static void ConvertNumberToInt32(MacroAssembler* masm, | 628 static void ConvertNumberToInt32(MacroAssembler* masm, |
| 745 Register object, | 629 Register object, |
| 746 Register dst, | 630 Register dst, |
| 747 Register heap_number_map, | 631 Register heap_number_map, |
| 748 Register scratch1, | 632 Register scratch1, |
| 749 Register scratch2, | 633 Register scratch2, |
| 750 Register scratch3, | 634 Register scratch3, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 // Requires the following layout on entry: | 711 // Requires the following layout on entry: |
| 828 // a0: Left value (least significant part of mantissa). | 712 // a0: Left value (least significant part of mantissa). |
| 829 // a1: Left value (sign, exponent, top of mantissa). | 713 // a1: Left value (sign, exponent, top of mantissa). |
| 830 // a2: Right value (least significant part of mantissa). | 714 // a2: Right value (least significant part of mantissa). |
| 831 // a3: Right value (sign, exponent, top of mantissa). | 715 // a3: Right value (sign, exponent, top of mantissa). |
| 832 static void CallCCodeForDoubleOperation(MacroAssembler* masm, | 716 static void CallCCodeForDoubleOperation(MacroAssembler* masm, |
| 833 Token::Value op, | 717 Token::Value op, |
| 834 Register heap_number_result, | 718 Register heap_number_result, |
| 835 Register scratch); | 719 Register scratch); |
| 836 | 720 |
| 837 private: | 721 // Loads the objects from |object| into floating point registers. |
| 722 // Depending on |destination| the value ends up either in |dst| or |
| 723 // in |dst1|/|dst2|. If |destination| is kFPURegisters, then FPU |
| 724 // must be supported. If kCoreRegisters are requested and FPU is |
| 725 // supported, |dst| will be scratched. If |object| is neither smi nor |
| 726 // heap number, |not_number| is jumped to with |object| still intact. |
| 838 static void LoadNumber(MacroAssembler* masm, | 727 static void LoadNumber(MacroAssembler* masm, |
| 839 FloatingPointHelper::Destination destination, | 728 FloatingPointHelper::Destination destination, |
| 840 Register object, | 729 Register object, |
| 841 FPURegister dst, | 730 FPURegister dst, |
| 842 Register dst1, | 731 Register dst1, |
| 843 Register dst2, | 732 Register dst2, |
| 844 Register heap_number_map, | 733 Register heap_number_map, |
| 845 Register scratch1, | 734 Register scratch1, |
| 846 Register scratch2, | 735 Register scratch2, |
| 847 Label* not_number); | 736 Label* not_number); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 783 |
| 895 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; | 784 class LookupModeBits: public BitField<LookupMode, 0, 1> {}; |
| 896 | 785 |
| 897 LookupMode mode_; | 786 LookupMode mode_; |
| 898 }; | 787 }; |
| 899 | 788 |
| 900 | 789 |
| 901 } } // namespace v8::internal | 790 } } // namespace v8::internal |
| 902 | 791 |
| 903 #endif // V8_MIPS_CODE_STUBS_ARM_H_ | 792 #endif // V8_MIPS_CODE_STUBS_ARM_H_ |
| OLD | NEW |