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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 // Initial map for the builtin InternalArray functions should be maps. | 473 // Initial map for the builtin InternalArray functions should be maps. |
474 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 474 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
475 __ SmiTst(r2); | 475 __ SmiTst(r2); |
476 __ Assert(ne, "Unexpected initial map for InternalArray function"); | 476 __ Assert(ne, "Unexpected initial map for InternalArray function"); |
477 __ CompareObjectType(r2, r3, r4, MAP_TYPE); | 477 __ CompareObjectType(r2, r3, r4, MAP_TYPE); |
478 __ Assert(eq, "Unexpected initial map for InternalArray function"); | 478 __ Assert(eq, "Unexpected initial map for InternalArray function"); |
479 } | 479 } |
480 | 480 |
481 // Run the native code for the InternalArray function called as a normal | 481 // Run the native code for the InternalArray function called as a normal |
482 // function. | 482 // function. |
483 ArrayNativeCode(masm, &generic_array_code); | 483 if (FLAG_optimize_constructed_arrays) { |
| 484 // tail call a stub |
| 485 InternalArrayConstructorStub stub(masm->isolate()); |
| 486 __ TailCallStub(&stub); |
| 487 } else { |
| 488 ArrayNativeCode(masm, &generic_array_code); |
484 | 489 |
485 // Jump to the generic array code if the specialized code cannot handle the | 490 // Jump to the generic array code if the specialized code cannot handle the |
486 // construction. | 491 // construction. |
487 __ bind(&generic_array_code); | 492 __ bind(&generic_array_code); |
488 | 493 Handle<Code> array_code = |
489 Handle<Code> array_code = | 494 masm->isolate()->builtins()->InternalArrayCodeGeneric(); |
490 masm->isolate()->builtins()->InternalArrayCodeGeneric(); | 495 __ Jump(array_code, RelocInfo::CODE_TARGET); |
491 __ Jump(array_code, RelocInfo::CODE_TARGET); | 496 } |
492 } | 497 } |
493 | 498 |
494 | 499 |
495 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 500 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
496 // ----------- S t a t e ------------- | 501 // ----------- S t a t e ------------- |
497 // -- r0 : number of arguments | 502 // -- r0 : number of arguments |
498 // -- lr : return address | 503 // -- lr : return address |
499 // -- sp[...]: constructor arguments | 504 // -- sp[...]: constructor arguments |
500 // ----------------------------------- | 505 // ----------------------------------- |
501 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; | 506 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; |
502 | 507 |
503 // Get the Array function. | 508 // Get the Array function. |
504 GenerateLoadArrayFunction(masm, r1); | 509 GenerateLoadArrayFunction(masm, r1); |
505 | 510 |
506 if (FLAG_debug_code) { | 511 if (FLAG_debug_code) { |
507 // Initial map for the builtin Array functions should be maps. | 512 // Initial map for the builtin Array functions should be maps. |
508 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 513 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
509 __ SmiTst(r2); | 514 __ SmiTst(r2); |
510 __ Assert(ne, "Unexpected initial map for Array function"); | 515 __ Assert(ne, "Unexpected initial map for Array function"); |
511 __ CompareObjectType(r2, r3, r4, MAP_TYPE); | 516 __ CompareObjectType(r2, r3, r4, MAP_TYPE); |
512 __ Assert(eq, "Unexpected initial map for Array function"); | 517 __ Assert(eq, "Unexpected initial map for Array function"); |
513 } | 518 } |
514 | 519 |
515 // Run the native code for the Array function called as a normal function. | 520 // Run the native code for the Array function called as a normal function. |
516 ArrayNativeCode(masm, &generic_array_code); | 521 if (FLAG_optimize_constructed_arrays) { |
| 522 // tail call a stub |
| 523 Handle<Object> undefined_sentinel( |
| 524 masm->isolate()->heap()->undefined_value(), |
| 525 masm->isolate()); |
| 526 __ mov(r2, Operand(undefined_sentinel)); |
| 527 ArrayConstructorStub stub(masm->isolate()); |
| 528 __ TailCallStub(&stub); |
| 529 } else { |
| 530 ArrayNativeCode(masm, &generic_array_code); |
517 | 531 |
518 // Jump to the generic array code if the specialized code cannot handle | 532 // Jump to the generic array code if the specialized code cannot handle |
519 // the construction. | 533 // the construction. |
520 __ bind(&generic_array_code); | 534 __ bind(&generic_array_code); |
521 | 535 Handle<Code> array_code = |
522 Handle<Code> array_code = | 536 masm->isolate()->builtins()->ArrayCodeGeneric(); |
523 masm->isolate()->builtins()->ArrayCodeGeneric(); | 537 __ Jump(array_code, RelocInfo::CODE_TARGET); |
524 __ Jump(array_code, RelocInfo::CODE_TARGET); | 538 } |
525 } | 539 } |
526 | 540 |
527 | 541 |
528 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { | 542 void Builtins::Generate_CommonArrayConstructCode(MacroAssembler* masm) { |
529 // ----------- S t a t e ------------- | 543 // ----------- S t a t e ------------- |
530 // -- r0 : number of arguments | 544 // -- r0 : number of arguments |
531 // -- r1 : constructor function | 545 // -- r1 : constructor function |
532 // -- r2 : type info cell | 546 // -- r2 : type info cell |
533 // -- lr : return address | 547 // -- lr : return address |
534 // -- sp[...]: constructor arguments | 548 // -- sp[...]: constructor arguments |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 __ bind(&dont_adapt_arguments); | 1883 __ bind(&dont_adapt_arguments); |
1870 __ Jump(r3); | 1884 __ Jump(r3); |
1871 } | 1885 } |
1872 | 1886 |
1873 | 1887 |
1874 #undef __ | 1888 #undef __ |
1875 | 1889 |
1876 } } // namespace v8::internal | 1890 } } // namespace v8::internal |
1877 | 1891 |
1878 #endif // V8_TARGET_ARCH_ARM | 1892 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |