OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 | 873 |
874 void MacroAssembler::GetCFunctionDoubleResult(const DoubleRegister dst) { | 874 void MacroAssembler::GetCFunctionDoubleResult(const DoubleRegister dst) { |
875 if (use_eabi_hardfloat()) { | 875 if (use_eabi_hardfloat()) { |
876 Move(dst, d0); | 876 Move(dst, d0); |
877 } else { | 877 } else { |
878 vmov(dst, r0, r1); | 878 vmov(dst, r0, r1); |
879 } | 879 } |
880 } | 880 } |
881 | 881 |
882 | 882 |
| 883 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) { |
| 884 // This macro takes the dst register to make the code more readable |
| 885 // at the call sites. However, the dst register has to be r5 to |
| 886 // follow the calling convention which requires the call type to be |
| 887 // in r5. |
| 888 ASSERT(dst.is(r5)); |
| 889 if (call_kind == CALL_AS_FUNCTION) { |
| 890 mov(dst, Operand(Smi::FromInt(1))); |
| 891 } else { |
| 892 mov(dst, Operand(Smi::FromInt(0))); |
| 893 } |
| 894 } |
| 895 |
| 896 |
883 void MacroAssembler::InvokePrologue(const ParameterCount& expected, | 897 void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
884 const ParameterCount& actual, | 898 const ParameterCount& actual, |
885 Handle<Code> code_constant, | 899 Handle<Code> code_constant, |
886 Register code_reg, | 900 Register code_reg, |
887 Label* done, | 901 Label* done, |
888 InvokeFlag flag, | 902 InvokeFlag flag, |
889 const CallWrapper& call_wrapper) { | 903 const CallWrapper& call_wrapper, |
| 904 CallKind call_kind) { |
890 bool definitely_matches = false; | 905 bool definitely_matches = false; |
891 Label regular_invoke; | 906 Label regular_invoke; |
892 | 907 |
893 // Check whether the expected and actual arguments count match. If not, | 908 // Check whether the expected and actual arguments count match. If not, |
894 // setup registers according to contract with ArgumentsAdaptorTrampoline: | 909 // setup registers according to contract with ArgumentsAdaptorTrampoline: |
895 // r0: actual arguments count | 910 // r0: actual arguments count |
896 // r1: function (passed through to callee) | 911 // r1: function (passed through to callee) |
897 // r2: expected arguments count | 912 // r2: expected arguments count |
898 // r3: callee code entry | 913 // r3: callee code entry |
899 | 914 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 if (!definitely_matches) { | 950 if (!definitely_matches) { |
936 if (!code_constant.is_null()) { | 951 if (!code_constant.is_null()) { |
937 mov(r3, Operand(code_constant)); | 952 mov(r3, Operand(code_constant)); |
938 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); | 953 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
939 } | 954 } |
940 | 955 |
941 Handle<Code> adaptor = | 956 Handle<Code> adaptor = |
942 isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 957 isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
943 if (flag == CALL_FUNCTION) { | 958 if (flag == CALL_FUNCTION) { |
944 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); | 959 call_wrapper.BeforeCall(CallSize(adaptor, RelocInfo::CODE_TARGET)); |
| 960 SetCallKind(r5, call_kind); |
945 Call(adaptor, RelocInfo::CODE_TARGET); | 961 Call(adaptor, RelocInfo::CODE_TARGET); |
946 call_wrapper.AfterCall(); | 962 call_wrapper.AfterCall(); |
947 b(done); | 963 b(done); |
948 } else { | 964 } else { |
| 965 SetCallKind(r5, call_kind); |
949 Jump(adaptor, RelocInfo::CODE_TARGET); | 966 Jump(adaptor, RelocInfo::CODE_TARGET); |
950 } | 967 } |
951 bind(®ular_invoke); | 968 bind(®ular_invoke); |
952 } | 969 } |
953 } | 970 } |
954 | 971 |
955 | 972 |
956 void MacroAssembler::InvokeCode(Register code, | 973 void MacroAssembler::InvokeCode(Register code, |
957 const ParameterCount& expected, | 974 const ParameterCount& expected, |
958 const ParameterCount& actual, | 975 const ParameterCount& actual, |
959 InvokeFlag flag, | 976 InvokeFlag flag, |
960 const CallWrapper& call_wrapper) { | 977 const CallWrapper& call_wrapper, |
| 978 CallKind call_kind) { |
961 Label done; | 979 Label done; |
962 | 980 |
963 InvokePrologue(expected, actual, Handle<Code>::null(), code, &done, flag, | 981 InvokePrologue(expected, actual, Handle<Code>::null(), code, &done, flag, |
964 call_wrapper); | 982 call_wrapper, call_kind); |
965 if (flag == CALL_FUNCTION) { | 983 if (flag == CALL_FUNCTION) { |
966 call_wrapper.BeforeCall(CallSize(code)); | 984 call_wrapper.BeforeCall(CallSize(code)); |
| 985 SetCallKind(r5, call_kind); |
967 Call(code); | 986 Call(code); |
968 call_wrapper.AfterCall(); | 987 call_wrapper.AfterCall(); |
969 } else { | 988 } else { |
970 ASSERT(flag == JUMP_FUNCTION); | 989 ASSERT(flag == JUMP_FUNCTION); |
| 990 SetCallKind(r5, call_kind); |
971 Jump(code); | 991 Jump(code); |
972 } | 992 } |
973 | 993 |
974 // Continue here if InvokePrologue does handle the invocation due to | 994 // Continue here if InvokePrologue does handle the invocation due to |
975 // mismatched parameter counts. | 995 // mismatched parameter counts. |
976 bind(&done); | 996 bind(&done); |
977 } | 997 } |
978 | 998 |
979 | 999 |
980 void MacroAssembler::InvokeCode(Handle<Code> code, | 1000 void MacroAssembler::InvokeCode(Handle<Code> code, |
981 const ParameterCount& expected, | 1001 const ParameterCount& expected, |
982 const ParameterCount& actual, | 1002 const ParameterCount& actual, |
983 RelocInfo::Mode rmode, | 1003 RelocInfo::Mode rmode, |
984 InvokeFlag flag) { | 1004 InvokeFlag flag, |
| 1005 CallKind call_kind) { |
985 Label done; | 1006 Label done; |
986 | 1007 |
987 InvokePrologue(expected, actual, code, no_reg, &done, flag); | 1008 InvokePrologue(expected, actual, code, no_reg, &done, flag, |
| 1009 NullCallWrapper(), call_kind); |
988 if (flag == CALL_FUNCTION) { | 1010 if (flag == CALL_FUNCTION) { |
| 1011 SetCallKind(r5, call_kind); |
989 Call(code, rmode); | 1012 Call(code, rmode); |
990 } else { | 1013 } else { |
| 1014 SetCallKind(r5, call_kind); |
991 Jump(code, rmode); | 1015 Jump(code, rmode); |
992 } | 1016 } |
993 | 1017 |
994 // Continue here if InvokePrologue does handle the invocation due to | 1018 // Continue here if InvokePrologue does handle the invocation due to |
995 // mismatched parameter counts. | 1019 // mismatched parameter counts. |
996 bind(&done); | 1020 bind(&done); |
997 } | 1021 } |
998 | 1022 |
999 | 1023 |
1000 void MacroAssembler::InvokeFunction(Register fun, | 1024 void MacroAssembler::InvokeFunction(Register fun, |
1001 const ParameterCount& actual, | 1025 const ParameterCount& actual, |
1002 InvokeFlag flag, | 1026 InvokeFlag flag, |
1003 const CallWrapper& call_wrapper) { | 1027 const CallWrapper& call_wrapper, |
| 1028 CallKind call_kind) { |
1004 // Contract with called JS functions requires that function is passed in r1. | 1029 // Contract with called JS functions requires that function is passed in r1. |
1005 ASSERT(fun.is(r1)); | 1030 ASSERT(fun.is(r1)); |
1006 | 1031 |
1007 Register expected_reg = r2; | 1032 Register expected_reg = r2; |
1008 Register code_reg = r3; | 1033 Register code_reg = r3; |
1009 | 1034 |
1010 ldr(code_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 1035 ldr(code_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
1011 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 1036 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
1012 ldr(expected_reg, | 1037 ldr(expected_reg, |
1013 FieldMemOperand(code_reg, | 1038 FieldMemOperand(code_reg, |
1014 SharedFunctionInfo::kFormalParameterCountOffset)); | 1039 SharedFunctionInfo::kFormalParameterCountOffset)); |
1015 mov(expected_reg, Operand(expected_reg, ASR, kSmiTagSize)); | 1040 mov(expected_reg, Operand(expected_reg, ASR, kSmiTagSize)); |
1016 ldr(code_reg, | 1041 ldr(code_reg, |
1017 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1042 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
1018 | 1043 |
1019 ParameterCount expected(expected_reg); | 1044 ParameterCount expected(expected_reg); |
1020 InvokeCode(code_reg, expected, actual, flag, call_wrapper); | 1045 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); |
1021 } | 1046 } |
1022 | 1047 |
1023 | 1048 |
1024 void MacroAssembler::InvokeFunction(JSFunction* function, | 1049 void MacroAssembler::InvokeFunction(JSFunction* function, |
1025 const ParameterCount& actual, | 1050 const ParameterCount& actual, |
1026 InvokeFlag flag) { | 1051 InvokeFlag flag) { |
1027 ASSERT(function->is_compiled()); | 1052 ASSERT(function->is_compiled()); |
1028 | 1053 |
1029 // Get the function and setup the context. | 1054 // Get the function and setup the context. |
1030 mov(r1, Operand(Handle<JSFunction>(function))); | 1055 mov(r1, Operand(Handle<JSFunction>(function))); |
(...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3118 void CodePatcher::EmitCondition(Condition cond) { | 3143 void CodePatcher::EmitCondition(Condition cond) { |
3119 Instr instr = Assembler::instr_at(masm_.pc_); | 3144 Instr instr = Assembler::instr_at(masm_.pc_); |
3120 instr = (instr & ~kCondMask) | cond; | 3145 instr = (instr & ~kCondMask) | cond; |
3121 masm_.emit(instr); | 3146 masm_.emit(instr); |
3122 } | 3147 } |
3123 | 3148 |
3124 | 3149 |
3125 } } // namespace v8::internal | 3150 } } // namespace v8::internal |
3126 | 3151 |
3127 #endif // V8_TARGET_ARCH_ARM | 3152 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |