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

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

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month 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/x64/code-stubs-x64.cc ('k') | src/x64/deoptimizer-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 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_X64) 30 #if defined(V8_TARGET_ARCH_X64)
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
37 // ------------------------------------------------------------------------- 38 // -------------------------------------------------------------------------
38 // Platform-specific RuntimeCallHelper functions. 39 // Platform-specific RuntimeCallHelper functions.
39 40
40 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const { 41 void StubRuntimeCallHelper::BeforeCall(MacroAssembler* masm) const {
41 masm->EnterFrame(StackFrame::INTERNAL); 42 masm->EnterFrame(StackFrame::INTERNAL);
42 ASSERT(!masm->has_frame()); 43 ASSERT(!masm->has_frame());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 137
137 CodeDesc desc; 138 CodeDesc desc;
138 masm.GetCode(&desc); 139 masm.GetCode(&desc);
139 OS::ProtectCode(buffer, actual_size); 140 OS::ProtectCode(buffer, actual_size);
140 // Call the function from C++ through this pointer. 141 // Call the function from C++ through this pointer.
141 return FUNCTION_CAST<ModuloFunction>(buffer); 142 return FUNCTION_CAST<ModuloFunction>(buffer);
142 } 143 }
143 144
144 #endif 145 #endif
145 146
146
147 #undef __ 147 #undef __
148 148
149 // -------------------------------------------------------------------------
150 // Code generators
151
152 #define __ ACCESS_MASM(masm)
153
154 void ElementsTransitionGenerator::GenerateSmiOnlyToObject(
155 MacroAssembler* masm) {
156 // ----------- S t a t e -------------
157 // -- rax : value
158 // -- rbx : target map
159 // -- rcx : key
160 // -- rdx : receiver
161 // -- rsp[0] : return address
162 // -----------------------------------
163 // Set transitioned map.
164 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
165 __ RecordWriteField(rdx,
166 HeapObject::kMapOffset,
167 rbx,
168 rdi,
169 kDontSaveFPRegs,
170 EMIT_REMEMBERED_SET,
171 OMIT_SMI_CHECK);
172 }
173
174
175 void ElementsTransitionGenerator::GenerateSmiOnlyToDouble(
176 MacroAssembler* masm, Label* fail) {
177 // ----------- S t a t e -------------
178 // -- rax : value
179 // -- rbx : target map
180 // -- rcx : key
181 // -- rdx : receiver
182 // -- rsp[0] : return address
183 // -----------------------------------
184 // The fail label is not actually used since we do not allocate.
185 Label allocated, cow_array;
186
187 // Check backing store for COW-ness. If the negative case, we do not have to
188 // allocate a new array, since FixedArray and FixedDoubleArray do not differ
189 // in size.
190 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
191 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
192 __ CompareRoot(FieldOperand(r8, HeapObject::kMapOffset),
193 Heap::kFixedCOWArrayMapRootIndex);
194 __ j(equal, &cow_array);
195 __ movq(r14, r8); // Destination array equals source array.
196
197 __ bind(&allocated);
198 // r8 : source FixedArray
199 // r9 : elements array length
200 // r14: destination FixedDoubleArray
201 // Set backing store's map
202 __ LoadRoot(rdi, Heap::kFixedDoubleArrayMapRootIndex);
203 __ movq(FieldOperand(r14, HeapObject::kMapOffset), rdi);
204
205 // Set transitioned map.
206 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
207 __ RecordWriteField(rdx,
208 HeapObject::kMapOffset,
209 rbx,
210 rdi,
211 kDontSaveFPRegs,
212 EMIT_REMEMBERED_SET,
213 OMIT_SMI_CHECK);
214
215 // Convert smis to doubles and holes to hole NaNs. The Array's length
216 // remains unchanged.
217 STATIC_ASSERT(FixedDoubleArray::kLengthOffset == FixedArray::kLengthOffset);
218 STATIC_ASSERT(FixedDoubleArray::kHeaderSize == FixedArray::kHeaderSize);
219
220 Label loop, entry, convert_hole;
221 __ movq(r15, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
222 // r15: the-hole NaN
223 __ jmp(&entry);
224
225 // Allocate new array if the source array is a COW array.
226 __ bind(&cow_array);
227 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize));
228 __ AllocateInNewSpace(rdi, r14, r11, r15, fail, TAG_OBJECT);
229 // Set receiver's backing store.
230 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), r14);
231 __ movq(r11, r14);
232 __ RecordWriteField(rdx,
233 JSObject::kElementsOffset,
234 r11,
235 r15,
236 kDontSaveFPRegs,
237 EMIT_REMEMBERED_SET,
238 OMIT_SMI_CHECK);
239 // Set backing store's length.
240 __ Integer32ToSmi(r11, r9);
241 __ movq(FieldOperand(r14, FixedDoubleArray::kLengthOffset), r11);
242 __ jmp(&allocated);
243
244 // Conversion loop.
245 __ bind(&loop);
246 __ decq(r9);
247 __ movq(rbx,
248 FieldOperand(r8, r9, times_8, FixedArray::kHeaderSize));
249 // r9 : current element's index
250 // rbx: current element (smi-tagged)
251 __ JumpIfNotSmi(rbx, &convert_hole);
252 __ SmiToInteger32(rbx, rbx);
253 __ cvtlsi2sd(xmm0, rbx);
254 __ movsd(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize),
255 xmm0);
256 __ jmp(&entry);
257 __ bind(&convert_hole);
258 __ movq(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), r15);
259 __ bind(&entry);
260 __ testq(r9, r9);
261 __ j(not_zero, &loop);
262 }
263
264
265 void ElementsTransitionGenerator::GenerateDoubleToObject(
266 MacroAssembler* masm, Label* fail) {
267 // ----------- S t a t e -------------
268 // -- rax : value
269 // -- rbx : target map
270 // -- rcx : key
271 // -- rdx : receiver
272 // -- rsp[0] : return address
273 // -----------------------------------
274 Label loop, entry, convert_hole, gc_required;
275 __ push(rax);
276
277 __ movq(r8, FieldOperand(rdx, JSObject::kElementsOffset));
278 __ SmiToInteger32(r9, FieldOperand(r8, FixedDoubleArray::kLengthOffset));
279 // r8 : source FixedDoubleArray
280 // r9 : number of elements
281 __ lea(rdi, Operand(r9, times_pointer_size, FixedArray::kHeaderSize));
282 __ AllocateInNewSpace(rdi, r11, r14, r15, &gc_required, TAG_OBJECT);
283 // r11: destination FixedArray
284 __ LoadRoot(rdi, Heap::kFixedArrayMapRootIndex);
285 __ movq(FieldOperand(r11, HeapObject::kMapOffset), rdi);
286 __ Integer32ToSmi(r14, r9);
287 __ movq(FieldOperand(r11, FixedArray::kLengthOffset), r14);
288
289 // Prepare for conversion loop.
290 __ movq(rsi, BitCast<int64_t, uint64_t>(kHoleNanInt64), RelocInfo::NONE);
291 __ LoadRoot(rdi, Heap::kTheHoleValueRootIndex);
292 // rsi: the-hole NaN
293 // rdi: pointer to the-hole
294 __ jmp(&entry);
295
296 // Call into runtime if GC is required.
297 __ bind(&gc_required);
298 __ pop(rax);
299 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
300 __ jmp(fail);
301
302 // Box doubles into heap numbers.
303 __ bind(&loop);
304 __ decq(r9);
305 __ movq(r14, FieldOperand(r8,
306 r9,
307 times_pointer_size,
308 FixedDoubleArray::kHeaderSize));
309 // r9 : current element's index
310 // r14: current element
311 __ cmpq(r14, rsi);
312 __ j(equal, &convert_hole);
313
314 // Non-hole double, copy value into a heap number.
315 __ AllocateHeapNumber(rax, r15, &gc_required);
316 // rax: new heap number
317 __ movq(FieldOperand(rax, HeapNumber::kValueOffset), r14);
318 __ movq(FieldOperand(r11,
319 r9,
320 times_pointer_size,
321 FixedArray::kHeaderSize),
322 rax);
323 __ movq(r15, r9);
324 __ RecordWriteArray(r11,
325 rax,
326 r15,
327 kDontSaveFPRegs,
328 EMIT_REMEMBERED_SET,
329 OMIT_SMI_CHECK);
330 __ jmp(&entry, Label::kNear);
331
332 // Replace the-hole NaN with the-hole pointer.
333 __ bind(&convert_hole);
334 __ movq(FieldOperand(r11,
335 r9,
336 times_pointer_size,
337 FixedArray::kHeaderSize),
338 rdi);
339
340 __ bind(&entry);
341 __ testq(r9, r9);
342 __ j(not_zero, &loop);
343
344 // Set transitioned map.
345 __ movq(FieldOperand(rdx, HeapObject::kMapOffset), rbx);
346 __ RecordWriteField(rdx,
347 HeapObject::kMapOffset,
348 rbx,
349 rdi,
350 kDontSaveFPRegs,
351 EMIT_REMEMBERED_SET,
352 OMIT_SMI_CHECK);
353 // Replace receiver's backing store with newly created and filled FixedArray.
354 __ movq(FieldOperand(rdx, JSObject::kElementsOffset), r11);
355 __ RecordWriteField(rdx,
356 JSObject::kElementsOffset,
357 r11,
358 r15,
359 kDontSaveFPRegs,
360 EMIT_REMEMBERED_SET,
361 OMIT_SMI_CHECK);
362 __ pop(rax);
363 __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
364 }
365
366 #undef __
367
149 } } // namespace v8::internal 368 } } // namespace v8::internal
150 369
151 #endif // V8_TARGET_ARCH_X64 370 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | src/x64/deoptimizer-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698