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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // rsp: stack pointer, points to return address from this function. | 58 // rsp: stack pointer, points to return address from this function. |
59 // rbp: base pointer, points to previous JS, ArgumentsAdaptor, or | 59 // rbp: base pointer, points to previous JS, ArgumentsAdaptor, or |
60 // Trampoline frame. | 60 // Trampoline frame. |
61 // rsi: context of this function call. | 61 // rsi: context of this function call. |
62 // rdi: pointer to this function object. | 62 // rdi: pointer to this function object. |
63 Comment cmnt(masm(), "[ Enter JS frame"); | 63 Comment cmnt(masm(), "[ Enter JS frame"); |
64 | 64 |
65 #ifdef DEBUG | 65 #ifdef DEBUG |
66 // Verify that rdi contains a JS function. The following code | 66 // Verify that rdi contains a JS function. The following code |
67 // relies on rax being available for use. | 67 // relies on rax being available for use. |
68 __ testq(rdi, Immediate(kSmiTagMask)); | 68 __ testl(rdi, Immediate(kSmiTagMask)); |
69 __ Check(not_zero, | 69 __ Check(not_zero, |
70 "VirtualFrame::Enter - rdi is not a function (smi check)."); | 70 "VirtualFrame::Enter - rdi is not a function (smi check)."); |
71 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rax); | 71 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rax); |
72 __ Check(equal, | 72 __ Check(equal, |
73 "VirtualFrame::Enter - rdi is not a function (map check)."); | 73 "VirtualFrame::Enter - rdi is not a function (map check)."); |
74 #endif | 74 #endif |
75 | 75 |
76 EmitPush(rbp); | 76 EmitPush(rbp); |
77 | 77 |
78 __ movq(rbp, rsp); | 78 __ movq(rbp, rsp); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 // name slot (but it does drop the rest). | 886 // name slot (but it does drop the rest). |
887 InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP; | 887 InLoopFlag in_loop = loop_nesting > 0 ? IN_LOOP : NOT_IN_LOOP; |
888 Handle<Code> ic = cgen()->ComputeCallInitialize(arg_count, in_loop); | 888 Handle<Code> ic = cgen()->ComputeCallInitialize(arg_count, in_loop); |
889 // Spill args, receiver, and function. The call will drop args and | 889 // Spill args, receiver, and function. The call will drop args and |
890 // receiver. | 890 // receiver. |
891 PrepareForCall(arg_count + 2, arg_count + 1); | 891 PrepareForCall(arg_count + 2, arg_count + 1); |
892 return RawCallCodeObject(ic, mode); | 892 return RawCallCodeObject(ic, mode); |
893 } | 893 } |
894 | 894 |
895 | 895 |
| 896 Result VirtualFrame::CallConstructor(int arg_count) { |
| 897 // Arguments, receiver, and function are on top of the frame. The |
| 898 // IC expects arg count in rax, function in rdi, and the arguments |
| 899 // and receiver on the stack. |
| 900 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); |
| 901 // Duplicate the function before preparing the frame. |
| 902 PushElementAt(arg_count + 1); |
| 903 Result function = Pop(); |
| 904 PrepareForCall(arg_count + 1, arg_count + 1); // Spill args and receiver. |
| 905 function.ToRegister(rdi); |
| 906 |
| 907 // Constructors are called with the number of arguments in register |
| 908 // eax for now. Another option would be to have separate construct |
| 909 // call trampolines per different arguments counts encountered. |
| 910 Result num_args = cgen()->allocator()->Allocate(rax); |
| 911 ASSERT(num_args.is_valid()); |
| 912 __ movq(num_args.reg(), Immediate(arg_count)); |
| 913 |
| 914 function.Unuse(); |
| 915 num_args.Unuse(); |
| 916 return RawCallCodeObject(ic, RelocInfo::CONSTRUCT_CALL); |
| 917 } |
| 918 |
| 919 |
896 Result VirtualFrame::CallStoreIC() { | 920 Result VirtualFrame::CallStoreIC() { |
897 // Name, value, and receiver are on top of the frame. The IC | 921 // Name, value, and receiver are on top of the frame. The IC |
898 // expects name in rcx, value in rax, and receiver on the stack. It | 922 // expects name in rcx, value in rax, and receiver on the stack. It |
899 // does not drop the receiver. | 923 // does not drop the receiver. |
900 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 924 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
901 Result name = Pop(); | 925 Result name = Pop(); |
902 Result value = Pop(); | 926 Result value = Pop(); |
903 PrepareForCall(1, 0); // One stack arg, not callee-dropped. | 927 PrepareForCall(1, 0); // One stack arg, not callee-dropped. |
904 | 928 |
905 if (value.is_register() && value.reg().is(rcx)) { | 929 if (value.is_register() && value.reg().is(rcx)) { |
(...skipping 14 matching lines...) Expand all Loading... |
920 | 944 |
921 name.Unuse(); | 945 name.Unuse(); |
922 value.Unuse(); | 946 value.Unuse(); |
923 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); | 947 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); |
924 } | 948 } |
925 | 949 |
926 | 950 |
927 #undef __ | 951 #undef __ |
928 | 952 |
929 } } // namespace v8::internal | 953 } } // namespace v8::internal |
OLD | NEW |