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

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

Issue 11190049: Improve ClampDoubleToUint8 on ia32/x64 (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 ASSERT(and_then == kFallThroughAtEnd); 122 ASSERT(and_then == kFallThroughAtEnd);
123 bind(&done); 123 bind(&done);
124 } 124 }
125 } 125 }
126 126
127 127
128 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg, 128 void MacroAssembler::ClampDoubleToUint8(XMMRegister input_reg,
129 XMMRegister scratch_reg, 129 XMMRegister scratch_reg,
130 Register result_reg) { 130 Register result_reg) {
131 Label done; 131 Label done;
132 ExternalReference zero_ref = ExternalReference::address_of_zero(); 132 Label conv_failure;
133 movdbl(scratch_reg, Operand::StaticVariable(zero_ref)); 133 pxor(scratch_reg, scratch_reg);
134 cvtsd2si(result_reg, input_reg);
135 test(result_reg, Immediate(0xFFFFFF00));
136 j(zero, &done, Label::kNear);
137 cmp(result_reg, Immediate(0x80000000));
138 j(equal, &conv_failure, Label::kNear);
139 mov(result_reg, Immediate(0));
140 setcc(above, result_reg);
141 sub(result_reg, Immediate(1));
142 and_(result_reg, Immediate(255));
143 jmp(&done, Label::kNear);
144 bind(&conv_failure);
134 Set(result_reg, Immediate(0)); 145 Set(result_reg, Immediate(0));
135 ucomisd(input_reg, scratch_reg); 146 ucomisd(input_reg, scratch_reg);
136 j(below, &done, Label::kNear); 147 j(below, &done, Label::kNear);
137 cvtsd2si(result_reg, input_reg);
138 test(result_reg, Immediate(0xFFFFFF00));
139 j(zero, &done, Label::kNear);
140 Set(result_reg, Immediate(255)); 148 Set(result_reg, Immediate(255));
141 bind(&done); 149 bind(&done);
142 } 150 }
143 151
144 152
145 void MacroAssembler::ClampUint8(Register reg) { 153 void MacroAssembler::ClampUint8(Register reg) {
146 Label done; 154 Label done;
147 test(reg, Immediate(0xFFFFFF00)); 155 test(reg, Immediate(0xFFFFFF00));
148 j(zero, &done, Label::kNear); 156 j(zero, &done, Label::kNear);
149 setcc(negative, reg); // 1 if negative, 0 if positive. 157 setcc(negative, reg); // 1 if negative, 0 if positive.
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2969 j(not_equal, call_runtime); 2977 j(not_equal, call_runtime);
2970 2978
2971 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset)); 2979 mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
2972 cmp(ecx, isolate()->factory()->null_value()); 2980 cmp(ecx, isolate()->factory()->null_value());
2973 j(not_equal, &next); 2981 j(not_equal, &next);
2974 } 2982 }
2975 2983
2976 } } // namespace v8::internal 2984 } } // namespace v8::internal
2977 2985
2978 #endif // V8_TARGET_ARCH_IA32 2986 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698