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

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: Fixed a bunch of issues and included suggestions. 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 { rax, r11, r15, EMIT_REMEMBERED_SET},
5673 { rdx, rax, 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 __ movq(r15, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
5974 // r15: the-hole NaN
5975 __ jmp(&entry);
5976 __ bind(&loop);
5977 __ decq(r9);
5978 __ movq(rbx,
5979 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize));
5980 // r9 : current element's index
5981 // rbx: current element (smi-tagged)
5982 __ JumpIfNotSmi(rbx, &convert_hole);
5983 __ SmiToInteger32(rbx, rbx);
5984 __ cvtlsi2sd(xmm0, rbx);
5985 __ movsd(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize),
5986 xmm0);
5987 __ jmp(&entry);
5988 __ bind(&convert_hole);
5989 __ movq(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize), r15);
5990 __ bind(&entry);
5991 __ testq(r9, r9);
5992 __ j(not_zero, &loop);
5993 }
5994
5995
5996 void FastElementsConversionStub::GenerateDoubleToObject(
5997 MacroAssembler* masm, StrictModeFlag strict_mode) {
5998 // ----------- S t a t e -------------
5999 // -- rax : value
6000 // -- rbx : target map
6001 // -- rcx : key
6002 // -- rdx : receiver
6003 // -- rsp[0] : return address
6004 // -----------------------------------
6005 Label loop, entry, convert_hole, gc_required;
6006 __ push(rax);
6007
6008 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
6009 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
6010 // r8 : source FixedDoubleArray
6011 // r9 : number of elements
6012 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize));
6013 __ AllocateInNewSpace(rdi, rax, r14, r15, &gc_required, TAG_OBJECT);
6014 // rax: destination FixedArray
6015 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex);
6016 __ movq(FieldOperand(rax, HeapObject::kMapOffset), rdi);
6017 __ Integer32ToSmi(r14, r9);
6018 __ movq(FieldOperand(rax, FixedArray::kLengthOffset), r14);
6019
6020 // Prepare for conversion loop.
6021 __ movq(rsi, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
6022 __ Move(rdi, masm->isolate()->factory()->the_hole_value());
6023 // rsi: the-hole NaN
6024 // rdi: pointer to the-hole
6025 __ jmp(&entry);
6026
6027 // Call into runtime if GC is required.
6028 __ bind(&gc_required);
6029 __ pop(rax);
6030 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
6031 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
6032
6033 // Box doubles into heap numbers.
6034 __ bind(&loop);
6035 __ decq(r9);
6036 __ movq(r14, FieldOperand(r8,
6037 r9,
6038 times_pointer_size,
6039 FixedDoubleArray::kHeaderSize));
6040 // r9 : current element's index
6041 // r14: current element
6042 __ cmpq(r14, rsi);
6043 __ j(equal, &convert_hole);
6044
6045 // Non-hole double, copy value into a heap number.
6046 __ AllocateHeapNumber(r11, r15, &gc_required);
6047 // r11: new heap number
6048 __ movq(FieldOperand(r11, HeapNumber::kValueOffset), r14);
6049 __ movq(FieldOperand(rax,
6050 r9,
6051 times_pointer_size,
6052 FixedArray::kHeaderSize),
6053 r11);
6054 __ movq(r15, r9);
6055 __ RecordWriteArray(rax,
6056 r11,
6057 r15,
6058 kDontSaveFPRegs,
6059 EMIT_REMEMBERED_SET,
6060 OMIT_SMI_CHECK);
6061 __ jmp(&entry, Label::kNear);
6062
6063 // Replace the-hole NaN with the-hole pointer.
6064 __ bind(&convert_hole);
6065 __ movq(FieldOperand(rax,
6066 r9,
6067 times_pointer_size,
6068 FixedArray::kHeaderSize),
6069 rdi);
6070
6071 __ bind(&entry);
6072 __ testq(r9, r9);
6073 __ j(not_zero, &loop);
6074
6075 // Set transitioned map.
6076 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
6077 __ RecordWriteField(rdx,
6078 HeapObject::kMapOffset,
6079 rbx,
6080 rdi,
6081 kDontSaveFPRegs,
6082 EMIT_REMEMBERED_SET,
6083 OMIT_SMI_CHECK);
6084 // Replace receiver's backing store with newly created and filled FixedArray.
6085 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), rax);
6086 __ RecordWriteField(rdx,
6087 JSObject::kElementsOffset,
6088 rax,
6089 rdi,
6090 kDontSaveFPRegs,
6091 EMIT_REMEMBERED_SET,
6092 OMIT_SMI_CHECK);
6093 __ pop(rax);
6094 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
6095 }
6096
5916 #undef __ 6097 #undef __
5917 6098
5918 } } // namespace v8::internal 6099 } } // namespace v8::internal
5919 6100
5920 #endif // V8_TARGET_ARCH_X64 6101 #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