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

Side by Side Diff: src/x64/macro-assembler-x64.cc

Issue 202083002: [ia32/x64] Smaller instruction to check NaN (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3041 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 3052
3053 CompareMap(obj, map); 3053 CompareMap(obj, map);
3054 j(not_equal, fail); 3054 j(not_equal, fail);
3055 } 3055 }
3056 3056
3057 3057
3058 void MacroAssembler::ClampUint8(Register reg) { 3058 void MacroAssembler::ClampUint8(Register reg) {
3059 Label done; 3059 Label done;
3060 testl(reg, Immediate(0xFFFFFF00)); 3060 testl(reg, Immediate(0xFFFFFF00));
3061 j(zero, &done, Label::kNear); 3061 j(zero, &done, Label::kNear);
3062 setcc(negative, reg); // 1 if negative, 0 if positive. 3062 sarl(reg, Immediate(31));
3063 decb(reg); // 0 if negative, 255 if positive. 3063 notl(reg);
3064 bind(&done); 3064 bind(&done);
3065 } 3065 }
3066 3066
3067 3067
3068 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg, 3068 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg,
3069 XMMRegister temp_xmm_reg, 3069 XMMRegister temp_xmm_reg,
3070 Register result_reg) { 3070 Register result_reg) {
3071 Label done; 3071 Label done;
3072 Label conv_failure; 3072 Label conv_failure;
3073 xorps(temp_xmm_reg, temp_xmm_reg); 3073 xorps(temp_xmm_reg, temp_xmm_reg);
3074 cvtsd2si(result_reg, input_reg); 3074 cvtsd2si(result_reg, input_reg);
3075 testl(result_reg, Immediate(0xFFFFFF00)); 3075 testl(result_reg, Immediate(0xFFFFFF00));
3076 j(zero, &done, Label::kNear); 3076 j(below_equal, &done, Label::kNear);
Jakob Kummerow 2014/03/17 18:06:46 This change is confusing. "zero" should have the s
Weiliang 2014/03/18 06:06:40 Oh, this is a stale change which I forget to chang
Weiliang 2014/03/18 06:06:40 Done.
3077 cmpl(result_reg, Immediate(0x80000000)); 3077 cmpl(result_reg, Immediate(1));
3078 j(equal, &conv_failure, Label::kNear); 3078 j(overflow, &conv_failure, Label::kNear);
3079 movl(result_reg, Immediate(0)); 3079 sarl(result_reg, Immediate(31));
3080 setcc(above, result_reg); 3080 notl(result_reg);
3081 subl(result_reg, Immediate(1)); 3081 movzxbl(result_reg, result_reg);
3082 andl(result_reg, Immediate(255));
3083 jmp(&done, Label::kNear); 3082 jmp(&done, Label::kNear);
3084 bind(&conv_failure); 3083 bind(&conv_failure);
3085 Set(result_reg, 0); 3084 Set(result_reg, 0);
3086 ucomisd(input_reg, temp_xmm_reg); 3085 ucomisd(input_reg, temp_xmm_reg);
3087 j(below, &done, Label::kNear); 3086 j(below, &done, Label::kNear);
3088 Set(result_reg, 255); 3087 Set(result_reg, 255);
3089 bind(&done); 3088 bind(&done);
3090 } 3089 }
3091 3090
3092 3091
(...skipping 14 matching lines...) Expand all
3107 DoubleToIStub stub(input_reg, result_reg, offset, true); 3106 DoubleToIStub stub(input_reg, result_reg, offset, true);
3108 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); 3107 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
3109 } 3108 }
3110 3109
3111 3110
3112 void MacroAssembler::TruncateHeapNumberToI(Register result_reg, 3111 void MacroAssembler::TruncateHeapNumberToI(Register result_reg,
3113 Register input_reg) { 3112 Register input_reg) {
3114 Label done; 3113 Label done;
3115 movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset)); 3114 movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3116 cvttsd2siq(result_reg, xmm0); 3115 cvttsd2siq(result_reg, xmm0);
3117 Set(kScratchRegister, V8_UINT64_C(0x8000000000000000)); 3116 cmpq(result_reg, Immediate(1));
3118 cmpq(result_reg, kScratchRegister); 3117 j(no_overflow, &done, Label::kNear);
3119 j(not_equal, &done, Label::kNear);
3120 3118
3121 // Slow case. 3119 // Slow case.
3122 if (input_reg.is(result_reg)) { 3120 if (input_reg.is(result_reg)) {
3123 subq(rsp, Immediate(kDoubleSize)); 3121 subq(rsp, Immediate(kDoubleSize));
3124 movsd(MemOperand(rsp, 0), xmm0); 3122 movsd(MemOperand(rsp, 0), xmm0);
3125 SlowTruncateToI(result_reg, rsp, 0); 3123 SlowTruncateToI(result_reg, rsp, 0);
3126 addq(rsp, Immediate(kDoubleSize)); 3124 addq(rsp, Immediate(kDoubleSize));
3127 } else { 3125 } else {
3128 SlowTruncateToI(result_reg, input_reg); 3126 SlowTruncateToI(result_reg, input_reg);
3129 } 3127 }
3130 3128
3131 bind(&done); 3129 bind(&done);
3132 } 3130 }
3133 3131
3134 3132
3135 void MacroAssembler::TruncateDoubleToI(Register result_reg, 3133 void MacroAssembler::TruncateDoubleToI(Register result_reg,
3136 XMMRegister input_reg) { 3134 XMMRegister input_reg) {
3137 Label done; 3135 Label done;
3138 cvttsd2siq(result_reg, input_reg); 3136 cvttsd2siq(result_reg, input_reg);
3139 movq(kScratchRegister, V8_INT64_C(0x8000000000000000)); 3137 cmpq(result_reg, Immediate(1));
3140 cmpq(result_reg, kScratchRegister); 3138 j(no_overflow, &done, Label::kNear);
3141 j(not_equal, &done, Label::kNear);
3142 3139
3143 subq(rsp, Immediate(kDoubleSize)); 3140 subq(rsp, Immediate(kDoubleSize));
3144 movsd(MemOperand(rsp, 0), input_reg); 3141 movsd(MemOperand(rsp, 0), input_reg);
3145 SlowTruncateToI(result_reg, rsp, 0); 3142 SlowTruncateToI(result_reg, rsp, 0);
3146 addq(rsp, Immediate(kDoubleSize)); 3143 addq(rsp, Immediate(kDoubleSize));
3147 3144
3148 bind(&done); 3145 bind(&done);
3149 } 3146 }
3150 3147
3151 3148
(...skipping 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 imull(dividend); 4984 imull(dividend);
4988 if (divisor > 0 && ms.multiplier() < 0) addl(rdx, dividend); 4985 if (divisor > 0 && ms.multiplier() < 0) addl(rdx, dividend);
4989 if (divisor < 0 && ms.multiplier() > 0) subl(rdx, dividend); 4986 if (divisor < 0 && ms.multiplier() > 0) subl(rdx, dividend);
4990 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift())); 4987 if (ms.shift() > 0) sarl(rdx, Immediate(ms.shift()));
4991 } 4988 }
4992 4989
4993 4990
4994 } } // namespace v8::internal 4991 } } // namespace v8::internal
4995 4992
4996 #endif // V8_TARGET_ARCH_X64 4993 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/lithium-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698