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

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

Issue 8366031: MIPS: Porting r9605 to arm (elements kind conversion in generated code). (Closed)
Patch Set: Remove unneeded moves to v0, per review comments. 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
« no previous file with comments | « src/mips/codegen-mips.h ('k') | src/mips/ic-mips.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 12 matching lines...) Expand all
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h" 28 #include "v8.h"
29 29
30 #if defined(V8_TARGET_ARCH_MIPS) 30 #if defined(V8_TARGET_ARCH_MIPS)
31 31
32 #include "codegen.h" 32 #include "codegen.h"
33 #include "macro-assembler.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
38 #define __ ACCESS_MASM(masm)
39
37 // ------------------------------------------------------------------------- 40 // -------------------------------------------------------------------------
38 // Platform-specific RuntimeCallHelper functions. 41 // Platform-specific RuntimeCallHelper functions.
39 42
40 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const { 43 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const {
41 masm->EnterFrame(StackFrame::INTERNAL); 44 masm->EnterFrame(StackFrame::INTERNAL);
42 ASSERT(!masm->has_frame()); 45 ASSERT(!masm->has_frame());
43 masm->set_has_frame(true); 46 masm->set_has_frame(true);
44 } 47 }
45 48
46 49
47 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { 50 void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const {
48 masm->LeaveFrame(StackFrame::INTERNAL); 51 masm->LeaveFrame(StackFrame::INTERNAL);
49 ASSERT(masm->has_frame()); 52 ASSERT(masm->has_frame());
50 masm->set_has_frame(false); 53 masm->set_has_frame(false);
51 } 54 }
52 55
56 // -------------------------------------------------------------------------
57 // Code generators
58
59 void ElementsTransitionGenerator::GenerateSmiOnlyToObject(
60 MacroAssembler* masm) {
61 // ----------- S t a t e -------------
62 // -- a0 : value
63 // -- a1 : key
64 // -- a2 : receiver
65 // -- ra : return address
66 // -- a3 : target map, scratch for subsequent call
67 // -- t0 : scratch (elements)
68 // -----------------------------------
69 // Set transitioned map.
70 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset));
71 __ RecordWriteField(a2,
72 HeapObject::kMapOffset,
73 a3,
74 t5,
75 kRAHasNotBeenSaved,
76 kDontSaveFPRegs,
77 EMIT_REMEMBERED_SET,
78 OMIT_SMI_CHECK);
79 }
80
81
82 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble(
83 MacroAssembler* masm, Label* fail) {
84 // ----------- S t a t e -------------
85 // -- a0 : value
86 // -- a1 : key
87 // -- a2 : receiver
88 // -- ra : return address
89 // -- a3 : target map, scratch for subsequent call
90 // -- t0 : scratch (elements)
91 // -----------------------------------
92 Label loop, entry, convert_hole, gc_required;
93 bool fpu_supported = CpuFeatures::IsSupported(FPU);
94 __ push(ra);
95
96 Register scratch = t6;
97
98 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset));
99 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset));
100 // t0: source FixedArray
101 // t1: number of elements (smi-tagged)
102
103 // Allocate new FixedDoubleArray.
104 __ sll(scratch, t1, 2);
105 __ Addu(scratch, scratch, FixedDoubleArray::kHeaderSize);
106 __ AllocateInNewSpace(scratch, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS);
107 // t2: destination FixedDoubleArray, not tagged as heap object
108 __ LoadRoot(t5, Heap::kFixedDoubleArrayMapRootIndex);
109 __ sw(t5, MemOperand(t2, HeapObject::kMapOffset));
110 // Set destination FixedDoubleArray's length.
111 __ sw(t1, MemOperand(t2, FixedDoubleArray::kLengthOffset));
112 // Update receiver's map.
113
114 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset));
115 __ RecordWriteField(a2,
116 HeapObject::kMapOffset,
117 a3,
118 t5,
119 kRAHasBeenSaved,
120 kDontSaveFPRegs,
121 EMIT_REMEMBERED_SET,
122 OMIT_SMI_CHECK);
123 // Replace receiver's backing store with newly created FixedDoubleArray.
124 __ Addu(a3, t2, Operand(kHeapObjectTag));
125 __ sw(a3, FieldMemOperand(a2, JSObject::kElementsOffset));
126 __ RecordWriteField(a2,
127 JSObject::kElementsOffset,
128 a3,
129 t5,
130 kRAHasBeenSaved,
131 kDontSaveFPRegs,
132 EMIT_REMEMBERED_SET,
133 OMIT_SMI_CHECK);
134
135
136 // Prepare for conversion loop.
137 __ Addu(a3, t0, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
138 __ Addu(t3, t2, Operand(FixedDoubleArray::kHeaderSize));
139 __ sll(t2, t1, 2);
140 __ Addu(t2, t2, t3);
141 __ li(t0, Operand(kHoleNanLower32));
142 __ li(t1, Operand(kHoleNanUpper32));
143 // t0: kHoleNanLower32
144 // t1: kHoleNanUpper32
145 // t2: end of destination FixedDoubleArray, not tagged
146 // t3: begin of FixedDoubleArray element fields, not tagged
147
148 if (!fpu_supported) __ Push(a1, a0);
149
150 __ Branch(&entry);
151
152 // Call into runtime if GC is required.
153 __ bind(&gc_required);
154 __ pop(ra);
155 __ Branch(fail);
156
157 // Convert and copy elements.
158 __ bind(&loop);
159 __ lw(t5, MemOperand(a3));
160 __ Addu(a3, a3, kIntSize);
161 // t5: current element
162 __ JumpIfNotSmi(t5, &convert_hole);
163
164 // Normal smi, convert to double and store.
165 __ SmiUntag(t5);
166 if (fpu_supported) {
167 CpuFeatures::Scope scope(FPU);
168 __ mtc1(t5, f0);
169 __ cvt_d_w(f0, f0);
170 __ sdc1(f0, MemOperand(t3));
171 __ Addu(t3, t3, kDoubleSize);
172 } else {
173 FloatingPointHelper::ConvertIntToDouble(masm,
174 t5,
175 FloatingPointHelper::kCoreRegisters,
176 f0,
177 a0,
178 a1,
179 t7,
180 f0);
181 __ sw(a0, MemOperand(t3)); // mantissa
182 __ sw(a1, MemOperand(t3, kIntSize)); // exponent
183 __ Addu(t3, t3, kDoubleSize);
184 }
185 __ Branch(&entry);
186
187 // Hole found, store the-hole NaN.
188 __ bind(&convert_hole);
189 __ sw(t0, MemOperand(t3)); // mantissa
190 __ sw(t1, MemOperand(t3, kIntSize)); // exponent
191 __ Addu(t3, t3, kDoubleSize);
192
193 __ bind(&entry);
194 __ Branch(&loop, lt, t3, Operand(t2));
195
196 if (!fpu_supported) __ Pop(a1, a0);
197 __ pop(ra);
198 }
199
200
201 void ElementsTransitionGenerator::GenerateDoubleToObject(
202 MacroAssembler* masm, Label* fail) {
203 // ----------- S t a t e -------------
204 // -- a0 : value
205 // -- a1 : key
206 // -- a2 : receiver
207 // -- ra : return address
208 // -- a3 : target map, scratch for subsequent call
209 // -- t0 : scratch (elements)
210 // -----------------------------------
211 Label entry, loop, convert_hole, gc_required;
212 __ MultiPush(a0.bit() | a1.bit() | a2.bit() | a3.bit() | ra.bit());
213
214 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset));
215 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset));
216 // t0: source FixedArray
217 // t1: number of elements (smi-tagged)
218
219 // Allocate new FixedArray.
220 __ sll(a0, t1, 1);
221 __ Addu(a0, a0, FixedDoubleArray::kHeaderSize);
222 __ AllocateInNewSpace(a0, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS);
223 // t2: destination FixedArray, not tagged as heap object
224 __ LoadRoot(t5, Heap::kFixedArrayMapRootIndex);
225 __ sw(t5, MemOperand(t2, HeapObject::kMapOffset));
226 // Set destination FixedDoubleArray's length.
227 __ sw(t1, MemOperand(t2, FixedDoubleArray::kLengthOffset));
228
229 // Prepare for conversion loop.
230 __ Addu(t0, t0, Operand(FixedDoubleArray::kHeaderSize - kHeapObjectTag + 4));
231 __ Addu(a3, t2, Operand(FixedArray::kHeaderSize));
232 __ Addu(t2, t2, Operand(kHeapObjectTag));
233 __ sll(t1, t1, 1);
234 __ Addu(t1, a3, t1);
235 __ LoadRoot(t3, Heap::kTheHoleValueRootIndex);
236 __ LoadRoot(t5, Heap::kHeapNumberMapRootIndex);
237 // Using offsetted addresses.
238 // a3: begin of destination FixedArray element fields, not tagged
239 // t0: begin of source FixedDoubleArray element fields, not tagged, +4
240 // t1: end of destination FixedArray, not tagged
241 // t2: destination FixedArray
242 // t3: the-hole pointer
243 // t5: heap number map
244 __ Branch(&entry);
245
246 // Call into runtime if GC is required.
247 __ bind(&gc_required);
248 __ MultiPop(a0.bit() | a1.bit() | a2.bit() | a3.bit() | ra.bit());
249
250 __ Branch(fail);
251
252 __ bind(&loop);
253 __ lw(a1, MemOperand(t0));
254 __ Addu(t0, t0, kDoubleSize);
255 // a1: current element's upper 32 bit
256 // t0: address of next element's upper 32 bit
257 __ Branch(&convert_hole, eq, a1, Operand(kHoleNanUpper32));
258
259 // Non-hole double, copy value into a heap number.
260 __ AllocateHeapNumber(a2, a0, t6, t5, &gc_required);
261 // a2: new heap number
262 __ lw(a0, MemOperand(t0, -12));
263 __ sw(a0, FieldMemOperand(a2, HeapNumber::kMantissaOffset));
264 __ sw(a1, FieldMemOperand(a2, HeapNumber::kExponentOffset));
265 __ mov(a0, a3);
266 __ sw(a2, MemOperand(a3));
267 __ Addu(a3, a3, kIntSize);
268 __ RecordWrite(t2,
269 a0,
270 a2,
271 kRAHasBeenSaved,
272 kDontSaveFPRegs,
273 EMIT_REMEMBERED_SET,
274 OMIT_SMI_CHECK);
275 __ Branch(&entry);
276
277 // Replace the-hole NaN with the-hole pointer.
278 __ bind(&convert_hole);
279 __ sw(t3, MemOperand(a3));
280 __ Addu(a3, a3, kIntSize);
281
282 __ bind(&entry);
283 __ Branch(&loop, lt, a3, Operand(t1));
284
285 __ MultiPop(a2.bit() | a3.bit() | a0.bit() | a1.bit());
286 // Update receiver's map.
287 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset));
288 __ RecordWriteField(a2,
289 HeapObject::kMapOffset,
290 a3,
291 t5,
292 kRAHasBeenSaved,
293 kDontSaveFPRegs,
294 EMIT_REMEMBERED_SET,
295 OMIT_SMI_CHECK);
296 // Replace receiver's backing store with newly created and filled FixedArray.
297 __ sw(t2, FieldMemOperand(a2, JSObject::kElementsOffset));
298 __ RecordWriteField(a2,
299 JSObject::kElementsOffset,
300 t2,
301 t5,
302 kRAHasBeenSaved,
303 kDontSaveFPRegs,
304 EMIT_REMEMBERED_SET,
305 OMIT_SMI_CHECK);
306 __ pop(ra);
307 }
308
309 #undef __
53 310
54 } } // namespace v8::internal 311 } } // namespace v8::internal
55 312
56 #endif // V8_TARGET_ARCH_MIPS 313 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/mips/codegen-mips.h ('k') | src/mips/ic-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698