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

Side by Side Diff: src/x64/code-stubs-x64.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/ic.cc ('k') | src/x64/codegen-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 5670 matching lines...) Expand 10 before | Expand all | Expand 10 after
5681 { rdx, rcx, rbx, EMIT_REMEMBERED_SET }, 5681 { rdx, rcx, rbx, EMIT_REMEMBERED_SET },
5682 // GenerateStoreField calls the stub with two different permutations of 5682 // GenerateStoreField calls the stub with two different permutations of
5683 // registers. This is the second. 5683 // registers. This is the second.
5684 { rbx, rcx, rdx, EMIT_REMEMBERED_SET }, 5684 { rbx, rcx, rdx, EMIT_REMEMBERED_SET },
5685 // StoreIC::GenerateNormal via GenerateDictionaryStore. 5685 // StoreIC::GenerateNormal via GenerateDictionaryStore.
5686 { rbx, r8, r9, EMIT_REMEMBERED_SET }, 5686 { rbx, r8, r9, EMIT_REMEMBERED_SET },
5687 // KeyedStoreIC::GenerateGeneric. 5687 // KeyedStoreIC::GenerateGeneric.
5688 { rbx, rdx, rcx, EMIT_REMEMBERED_SET}, 5688 { rbx, rdx, rcx, EMIT_REMEMBERED_SET},
5689 // KeyedStoreStubCompiler::GenerateStoreFastElement. 5689 // KeyedStoreStubCompiler::GenerateStoreFastElement.
5690 { rdi, rdx, rcx, EMIT_REMEMBERED_SET}, 5690 { rdi, rdx, rcx, EMIT_REMEMBERED_SET},
5691 // FastElementsConversionStub::GenerateSmiOnlyToObject 5691 // ElementsTransitionGenerator::GenerateSmiOnlyToObject
5692 // and FastElementsConversionStub::GenerateDoubleToObject 5692 // and ElementsTransitionGenerator::GenerateDoubleToObject
5693 { rdx, rbx, rdi, EMIT_REMEMBERED_SET}, 5693 { rdx, rbx, rdi, EMIT_REMEMBERED_SET},
5694 // FastElementsConversionStub::GenerateDoubleToObject 5694 // ElementsTransitionGenerator::GenerateDoubleToObject
5695 { rax, r11, r15, EMIT_REMEMBERED_SET}, 5695 { rax, r11, r15, EMIT_REMEMBERED_SET},
5696 { rdx, rax, rdi, EMIT_REMEMBERED_SET}, 5696 { rdx, rax, rdi, EMIT_REMEMBERED_SET},
5697 // Null termination. 5697 // Null termination.
5698 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET} 5698 { no_reg, no_reg, no_reg, EMIT_REMEMBERED_SET}
5699 }; 5699 };
5700 5700
5701 5701
5702 bool RecordWriteStub::IsPregenerated() { 5702 bool RecordWriteStub::IsPregenerated() {
5703 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime; 5703 for (AheadOfTimeWriteBarrierStubList* entry = kAheadOfTime;
5704 !entry->object.is(no_reg); 5704 !entry->object.is(no_reg);
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
5934 } 5934 }
5935 5935
5936 __ bind(&need_incremental_pop_object); 5936 __ bind(&need_incremental_pop_object);
5937 __ pop(regs_.object()); 5937 __ pop(regs_.object());
5938 5938
5939 __ bind(&need_incremental); 5939 __ bind(&need_incremental);
5940 5940
5941 // Fall through when we need to inform the incremental marker. 5941 // Fall through when we need to inform the incremental marker.
5942 } 5942 }
5943 5943
5944
5945 void FastElementsConversionStub::GenerateSmiOnlyToObject(
5946 MacroAssembler* masm,
5947 StrictModeFlag strict_mode) {
5948 // ----------- S t a t e -------------
5949 // -- rax : value
5950 // -- rbx : target map
5951 // -- rcx : key
5952 // -- rdx : receiver
5953 // -- rsp[0] : return address
5954 // -----------------------------------
5955 // Set transitioned map.
5956 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
5957 __ RecordWriteField(rdx,
5958 HeapObject::kMapOffset,
5959 rbx,
5960 rdi,
5961 kDontSaveFPRegs,
5962 EMIT_REMEMBERED_SET,
5963 OMIT_SMI_CHECK);
5964 }
5965
5966
5967 void FastElementsConversionStub::GenerateSmiOnlyToDouble(
5968 MacroAssembler* masm, StrictModeFlag strict_mode) {
5969 // ----------- S t a t e -------------
5970 // -- rax : value
5971 // -- rbx : target map
5972 // -- rcx : key
5973 // -- rdx : receiver
5974 // -- rsp[0] : return address
5975 // -----------------------------------
5976 // Set transitioned map.
5977 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
5978 __ RecordWriteField(rdx,
5979 HeapObject::kMapOffset,
5980 rbx,
5981 rdi,
5982 kDontSaveFPRegs,
5983 EMIT_REMEMBERED_SET,
5984 OMIT_SMI_CHECK);
5985 // Set backing store's map
5986 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
5987 __ LoadRoot(rdi, Heap::kFixedDoubleArrayMapRootIndex);
5988 __ movq(FieldOperand(r8, HeapObject::kMapOffset), rdi);
5989
5990 // Convert smis to doubles and holes to hole NaNs. Since FixedArray and
5991 // FixedDoubleArray do not differ in size, we do not allocate a new array.
5992 STATIC_ASSERT(FixedDoubleArray::kLengthOffset == FixedArray::kLengthOffset);
5993 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
5994 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
5995 // r8 : elements array
5996 // r9 : elements array length
5997 Label loop, entry, convert_hole;
5998 __ movq(r15, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
5999 // r15: the-hole NaN
6000 __ jmp(&entry);
6001 __ bind(&loop);
6002 __ decq(r9);
6003 __ movq(rbx,
6004 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize));
6005 // r9 : current element's index
6006 // rbx: current element (smi-tagged)
6007 __ JumpIfNotSmi(rbx, &convert_hole);
6008 __ SmiToInteger32(rbx, rbx);
6009 __ cvtlsi2sd(xmm0, rbx);
6010 __ movsd(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize),
6011 xmm0);
6012 __ jmp(&entry);
6013 __ bind(&convert_hole);
6014 __ movq(FieldOperand(r8, r9, times_8, FixedDoubleArray::kHeaderSize), r15);
6015 __ bind(&entry);
6016 __ testq(r9, r9);
6017 __ j(not_zero, &loop);
6018 }
6019
6020
6021 void FastElementsConversionStub::GenerateDoubleToObject(
6022 MacroAssembler* masm, StrictModeFlag strict_mode) {
6023 // ----------- S t a t e -------------
6024 // -- rax : value
6025 // -- rbx : target map
6026 // -- rcx : key
6027 // -- rdx : receiver
6028 // -- rsp[0] : return address
6029 // -----------------------------------
6030 Label loop, entry, convert_hole, gc_required;
6031 __ push(rax);
6032
6033 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
6034 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
6035 // r8 : source FixedDoubleArray
6036 // r9 : number of elements
6037 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize));
6038 __ AllocateInNewSpace(rdi, rax, r14, r15, &gc_required, TAG_OBJECT);
6039 // rax: destination FixedArray
6040 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex);
6041 __ movq(FieldOperand(rax, HeapObject::kMapOffset), rdi);
6042 __ Integer32ToSmi(r14, r9);
6043 __ movq(FieldOperand(rax, FixedArray::kLengthOffset), r14);
6044
6045 // Prepare for conversion loop.
6046 __ movq(rsi, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
6047 __ LoadRoot(rdi, Heap::kTheHoleValueRootIndex);
6048 // rsi: the-hole NaN
6049 // rdi: pointer to the-hole
6050 __ jmp(&entry);
6051
6052 // Call into runtime if GC is required.
6053 __ bind(&gc_required);
6054 __ pop(rax);
6055 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
6056 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode);
6057
6058 // Box doubles into heap numbers.
6059 __ bind(&loop);
6060 __ decq(r9);
6061 __ movq(r14, FieldOperand(r8,
6062 r9,
6063 times_pointer_size,
6064 FixedDoubleArray::kHeaderSize));
6065 // r9 : current element's index
6066 // r14: current element
6067 __ cmpq(r14, rsi);
6068 __ j(equal, &convert_hole);
6069
6070 // Non-hole double, copy value into a heap number.
6071 __ AllocateHeapNumber(r11, r15, &gc_required);
6072 // r11: new heap number
6073 __ movq(FieldOperand(r11, HeapNumber::kValueOffset), r14);
6074 __ movq(FieldOperand(rax,
6075 r9,
6076 times_pointer_size,
6077 FixedArray::kHeaderSize),
6078 r11);
6079 __ movq(r15, r9);
6080 __ RecordWriteArray(rax,
6081 r11,
6082 r15,
6083 kDontSaveFPRegs,
6084 EMIT_REMEMBERED_SET,
6085 OMIT_SMI_CHECK);
6086 __ jmp(&entry, Label::kNear);
6087
6088 // Replace the-hole NaN with the-hole pointer.
6089 __ bind(&convert_hole);
6090 __ movq(FieldOperand(rax,
6091 r9,
6092 times_pointer_size,
6093 FixedArray::kHeaderSize),
6094 rdi);
6095
6096 __ bind(&entry);
6097 __ testq(r9, r9);
6098 __ j(not_zero, &loop);
6099
6100 // Set transitioned map.
6101 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
6102 __ RecordWriteField(rdx,
6103 HeapObject::kMapOffset,
6104 rbx,
6105 rdi,
6106 kDontSaveFPRegs,
6107 EMIT_REMEMBERED_SET,
6108 OMIT_SMI_CHECK);
6109 // Replace receiver's backing store with newly created and filled FixedArray.
6110 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), rax);
6111 __ RecordWriteField(rdx,
6112 JSObject::kElementsOffset,
6113 rax,
6114 rdi,
6115 kDontSaveFPRegs,
6116 EMIT_REMEMBERED_SET,
6117 OMIT_SMI_CHECK);
6118 __ pop(rax);
6119 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
6120 }
6121
6122 #undef __ 5944 #undef __
6123 5945
6124 } } // namespace v8::internal 5946 } } // namespace v8::internal
6125 5947
6126 #endif // V8_TARGET_ARCH_X64 5948 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/x64/codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698