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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { | 835 static void FreeSpaceForFastApiCall(MacroAssembler* masm) { |
836 __ Drop(kFastApiCallArguments); | 836 __ Drop(kFastApiCallArguments); |
837 } | 837 } |
838 | 838 |
839 | 839 |
840 static void GenerateFastApiDirectCall(MacroAssembler* masm, | 840 static void GenerateFastApiDirectCall(MacroAssembler* masm, |
841 const CallOptimization& optimization, | 841 const CallOptimization& optimization, |
842 int argc, | 842 int argc, |
843 bool restore_context) { | 843 bool restore_context) { |
844 // ----------- S t a t e ------------- | 844 // ----------- S t a t e ------------- |
845 // -- sp[0] : context | 845 // -- sp[0] - sp[24] : FunctionCallbackInfo, incl. |
846 // -- sp[4] : holder (set by CheckPrototypes) | 846 // : holder (set by CheckPrototypes) |
847 // -- sp[8] : callee JS function | |
848 // -- sp[12] : call data | |
849 // -- sp[16] : isolate | |
850 // -- sp[20] : ReturnValue default value | |
851 // -- sp[24] : ReturnValue | |
852 // -- sp[28] : last JS argument | 847 // -- sp[28] : last JS argument |
853 // -- ... | 848 // -- ... |
854 // -- sp[(argc + 6) * 4] : first JS argument | 849 // -- sp[(argc + 6) * 4] : first JS argument |
855 // -- sp[(argc + 7) * 4] : receiver | 850 // -- sp[(argc + 7) * 4] : receiver |
856 // ----------------------------------- | 851 // ----------------------------------- |
| 852 typedef FunctionCallbackArguments FCA; |
| 853 const int kArgs = kFastApiCallArguments; |
857 // Save calling context. | 854 // Save calling context. |
858 __ str(cp, MemOperand(sp)); | 855 __ str(cp, |
| 856 MemOperand(sp, (kArgs - 1 + FCA::kContextSaveIndex) * kPointerSize)); |
859 // Get the function and setup the context. | 857 // Get the function and setup the context. |
860 Handle<JSFunction> function = optimization.constant_function(); | 858 Handle<JSFunction> function = optimization.constant_function(); |
861 __ LoadHeapObject(r5, function); | 859 __ LoadHeapObject(r5, function); |
862 __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); | 860 __ ldr(cp, FieldMemOperand(r5, JSFunction::kContextOffset)); |
863 __ str(r5, MemOperand(sp, 2 * kPointerSize)); | 861 __ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kCalleeIndex) * kPointerSize)); |
864 | 862 |
865 // Pass the additional arguments. | 863 // Construct the FunctionCallbackInfo. |
866 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 864 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
867 Handle<Object> call_data(api_call_info->data(), masm->isolate()); | 865 Handle<Object> call_data(api_call_info->data(), masm->isolate()); |
868 if (masm->isolate()->heap()->InNewSpace(*call_data)) { | 866 if (masm->isolate()->heap()->InNewSpace(*call_data)) { |
869 __ Move(r0, api_call_info); | 867 __ Move(r0, api_call_info); |
870 __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); | 868 __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); |
871 } else { | 869 } else { |
872 __ Move(r6, call_data); | 870 __ Move(r6, call_data); |
873 } | 871 } |
874 // Store call data. | 872 // Store call data. |
875 __ str(r6, MemOperand(sp, 3 * kPointerSize)); | 873 __ str(r6, MemOperand(sp, (kArgs - 1 + FCA::kDataIndex) * kPointerSize)); |
876 // Store isolate. | 874 // Store isolate. |
877 __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate()))); | 875 __ mov(r5, Operand(ExternalReference::isolate_address(masm->isolate()))); |
878 __ str(r5, MemOperand(sp, 4 * kPointerSize)); | 876 __ str(r5, MemOperand(sp, (kArgs - 1 + FCA::kIsolateIndex) * kPointerSize)); |
879 // Store ReturnValue default and ReturnValue. | 877 // Store ReturnValue default and ReturnValue. |
880 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | 878 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
881 __ str(r5, MemOperand(sp, 5 * kPointerSize)); | 879 __ str(r5, |
882 __ str(r5, MemOperand(sp, 6 * kPointerSize)); | 880 MemOperand(sp, (kArgs - 1 + FCA::kReturnValueOffset) * kPointerSize)); |
| 881 __ str( |
| 882 r5, |
| 883 MemOperand( |
| 884 sp, (kArgs - 1 + FCA::kReturnValueDefaultValueIndex) * kPointerSize)); |
883 | 885 |
884 // Prepare arguments. | 886 // Prepare arguments. |
885 __ add(r2, sp, Operand((kFastApiCallArguments - 1) * kPointerSize)); | 887 __ add(r2, sp, Operand((kArgs - 1) * kPointerSize)); |
886 | 888 |
887 // Allocate the v8::Arguments structure in the arguments' space since | 889 // Allocate the v8::Arguments structure in the arguments' space since |
888 // it's not controlled by GC. | 890 // it's not controlled by GC. |
889 const int kApiStackSpace = 4; | 891 const int kApiStackSpace = 4; |
890 | 892 |
891 FrameScope frame_scope(masm, StackFrame::MANUAL); | 893 FrameScope frame_scope(masm, StackFrame::MANUAL); |
892 __ EnterExitFrame(false, kApiStackSpace); | 894 __ EnterExitFrame(false, kApiStackSpace); |
893 | 895 |
894 // r0 = v8::Arguments& | 896 // r0 = v8::Arguments& |
895 // Arguments is after the return address. | 897 // Arguments is after the return address. |
896 __ add(r0, sp, Operand(1 * kPointerSize)); | 898 __ add(r0, sp, Operand(1 * kPointerSize)); |
897 // v8::Arguments::implicit_args_ | 899 // v8::Arguments::implicit_args_ |
898 __ str(r2, MemOperand(r0, 0 * kPointerSize)); | 900 __ str(r2, MemOperand(r0, 0 * kPointerSize)); |
899 // v8::Arguments::values_ | 901 // v8::Arguments::values_ |
900 __ add(ip, r2, Operand(argc * kPointerSize)); | 902 __ add(ip, r2, Operand(argc * kPointerSize)); |
901 __ str(ip, MemOperand(r0, 1 * kPointerSize)); | 903 __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
902 // v8::Arguments::length_ = argc | 904 // v8::Arguments::length_ = argc |
903 __ mov(ip, Operand(argc)); | 905 __ mov(ip, Operand(argc)); |
904 __ str(ip, MemOperand(r0, 2 * kPointerSize)); | 906 __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
905 // v8::Arguments::is_construct_call = 0 | 907 // v8::Arguments::is_construct_call = 0 |
906 __ mov(ip, Operand::Zero()); | 908 __ mov(ip, Operand::Zero()); |
907 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 909 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
908 | 910 |
909 const int kStackUnwindSpace = argc + kFastApiCallArguments + 1; | 911 const int kStackUnwindSpace = argc + kArgs + 1; |
910 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 912 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
911 ApiFunction fun(function_address); | 913 ApiFunction fun(function_address); |
912 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; | 914 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; |
913 ExternalReference ref = ExternalReference(&fun, | 915 ExternalReference ref = ExternalReference(&fun, |
914 type, | 916 type, |
915 masm->isolate()); | 917 masm->isolate()); |
916 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); | 918 Address thunk_address = FUNCTION_ADDR(&InvokeFunctionCallback); |
917 ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL; | 919 ExternalReference::Type thunk_type = ExternalReference::PROFILING_API_CALL; |
918 ApiFunction thunk_fun(thunk_address); | 920 ApiFunction thunk_fun(thunk_address); |
919 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, | 921 ExternalReference thunk_ref = ExternalReference(&thunk_fun, thunk_type, |
920 masm->isolate()); | 922 masm->isolate()); |
921 | 923 |
922 AllowExternalCallThatCantCauseGC scope(masm); | 924 AllowExternalCallThatCantCauseGC scope(masm); |
923 MemOperand context_restore_operand( | 925 MemOperand context_restore_operand( |
924 fp, 2 * kPointerSize); | 926 fp, (kArgs + 1 + FCA::kContextSaveIndex) * kPointerSize); |
925 MemOperand return_value_operand( | 927 MemOperand return_value_operand( |
926 fp, (kFastApiCallArguments + 1) * kPointerSize); | 928 fp, (kArgs + 1 + FCA::kReturnValueOffset) * kPointerSize); |
927 __ CallApiFunctionAndReturn(ref, | 929 __ CallApiFunctionAndReturn(ref, |
928 function_address, | 930 function_address, |
929 thunk_ref, | 931 thunk_ref, |
930 r1, | 932 r1, |
931 kStackUnwindSpace, | 933 kStackUnwindSpace, |
932 return_value_operand, | 934 return_value_operand, |
933 restore_context ? | 935 restore_context ? |
934 &context_restore_operand : NULL); | 936 &context_restore_operand : NULL); |
935 } | 937 } |
936 | 938 |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3191 // ----------------------------------- | 3193 // ----------------------------------- |
3192 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); | 3194 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_MissForceGeneric); |
3193 } | 3195 } |
3194 | 3196 |
3195 | 3197 |
3196 #undef __ | 3198 #undef __ |
3197 | 3199 |
3198 } } // namespace v8::internal | 3200 } } // namespace v8::internal |
3199 | 3201 |
3200 #endif // V8_TARGET_ARCH_ARM | 3202 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |