OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 | 84 |
85 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 85 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
86 // ----------- S t a t e ------------- | 86 // ----------- S t a t e ------------- |
87 // -- rax : actual number of arguments | 87 // -- rax : actual number of arguments |
88 // -- rbx : expected number of arguments | 88 // -- rbx : expected number of arguments |
89 // -- rdx : code entry to call | 89 // -- rdx : code entry to call |
90 // ----------------------------------- | 90 // ----------------------------------- |
91 | 91 |
92 Label invoke, dont_adapt_arguments; | 92 Label invoke, dont_adapt_arguments; |
93 __ IncrementCounter(&Counters::arguments_adaptors, 1); | 93 __ IncrementCounter(&COUNTER(arguments_adaptors), 1); |
94 | 94 |
95 Label enough, too_few; | 95 Label enough, too_few; |
96 __ cmpq(rax, rbx); | 96 __ cmpq(rax, rbx); |
97 __ j(less, &too_few); | 97 __ j(less, &too_few); |
98 __ cmpq(rbx, Immediate(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 98 __ cmpq(rbx, Immediate(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
99 __ j(equal, &dont_adapt_arguments); | 99 __ j(equal, &dont_adapt_arguments); |
100 | 100 |
101 { // Enough parameters: Actual >= expected. | 101 { // Enough parameters: Actual >= expected. |
102 __ bind(&enough); | 102 __ bind(&enough); |
103 EnterArgumentsAdaptorFrame(masm); | 103 EnterArgumentsAdaptorFrame(masm); |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 681 |
682 // Handle construction of an empty array. | 682 // Handle construction of an empty array. |
683 AllocateEmptyJSArray(masm, | 683 AllocateEmptyJSArray(masm, |
684 rdi, | 684 rdi, |
685 rbx, | 685 rbx, |
686 rcx, | 686 rcx, |
687 rdx, | 687 rdx, |
688 r8, | 688 r8, |
689 kPreallocatedArrayElements, | 689 kPreallocatedArrayElements, |
690 call_generic_code); | 690 call_generic_code); |
691 __ IncrementCounter(&Counters::array_function_native, 1); | 691 __ IncrementCounter(&COUNTER(array_function_native), 1); |
692 __ movq(rax, rbx); | 692 __ movq(rax, rbx); |
693 __ ret(kPointerSize); | 693 __ ret(kPointerSize); |
694 | 694 |
695 // Check for one argument. Bail out if argument is not smi or if it is | 695 // Check for one argument. Bail out if argument is not smi or if it is |
696 // negative. | 696 // negative. |
697 __ bind(&argc_one_or_more); | 697 __ bind(&argc_one_or_more); |
698 __ cmpq(rax, Immediate(1)); | 698 __ cmpq(rax, Immediate(1)); |
699 __ j(not_equal, &argc_two_or_more); | 699 __ j(not_equal, &argc_two_or_more); |
700 __ movq(rdx, Operand(rsp, kPointerSize)); // Get the argument from the stack. | 700 __ movq(rdx, Operand(rsp, kPointerSize)); // Get the argument from the stack. |
701 __ JumpIfNotPositiveSmi(rdx, call_generic_code); | 701 __ JumpIfNotPositiveSmi(rdx, call_generic_code); |
(...skipping 10 matching lines...) Expand all Loading... |
712 // esp[8]: argument | 712 // esp[8]: argument |
713 AllocateJSArray(masm, | 713 AllocateJSArray(masm, |
714 rdi, | 714 rdi, |
715 rdx, | 715 rdx, |
716 rbx, | 716 rbx, |
717 rcx, | 717 rcx, |
718 r8, | 718 r8, |
719 r9, | 719 r9, |
720 true, | 720 true, |
721 call_generic_code); | 721 call_generic_code); |
722 __ IncrementCounter(&Counters::array_function_native, 1); | 722 __ IncrementCounter(&COUNTER(array_function_native), 1); |
723 __ movq(rax, rbx); | 723 __ movq(rax, rbx); |
724 __ ret(2 * kPointerSize); | 724 __ ret(2 * kPointerSize); |
725 | 725 |
726 // Handle construction of an array from a list of arguments. | 726 // Handle construction of an array from a list of arguments. |
727 __ bind(&argc_two_or_more); | 727 __ bind(&argc_two_or_more); |
728 __ movq(rdx, rax); | 728 __ movq(rdx, rax); |
729 __ Integer32ToSmi(rdx, rdx); // Convet argc to a smi. | 729 __ Integer32ToSmi(rdx, rdx); // Convet argc to a smi. |
730 // rax: argc | 730 // rax: argc |
731 // rdx: array_size (smi) | 731 // rdx: array_size (smi) |
732 // rdi: constructor | 732 // rdi: constructor |
733 // esp[0] : return address | 733 // esp[0] : return address |
734 // esp[8] : last argument | 734 // esp[8] : last argument |
735 AllocateJSArray(masm, | 735 AllocateJSArray(masm, |
736 rdi, | 736 rdi, |
737 rdx, | 737 rdx, |
738 rbx, | 738 rbx, |
739 rcx, | 739 rcx, |
740 r8, | 740 r8, |
741 r9, | 741 r9, |
742 false, | 742 false, |
743 call_generic_code); | 743 call_generic_code); |
744 __ IncrementCounter(&Counters::array_function_native, 1); | 744 __ IncrementCounter(&COUNTER(array_function_native), 1); |
745 | 745 |
746 // rax: argc | 746 // rax: argc |
747 // rbx: JSArray | 747 // rbx: JSArray |
748 // rcx: elements_array | 748 // rcx: elements_array |
749 // r8: elements_array_end (untagged) | 749 // r8: elements_array_end (untagged) |
750 // esp[0]: return address | 750 // esp[0]: return address |
751 // esp[8]: last argument | 751 // esp[8]: last argument |
752 | 752 |
753 // Location of the last argument | 753 // Location of the last argument |
754 __ lea(r9, Operand(rsp, kPointerSize)); | 754 __ lea(r9, Operand(rsp, kPointerSize)); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 // Restore the arguments count and leave the construct frame. | 1117 // Restore the arguments count and leave the construct frame. |
1118 __ bind(&exit); | 1118 __ bind(&exit); |
1119 __ movq(rbx, Operand(rsp, kPointerSize)); // get arguments count | 1119 __ movq(rbx, Operand(rsp, kPointerSize)); // get arguments count |
1120 __ LeaveConstructFrame(); | 1120 __ LeaveConstructFrame(); |
1121 | 1121 |
1122 // Remove caller arguments from the stack and return. | 1122 // Remove caller arguments from the stack and return. |
1123 __ pop(rcx); | 1123 __ pop(rcx); |
1124 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); | 1124 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |
1125 __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); | 1125 __ lea(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |
1126 __ push(rcx); | 1126 __ push(rcx); |
1127 __ IncrementCounter(&Counters::constructed_objects, 1); | 1127 __ IncrementCounter(&COUNTER(constructed_objects), 1); |
1128 __ ret(0); | 1128 __ ret(0); |
1129 } | 1129 } |
1130 | 1130 |
1131 | 1131 |
1132 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 1132 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
1133 bool is_construct) { | 1133 bool is_construct) { |
1134 // Expects five C++ function parameters. | 1134 // Expects five C++ function parameters. |
1135 // - Address entry (ignored) | 1135 // - Address entry (ignored) |
1136 // - JSFunction* function ( | 1136 // - JSFunction* function ( |
1137 // - Object* receiver | 1137 // - Object* receiver |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 1246 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
1247 Generate_JSEntryTrampolineHelper(masm, false); | 1247 Generate_JSEntryTrampolineHelper(masm, false); |
1248 } | 1248 } |
1249 | 1249 |
1250 | 1250 |
1251 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 1251 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
1252 Generate_JSEntryTrampolineHelper(masm, true); | 1252 Generate_JSEntryTrampolineHelper(masm, true); |
1253 } | 1253 } |
1254 | 1254 |
1255 } } // namespace v8::internal | 1255 } } // namespace v8::internal |
OLD | NEW |