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

Side by Side Diff: src/mips/lithium-codegen-mips.cc

Issue 23694014: MIPS: Support for DoubleToIStub (truncating). (Closed) Base URL: https://github.com/v8/v8.git@gbl
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
4846 __ cvt_d_w(result_reg, result_reg); 4846 __ cvt_d_w(result_reg, result_reg);
4847 __ bind(&done); 4847 __ bind(&done);
4848 } 4848 }
4849 4849
4850 4850
4851 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) { 4851 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
4852 Register input_reg = ToRegister(instr->value()); 4852 Register input_reg = ToRegister(instr->value());
4853 Register scratch1 = scratch0(); 4853 Register scratch1 = scratch0();
4854 Register scratch2 = ToRegister(instr->temp()); 4854 Register scratch2 = ToRegister(instr->temp());
4855 DoubleRegister double_scratch = double_scratch0(); 4855 DoubleRegister double_scratch = double_scratch0();
4856 DoubleRegister double_scratch2 = ToDoubleRegister(instr->temp3()); 4856 DoubleRegister double_scratch2 = ToDoubleRegister(instr->temp2());
4857 4857
4858 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2)); 4858 ASSERT(!scratch1.is(input_reg) && !scratch1.is(scratch2));
4859 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1)); 4859 ASSERT(!scratch2.is(input_reg) && !scratch2.is(scratch1));
4860 4860
4861 Label done; 4861 Label done;
4862 4862
4863 // The input is a tagged HeapObject. 4863 // The input is a tagged HeapObject.
4864 // Heap number map check. 4864 // Heap number map check.
4865 __ lw(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset)); 4865 __ lw(scratch1, FieldMemOperand(input_reg, HeapObject::kMapOffset));
4866 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); 4866 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
4867 // This 'at' value and scratch1 map value are used for tests in both clauses 4867 // This 'at' value and scratch1 map value are used for tests in both clauses
4868 // of the if. 4868 // of the if.
4869 4869
4870 if (instr->truncating()) { 4870 if (instr->truncating()) {
4871 Register scratch3 = ToRegister(instr->temp2());
4872 FPURegister single_scratch = double_scratch.low();
4873 ASSERT(!scratch3.is(input_reg) &&
4874 !scratch3.is(scratch1) &&
4875 !scratch3.is(scratch2));
4876 // Performs a truncating conversion of a floating point number as used by 4871 // Performs a truncating conversion of a floating point number as used by
4877 // the JS bitwise operations. 4872 // the JS bitwise operations.
4878 Label heap_number; 4873 Label heap_number;
4879 __ Branch(&heap_number, eq, scratch1, Operand(at)); // HeapNumber map? 4874 __ Branch(&heap_number, eq, scratch1, Operand(at)); // HeapNumber map?
4880 // Check for undefined. Undefined is converted to zero for truncating 4875 // Check for undefined. Undefined is converted to zero for truncating
4881 // conversions. 4876 // conversions.
4882 __ LoadRoot(at, Heap::kUndefinedValueRootIndex); 4877 __ LoadRoot(at, Heap::kUndefinedValueRootIndex);
4883 DeoptimizeIf(ne, instr->environment(), input_reg, Operand(at)); 4878 DeoptimizeIf(ne, instr->environment(), input_reg, Operand(at));
4884 ASSERT(ToRegister(instr->result()).is(input_reg)); 4879 ASSERT(ToRegister(instr->result()).is(input_reg));
4885 __ mov(input_reg, zero_reg); 4880 __ mov(input_reg, zero_reg);
4886 __ Branch(&done); 4881 __ Branch(&done);
4887 4882
4888 __ bind(&heap_number); 4883 __ bind(&heap_number);
4889 __ ldc1(double_scratch2, 4884 __ mov(scratch2, input_reg);
4890 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); 4885 __ TruncateHeapNumberToI(input_reg, scratch2);
4891 __ EmitECMATruncate(input_reg,
4892 double_scratch2,
4893 single_scratch,
4894 scratch1,
4895 scratch2,
4896 scratch3);
4897 } else { 4886 } else {
4898 // Deoptimize if we don't have a heap number. 4887 // Deoptimize if we don't have a heap number.
4899 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at)); 4888 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at));
4900 4889
4901 // Load the double value. 4890 // Load the double value.
4902 __ ldc1(double_scratch, 4891 __ ldc1(double_scratch,
4903 FieldMemOperand(input_reg, HeapNumber::kValueOffset)); 4892 FieldMemOperand(input_reg, HeapNumber::kValueOffset));
4904 4893
4905 Register except_flag = scratch2; 4894 Register except_flag = scratch2;
4906 __ EmitFPUTruncate(kRoundToZero, 4895 __ EmitFPUTruncate(kRoundToZero,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4973 instr->hydrogen()->can_convert_undefined_to_nan(), 4962 instr->hydrogen()->can_convert_undefined_to_nan(),
4974 instr->hydrogen()->deoptimize_on_minus_zero(), 4963 instr->hydrogen()->deoptimize_on_minus_zero(),
4975 instr->environment(), 4964 instr->environment(),
4976 mode); 4965 mode);
4977 } 4966 }
4978 4967
4979 4968
4980 void LCodeGen::DoDoubleToI(LDoubleToI* instr) { 4969 void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
4981 Register result_reg = ToRegister(instr->result()); 4970 Register result_reg = ToRegister(instr->result());
4982 Register scratch1 = scratch0(); 4971 Register scratch1 = scratch0();
4983 Register scratch2 = ToRegister(instr->temp());
4984 DoubleRegister double_input = ToDoubleRegister(instr->value()); 4972 DoubleRegister double_input = ToDoubleRegister(instr->value());
4985 4973
4986 if (instr->truncating()) { 4974 if (instr->truncating()) {
4987 Register scratch3 = ToRegister(instr->temp2()); 4975 __ TruncateDoubleToI(result_reg, double_input);
4988 FPURegister single_scratch = double_scratch0().low();
4989 __ EmitECMATruncate(result_reg,
4990 double_input,
4991 single_scratch,
4992 scratch1,
4993 scratch2,
4994 scratch3);
4995 } else { 4976 } else {
4996 Register except_flag = scratch2; 4977 Register except_flag = LCodeGen::scratch1();
4997 4978
4998 __ EmitFPUTruncate(kRoundToMinusInf, 4979 __ EmitFPUTruncate(kRoundToMinusInf,
4999 result_reg, 4980 result_reg,
5000 double_input, 4981 double_input,
5001 scratch1, 4982 scratch1,
5002 double_scratch0(), 4983 double_scratch0(),
5003 except_flag, 4984 except_flag,
5004 kCheckForInexactConversion); 4985 kCheckForInexactConversion);
5005 4986
5006 // Deopt if the operation did not succeed (except_flag != 0). 4987 // Deopt if the operation did not succeed (except_flag != 0).
5007 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg)); 4988 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
5008 4989
5009 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { 4990 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
5010 Label done; 4991 Label done;
5011 __ Branch(&done, ne, result_reg, Operand(zero_reg)); 4992 __ Branch(&done, ne, result_reg, Operand(zero_reg));
5012 __ mfc1(scratch1, double_input.high()); 4993 __ mfc1(scratch1, double_input.high());
5013 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask)); 4994 __ And(scratch1, scratch1, Operand(HeapNumber::kSignMask));
5014 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg)); 4995 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg));
5015 __ bind(&done); 4996 __ bind(&done);
5016 } 4997 }
5017 } 4998 }
5018 } 4999 }
5019 5000
5020 5001
5021 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) { 5002 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
5022 Register result_reg = ToRegister(instr->result()); 5003 Register result_reg = ToRegister(instr->result());
5023 Register scratch1 = scratch0(); 5004 Register scratch1 = LCodeGen::scratch0();
5024 Register scratch2 = ToRegister(instr->temp());
5025 DoubleRegister double_input = ToDoubleRegister(instr->value()); 5005 DoubleRegister double_input = ToDoubleRegister(instr->value());
5026 5006
5027 if (instr->truncating()) { 5007 if (instr->truncating()) {
5028 Register scratch3 = ToRegister(instr->temp2()); 5008 __ TruncateDoubleToI(result_reg, double_input);
5029 FPURegister single_scratch = double_scratch0().low();
5030 __ EmitECMATruncate(result_reg,
5031 double_input,
5032 single_scratch,
5033 scratch1,
5034 scratch2,
5035 scratch3);
5036 } else { 5009 } else {
5037 Register except_flag = scratch2; 5010 Register except_flag = LCodeGen::scratch1();
5038 5011
5039 __ EmitFPUTruncate(kRoundToMinusInf, 5012 __ EmitFPUTruncate(kRoundToMinusInf,
5040 result_reg, 5013 result_reg,
5041 double_input, 5014 double_input,
5042 scratch1, 5015 scratch1,
5043 double_scratch0(), 5016 double_scratch0(),
5044 except_flag, 5017 except_flag,
5045 kCheckForInexactConversion); 5018 kCheckForInexactConversion);
5046 5019
5047 // Deopt if the operation did not succeed (except_flag != 0). 5020 // Deopt if the operation did not succeed (except_flag != 0).
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
5802 __ Subu(scratch, result, scratch); 5775 __ Subu(scratch, result, scratch);
5803 __ lw(result, FieldMemOperand(scratch, 5776 __ lw(result, FieldMemOperand(scratch,
5804 FixedArray::kHeaderSize - kPointerSize)); 5777 FixedArray::kHeaderSize - kPointerSize));
5805 __ bind(&done); 5778 __ bind(&done);
5806 } 5779 }
5807 5780
5808 5781
5809 #undef __ 5782 #undef __
5810 5783
5811 } } // namespace v8::internal 5784 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698