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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // This function is used for both construct and normal calls of Array. The only | 306 // This function is used for both construct and normal calls of Array. The only |
307 // difference between handling a construct call and a normal call is that for a | 307 // difference between handling a construct call and a normal call is that for a |
308 // construct call the constructor function in r1 needs to be preserved for | 308 // construct call the constructor function in r1 needs to be preserved for |
309 // entering the generic code. In both cases argc in r0 needs to be preserved. | 309 // entering the generic code. In both cases argc in r0 needs to be preserved. |
310 // Both registers are preserved by this code so no need to differentiate between | 310 // Both registers are preserved by this code so no need to differentiate between |
311 // construct call and normal call. | 311 // construct call and normal call. |
312 static void ArrayNativeCode(MacroAssembler* masm, | 312 static void ArrayNativeCode(MacroAssembler* masm, |
313 Label* call_generic_code) { | 313 Label* call_generic_code) { |
314 Counters* counters = masm->isolate()->counters(); | 314 Counters* counters = masm->isolate()->counters(); |
315 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array, | 315 Label argc_one_or_more, argc_two_or_more, not_empty_array, empty_array, |
316 has_non_smi_element; | 316 has_non_smi_element, finish, cant_transition_map, not_double; |
317 | 317 |
318 // Check for array construction with zero arguments or one. | 318 // Check for array construction with zero arguments or one. |
319 __ cmp(r0, Operand(0, RelocInfo::NONE)); | 319 __ cmp(r0, Operand(0, RelocInfo::NONE)); |
320 __ b(ne, &argc_one_or_more); | 320 __ b(ne, &argc_one_or_more); |
321 | 321 |
322 // Handle construction of an empty array. | 322 // Handle construction of an empty array. |
323 __ bind(&empty_array); | 323 __ bind(&empty_array); |
324 AllocateEmptyJSArray(masm, | 324 AllocateEmptyJSArray(masm, |
325 r1, | 325 r1, |
326 r2, | 326 r2, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 __ jmp(&entry); | 411 __ jmp(&entry); |
412 __ bind(&loop); | 412 __ bind(&loop); |
413 __ ldr(r2, MemOperand(r7, kPointerSize, PostIndex)); | 413 __ ldr(r2, MemOperand(r7, kPointerSize, PostIndex)); |
414 if (FLAG_smi_only_arrays) { | 414 if (FLAG_smi_only_arrays) { |
415 __ JumpIfNotSmi(r2, &has_non_smi_element); | 415 __ JumpIfNotSmi(r2, &has_non_smi_element); |
416 } | 416 } |
417 __ str(r2, MemOperand(r5, -kPointerSize, PreIndex)); | 417 __ str(r2, MemOperand(r5, -kPointerSize, PreIndex)); |
418 __ bind(&entry); | 418 __ bind(&entry); |
419 __ cmp(r4, r5); | 419 __ cmp(r4, r5); |
420 __ b(lt, &loop); | 420 __ b(lt, &loop); |
| 421 |
| 422 __ bind(&finish); |
421 __ mov(sp, r7); | 423 __ mov(sp, r7); |
422 | 424 |
423 // Remove caller arguments and receiver from the stack, setup return value and | 425 // Remove caller arguments and receiver from the stack, setup return value and |
424 // return. | 426 // return. |
425 // r0: argc | 427 // r0: argc |
426 // r3: JSArray | 428 // r3: JSArray |
427 // sp[0]: receiver | 429 // sp[0]: receiver |
428 __ add(sp, sp, Operand(kPointerSize)); | 430 __ add(sp, sp, Operand(kPointerSize)); |
429 __ mov(r0, r3); | 431 __ mov(r0, r3); |
430 __ Jump(lr); | 432 __ Jump(lr); |
431 | 433 |
432 __ bind(&has_non_smi_element); | 434 __ bind(&has_non_smi_element); |
| 435 // Double values are handled by the runtime. |
| 436 __ CheckMap( |
| 437 r2, r9, Heap::kHeapNumberMapRootIndex, ¬_double, DONT_DO_SMI_CHECK); |
| 438 __ bind(&cant_transition_map); |
433 __ UndoAllocationInNewSpace(r3, r4); | 439 __ UndoAllocationInNewSpace(r3, r4); |
434 __ b(call_generic_code); | 440 __ b(call_generic_code); |
| 441 |
| 442 __ bind(¬_double); |
| 443 // Transition FAST_SMI_ONLY_ELEMENTS to FAST_ELEMENTS. |
| 444 // r3: JSArray |
| 445 __ ldr(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 446 __ LoadTransitionedArrayMapConditional(FAST_SMI_ONLY_ELEMENTS, |
| 447 FAST_ELEMENTS, |
| 448 r2, |
| 449 r9, |
| 450 &cant_transition_map); |
| 451 __ str(r2, FieldMemOperand(r3, HeapObject::kMapOffset)); |
| 452 __ RecordWriteField(r3, |
| 453 HeapObject::kMapOffset, |
| 454 r2, |
| 455 r9, |
| 456 kLRHasNotBeenSaved, |
| 457 kDontSaveFPRegs, |
| 458 EMIT_REMEMBERED_SET, |
| 459 OMIT_SMI_CHECK); |
| 460 Label loop2; |
| 461 __ sub(r7, r7, Operand(kPointerSize)); |
| 462 __ bind(&loop2); |
| 463 __ ldr(r2, MemOperand(r7, kPointerSize, PostIndex)); |
| 464 __ str(r2, MemOperand(r5, -kPointerSize, PreIndex)); |
| 465 __ cmp(r4, r5); |
| 466 __ b(lt, &loop2); |
| 467 __ b(&finish); |
435 } | 468 } |
436 | 469 |
437 | 470 |
438 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 471 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
439 // ----------- S t a t e ------------- | 472 // ----------- S t a t e ------------- |
440 // -- r0 : number of arguments | 473 // -- r0 : number of arguments |
441 // -- lr : return address | 474 // -- lr : return address |
442 // -- sp[...]: constructor arguments | 475 // -- sp[...]: constructor arguments |
443 // ----------------------------------- | 476 // ----------------------------------- |
444 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; | 477 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; |
(...skipping 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 __ bind(&dont_adapt_arguments); | 1752 __ bind(&dont_adapt_arguments); |
1720 __ Jump(r3); | 1753 __ Jump(r3); |
1721 } | 1754 } |
1722 | 1755 |
1723 | 1756 |
1724 #undef __ | 1757 #undef __ |
1725 | 1758 |
1726 } } // namespace v8::internal | 1759 } } // namespace v8::internal |
1727 | 1760 |
1728 #endif // V8_TARGET_ARCH_ARM | 1761 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |