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

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

Issue 164061: Make sure use of eax in inlined sin and cos is safe. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 __ test(temp.reg(), Operand(temp.reg())); 747 __ test(temp.reg(), Operand(temp.reg()));
748 temp.Unuse(); 748 temp.Unuse();
749 dest->Split(not_equal); 749 dest->Split(not_equal);
750 } 750 }
751 751
752 752
753 class FloatingPointHelper : public AllStatic { 753 class FloatingPointHelper : public AllStatic {
754 public: 754 public:
755 // Code pattern for loading a floating point value. Input value must 755 // Code pattern for loading a floating point value. Input value must
756 // be either a smi or a heap number object (fp value). Requirements: 756 // be either a smi or a heap number object (fp value). Requirements:
757 // operand on TOS+1. Returns operand as floating point number on FPU 757 // operand in register number. Returns operand as floating point number
758 // stack. 758 // on FPU stack.
759 static void LoadFloatOperand(MacroAssembler* masm, Register scratch); 759 static void LoadFloatOperand(MacroAssembler* masm, Register number);
760 // Code pattern for loading floating point values. Input values must 760 // Code pattern for loading floating point values. Input values must
761 // be either smi or heap number objects (fp values). Requirements: 761 // be either smi or heap number objects (fp values). Requirements:
762 // operand_1 on TOS+1 , operand_2 on TOS+2; Returns operands as 762 // operand_1 on TOS+1 , operand_2 on TOS+2; Returns operands as
763 // floating point numbers on FPU stack. 763 // floating point numbers on FPU stack.
764 static void LoadFloatOperands(MacroAssembler* masm, Register scratch); 764 static void LoadFloatOperands(MacroAssembler* masm, Register scratch);
765 // Test if operands are smi or number objects (fp). Requirements: 765 // Test if operands are smi or number objects (fp). Requirements:
766 // operand_1 in eax, operand_2 in edx; falls through on float 766 // operand_1 in eax, operand_2 in edx; falls through on float
767 // operands, jumps to the non_float label otherwise. 767 // operands, jumps to the non_float label otherwise.
768 static void CheckFloatOperands(MacroAssembler* masm, 768 static void CheckFloatOperands(MacroAssembler* masm,
769 Label* non_float, 769 Label* non_float,
(...skipping 4387 matching lines...) Expand 10 before | Expand all | Expand 10 after
5157 switch (op) { 5157 switch (op) {
5158 case SIN: 5158 case SIN:
5159 __ fsin(); 5159 __ fsin();
5160 break; 5160 break;
5161 case COS: 5161 case COS:
5162 __ fcos(); 5162 __ fcos();
5163 break; 5163 break;
5164 } 5164 }
5165 5165
5166 // Go slow case if argument to operation is out of range. 5166 // Go slow case if argument to operation is out of range.
5167 Result eax_reg = allocator_->Allocate(eax);
5168 ASSERT(eax_reg.is_valid());
5167 __ fnstsw_ax(); 5169 __ fnstsw_ax();
5168 __ sahf(); 5170 __ sahf();
5171 eax_reg.Unuse();
5169 call_runtime.Branch(parity_even, not_taken); 5172 call_runtime.Branch(parity_even, not_taken);
5170 5173
5171 // Allocate heap number for result if possible. 5174 // Allocate heap number for result if possible.
5172 Result scratch1 = allocator()->Allocate(); 5175 Result scratch1 = allocator()->Allocate();
5173 Result scratch2 = allocator()->Allocate(); 5176 Result scratch2 = allocator()->Allocate();
5174 Result heap_number = allocator()->Allocate(); 5177 Result heap_number = allocator()->Allocate();
5175 FloatingPointHelper::AllocateHeapNumber(masm_, 5178 FloatingPointHelper::AllocateHeapNumber(masm_,
5176 call_runtime.entry_label(), 5179 call_runtime.entry_label(),
5177 scratch1.reg(), 5180 scratch1.reg(),
5178 scratch2.reg(), 5181 scratch2.reg(),
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
6957 6960
6958 __ mov(Operand(scratch1, 0), scratch2); // store new top 6961 __ mov(Operand(scratch1, 0), scratch2); // store new top
6959 __ mov(Operand(result, HeapObject::kMapOffset), 6962 __ mov(Operand(result, HeapObject::kMapOffset),
6960 Immediate(Factory::heap_number_map())); 6963 Immediate(Factory::heap_number_map()));
6961 // Tag old top and use as result. 6964 // Tag old top and use as result.
6962 __ add(Operand(result), Immediate(kHeapObjectTag)); 6965 __ add(Operand(result), Immediate(kHeapObjectTag));
6963 } 6966 }
6964 6967
6965 6968
6966 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm, 6969 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
6967 Register scratch) { 6970 Register number) {
6968 Label load_smi, done; 6971 Label load_smi, done;
6969 6972
6970 __ test(scratch, Immediate(kSmiTagMask)); 6973 __ test(number, Immediate(kSmiTagMask));
6971 __ j(zero, &load_smi, not_taken); 6974 __ j(zero, &load_smi, not_taken);
6972 __ fld_d(FieldOperand(scratch, HeapNumber::kValueOffset)); 6975 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset));
6973 __ jmp(&done); 6976 __ jmp(&done);
6974 6977
6975 __ bind(&load_smi); 6978 __ bind(&load_smi);
6976 __ sar(scratch, kSmiTagSize); 6979 __ sar(number, kSmiTagSize);
6977 __ push(scratch); 6980 __ push(number);
6978 __ fild_s(Operand(esp, 0)); 6981 __ fild_s(Operand(esp, 0));
6979 __ pop(scratch); 6982 __ pop(number);
6980 6983
6981 __ bind(&done); 6984 __ bind(&done);
6982 } 6985 }
6983 6986
6984 6987
6985 void FloatingPointHelper::LoadFloatOperands(MacroAssembler* masm, 6988 void FloatingPointHelper::LoadFloatOperands(MacroAssembler* masm,
6986 Register scratch) { 6989 Register scratch) {
6987 Label load_smi_1, load_smi_2, done_load_1, done; 6990 Label load_smi_1, load_smi_2, done_load_1, done;
6988 __ mov(scratch, Operand(esp, 2 * kPointerSize)); 6991 __ mov(scratch, Operand(esp, 2 * kPointerSize));
6989 __ test(scratch, Immediate(kSmiTagMask)); 6992 __ test(scratch, Immediate(kSmiTagMask));
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
7865 7868
7866 int CompareStub::MinorKey() { 7869 int CompareStub::MinorKey() {
7867 // Encode the two parameters in a unique 16 bit value. 7870 // Encode the two parameters in a unique 16 bit value.
7868 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 7871 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
7869 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 7872 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
7870 } 7873 }
7871 7874
7872 #undef __ 7875 #undef __
7873 7876
7874 } } // namespace v8::internal 7877 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698