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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

Issue 8355035: Refactor elements kind conversion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Bugfix Created 9 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/codegen.h ('k') | src/ia32/codegen-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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 6755 matching lines...) Expand 10 before | Expand all | Expand 10 after
6766 { edx, ecx, ebx, EMIT_REMEMBERED_SET }, 6766 { edx, ecx, ebx, EMIT_REMEMBERED_SET },
6767 // GenerateStoreField calls the stub with two different permutations of 6767 // GenerateStoreField calls the stub with two different permutations of
6768 // registers. This is the second. 6768 // registers. This is the second.
6769 { ebx, ecx, edx, EMIT_REMEMBERED_SET }, 6769 { ebx, ecx, edx, EMIT_REMEMBERED_SET },
6770 // StoreIC::GenerateNormal via GenerateDictionaryStore 6770 // StoreIC::GenerateNormal via GenerateDictionaryStore
6771 { ebx, edi, edx, EMIT_REMEMBERED_SET }, 6771 { ebx, edi, edx, EMIT_REMEMBERED_SET },
6772 // KeyedStoreIC::GenerateGeneric. 6772 // KeyedStoreIC::GenerateGeneric.
6773 { ebx, edx, ecx, EMIT_REMEMBERED_SET}, 6773 { ebx, edx, ecx, EMIT_REMEMBERED_SET},
6774 // KeyedStoreStubCompiler::GenerateStoreFastElement. 6774 // KeyedStoreStubCompiler::GenerateStoreFastElement.
6775 { edi, edx, ecx, EMIT_REMEMBERED_SET}, 6775 { edi, edx, ecx, EMIT_REMEMBERED_SET},
6776 // FastElementConversionStub::GenerateSmiOnlyToObject 6776 // ElementsTransitionGenerator::GenerateSmiOnlyToObject
6777 // and FastElementsConversionStub::GenerateSmiOnlyToDouble 6777 // and ElementsTransitionGenerator::GenerateSmiOnlyToDouble
6778 // and FastElementsConversionStub::GenerateDoubleToObject 6778 // and ElementsTransitionGenerator::GenerateDoubleToObject
6779 { edx, ebx, edi, EMIT_REMEMBERED_SET}, 6779 { edx, ebx, edi, EMIT_REMEMBERED_SET},
6780 // FastElementConversionStub::GenerateDoubleToObject 6780 // ElementsTransitionGenerator::GenerateDoubleToObject
6781 { eax, edx, esi, EMIT_REMEMBERED_SET}, 6781 { eax, edx, esi, EMIT_REMEMBERED_SET},
6782 { edx, eax, edi, EMIT_REMEMBERED_SET}, 6782 { edx, eax, edi, EMIT_REMEMBERED_SET},
6783 // Null termination. 6783 // Null termination.
6784 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET} 6784 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET}
6785 }; 6785 };
6786 6786
6787 6787
6788 bool RecordWriteStub::IsPregenerated() { 6788 bool RecordWriteStub::IsPregenerated() {
6789 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime; 6789 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
6790 !entry->object.is(no_reg); 6790 !entry->object.is(no_reg);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
7015 } 7015 }
7016 7016
7017 __ bind(&need_incremental_pop_object); 7017 __ bind(&need_incremental_pop_object);
7018 __ pop(regs_.object()); 7018 __ pop(regs_.object());
7019 7019
7020 __ bind(&need_incremental); 7020 __ bind(&need_incremental);
7021 7021
7022 // Fall through when we need to inform the incremental marker. 7022 // Fall through when we need to inform the incremental marker.
7023 } 7023 }
7024 7024
7025
7026 void FastElementsConversionStub::GenerateSmiOnlyToObject(MacroAssembler* masm,
7027 StrictModeFlag
7028 strict_mode) {
7029 // ----------- S t a t e -------------
7030 // -- eax : value
7031 // -- ebx : target map
7032 // -- ecx : key
7033 // -- edx : receiver
7034 // -- esp[0] : return address
7035 // -----------------------------------
7036 // Set transitioned map.
7037 if (FLAG_trace_elements_transitions) {
7038 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
7039 } else {
7040 __ mov(FieldOperand(edx, HeapObject::kMapOffset), ebx);
7041 __ RecordWriteField(edx,
7042 HeapObject::kMapOffset,
7043 ebx,
7044 edi,
7045 kDontSaveFPRegs,
7046 EMIT_REMEMBERED_SET,
7047 OMIT_SMI_CHECK);
7048 }
7049 }
7050
7051
7052 void FastElementsConversionStub::GenerateSmiOnlyToDouble(
7053 MacroAssembler* masm, StrictModeFlag strict_mode) {
7054 // ----------- S t a t e -------------
7055 // -- eax : value
7056 // -- ebx : target map
7057 // -- ecx : key
7058 // -- edx : receiver
7059 // -- esp[0] : return address
7060 // -----------------------------------
7061 if (FLAG_trace_elements_transitions) {
7062 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
7063 } else {
7064 Label loop, entry, convert_hole, gc_required;
7065
7066 __ push(eax);
7067 __ push(ebx);
7068 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
7069 __ mov(edi, FieldOperand(edi, FixedArray::kLengthOffset));
7070
7071 // Allocate new FixedDoubleArray.
7072 // edx: receiver
7073 // edi: length of source FixedArray (smi-tagged)
7074 __ lea(esi, Operand(edi, times_4, FixedDoubleArray::kHeaderSize));
7075 __ AllocateInNewSpace(esi, eax, ebx, no_reg, &gc_required, TAG_OBJECT);
7076
7077 // eax: destination FixedDoubleArray
7078 // edi: number of elements
7079 // edx: receiver
7080 __ mov(FieldOperand(eax, HeapObject::kMapOffset),
7081 Immediate(masm->isolate()->factory()->fixed_double_array_map()));
7082 __ mov(FieldOperand(eax, FixedDoubleArray::kLengthOffset), edi);
7083 __ mov(esi, FieldOperand(edx, JSObject::kElementsOffset));
7084 // Replace receiver's backing store with newly created FixedDoubleArray.
7085 __ mov(FieldOperand(edx, JSObject::kElementsOffset), eax);
7086 __ mov(ebx, eax);
7087 __ RecordWriteField(edx,
7088 JSObject::kElementsOffset,
7089 ebx,
7090 edi,
7091 kDontSaveFPRegs,
7092 EMIT_REMEMBERED_SET,
7093 OMIT_SMI_CHECK);
7094
7095 __ mov(edi, FieldOperand(esi, FixedArray::kLengthOffset));
7096
7097 // Prepare for conversion loop.
7098 ExternalReference canonical_the_hole_nan_reference =
7099 ExternalReference::address_of_the_hole_nan();
7100 XMMRegister the_hole_nan = xmm1;
7101 if (CpuFeatures::IsSupported(SSE2)) {
7102 CpuFeatures::Scope use_sse2(SSE2);
7103 __ movdbl(the_hole_nan,
7104 Operand::StaticVariable(canonical_the_hole_nan_reference));
7105 }
7106 __ jmp(&entry);
7107
7108 // Call into runtime if GC is required.
7109 __ bind(&gc_required);
7110 // Restore registers before jumping into runtime.
7111 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
7112 __ pop(ebx);
7113 __ pop(eax);
7114 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
7115
7116 // Convert and copy elements
7117 // esi: source FixedArray
7118 // edi: number of elements to convert/copy
7119 __ bind(&loop);
7120 __ sub(edi, Immediate(Smi::FromInt(1)));
7121 __ mov(ebx, FieldOperand(esi, edi, times_2, FixedArray::kHeaderSize));
7122 // ebx: current element from source
7123 // edi: index of current element
7124 __ JumpIfNotSmi(ebx, &convert_hole);
7125
7126 // Normal smi, convert it to double and store.
7127 __ SmiUntag(ebx);
7128 if (CpuFeatures::IsSupported(SSE2)) {
7129 CpuFeatures::Scope fscope(SSE2);
7130 __ cvtsi2sd(xmm0, ebx);
7131 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize),
7132 xmm0);
7133 } else {
7134 __ push(ebx);
7135 __ fild_s(Operand(esp, 0));
7136 __ pop(ebx);
7137 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize));
7138 }
7139 __ jmp(&entry);
7140
7141 // Found hole, store hole_nan_as_double instead.
7142 __ bind(&convert_hole);
7143 if (CpuFeatures::IsSupported(SSE2)) {
7144 CpuFeatures::Scope use_sse2(SSE2);
7145 __ movdbl(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize),
7146 the_hole_nan);
7147 } else {
7148 __ fld_d(Operand::StaticVariable(canonical_the_hole_nan_reference));
7149 __ fstp_d(FieldOperand(eax, edi, times_4, FixedDoubleArray::kHeaderSize));
7150 }
7151
7152 __ bind(&entry);
7153 __ test(edi, edi);
7154 __ j(not_zero, &loop);
7155
7156 __ pop(ebx);
7157 __ pop(eax);
7158 // eax: value
7159 // ebx: target map
7160 // Set transitioned map.
7161 __ mov(FieldOperand(edx, HeapObject::kMapOffset), ebx);
7162 __ RecordWriteField(edx,
7163 HeapObject::kMapOffset,
7164 ebx,
7165 edi,
7166 kDontSaveFPRegs,
7167 EMIT_REMEMBERED_SET,
7168 OMIT_SMI_CHECK);
7169 // Restore esi.
7170 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
7171 }
7172 }
7173
7174
7175 void FastElementsConversionStub::GenerateDoubleToObject(
7176 MacroAssembler* masm, StrictModeFlag strict_mode) {
7177 // ----------- S t a t e -------------
7178 // -- eax : value
7179 // -- ebx : target map
7180 // -- ecx : key
7181 // -- edx : receiver
7182 // -- esp[0] : return address
7183 // -----------------------------------
7184 if (FLAG_trace_elements_transitions) {
7185 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
7186 } else {
7187 Label loop, entry, convert_hole, gc_required;
7188 __ push(eax);
7189 __ push(edx);
7190 __ push(ebx);
7191
7192 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
7193 __ mov(ebx, FieldOperand(edi, FixedDoubleArray::kLengthOffset));
7194
7195 // Allocate new FixedArray.
7196 // ebx: length of source FixedDoubleArray (smi-tagged)
7197 __ lea(edi, Operand(ebx, times_2, FixedArray::kHeaderSize));
7198 __ AllocateInNewSpace(edi, eax, esi, no_reg, &gc_required, TAG_OBJECT);
7199
7200 // eax: destination FixedArray
7201 // ebx: number of elements
7202 __ mov(FieldOperand(eax, HeapObject::kMapOffset),
7203 Immediate(masm->isolate()->factory()->fixed_array_map()));
7204 __ mov(FieldOperand(eax, FixedArray::kLengthOffset), ebx);
7205 __ mov(edi, FieldOperand(edx, JSObject::kElementsOffset));
7206
7207 __ jmp(&entry);
7208
7209 // Call into runtime if GC is required.
7210 __ bind(&gc_required);
7211 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
7212 __ pop(ebx);
7213 __ pop(edx);
7214 __ pop(eax);
7215 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
7216
7217 // Box doubles into heap numbers.
7218 // edi: source FixedDoubleArray
7219 // eax: destination FixedArray
7220 __ bind(&loop);
7221 __ sub(ebx, Immediate(Smi::FromInt(1)));
7222 // ebx: index of current element (smi-tagged)
7223 uint32_t offset = FixedDoubleArray::kHeaderSize + sizeof(kHoleNanLower32);
7224 __ cmp(FieldOperand(edi, ebx, times_4, offset), Immediate(kHoleNanUpper32));
7225 __ j(equal, &convert_hole);
7226
7227 // Non-hole double, copy value into a heap number.
7228 __ AllocateHeapNumber(edx, esi, no_reg, &gc_required);
7229 // edx: new heap number
7230 if (CpuFeatures::IsSupported(SSE2)) {
7231 CpuFeatures::Scope fscope(SSE2);
7232 __ movdbl(xmm0,
7233 FieldOperand(edi, ebx, times_4, FixedDoubleArray::kHeaderSize));
7234 __ movdbl(FieldOperand(edx, HeapNumber::kValueOffset), xmm0);
7235 } else {
7236 __ mov(esi, FieldOperand(edi, ebx, times_4,
7237 FixedDoubleArray::kHeaderSize));
7238 __ mov(FieldOperand(edx, HeapNumber::kValueOffset), esi);
7239 __ mov(esi, FieldOperand(edi, ebx, times_4, offset));
7240 __ mov(FieldOperand(edx, HeapNumber::kValueOffset + kPointerSize), esi);
7241 }
7242 __ mov(FieldOperand(eax, ebx, times_2, FixedArray::kHeaderSize), edx);
7243 __ mov(esi, ebx);
7244 __ RecordWriteArray(eax,
7245 edx,
7246 esi,
7247 kDontSaveFPRegs,
7248 EMIT_REMEMBERED_SET,
7249 OMIT_SMI_CHECK);
7250 __ jmp(&entry, Label::kNear);
7251
7252 // Replace the-hole NaN with the-hole pointer.
7253 __ bind(&convert_hole);
7254 __ mov(FieldOperand(eax, ebx, times_2, FixedArray::kHeaderSize),
7255 masm->isolate()->factory()->the_hole_value());
7256
7257 __ bind(&entry);
7258 __ test(ebx, ebx);
7259 __ j(not_zero, &loop);
7260
7261 __ pop(ebx);
7262 __ pop(edx);
7263 // ebx: target map
7264 // edx: receiver
7265 // Set transitioned map.
7266 __ mov(FieldOperand(edx, HeapObject::kMapOffset), ebx);
7267 __ RecordWriteField(edx,
7268 HeapObject::kMapOffset,
7269 ebx,
7270 edi,
7271 kDontSaveFPRegs,
7272 EMIT_REMEMBERED_SET,
7273 OMIT_SMI_CHECK);
7274 // Replace receiver's backing store with newly created and filled
7275 // FixedArray.
7276 __ mov(FieldOperand(edx, JSObject::kElementsOffset), eax);
7277 __ RecordWriteField(edx,
7278 JSObject::kElementsOffset,
7279 eax,
7280 edi,
7281 kDontSaveFPRegs,
7282 EMIT_REMEMBERED_SET,
7283 OMIT_SMI_CHECK);
7284
7285 // Restore registers.
7286 __ pop(eax);
7287 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
7288 }
7289 }
7290
7291 #undef __ 7025 #undef __
7292 7026
7293 } } // namespace v8::internal 7027 } } // namespace v8::internal
7294 7028
7295 #endif // V8_TARGET_ARCH_IA32 7029 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/codegen.h ('k') | src/ia32/codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698