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

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

Issue 211383008: Refine a bit ClampXToUint8 (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 | « no previous file | src/x64/macro-assembler-x64.cc » ('j') | 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 XMMRegister scratch_reg, 213 XMMRegister scratch_reg,
214 Register result_reg) { 214 Register result_reg) {
215 Label done; 215 Label done;
216 Label conv_failure; 216 Label conv_failure;
217 xorps(scratch_reg, scratch_reg); 217 xorps(scratch_reg, scratch_reg);
218 cvtsd2si(result_reg, input_reg); 218 cvtsd2si(result_reg, input_reg);
219 test(result_reg, Immediate(0xFFFFFF00)); 219 test(result_reg, Immediate(0xFFFFFF00));
220 j(zero, &done, Label::kNear); 220 j(zero, &done, Label::kNear);
221 cmp(result_reg, Immediate(0x1)); 221 cmp(result_reg, Immediate(0x1));
222 j(overflow, &conv_failure, Label::kNear); 222 j(overflow, &conv_failure, Label::kNear);
223 mov(result_reg, Immediate(0)); 223 sar(result_reg, 31);
224 setcc(sign, result_reg); 224 not_(result_reg); // No zero extension seems to be safe here.
225 sub(result_reg, Immediate(1));
226 and_(result_reg, Immediate(255));
227 jmp(&done, Label::kNear); 225 jmp(&done, Label::kNear);
228 bind(&conv_failure); 226 bind(&conv_failure);
229 Move(result_reg, Immediate(0)); 227 sar(result_reg, 31);
230 ucomisd(input_reg, scratch_reg); 228 ucomisd(input_reg, scratch_reg);
231 j(below, &done, Label::kNear); 229 j(above_equal, &done, Label::kNear);
232 Move(result_reg, Immediate(255)); 230 Set(result_reg, Immediate(0));
233 bind(&done); 231 bind(&done);
234 } 232 }
235 233
236 234
237 void MacroAssembler::ClampUint8(Register reg) { 235 void MacroAssembler::ClampUint8(Register reg) {
238 Label done; 236 Label done;
239 test(reg, Immediate(0xFFFFFF00)); 237 test(reg, Immediate(0xFFFFFF00));
240 j(zero, &done, Label::kNear); 238 j(zero, &done, Label::kNear);
241 setcc(negative, reg); // 1 if negative, 0 if positive. 239 sar(reg, 31);
242 dec_b(reg); // 0 if negative, 255 if positive. 240 not_(reg); // No zero extension seems to be safe here.
243 bind(&done); 241 bind(&done);
244 } 242 }
245 243
246 244
247 void MacroAssembler::SlowTruncateToI(Register result_reg, 245 void MacroAssembler::SlowTruncateToI(Register result_reg,
248 Register input_reg, 246 Register input_reg,
249 int offset) { 247 int offset) {
250 DoubleToIStub stub(input_reg, result_reg, offset, true); 248 DoubleToIStub stub(input_reg, result_reg, offset, true);
251 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); 249 call(stub.GetCode(isolate()), RelocInfo::CODE_TARGET);
252 } 250 }
(...skipping 3393 matching lines...) Expand 10 before | Expand all | Expand 10 after
3646 if (ms.shift() > 0) sar(edx, ms.shift()); 3644 if (ms.shift() > 0) sar(edx, ms.shift());
3647 mov(eax, dividend); 3645 mov(eax, dividend);
3648 shr(eax, 31); 3646 shr(eax, 31);
3649 add(edx, eax); 3647 add(edx, eax);
3650 } 3648 }
3651 3649
3652 3650
3653 } } // namespace v8::internal 3651 } } // namespace v8::internal
3654 3652
3655 #endif // V8_TARGET_ARCH_IA32 3653 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « no previous file | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698