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

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

Issue 8271007: Porting r9605 to x64 (elements kind conversion in generated code). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Some fixes. 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/ia32/code-stubs-ia32.cc ('k') | src/x64/ic-x64.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 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after
5658 { rdx, rcx, rbx, EMIT_REMEMBERED_SET }, 5658 { rdx, rcx, rbx, EMIT_REMEMBERED_SET },
5659 // GenerateStoreField calls the stub with two different permutations of 5659 // GenerateStoreField calls the stub with two different permutations of
5660 // registers. This is the second. 5660 // registers. This is the second.
5661 { rbx, rcx, rdx, EMIT_REMEMBERED_SET }, 5661 { rbx, rcx, rdx, EMIT_REMEMBERED_SET },
5662 // StoreIC::GenerateNormal via GenerateDictionaryStore. 5662 // StoreIC::GenerateNormal via GenerateDictionaryStore.
5663 { rbx, r8, r9, EMIT_REMEMBERED_SET }, 5663 { rbx, r8, r9, EMIT_REMEMBERED_SET },
5664 // KeyedStoreIC::GenerateGeneric. 5664 // KeyedStoreIC::GenerateGeneric.
5665 { rbx, rdx, rcx, EMIT_REMEMBERED_SET}, 5665 { rbx, rdx, rcx, EMIT_REMEMBERED_SET},
5666 // KeyedStoreStubCompiler::GenerateStoreFastElement. 5666 // KeyedStoreStubCompiler::GenerateStoreFastElement.
5667 { rdi, rdx, rcx, EMIT_REMEMBERED_SET}, 5667 { rdi, rdx, rcx, EMIT_REMEMBERED_SET},
5668 // FastElementsConversionStub::GenerateSmiOnlyToObject
5669 // and FastElementsConversionStub::GenerateDoubleToObject
5670 { rdx, rbx, rdi, EMIT_REMEMBERED_SET},
5671 // FastElementsConversionStub::GenerateDoubleToObject
5672 { r11, r12, r13, EMIT_REMEMBERED_SET},
5673 { rdx, r11, rdi, EMIT_REMEMBERED_SET},
5668 // Null termination. 5674 // Null termination.
5669 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET} 5675 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET}
5670 }; 5676 };
5671 5677
5672 5678
5673 bool RecordWriteStub::IsPregenerated() { 5679 bool RecordWriteStub::IsPregenerated() {
5674 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime; 5680 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
5675 !entry->object.is(no_reg); 5681 !entry->object.is(no_reg);
5676 entry++) { 5682 entry++) {
5677 if (object_.is(entry->object) && 5683 if (object_.is(entry->object) &&
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
5906 5912
5907 __ bind(&need_incremental_pop_object); 5913 __ bind(&need_incremental_pop_object);
5908 __ pop(regs_.object()); 5914 __ pop(regs_.object());
5909 5915
5910 __ bind(&need_incremental); 5916 __ bind(&need_incremental);
5911 5917
5912 // Fall through when we need to inform the incremental marker. 5918 // Fall through when we need to inform the incremental marker.
5913 } 5919 }
5914 5920
5915 5921
5922 void FastElementsConversionStub::GenerateSmiOnlyToObject(MacroAssembler* masm) {
5923 // ----------- S t a t e -------------
5924 // -- rax : value
5925 // -- rbx : target map
5926 // -- rcx : key
5927 // -- rdx : receiver
5928 // -- rsp[0] : return address
5929 // -----------------------------------
5930 // Set transitioned map.
5931 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
5932 __ RecordWriteField(rdx,
5933 HeapObject::kMapOffset,
5934 rbx,
5935 rdi,
5936 kDontSaveFPRegs,
5937 EMIT_REMEMBERED_SET,
5938 OMIT_SMI_CHECK);
5939 }
5940
5941
5942 void FastElementsConversionStub::GenerateSmiOnlyToDouble(
5943 MacroAssembler* masm, StrictModeFlag strict_mode) {
5944 // ----------- S t a t e -------------
5945 // -- rax : value
5946 // -- rbx : target map
5947 // -- rcx : key
5948 // -- rdx : receiver
5949 // -- rsp[0] : return address
5950 // -----------------------------------
5951 // Set transitioned map.
5952 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
5953 __ RecordWriteField(rdx,
5954 HeapObject::kMapOffset,
5955 rbx,
5956 rdi,
5957 kDontSaveFPRegs,
5958 EMIT_REMEMBERED_SET,
5959 OMIT_SMI_CHECK);
5960 // Set backing store's map
5961 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
5962 __ LoadRoot(rdi, Heap::kFixedDoubleArrayMapRootIndex);
5963 __ movq(FieldOperand(r8, HeapObject::kMapOffset), rdi);
5964
5965 // Convert smis to doubles and holes to hole NaNs. Since FixedArray and
5966 // FixedDoubleArray do not differ in size, we do not allocate a new array.
5967 STATIC_ASSERT(FixedDoubleArray::kLengthOffset == FixedArray::kLengthOffset);
5968 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
5969 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
5970 // r8 : elements array
5971 // r9 : elements array length
5972 Label loop, entry, convert_hole;
5973 __ jmp(&entry);
5974 __ bind(&loop);
5975 __ decq(r9);
5976 __ movq(rbx,
5977 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize));
5978 // r9 : current element's index
5979 // rbx: current element (smi-tagged)
5980 __ JumpIfNotSmi(rbx, &convert_hole);
5981 __ SmiToInteger32(rbx, rbx);
5982 __ cvtlsi2sd(xmm0, rbx);
5983 __ movsd(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize),
5984 xmm0);
5985 __ jmp(&entry);
5986 __ bind(&convert_hole);
5987 __ movq(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize),
5988 Immediate(BitCast<int64_t>(kHoleNanInt64)));
5989 __ bind(&entry);
5990 __ testq(r9, r9);
5991 __ j(not_zero, &loop);
5992 }
5993
5994
5995 void FastElementsConversionStub::GenerateDoubleToObject(
5996 MacroAssembler* masm, StrictModeFlag strict_mode) {
5997 // ----------- S t a t e -------------
5998 // -- rax : value
5999 // -- rbx : target map
6000 // -- rcx : key
6001 // -- rdx : receiver
6002 // -- rsp[0] : return address
6003 // -----------------------------------
6004 Label loop, entry, convert_hole, gc_required;
6005
6006 __ jmp(&gc_required);
Jakob Kummerow 2011/10/14 09:25:38 lolwut?
Yang 2011/10/14 16:04:28 Forgot to take this out after some debugging.
6007 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
6008 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
6009 // r8 : source FixedDoubleArray
6010 // r9 : number of elements
6011 __ lea(rdi, Operand(r9, times_8, FixedArray::kHeaderSize));
6012 __ AllocateInNewSpace(rdi, r11, r12, r13, &gc_required, TAG_OBJECT);
6013 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex);
6014 __ movq(FieldOperand(r11, HeapObject::kMapOffset), rdi);
6015 __ Integer32ToSmiField(FieldOperand(r11, FixedArray::kLengthOffset), r9);
6016 // r11: destination FixedArray
Jakob Kummerow 2011/10/14 09:25:38 Please move this up to after the AllocateInNewSpac
Yang 2011/10/14 16:04:28 Done.
6017
6018 // Prepare for conversion loop.
6019 __ Move(rdi, masm->isolate()->factory()->the_hole_value());
6020 __ jmp(&entry);
6021
6022 // Call into runtime if GC is required.
6023 __ bind(&gc_required);
6024 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
6025
6026 // Box doubles into heap numbers.
6027 __ bind(&loop);
6028 __ decq(r9);
6029 __ movq(r14, FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize));
6030 // r9 : current element's index
6031 // r14: current element
6032 // rdi: the hole NaN
6033 __ cmpq(r14, Immediate(BitCast<int64_t>(kHoleNanInt64)));
6034 __ j(equal, &convert_hole);
6035
6036 // Non-hole double, copy value into a heap number.
6037 __ AllocateHeapNumber(r12, r13, &gc_required);
6038 // r12: new heap number
6039 __ movq(FieldOperand(r12, HeapNumber::kValueOffset), r14);
6040 __ movq(FieldOperand(r11, r9, times_8, FixedDoubleArray::kHeaderSize), r12);
Jakob Kummerow 2011/10/14 09:25:38 FixedArray::kHeaderSize (I know they're the same,
Yang 2011/10/14 16:04:28 Done.
6041 __ movq(r13, r9);
6042 __ RecordWriteArray(r11,
6043 r12,
6044 r13,
6045 kDontSaveFPRegs,
6046 EMIT_REMEMBERED_SET,
6047 OMIT_SMI_CHECK);
6048 __ jmp(&entry, Label::kNear);
6049
6050 // Replace the-hole NaN with the-hole pointer.
6051 __ bind(&convert_hole);
6052 __ movq(FieldOperand(r11, r9, times_8, FixedDoubleArray::kHeaderSize), rdi);
Jakob Kummerow 2011/10/14 09:25:38 times_pointer_size, FixedArray::kHeaderSize
Yang 2011/10/14 16:04:28 Done.
6053
6054 __ bind(&entry);
6055 __ testq(r9, r9);
6056 __ j(not_zero, &loop);
6057
6058 // Set transitioned map.
6059 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
6060 __ RecordWriteField(rdx,
6061 HeapObject::kMapOffset,
6062 rbx,
6063 rdi,
6064 kDontSaveFPRegs,
6065 EMIT_REMEMBERED_SET,
6066 OMIT_SMI_CHECK);
6067 // Replace receiver's backing store with newly created and filled FixedArray.
6068 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), r11);
6069 __ RecordWriteField(rdx,
6070 HeapObject::kMapOffset,
Jakob Kummerow 2011/10/14 09:25:38 JSObject::kElementsOffset!
Yang 2011/10/14 16:04:28 Done.
6071 r11,
6072 rdi,
6073 kDontSaveFPRegs,
6074 EMIT_REMEMBERED_SET,
6075 OMIT_SMI_CHECK);
6076 }
6077
5916 #undef __ 6078 #undef __
5917 6079
5918 } } // namespace v8::internal 6080 } } // namespace v8::internal
5919 6081
5920 #endif // V8_TARGET_ARCH_X64 6082 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ia32/code-stubs-ia32.cc ('k') | src/x64/ic-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698