OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble( | 82 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble( |
83 MacroAssembler* masm, Label* fail) { | 83 MacroAssembler* masm, Label* fail) { |
84 // ----------- S t a t e ------------- | 84 // ----------- S t a t e ------------- |
85 // -- a0 : value | 85 // -- a0 : value |
86 // -- a1 : key | 86 // -- a1 : key |
87 // -- a2 : receiver | 87 // -- a2 : receiver |
88 // -- ra : return address | 88 // -- ra : return address |
89 // -- a3 : target map, scratch for subsequent call | 89 // -- a3 : target map, scratch for subsequent call |
90 // -- t0 : scratch (elements) | 90 // -- t0 : scratch (elements) |
91 // ----------------------------------- | 91 // ----------------------------------- |
92 Label loop, entry, convert_hole, gc_required; | 92 Label loop, entry, convert_hole, gc_required, only_change_map, done; |
93 bool fpu_supported = CpuFeatures::IsSupported(FPU); | 93 bool fpu_supported = CpuFeatures::IsSupported(FPU); |
94 __ push(ra); | |
95 | 94 |
96 Register scratch = t6; | 95 Register scratch = t6; |
97 | 96 |
| 97 // Check for empty arrays, which only require a map transition and no changes |
| 98 // to the backing store. |
98 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset)); | 99 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset)); |
| 100 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); |
| 101 __ Branch(&only_change_map, eq, at, Operand(t0)); |
| 102 |
| 103 __ push(ra); |
99 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset)); | 104 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset)); |
100 // t0: source FixedArray | 105 // t0: source FixedArray |
101 // t1: number of elements (smi-tagged) | 106 // t1: number of elements (smi-tagged) |
102 | 107 |
103 // Allocate new FixedDoubleArray. | 108 // Allocate new FixedDoubleArray. |
104 __ sll(scratch, t1, 2); | 109 __ sll(scratch, t1, 2); |
105 __ Addu(scratch, scratch, FixedDoubleArray::kHeaderSize); | 110 __ Addu(scratch, scratch, FixedDoubleArray::kHeaderSize); |
106 __ AllocateInNewSpace(scratch, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS); | 111 __ AllocateInNewSpace(scratch, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS); |
107 // t2: destination FixedDoubleArray, not tagged as heap object | 112 // t2: destination FixedDoubleArray, not tagged as heap object |
108 // Set destination FixedDoubleArray's length and map. | 113 // Set destination FixedDoubleArray's length and map. |
109 __ LoadRoot(t5, Heap::kFixedDoubleArrayMapRootIndex); | 114 __ LoadRoot(t5, Heap::kFixedDoubleArrayMapRootIndex); |
110 __ sw(t1, MemOperand(t2, FixedDoubleArray::kLengthOffset)); | 115 __ sw(t1, MemOperand(t2, FixedDoubleArray::kLengthOffset)); |
111 __ sw(t5, MemOperand(t2, HeapObject::kMapOffset)); | 116 __ sw(t5, MemOperand(t2, HeapObject::kMapOffset)); |
112 // Update receiver's map. | 117 // Update receiver's map. |
113 | 118 |
114 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset)); | 119 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset)); |
115 __ RecordWriteField(a2, | 120 __ RecordWriteField(a2, |
116 HeapObject::kMapOffset, | 121 HeapObject::kMapOffset, |
117 a3, | 122 a3, |
118 t5, | 123 t5, |
119 kRAHasBeenSaved, | 124 kRAHasBeenSaved, |
120 kDontSaveFPRegs, | 125 kDontSaveFPRegs, |
121 EMIT_REMEMBERED_SET, | 126 OMIT_REMEMBERED_SET, |
122 OMIT_SMI_CHECK); | 127 OMIT_SMI_CHECK); |
123 // Replace receiver's backing store with newly created FixedDoubleArray. | 128 // Replace receiver's backing store with newly created FixedDoubleArray. |
124 __ Addu(a3, t2, Operand(kHeapObjectTag)); | 129 __ Addu(a3, t2, Operand(kHeapObjectTag)); |
125 __ sw(a3, FieldMemOperand(a2, JSObject::kElementsOffset)); | 130 __ sw(a3, FieldMemOperand(a2, JSObject::kElementsOffset)); |
126 __ RecordWriteField(a2, | 131 __ RecordWriteField(a2, |
127 JSObject::kElementsOffset, | 132 JSObject::kElementsOffset, |
128 a3, | 133 a3, |
129 t5, | 134 t5, |
130 kRAHasBeenSaved, | 135 kRAHasBeenSaved, |
131 kDontSaveFPRegs, | 136 kDontSaveFPRegs, |
(...skipping 10 matching lines...) Expand all Loading... |
142 __ li(t1, Operand(kHoleNanUpper32)); | 147 __ li(t1, Operand(kHoleNanUpper32)); |
143 // t0: kHoleNanLower32 | 148 // t0: kHoleNanLower32 |
144 // t1: kHoleNanUpper32 | 149 // t1: kHoleNanUpper32 |
145 // t2: end of destination FixedDoubleArray, not tagged | 150 // t2: end of destination FixedDoubleArray, not tagged |
146 // t3: begin of FixedDoubleArray element fields, not tagged | 151 // t3: begin of FixedDoubleArray element fields, not tagged |
147 | 152 |
148 if (!fpu_supported) __ Push(a1, a0); | 153 if (!fpu_supported) __ Push(a1, a0); |
149 | 154 |
150 __ Branch(&entry); | 155 __ Branch(&entry); |
151 | 156 |
| 157 __ bind(&only_change_map); |
| 158 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset)); |
| 159 __ RecordWriteField(a2, |
| 160 HeapObject::kMapOffset, |
| 161 a3, |
| 162 t5, |
| 163 kRAHasBeenSaved, |
| 164 kDontSaveFPRegs, |
| 165 OMIT_REMEMBERED_SET, |
| 166 OMIT_SMI_CHECK); |
| 167 __ Branch(&done); |
| 168 |
152 // Call into runtime if GC is required. | 169 // Call into runtime if GC is required. |
153 __ bind(&gc_required); | 170 __ bind(&gc_required); |
154 __ pop(ra); | 171 __ pop(ra); |
155 __ Branch(fail); | 172 __ Branch(fail); |
156 | 173 |
157 // Convert and copy elements. | 174 // Convert and copy elements. |
158 __ bind(&loop); | 175 __ bind(&loop); |
159 __ lw(t5, MemOperand(a3)); | 176 __ lw(t5, MemOperand(a3)); |
160 __ Addu(a3, a3, kIntSize); | 177 __ Addu(a3, a3, kIntSize); |
161 // t5: current element | 178 // t5: current element |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 211 } |
195 __ sw(t0, MemOperand(t3)); // mantissa | 212 __ sw(t0, MemOperand(t3)); // mantissa |
196 __ sw(t1, MemOperand(t3, kIntSize)); // exponent | 213 __ sw(t1, MemOperand(t3, kIntSize)); // exponent |
197 __ Addu(t3, t3, kDoubleSize); | 214 __ Addu(t3, t3, kDoubleSize); |
198 | 215 |
199 __ bind(&entry); | 216 __ bind(&entry); |
200 __ Branch(&loop, lt, t3, Operand(t2)); | 217 __ Branch(&loop, lt, t3, Operand(t2)); |
201 | 218 |
202 if (!fpu_supported) __ Pop(a1, a0); | 219 if (!fpu_supported) __ Pop(a1, a0); |
203 __ pop(ra); | 220 __ pop(ra); |
| 221 __ bind(&done); |
204 } | 222 } |
205 | 223 |
206 | 224 |
207 void ElementsTransitionGenerator::GenerateDoubleToObject( | 225 void ElementsTransitionGenerator::GenerateDoubleToObject( |
208 MacroAssembler* masm, Label* fail) { | 226 MacroAssembler* masm, Label* fail) { |
209 // ----------- S t a t e ------------- | 227 // ----------- S t a t e ------------- |
210 // -- a0 : value | 228 // -- a0 : value |
211 // -- a1 : key | 229 // -- a1 : key |
212 // -- a2 : receiver | 230 // -- a2 : receiver |
213 // -- ra : return address | 231 // -- ra : return address |
214 // -- a3 : target map, scratch for subsequent call | 232 // -- a3 : target map, scratch for subsequent call |
215 // -- t0 : scratch (elements) | 233 // -- t0 : scratch (elements) |
216 // ----------------------------------- | 234 // ----------------------------------- |
217 Label entry, loop, convert_hole, gc_required; | 235 Label entry, loop, convert_hole, gc_required, only_change_map; |
| 236 |
| 237 // Check for empty arrays, which only require a map transition and no changes |
| 238 // to the backing store. |
| 239 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset)); |
| 240 __ LoadRoot(at, Heap::kEmptyFixedArrayRootIndex); |
| 241 __ Branch(&only_change_map, eq, at, Operand(t0)); |
| 242 |
218 __ MultiPush(a0.bit() | a1.bit() | a2.bit() | a3.bit() | ra.bit()); | 243 __ MultiPush(a0.bit() | a1.bit() | a2.bit() | a3.bit() | ra.bit()); |
219 | 244 |
220 __ lw(t0, FieldMemOperand(a2, JSObject::kElementsOffset)); | |
221 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset)); | 245 __ lw(t1, FieldMemOperand(t0, FixedArray::kLengthOffset)); |
222 // t0: source FixedArray | 246 // t0: source FixedArray |
223 // t1: number of elements (smi-tagged) | 247 // t1: number of elements (smi-tagged) |
224 | 248 |
225 // Allocate new FixedArray. | 249 // Allocate new FixedArray. |
226 __ sll(a0, t1, 1); | 250 __ sll(a0, t1, 1); |
227 __ Addu(a0, a0, FixedDoubleArray::kHeaderSize); | 251 __ Addu(a0, a0, FixedDoubleArray::kHeaderSize); |
228 __ AllocateInNewSpace(a0, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS); | 252 __ AllocateInNewSpace(a0, t2, t3, t5, &gc_required, NO_ALLOCATION_FLAGS); |
229 // t2: destination FixedArray, not tagged as heap object | 253 // t2: destination FixedArray, not tagged as heap object |
230 // Set destination FixedDoubleArray's length and map. | 254 // Set destination FixedDoubleArray's length and map. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 306 |
283 // Replace the-hole NaN with the-hole pointer. | 307 // Replace the-hole NaN with the-hole pointer. |
284 __ bind(&convert_hole); | 308 __ bind(&convert_hole); |
285 __ sw(t3, MemOperand(a3)); | 309 __ sw(t3, MemOperand(a3)); |
286 __ Addu(a3, a3, kIntSize); | 310 __ Addu(a3, a3, kIntSize); |
287 | 311 |
288 __ bind(&entry); | 312 __ bind(&entry); |
289 __ Branch(&loop, lt, a3, Operand(t1)); | 313 __ Branch(&loop, lt, a3, Operand(t1)); |
290 | 314 |
291 __ MultiPop(a2.bit() | a3.bit() | a0.bit() | a1.bit()); | 315 __ MultiPop(a2.bit() | a3.bit() | a0.bit() | a1.bit()); |
292 // Update receiver's map. | |
293 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset)); | |
294 __ RecordWriteField(a2, | |
295 HeapObject::kMapOffset, | |
296 a3, | |
297 t5, | |
298 kRAHasBeenSaved, | |
299 kDontSaveFPRegs, | |
300 EMIT_REMEMBERED_SET, | |
301 OMIT_SMI_CHECK); | |
302 // Replace receiver's backing store with newly created and filled FixedArray. | 316 // Replace receiver's backing store with newly created and filled FixedArray. |
303 __ sw(t2, FieldMemOperand(a2, JSObject::kElementsOffset)); | 317 __ sw(t2, FieldMemOperand(a2, JSObject::kElementsOffset)); |
304 __ RecordWriteField(a2, | 318 __ RecordWriteField(a2, |
305 JSObject::kElementsOffset, | 319 JSObject::kElementsOffset, |
306 t2, | 320 t2, |
307 t5, | 321 t5, |
308 kRAHasBeenSaved, | 322 kRAHasBeenSaved, |
309 kDontSaveFPRegs, | 323 kDontSaveFPRegs, |
310 EMIT_REMEMBERED_SET, | 324 EMIT_REMEMBERED_SET, |
311 OMIT_SMI_CHECK); | 325 OMIT_SMI_CHECK); |
312 __ pop(ra); | 326 __ pop(ra); |
| 327 |
| 328 __ bind(&only_change_map); |
| 329 // Update receiver's map. |
| 330 __ sw(a3, FieldMemOperand(a2, HeapObject::kMapOffset)); |
| 331 __ RecordWriteField(a2, |
| 332 HeapObject::kMapOffset, |
| 333 a3, |
| 334 t5, |
| 335 kRAHasNotBeenSaved, |
| 336 kDontSaveFPRegs, |
| 337 OMIT_REMEMBERED_SET, |
| 338 OMIT_SMI_CHECK); |
313 } | 339 } |
314 | 340 |
315 | 341 |
316 void StringCharLoadGenerator::Generate(MacroAssembler* masm, | 342 void StringCharLoadGenerator::Generate(MacroAssembler* masm, |
317 Register string, | 343 Register string, |
318 Register index, | 344 Register index, |
319 Register result, | 345 Register result, |
320 Label* call_runtime) { | 346 Label* call_runtime) { |
321 // Fetch the instance type of the receiver into result register. | 347 // Fetch the instance type of the receiver into result register. |
322 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset)); | 348 __ lw(result, FieldMemOperand(string, HeapObject::kMapOffset)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 __ Addu(at, string, index); | 428 __ Addu(at, string, index); |
403 __ lbu(result, MemOperand(at)); | 429 __ lbu(result, MemOperand(at)); |
404 __ bind(&done); | 430 __ bind(&done); |
405 } | 431 } |
406 | 432 |
407 #undef __ | 433 #undef __ |
408 | 434 |
409 } } // namespace v8::internal | 435 } } // namespace v8::internal |
410 | 436 |
411 #endif // V8_TARGET_ARCH_MIPS | 437 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |