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

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

Issue 208073003: IA32: Rename MacroAssembler::Set() and MacroAssembler::SafeSet() to Move() and SafeMove(). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/regexp-macro-assembler-ia32.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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(0x80000000)); 221 cmp(result_reg, Immediate(0x80000000));
222 j(equal, &conv_failure, Label::kNear); 222 j(equal, &conv_failure, Label::kNear);
223 mov(result_reg, Immediate(0)); 223 mov(result_reg, Immediate(0));
224 setcc(above, result_reg); 224 setcc(above, result_reg);
225 sub(result_reg, Immediate(1)); 225 sub(result_reg, Immediate(1));
226 and_(result_reg, Immediate(255)); 226 and_(result_reg, Immediate(255));
227 jmp(&done, Label::kNear); 227 jmp(&done, Label::kNear);
228 bind(&conv_failure); 228 bind(&conv_failure);
229 Set(result_reg, Immediate(0)); 229 Move(result_reg, Immediate(0));
230 ucomisd(input_reg, scratch_reg); 230 ucomisd(input_reg, scratch_reg);
231 j(below, &done, Label::kNear); 231 j(below, &done, Label::kNear);
232 Set(result_reg, Immediate(255)); 232 Move(result_reg, Immediate(255));
233 bind(&done); 233 bind(&done);
234 } 234 }
235 235
236 236
237 void MacroAssembler::ClampUint8(Register reg) { 237 void MacroAssembler::ClampUint8(Register reg) {
238 Label done; 238 Label done;
239 test(reg, Immediate(0xFFFFFF00)); 239 test(reg, Immediate(0xFFFFFF00));
240 j(zero, &done, Label::kNear); 240 j(zero, &done, Label::kNear);
241 setcc(negative, reg); // 1 if negative, 0 if positive. 241 setcc(negative, reg); // 1 if negative, 0 if positive.
242 dec_b(reg); // 0 if negative, 255 if positive. 242 dec_b(reg); // 0 if negative, 255 if positive.
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 // turned on to provoke errors. 708 // turned on to provoke errors.
709 if (emit_debug_code()) { 709 if (emit_debug_code()) {
710 mov(address, Immediate(BitCast<int32_t>(kZapValue))); 710 mov(address, Immediate(BitCast<int32_t>(kZapValue)));
711 mov(value, Immediate(BitCast<int32_t>(kZapValue))); 711 mov(value, Immediate(BitCast<int32_t>(kZapValue)));
712 } 712 }
713 } 713 }
714 714
715 715
716 #ifdef ENABLE_DEBUGGER_SUPPORT 716 #ifdef ENABLE_DEBUGGER_SUPPORT
717 void MacroAssembler::DebugBreak() { 717 void MacroAssembler::DebugBreak() {
718 Set(eax, Immediate(0)); 718 Move(eax, Immediate(0));
719 mov(ebx, Immediate(ExternalReference(Runtime::kDebugBreak, isolate()))); 719 mov(ebx, Immediate(ExternalReference(Runtime::kDebugBreak, isolate())));
720 CEntryStub ces(1); 720 CEntryStub ces(1);
721 call(ces.GetCode(isolate()), RelocInfo::DEBUG_BREAK); 721 call(ces.GetCode(isolate()), RelocInfo::DEBUG_BREAK);
722 } 722 }
723 #endif 723 #endif
724 724
725 725
726 void MacroAssembler::Cvtsi2sd(XMMRegister dst, const Operand& src) { 726 void MacroAssembler::Cvtsi2sd(XMMRegister dst, const Operand& src) {
727 xorps(dst, dst); 727 xorps(dst, dst);
728 cvtsi2sd(dst, src); 728 cvtsi2sd(dst, src);
729 } 729 }
730 730
731 731
732 void MacroAssembler::Set(Register dst, const Immediate& x) {
733 if (x.is_zero()) {
734 xor_(dst, dst); // Shorter than mov.
735 } else {
736 mov(dst, x);
737 }
738 }
739
740
741 void MacroAssembler::Set(const Operand& dst, const Immediate& x) {
742 mov(dst, x);
743 }
744
745
746 bool MacroAssembler::IsUnsafeImmediate(const Immediate& x) { 732 bool MacroAssembler::IsUnsafeImmediate(const Immediate& x) {
747 static const int kMaxImmediateBits = 17; 733 static const int kMaxImmediateBits = 17;
748 if (!RelocInfo::IsNone(x.rmode_)) return false; 734 if (!RelocInfo::IsNone(x.rmode_)) return false;
749 return !is_intn(x.x_, kMaxImmediateBits); 735 return !is_intn(x.x_, kMaxImmediateBits);
750 } 736 }
751 737
752 738
753 void MacroAssembler::SafeSet(Register dst, const Immediate& x) { 739 void MacroAssembler::SafeMove(Register dst, const Immediate& x) {
754 if (IsUnsafeImmediate(x) && jit_cookie() != 0) { 740 if (IsUnsafeImmediate(x) && jit_cookie() != 0) {
755 Set(dst, Immediate(x.x_ ^ jit_cookie())); 741 Move(dst, Immediate(x.x_ ^ jit_cookie()));
756 xor_(dst, jit_cookie()); 742 xor_(dst, jit_cookie());
757 } else { 743 } else {
758 Set(dst, x); 744 Move(dst, x);
759 } 745 }
760 } 746 }
761 747
762 748
763 void MacroAssembler::SafePush(const Immediate& x) { 749 void MacroAssembler::SafePush(const Immediate& x) {
764 if (IsUnsafeImmediate(x) && jit_cookie() != 0) { 750 if (IsUnsafeImmediate(x) && jit_cookie() != 0) {
765 push(Immediate(x.x_ ^ jit_cookie())); 751 push(Immediate(x.x_ ^ jit_cookie()));
766 xor_(Operand(esp, 0), Immediate(jit_cookie())); 752 xor_(Operand(esp, 0), Immediate(jit_cookie()));
767 } else { 753 } else {
768 push(x); 754 push(x);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 // expectation. 2237 // expectation.
2252 if (f->nargs >= 0 && f->nargs != num_arguments) { 2238 if (f->nargs >= 0 && f->nargs != num_arguments) {
2253 IllegalOperation(num_arguments); 2239 IllegalOperation(num_arguments);
2254 return; 2240 return;
2255 } 2241 }
2256 2242
2257 // TODO(1236192): Most runtime routines don't need the number of 2243 // TODO(1236192): Most runtime routines don't need the number of
2258 // arguments passed in because it is constant. At some point we 2244 // arguments passed in because it is constant. At some point we
2259 // should remove this need and make the runtime routine entry code 2245 // should remove this need and make the runtime routine entry code
2260 // smarter. 2246 // smarter.
2261 Set(eax, Immediate(num_arguments)); 2247 Move(eax, Immediate(num_arguments));
2262 mov(ebx, Immediate(ExternalReference(f, isolate()))); 2248 mov(ebx, Immediate(ExternalReference(f, isolate())));
2263 CEntryStub ces(1, CpuFeatures::IsSupported(SSE2) ? save_doubles 2249 CEntryStub ces(1, CpuFeatures::IsSupported(SSE2) ? save_doubles
2264 : kDontSaveFPRegs); 2250 : kDontSaveFPRegs);
2265 CallStub(&ces); 2251 CallStub(&ces);
2266 } 2252 }
2267 2253
2268 2254
2269 void MacroAssembler::CallExternalReference(ExternalReference ref, 2255 void MacroAssembler::CallExternalReference(ExternalReference ref,
2270 int num_arguments) { 2256 int num_arguments) {
2271 mov(eax, Immediate(num_arguments)); 2257 mov(eax, Immediate(num_arguments));
2272 mov(ebx, Immediate(ref)); 2258 mov(ebx, Immediate(ref));
2273 2259
2274 CEntryStub stub(1); 2260 CEntryStub stub(1);
2275 CallStub(&stub); 2261 CallStub(&stub);
2276 } 2262 }
2277 2263
2278 2264
2279 void MacroAssembler::TailCallExternalReference(const ExternalReference& ext, 2265 void MacroAssembler::TailCallExternalReference(const ExternalReference& ext,
2280 int num_arguments, 2266 int num_arguments,
2281 int result_size) { 2267 int result_size) {
2282 // TODO(1236192): Most runtime routines don't need the number of 2268 // TODO(1236192): Most runtime routines don't need the number of
2283 // arguments passed in because it is constant. At some point we 2269 // arguments passed in because it is constant. At some point we
2284 // should remove this need and make the runtime routine entry code 2270 // should remove this need and make the runtime routine entry code
2285 // smarter. 2271 // smarter.
2286 Set(eax, Immediate(num_arguments)); 2272 Move(eax, Immediate(num_arguments));
2287 JumpToExternalReference(ext); 2273 JumpToExternalReference(ext);
2288 } 2274 }
2289 2275
2290 2276
2291 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid, 2277 void MacroAssembler::TailCallRuntime(Runtime::FunctionId fid,
2292 int num_arguments, 2278 int num_arguments,
2293 int result_size) { 2279 int result_size) {
2294 TailCallExternalReference(ExternalReference(fid, isolate()), 2280 TailCallExternalReference(ExternalReference(fid, isolate()),
2295 num_arguments, 2281 num_arguments,
2296 result_size); 2282 result_size);
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 } 2826 }
2841 2827
2842 2828
2843 void MacroAssembler::Move(Register dst, Register src) { 2829 void MacroAssembler::Move(Register dst, Register src) {
2844 if (!dst.is(src)) { 2830 if (!dst.is(src)) {
2845 mov(dst, src); 2831 mov(dst, src);
2846 } 2832 }
2847 } 2833 }
2848 2834
2849 2835
2850 void MacroAssembler::Move(Register dst, Immediate imm) { 2836 void MacroAssembler::Move(Register dst, const Immediate& x) {
2851 if (imm.is_zero()) { 2837 if (x.is_zero()) {
2852 xor_(dst, dst); 2838 xor_(dst, dst); // Shorter than mov of 32-bit immediate 0.
2853 } else { 2839 } else {
2854 mov(dst, imm); 2840 mov(dst, x);
2855 } 2841 }
2856 } 2842 }
2857 2843
2858 2844
2845 void MacroAssembler::Move(const Operand& dst, const Immediate& x) {
2846 mov(dst, x);
2847 }
2848
2849
2859 void MacroAssembler::Move(XMMRegister dst, double val) { 2850 void MacroAssembler::Move(XMMRegister dst, double val) {
2860 // TODO(titzer): recognize double constants with ExternalReferences. 2851 // TODO(titzer): recognize double constants with ExternalReferences.
2861 CpuFeatureScope scope(this, SSE2); 2852 CpuFeatureScope scope(this, SSE2);
2862 uint64_t int_val = BitCast<uint64_t, double>(val); 2853 uint64_t int_val = BitCast<uint64_t, double>(val);
2863 if (int_val == 0) { 2854 if (int_val == 0) {
2864 xorps(dst, dst); 2855 xorps(dst, dst);
2865 } else { 2856 } else {
2866 int32_t lower = static_cast<int32_t>(int_val); 2857 int32_t lower = static_cast<int32_t>(int_val);
2867 int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt); 2858 int32_t upper = static_cast<int32_t>(int_val >> kBitsPerInt);
2868 push(Immediate(upper)); 2859 push(Immediate(upper));
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
3655 if (ms.shift() > 0) sar(edx, ms.shift()); 3646 if (ms.shift() > 0) sar(edx, ms.shift());
3656 mov(eax, dividend); 3647 mov(eax, dividend);
3657 shr(eax, 31); 3648 shr(eax, 31);
3658 add(edx, eax); 3649 add(edx, eax);
3659 } 3650 }
3660 3651
3661 3652
3662 } } // namespace v8::internal 3653 } } // namespace v8::internal
3663 3654
3664 #endif // V8_TARGET_ARCH_IA32 3655 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.h ('k') | src/ia32/regexp-macro-assembler-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698