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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 Handle<Code> array_code = | 535 Handle<Code> array_code = |
536 masm->isolate()->builtins()->ArrayCodeGeneric(); | 536 masm->isolate()->builtins()->ArrayCodeGeneric(); |
537 __ Jump(array_code, RelocInfo::CODE_TARGET); | 537 __ Jump(array_code, RelocInfo::CODE_TARGET); |
538 } | 538 } |
539 | 539 |
540 | 540 |
541 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { | 541 void Builtins::Generate_ArrayConstructCode(MacroAssembler* masm) { |
542 // ----------- S t a t e ------------- | 542 // ----------- S t a t e ------------- |
543 // -- r0 : number of arguments | 543 // -- r0 : number of arguments |
544 // -- r1 : constructor function | 544 // -- r1 : constructor function |
| 545 // -- r2 : type info cell |
| 546 // -- lr : return address |
| 547 // -- sp[...]: constructor arguments |
| 548 // ----------------------------------- |
| 549 |
| 550 if (FLAG_debug_code) { |
| 551 // The array construct code is only set for the builtin and internal |
| 552 // Array functions which always have a map. |
| 553 // Initial map for the builtin Array function should be a map. |
| 554 __ stop("oh god"); |
| 555 __ ldr(r3, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
| 556 __ tst(r3, Operand(kSmiTagMask)); |
| 557 __ Assert(ne, "Unexpected initial map for Array function"); |
| 558 __ CompareObjectType(r1, r3, r4, MAP_TYPE); |
| 559 __ Assert(eq, "Unexpected initial map for Array function"); |
| 560 |
| 561 // We should either have undefined in r2 or a valid jsglobalpropertycell |
| 562 Label okay_here; |
| 563 Handle<Object> undefined_sentinel( |
| 564 masm->isolate()->heap()->undefined_value()); |
| 565 Handle<Map> global_property_cell_map( |
| 566 masm->isolate()->heap()->global_property_cell_map()); |
| 567 __ cmp(r2, Operand(undefined_sentinel)); |
| 568 __ b(eq, &okay_here); |
| 569 __ ldr(r3, FieldMemOperand(r2, 0)); |
| 570 __ cmp(r3, Operand(global_property_cell_map)); |
| 571 __ Assert(eq, "Expected property cell in register ebx"); |
| 572 __ bind(&okay_here); |
| 573 } |
| 574 |
| 575 if (FLAG_optimize_constructed_arrays) { |
| 576 Label not_zero_case, not_one_case; |
| 577 __ tst(r0, r0); |
| 578 __ b(ne, ¬_zero_case); |
| 579 ArrayNoArgumentConstructorStub no_argument_stub; |
| 580 __ TailCallStub(&no_argument_stub); |
| 581 |
| 582 __ bind(¬_zero_case); |
| 583 __ cmp(r0, Operand(1)); |
| 584 __ b(gt, ¬_one_case); |
| 585 ArraySingleArgumentConstructorStub single_argument_stub; |
| 586 __ TailCallStub(&single_argument_stub); |
| 587 |
| 588 __ bind(¬_one_case); |
| 589 ArrayNArgumentsConstructorStub n_argument_stub; |
| 590 __ TailCallStub(&n_argument_stub); |
| 591 } else { |
| 592 Label generic_constructor; |
| 593 // Run the native code for the Array function called as a constructor. |
| 594 ArrayNativeCode(masm, &generic_constructor); |
| 595 |
| 596 // Jump to the generic construct code in case the specialized code cannot |
| 597 // handle the construction. |
| 598 __ bind(&generic_constructor); |
| 599 Handle<Code> generic_construct_stub = |
| 600 masm->isolate()->builtins()->JSConstructStubGeneric(); |
| 601 __ Jump(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 602 } |
| 603 } |
| 604 |
| 605 |
| 606 void Builtins::Generate_InternalArrayConstructCode(MacroAssembler* masm) { |
| 607 // ----------- S t a t e ------------- |
| 608 // -- r0 : number of arguments |
| 609 // -- r1 : constructor function |
545 // -- lr : return address | 610 // -- lr : return address |
546 // -- sp[...]: constructor arguments | 611 // -- sp[...]: constructor arguments |
547 // ----------------------------------- | 612 // ----------------------------------- |
548 Label generic_constructor; | 613 Label generic_constructor; |
549 | 614 |
550 if (FLAG_debug_code) { | 615 if (FLAG_debug_code) { |
551 // The array construct code is only set for the builtin and internal | 616 // The array construct code is only set for the builtin and internal |
552 // Array functions which always have a map. | 617 // Array functions which always have a map. |
553 // Initial map for the builtin Array function should be a map. | 618 // Initial map for the builtin Array function should be a map. |
554 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); | 619 __ ldr(r2, FieldMemOperand(r1, JSFunction::kPrototypeOrInitialMapOffset)); |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 __ mov(r5, Operand(r4)); | 1199 __ mov(r5, Operand(r4)); |
1135 __ mov(r6, Operand(r4)); | 1200 __ mov(r6, Operand(r4)); |
1136 __ mov(r7, Operand(r4)); | 1201 __ mov(r7, Operand(r4)); |
1137 if (kR9Available == 1) { | 1202 if (kR9Available == 1) { |
1138 __ mov(r9, Operand(r4)); | 1203 __ mov(r9, Operand(r4)); |
1139 } | 1204 } |
1140 | 1205 |
1141 // Invoke the code and pass argc as r0. | 1206 // Invoke the code and pass argc as r0. |
1142 __ mov(r0, Operand(r3)); | 1207 __ mov(r0, Operand(r3)); |
1143 if (is_construct) { | 1208 if (is_construct) { |
| 1209 // No type feedback cell is available |
| 1210 Handle<Object> undefined_sentinel( |
| 1211 masm->isolate()->heap()->undefined_value()); |
| 1212 __ mov(r2, Operand(undefined_sentinel)); |
1144 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 1213 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
1145 __ CallStub(&stub); | 1214 __ CallStub(&stub); |
1146 } else { | 1215 } else { |
1147 ParameterCount actual(r0); | 1216 ParameterCount actual(r0); |
1148 __ InvokeFunction(r1, actual, CALL_FUNCTION, | 1217 __ InvokeFunction(r1, actual, CALL_FUNCTION, |
1149 NullCallWrapper(), CALL_AS_METHOD); | 1218 NullCallWrapper(), CALL_AS_METHOD); |
1150 } | 1219 } |
1151 // Exit the JS frame and remove the parameters (except function), and | 1220 // Exit the JS frame and remove the parameters (except function), and |
1152 // return. | 1221 // return. |
1153 // Respect ABI stack constraint. | 1222 // Respect ABI stack constraint. |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 __ bind(&dont_adapt_arguments); | 1919 __ bind(&dont_adapt_arguments); |
1851 __ Jump(r3); | 1920 __ Jump(r3); |
1852 } | 1921 } |
1853 | 1922 |
1854 | 1923 |
1855 #undef __ | 1924 #undef __ |
1856 | 1925 |
1857 } } // namespace v8::internal | 1926 } } // namespace v8::internal |
1858 | 1927 |
1859 #endif // V8_TARGET_ARCH_ARM | 1928 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |