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

Side by Side Diff: src/x64/codegen-x64.cc

Issue 197037: Use fucomi instruction to compare floats and put results directly into EFLAGS... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 6324 matching lines...) Expand 10 before | Expand all | Expand 10 after
6335 __ movl(rdx, FieldOperand(rax, String::kLengthOffset)); 6335 __ movl(rdx, FieldOperand(rax, String::kLengthOffset));
6336 __ shr(rdx, Immediate(String::kShortLengthShift)); 6336 __ shr(rdx, Immediate(String::kShortLengthShift));
6337 __ j(zero, &false_result); 6337 __ j(zero, &false_result);
6338 __ jmp(&true_result); 6338 __ jmp(&true_result);
6339 6339
6340 __ bind(&not_string); 6340 __ bind(&not_string);
6341 // HeapNumber => false iff +0, -0, or NaN. 6341 // HeapNumber => false iff +0, -0, or NaN.
6342 // These three cases set C3 when compared to zero in the FPU. 6342 // These three cases set C3 when compared to zero in the FPU.
6343 __ CompareRoot(rdx, Heap::kHeapNumberMapRootIndex); 6343 __ CompareRoot(rdx, Heap::kHeapNumberMapRootIndex);
6344 __ j(not_equal, &true_result); 6344 __ j(not_equal, &true_result);
6345 // TODO(x64): Don't use fp stack, use MMX registers?
6346 __ fldz(); // Load zero onto fp stack 6345 __ fldz(); // Load zero onto fp stack
6347 // Load heap-number double value onto fp stack 6346 // Load heap-number double value onto fp stack
6348 __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset)); 6347 __ fld_d(FieldOperand(rax, HeapNumber::kValueOffset));
6349 __ fucompp(); // Compare and pop both values. 6348 __ FCmp();
6350 __ movq(kScratchRegister, rax); 6349 __ j(zero, &false_result);
6351 __ fnstsw_ax(); // Store fp status word in ax, no checking for exceptions.
6352 __ testl(rax, Immediate(0x4000)); // Test FP condition flag C3, bit 16.
6353 __ movq(rax, kScratchRegister);
6354 __ j(not_zero, &false_result);
6355 // Fall through to |true_result|. 6350 // Fall through to |true_result|.
6356 6351
6357 // Return 1/0 for true/false in rax. 6352 // Return 1/0 for true/false in rax.
6358 __ bind(&true_result); 6353 __ bind(&true_result);
6359 __ movq(rax, Immediate(1)); 6354 __ movq(rax, Immediate(1));
6360 __ ret(1 * kPointerSize); 6355 __ ret(1 * kPointerSize);
6361 __ bind(&false_result); 6356 __ bind(&false_result);
6362 __ xor_(rax, rax); 6357 __ xor_(rax, rax);
6363 __ ret(1 * kPointerSize); 6358 __ ret(1 * kPointerSize);
6364 } 6359 }
(...skipping 1377 matching lines...) Expand 10 before | Expand all | Expand 10 after
7742 CpuFeatures::Scope scope(CpuFeatures::SSE3); 7737 CpuFeatures::Scope scope(CpuFeatures::SSE3);
7743 __ fisttp_s(Operand(rsp, 0 * kPointerSize)); 7738 __ fisttp_s(Operand(rsp, 0 * kPointerSize));
7744 __ fisttp_s(Operand(rsp, 1 * kPointerSize)); 7739 __ fisttp_s(Operand(rsp, 1 * kPointerSize));
7745 __ fnstsw_ax(); 7740 __ fnstsw_ax();
7746 __ testl(rax, Immediate(1)); 7741 __ testl(rax, Immediate(1));
7747 __ j(not_zero, &operand_conversion_failure); 7742 __ j(not_zero, &operand_conversion_failure);
7748 } else { 7743 } else {
7749 // Check if right operand is int32. 7744 // Check if right operand is int32.
7750 __ fist_s(Operand(rsp, 0 * kPointerSize)); 7745 __ fist_s(Operand(rsp, 0 * kPointerSize));
7751 __ fild_s(Operand(rsp, 0 * kPointerSize)); 7746 __ fild_s(Operand(rsp, 0 * kPointerSize));
7752 __ fucompp(); 7747 __ FCmp();
7753 __ fnstsw_ax(); 7748 __ j(not_zero, &operand_conversion_failure);
7754 if (CpuFeatures::IsSupported(CpuFeatures::SAHF)) { 7749 __ j(parity_even, &operand_conversion_failure);
7755 __ sahf(); 7750
7756 __ j(not_zero, &operand_conversion_failure);
7757 __ j(parity_even, &operand_conversion_failure);
7758 } else {
7759 __ and_(rax, Immediate(0x4400));
7760 __ cmpl(rax, Immediate(0x4000));
7761 __ j(not_zero, &operand_conversion_failure);
7762 }
7763 // Check if left operand is int32. 7751 // Check if left operand is int32.
7764 __ fist_s(Operand(rsp, 1 * kPointerSize)); 7752 __ fist_s(Operand(rsp, 1 * kPointerSize));
7765 __ fild_s(Operand(rsp, 1 * kPointerSize)); 7753 __ fild_s(Operand(rsp, 1 * kPointerSize));
7766 __ fucompp(); 7754 __ FCmp();
7767 __ fnstsw_ax(); 7755 __ j(not_zero, &operand_conversion_failure);
7768 if (CpuFeatures::IsSupported(CpuFeatures::SAHF)) { 7756 __ j(parity_even, &operand_conversion_failure);
7769 __ sahf();
7770 __ j(not_zero, &operand_conversion_failure);
7771 __ j(parity_even, &operand_conversion_failure);
7772 } else {
7773 __ and_(rax, Immediate(0x4400));
7774 __ cmpl(rax, Immediate(0x4000));
7775 __ j(not_zero, &operand_conversion_failure);
7776 }
7777 } 7757 }
7778 7758
7779 // Get int32 operands and perform bitop. 7759 // Get int32 operands and perform bitop.
7780 __ pop(rcx); 7760 __ pop(rcx);
7781 __ pop(rax); 7761 __ pop(rax);
7782 switch (op_) { 7762 switch (op_) {
7783 case Token::BIT_OR: __ or_(rax, rcx); break; 7763 case Token::BIT_OR: __ or_(rax, rcx); break;
7784 case Token::BIT_AND: __ and_(rax, rcx); break; 7764 case Token::BIT_AND: __ and_(rax, rcx); break;
7785 case Token::BIT_XOR: __ xor_(rax, rcx); break; 7765 case Token::BIT_XOR: __ xor_(rax, rcx); break;
7786 case Token::SAR: __ sarl(rax); break; 7766 case Token::SAR: __ sarl(rax); break;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
7904 int CompareStub::MinorKey() { 7884 int CompareStub::MinorKey() {
7905 // Encode the two parameters in a unique 16 bit value. 7885 // Encode the two parameters in a unique 16 bit value.
7906 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 7886 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
7907 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 7887 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
7908 } 7888 }
7909 7889
7910 7890
7911 #undef __ 7891 #undef __
7912 7892
7913 } } // namespace v8::internal 7893 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698