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

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

Issue 147201: X64 Implementation: Implement floating-point compare (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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 | « no previous file | src/x64/macro-assembler-x64.cc » ('j') | src/x64/macro-assembler-x64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2889 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 frame_->Push(&result); 2900 frame_->Push(&result);
2901 } 2901 }
2902 2902
2903 2903
2904 void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* a) { 2904 void CodeGenerator::GenerateFastCharCodeAt(ZoneList<Expression*>* a) {
2905 UNIMPLEMENTED(); 2905 UNIMPLEMENTED();
2906 } 2906 }
2907 2907
2908 2908
2909 void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) { 2909 void CodeGenerator::GenerateIsNonNegativeSmi(ZoneList<Expression*>* args) {
2910 UNIMPLEMENTED(); 2910 ASSERT(args->length() == 1);
2911 Load(args->at(0));
2912 Result value = frame_->Pop();
2913 value.ToRegister();
2914 ASSERT(value.is_valid());
2915 __ testl(value.reg(),
2916 Immediate(static_cast<uint32_t>(kSmiTagMask | 0x80000000U)));
2917 value.Unuse();
2918 destination()->Split(zero);
2911 } 2919 }
2912 2920
2913 2921
2914 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) { 2922 void CodeGenerator::GenerateIsSmi(ZoneList<Expression*>* args) {
2915 ASSERT(args->length() == 1); 2923 ASSERT(args->length() == 1);
2916 Load(args->at(0)); 2924 Load(args->at(0));
2917 Result value = frame_->Pop(); 2925 Result value = frame_->Pop();
2918 value.ToRegister(); 2926 value.ToRegister();
2919 ASSERT(value.is_valid()); 2927 ASSERT(value.is_valid());
2920 __ testl(value.reg(), Immediate(kSmiTagMask)); 2928 __ testl(value.reg(), Immediate(kSmiTagMask));
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
3873 // be either smi or heap number objects (fp values). Requirements: 3881 // be either smi or heap number objects (fp values). Requirements:
3874 // operand_1 on TOS+1 , operand_2 on TOS+2; Returns operands as 3882 // operand_1 on TOS+1 , operand_2 on TOS+2; Returns operands as
3875 // floating point numbers in XMM registers. 3883 // floating point numbers in XMM registers.
3876 static void LoadFloatOperands(MacroAssembler* masm, 3884 static void LoadFloatOperands(MacroAssembler* masm,
3877 XMMRegister dst1, 3885 XMMRegister dst1,
3878 XMMRegister dst2); 3886 XMMRegister dst2);
3879 3887
3880 // Code pattern for loading floating point values onto the fp stack. 3888 // Code pattern for loading floating point values onto the fp stack.
3881 // Input values must be either smi or heap number objects (fp values). 3889 // Input values must be either smi or heap number objects (fp values).
3882 // Requirements: 3890 // Requirements:
3883 // operand_1 on TOS+1 , operand_2 on TOS+2; Returns operands as 3891 // Register version: operands in registers lhs and rhs.
3884 // floating point numbers on fp stack. 3892 // Stack version: operands on TOS+1 and TOS+2.
3893 // Returns operands as floating point numbers on fp stack.
3885 static void LoadFloatOperands(MacroAssembler* masm); 3894 static void LoadFloatOperands(MacroAssembler* masm);
3895 static void LoadFloatOperands(MacroAssembler* masm,
3896 Register lhs,
3897 Register rhs);
3886 3898
3887 // Code pattern for loading a floating point value and converting it 3899 // Code pattern for loading a floating point value and converting it
3888 // to a 32 bit integer. Input value must be either a smi or a heap number 3900 // to a 32 bit integer. Input value must be either a smi or a heap number
3889 // object. 3901 // object.
3890 // Returns operands as 32-bit sign extended integers in a general purpose 3902 // Returns operands as 32-bit sign extended integers in a general purpose
3891 // registers. 3903 // registers.
3892 static void LoadInt32Operand(MacroAssembler* masm, 3904 static void LoadInt32Operand(MacroAssembler* masm,
3893 const Operand& src, 3905 const Operand& src,
3894 Register dst); 3906 Register dst);
3895 3907
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
5114 5126
5115 // Check for oddballs: true, false, null, undefined. 5127 // Check for oddballs: true, false, null, undefined.
5116 __ CmpInstanceType(rcx, ODDBALL_TYPE); 5128 __ CmpInstanceType(rcx, ODDBALL_TYPE);
5117 __ j(equal, &return_not_equal); 5129 __ j(equal, &return_not_equal);
5118 5130
5119 // Fall through to the general case. 5131 // Fall through to the general case.
5120 } 5132 }
5121 __ bind(&slow); 5133 __ bind(&slow);
5122 } 5134 }
5123 5135
5124 // Push arguments below the return address. 5136 // Push arguments below the return address to prepare jump to builtin.
5125 __ pop(rcx); 5137 __ pop(rcx);
5126 __ push(rax); 5138 __ push(rax);
5127 __ push(rdx); 5139 __ push(rdx);
5128 __ push(rcx); 5140 __ push(rcx);
5129 5141
5130 // Inlined floating point compare. 5142 // Inlined floating point compare.
5131 // Call builtin if operands are not floating point or smi. 5143 // Call builtin if operands are not floating point or smi.
5132 Label check_for_symbols; 5144 Label check_for_symbols;
5133 // TODO(X64): Implement floating point comparisons; 5145 // Push arguments on stack, for helper functions.
5134 __ int3(); 5146 FloatingPointHelper::CheckFloatOperands(masm, &check_for_symbols);
5147 FloatingPointHelper::LoadFloatOperands(masm, rax, rdx);
5148 __ FCmp();
5149
5150 // Jump to builtin for NaN.
5151 __ j(parity_even, &call_builtin);
5135 5152
5136 // TODO(1243847): Use cmov below once CpuFeatures are properly hooked up. 5153 // TODO(1243847): Use cmov below once CpuFeatures are properly hooked up.
5137 Label below_lbl, above_lbl; 5154 Label below_lbl, above_lbl;
5138 // use rdx, rax to convert unsigned to signed comparison 5155 // use rdx, rax to convert unsigned to signed comparison
5139 __ j(below, &below_lbl); 5156 __ j(below, &below_lbl);
5140 __ j(above, &above_lbl); 5157 __ j(above, &above_lbl);
5141 5158
5142 __ xor_(rax, rax); // equal 5159 __ xor_(rax, rax); // equal
5143 __ ret(2 * kPointerSize); 5160 __ ret(2 * kPointerSize);
5144 5161
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
5844 5861
5845 __ bind(&load_smi_2); 5862 __ bind(&load_smi_2);
5846 __ sar(kScratchRegister, Immediate(kSmiTagSize)); 5863 __ sar(kScratchRegister, Immediate(kSmiTagSize));
5847 __ push(kScratchRegister); 5864 __ push(kScratchRegister);
5848 __ fild_s(Operand(rsp, 0)); 5865 __ fild_s(Operand(rsp, 0));
5849 __ pop(kScratchRegister); 5866 __ pop(kScratchRegister);
5850 5867
5851 __ bind(&done); 5868 __ bind(&done);
5852 } 5869 }
5853 5870
5871 void FloatingPointHelper::LoadFloatOperands(MacroAssembler* masm,
5872 Register lhs,
5873 Register rhs) {
5874 Label load_smi_lhs, load_smi_rhs, done_load_lhs, done;
5875 __ testl(lhs, Immediate(kSmiTagMask));
5876 __ j(zero, &load_smi_lhs);
5877 __ fld_d(FieldOperand(lhs, HeapNumber::kValueOffset));
5878 __ bind(&done_load_lhs);
5879
5880 __ testl(rhs, Immediate(kSmiTagMask));
5881 __ j(zero, &load_smi_rhs);
5882 __ fld_d(FieldOperand(rhs, HeapNumber::kValueOffset));
5883 __ jmp(&done);
5884
5885 __ bind(&load_smi_lhs);
5886 __ movq(kScratchRegister, lhs);
5887 __ sar(kScratchRegister, Immediate(kSmiTagSize));
Lasse Reichstein 2009/06/26 09:41:04 __ lea(kScratchRegister, Operand(lhs, lhs, times_1
William Hesse 2009/06/26 19:45:59 Done.
5888 __ push(kScratchRegister);
5889 __ fild_s(Operand(rsp, 0));
5890 __ pop(kScratchRegister);
5891 __ jmp(&done_load_lhs);
5892
5893 __ bind(&load_smi_rhs);
5894 __ movq(kScratchRegister, rhs);
5895 __ sar(kScratchRegister, Immediate(kSmiTagSize));
5896 __ push(kScratchRegister);
5897 __ fild_s(Operand(rsp, 0));
5898 __ pop(kScratchRegister);
5899
5900 __ bind(&done);
5901 }
5854 5902
5855 void FloatingPointHelper::CheckFloatOperands(MacroAssembler* masm, 5903 void FloatingPointHelper::CheckFloatOperands(MacroAssembler* masm,
5856 Label* non_float) { 5904 Label* non_float) {
5857 Label test_other, done; 5905 Label test_other, done;
5858 // Test if both operands are floats or smi -> scratch=k_is_float; 5906 // Test if both operands are floats or smi -> scratch=k_is_float;
5859 // Otherwise scratch = k_not_float. 5907 // Otherwise scratch = k_not_float.
5860 __ testl(rdx, Immediate(kSmiTagMask)); 5908 __ testl(rdx, Immediate(kSmiTagMask));
5861 __ j(zero, &test_other); // argument in rdx is OK 5909 __ j(zero, &test_other); // argument in rdx is OK
5862 __ movq(kScratchRegister, 5910 __ movq(kScratchRegister,
5863 Factory::heap_number_map(), 5911 Factory::heap_number_map(),
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
6288 break; 6336 break;
6289 default: 6337 default:
6290 UNREACHABLE(); 6338 UNREACHABLE();
6291 } 6339 }
6292 } 6340 }
6293 6341
6294 6342
6295 #undef __ 6343 #undef __
6296 6344
6297 } } // namespace v8::internal 6345 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/x64/macro-assembler-x64.cc » ('j') | src/x64/macro-assembler-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698