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

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

Issue 293023: Added infrastructure for optimizing new CanvasArray types in WebGL... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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
« no previous file with comments | « src/heap.cc ('k') | src/ia32/ic-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 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
770 Register scratch); 770 Register scratch);
771 // Test if operands are numbers (smi or HeapNumber objects), and load 771 // Test if operands are numbers (smi or HeapNumber objects), and load
772 // them into xmm0 and xmm1 if they are. Jump to label not_numbers if 772 // them into xmm0 and xmm1 if they are. Jump to label not_numbers if
773 // either operand is not a number. Operands are in edx and eax. 773 // either operand is not a number. Operands are in edx and eax.
774 // Leaves operands unchanged. 774 // Leaves operands unchanged.
775 static void LoadSse2Operands(MacroAssembler* masm, Label* not_numbers); 775 static void LoadSse2Operands(MacroAssembler* masm, Label* not_numbers);
776 // Allocate a heap number in new space with undefined value.
777 // Returns tagged pointer in eax, or jumps to need_gc if new space is full.
778 static void AllocateHeapNumber(MacroAssembler* masm,
779 Label* need_gc,
780 Register scratch1,
781 Register scratch2,
782 Register result);
783 }; 776 };
784 777
785 778
786 const char* GenericBinaryOpStub::GetName() { 779 const char* GenericBinaryOpStub::GetName() {
787 switch (op_) { 780 switch (op_) {
788 case Token::ADD: return "GenericBinaryOpStub_ADD"; 781 case Token::ADD: return "GenericBinaryOpStub_ADD";
789 case Token::SUB: return "GenericBinaryOpStub_SUB"; 782 case Token::SUB: return "GenericBinaryOpStub_SUB";
790 case Token::MUL: return "GenericBinaryOpStub_MUL"; 783 case Token::MUL: return "GenericBinaryOpStub_MUL";
791 case Token::DIV: return "GenericBinaryOpStub_DIV"; 784 case Token::DIV: return "GenericBinaryOpStub_DIV";
792 case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR"; 785 case Token::BIT_OR: return "GenericBinaryOpStub_BIT_OR";
(...skipping 4375 matching lines...) Expand 10 before | Expand all | Expand 10 after
5168 ASSERT(eax_reg.is_valid()); 5161 ASSERT(eax_reg.is_valid());
5169 __ fnstsw_ax(); 5162 __ fnstsw_ax();
5170 __ sahf(); 5163 __ sahf();
5171 eax_reg.Unuse(); 5164 eax_reg.Unuse();
5172 call_runtime.Branch(parity_even, not_taken); 5165 call_runtime.Branch(parity_even, not_taken);
5173 5166
5174 // Allocate heap number for result if possible. 5167 // Allocate heap number for result if possible.
5175 Result scratch1 = allocator()->Allocate(); 5168 Result scratch1 = allocator()->Allocate();
5176 Result scratch2 = allocator()->Allocate(); 5169 Result scratch2 = allocator()->Allocate();
5177 Result heap_number = allocator()->Allocate(); 5170 Result heap_number = allocator()->Allocate();
5178 FloatingPointHelper::AllocateHeapNumber(masm_, 5171 __ AllocateHeapNumber(heap_number.reg(),
5179 call_runtime.entry_label(), 5172 scratch1.reg(),
5180 scratch1.reg(), 5173 scratch2.reg(),
5181 scratch2.reg(), 5174 call_runtime.entry_label());
5182 heap_number.reg());
5183 scratch1.Unuse(); 5175 scratch1.Unuse();
5184 scratch2.Unuse(); 5176 scratch2.Unuse();
5185 5177
5186 // Store the result in the allocated heap number. 5178 // Store the result in the allocated heap number.
5187 __ fstp_d(FieldOperand(heap_number.reg(), HeapNumber::kValueOffset)); 5179 __ fstp_d(FieldOperand(heap_number.reg(), HeapNumber::kValueOffset));
5188 // Replace the extra copy of the argument with the result. 5180 // Replace the extra copy of the argument with the result.
5189 frame_->SetElementAt(0, &heap_number); 5181 frame_->SetElementAt(0, &heap_number);
5190 done.Jump(); 5182 done.Jump();
5191 5183
5192 call_runtime.Bind(); 5184 call_runtime.Bind();
(...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after
6829 // Fall through! 6821 // Fall through!
6830 case OVERWRITE_RIGHT: 6822 case OVERWRITE_RIGHT:
6831 // If the argument in eax is already an object, we skip the 6823 // If the argument in eax is already an object, we skip the
6832 // allocation of a heap number. 6824 // allocation of a heap number.
6833 __ test(eax, Immediate(kSmiTagMask)); 6825 __ test(eax, Immediate(kSmiTagMask));
6834 __ j(not_zero, &skip_allocation, not_taken); 6826 __ j(not_zero, &skip_allocation, not_taken);
6835 // Fall through! 6827 // Fall through!
6836 case NO_OVERWRITE: { 6828 case NO_OVERWRITE: {
6837 // Allocate a heap number for the result. Keep eax and edx intact 6829 // Allocate a heap number for the result. Keep eax and edx intact
6838 // for the possible runtime call. 6830 // for the possible runtime call.
6839 FloatingPointHelper::AllocateHeapNumber(masm, 6831 __ AllocateHeapNumber(ebx, ecx, no_reg, &call_runtime);
6840 &call_runtime,
6841 ecx,
6842 no_reg,
6843 ebx);
6844 // Now eax can be overwritten losing one of the arguments as we are 6832 // Now eax can be overwritten losing one of the arguments as we are
6845 // now done and will not need it any more. 6833 // now done and will not need it any more.
6846 __ mov(eax, ebx); 6834 __ mov(eax, ebx);
6847 __ bind(&skip_allocation); 6835 __ bind(&skip_allocation);
6848 break; 6836 break;
6849 } 6837 }
6850 default: UNREACHABLE(); 6838 default: UNREACHABLE();
6851 } 6839 }
6852 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0); 6840 __ movdbl(FieldOperand(eax, HeapNumber::kValueOffset), xmm0);
6853 GenerateReturn(masm); 6841 GenerateReturn(masm);
6854 } else { // SSE2 not available, use FPU. 6842 } else { // SSE2 not available, use FPU.
6855 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx); 6843 FloatingPointHelper::CheckFloatOperands(masm, &call_runtime, ebx);
6856 // Allocate a heap number, if needed. 6844 // Allocate a heap number, if needed.
6857 Label skip_allocation; 6845 Label skip_allocation;
6858 switch (mode_) { 6846 switch (mode_) {
6859 case OVERWRITE_LEFT: 6847 case OVERWRITE_LEFT:
6860 __ mov(eax, Operand(edx)); 6848 __ mov(eax, Operand(edx));
6861 // Fall through! 6849 // Fall through!
6862 case OVERWRITE_RIGHT: 6850 case OVERWRITE_RIGHT:
6863 // If the argument in eax is already an object, we skip the 6851 // If the argument in eax is already an object, we skip the
6864 // allocation of a heap number. 6852 // allocation of a heap number.
6865 __ test(eax, Immediate(kSmiTagMask)); 6853 __ test(eax, Immediate(kSmiTagMask));
6866 __ j(not_zero, &skip_allocation, not_taken); 6854 __ j(not_zero, &skip_allocation, not_taken);
6867 // Fall through! 6855 // Fall through!
6868 case NO_OVERWRITE: 6856 case NO_OVERWRITE:
6869 // Allocate a heap number for the result. Keep eax and edx intact 6857 // Allocate a heap number for the result. Keep eax and edx intact
6870 // for the possible runtime call. 6858 // for the possible runtime call.
6871 FloatingPointHelper::AllocateHeapNumber(masm, 6859 __ AllocateHeapNumber(ebx, ecx, no_reg, &call_runtime);
6872 &call_runtime,
6873 ecx,
6874 no_reg,
6875 ebx);
6876 // Now eax can be overwritten losing one of the arguments as we are 6860 // Now eax can be overwritten losing one of the arguments as we are
6877 // now done and will not need it any more. 6861 // now done and will not need it any more.
6878 __ mov(eax, ebx); 6862 __ mov(eax, ebx);
6879 __ bind(&skip_allocation); 6863 __ bind(&skip_allocation);
6880 break; 6864 break;
6881 default: UNREACHABLE(); 6865 default: UNREACHABLE();
6882 } 6866 }
6883 FloatingPointHelper::LoadFloatOperands(masm, ecx); 6867 FloatingPointHelper::LoadFloatOperands(masm, ecx);
6884 6868
6885 switch (op_) { 6869 switch (op_) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
6975 case OVERWRITE_LEFT: 6959 case OVERWRITE_LEFT:
6976 case OVERWRITE_RIGHT: 6960 case OVERWRITE_RIGHT:
6977 // If the operand was an object, we skip the 6961 // If the operand was an object, we skip the
6978 // allocation of a heap number. 6962 // allocation of a heap number.
6979 __ mov(eax, Operand(esp, mode_ == OVERWRITE_RIGHT ? 6963 __ mov(eax, Operand(esp, mode_ == OVERWRITE_RIGHT ?
6980 1 * kPointerSize : 2 * kPointerSize)); 6964 1 * kPointerSize : 2 * kPointerSize));
6981 __ test(eax, Immediate(kSmiTagMask)); 6965 __ test(eax, Immediate(kSmiTagMask));
6982 __ j(not_zero, &skip_allocation, not_taken); 6966 __ j(not_zero, &skip_allocation, not_taken);
6983 // Fall through! 6967 // Fall through!
6984 case NO_OVERWRITE: 6968 case NO_OVERWRITE:
6985 FloatingPointHelper::AllocateHeapNumber(masm, &call_runtime, 6969 __ AllocateHeapNumber(eax, ecx, edx, &call_runtime);
6986 ecx, edx, eax);
6987 __ bind(&skip_allocation); 6970 __ bind(&skip_allocation);
6988 break; 6971 break;
6989 default: UNREACHABLE(); 6972 default: UNREACHABLE();
6990 } 6973 }
6991 // Store the result in the HeapNumber and return. 6974 // Store the result in the HeapNumber and return.
6992 __ mov(Operand(esp, 1 * kPointerSize), ebx); 6975 __ mov(Operand(esp, 1 * kPointerSize), ebx);
6993 __ fild_s(Operand(esp, 1 * kPointerSize)); 6976 __ fild_s(Operand(esp, 1 * kPointerSize));
6994 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset)); 6977 __ fstp_d(FieldOperand(eax, HeapNumber::kValueOffset));
6995 __ ret(2 * kPointerSize); 6978 __ ret(2 * kPointerSize);
6996 } 6979 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
7126 // If arguments are not passed in registers remove them from the stack before 7109 // If arguments are not passed in registers remove them from the stack before
7127 // returning. 7110 // returning.
7128 if (!HasArgumentsInRegisters()) { 7111 if (!HasArgumentsInRegisters()) {
7129 __ ret(2 * kPointerSize); // Remove both operands 7112 __ ret(2 * kPointerSize); // Remove both operands
7130 } else { 7113 } else {
7131 __ ret(0); 7114 __ ret(0);
7132 } 7115 }
7133 } 7116 }
7134 7117
7135 7118
7136 void FloatingPointHelper::AllocateHeapNumber(MacroAssembler* masm,
7137 Label* need_gc,
7138 Register scratch1,
7139 Register scratch2,
7140 Register result) {
7141 // Allocate heap number in new space.
7142 __ AllocateInNewSpace(HeapNumber::kSize,
7143 result,
7144 scratch1,
7145 scratch2,
7146 need_gc,
7147 TAG_OBJECT);
7148
7149 // Set the map.
7150 __ mov(FieldOperand(result, HeapObject::kMapOffset),
7151 Immediate(Factory::heap_number_map()));
7152 }
7153
7154
7155 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm, 7119 void FloatingPointHelper::LoadFloatOperand(MacroAssembler* masm,
7156 Register number) { 7120 Register number) {
7157 Label load_smi, done; 7121 Label load_smi, done;
7158 7122
7159 __ test(number, Immediate(kSmiTagMask)); 7123 __ test(number, Immediate(kSmiTagMask));
7160 __ j(zero, &load_smi, not_taken); 7124 __ j(zero, &load_smi, not_taken);
7161 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset)); 7125 __ fld_d(FieldOperand(number, HeapNumber::kValueOffset));
7162 __ jmp(&done); 7126 __ jmp(&done);
7163 7127
7164 __ bind(&load_smi); 7128 __ bind(&load_smi);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
7301 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset)); 7265 __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
7302 __ cmp(edx, Factory::heap_number_map()); 7266 __ cmp(edx, Factory::heap_number_map());
7303 __ j(not_equal, &slow); 7267 __ j(not_equal, &slow);
7304 if (overwrite_) { 7268 if (overwrite_) {
7305 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset)); 7269 __ mov(edx, FieldOperand(eax, HeapNumber::kExponentOffset));
7306 __ xor_(edx, HeapNumber::kSignMask); // Flip sign. 7270 __ xor_(edx, HeapNumber::kSignMask); // Flip sign.
7307 __ mov(FieldOperand(eax, HeapNumber::kExponentOffset), edx); 7271 __ mov(FieldOperand(eax, HeapNumber::kExponentOffset), edx);
7308 } else { 7272 } else {
7309 __ mov(edx, Operand(eax)); 7273 __ mov(edx, Operand(eax));
7310 // edx: operand 7274 // edx: operand
7311 FloatingPointHelper::AllocateHeapNumber(masm, &undo, ebx, ecx, eax); 7275 __ AllocateHeapNumber(eax, ebx, ecx, &undo);
7312 // eax: allocated 'empty' number 7276 // eax: allocated 'empty' number
7313 __ mov(ecx, FieldOperand(edx, HeapNumber::kExponentOffset)); 7277 __ mov(ecx, FieldOperand(edx, HeapNumber::kExponentOffset));
7314 __ xor_(ecx, HeapNumber::kSignMask); // Flip sign. 7278 __ xor_(ecx, HeapNumber::kSignMask); // Flip sign.
7315 __ mov(FieldOperand(eax, HeapNumber::kExponentOffset), ecx); 7279 __ mov(FieldOperand(eax, HeapNumber::kExponentOffset), ecx);
7316 __ mov(ecx, FieldOperand(edx, HeapNumber::kMantissaOffset)); 7280 __ mov(ecx, FieldOperand(edx, HeapNumber::kMantissaOffset));
7317 __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx); 7281 __ mov(FieldOperand(eax, HeapNumber::kMantissaOffset), ecx);
7318 } 7282 }
7319 7283
7320 __ bind(&done); 7284 __ bind(&done);
7321 7285
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
8126 8090
8127 int CompareStub::MinorKey() { 8091 int CompareStub::MinorKey() {
8128 // Encode the two parameters in a unique 16 bit value. 8092 // Encode the two parameters in a unique 16 bit value.
8129 ASSERT(static_cast<unsigned>(cc_) < (1 << 15)); 8093 ASSERT(static_cast<unsigned>(cc_) < (1 << 15));
8130 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0); 8094 return (static_cast<unsigned>(cc_) << 1) | (strict_ ? 1 : 0);
8131 } 8095 }
8132 8096
8133 #undef __ 8097 #undef __
8134 8098
8135 } } // namespace v8::internal 8099 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/ia32/ic-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698