Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "dex/compiler_ir.h" |
Vladimir Marko | 5c96e6b | 2013-11-14 15:34:17 +0000 | [diff] [blame] | 18 | #include "dex/frontend.h" |
| 19 | #include "dex/quick/dex_file_method_inliner.h" |
| 20 | #include "dex/quick/dex_file_to_method_inliner_map.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 21 | #include "dex_file-inl.h" |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 22 | #include "entrypoints/quick/quick_entrypoints.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 23 | #include "invoke_type.h" |
| 24 | #include "mirror/array.h" |
Dmitry Petrochenko | 37498b6 | 2014-05-05 20:33:38 +0700 | [diff] [blame] | 25 | #include "mirror/object_array-inl.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 26 | #include "mirror/string.h" |
| 27 | #include "mir_to_lir-inl.h" |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 28 | #include "x86/codegen_x86.h" |
| 29 | |
| 30 | namespace art { |
| 31 | |
Dmitry Petrochenko | 37498b6 | 2014-05-05 20:33:38 +0700 | [diff] [blame] | 32 | // Shortcuts to repeatedly used long types. |
| 33 | typedef mirror::ObjectArray<mirror::Object> ObjArray; |
| 34 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 35 | /* |
| 36 | * This source files contains "gen" codegen routines that should |
| 37 | * be applicable to most targets. Only mid-level support utilities |
| 38 | * and "op" calls may be used here. |
| 39 | */ |
| 40 | |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 41 | void Mir2Lir::AddIntrinsicSlowPath(CallInfo* info, LIR* branch, LIR* resume) { |
| 42 | class IntrinsicSlowPathPath : public Mir2Lir::LIRSlowPath { |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 43 | public: |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 44 | IntrinsicSlowPathPath(Mir2Lir* m2l, CallInfo* info, LIR* branch, LIR* resume = nullptr) |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 45 | : LIRSlowPath(m2l, info->offset, branch, resume), info_(info) { |
| 46 | } |
| 47 | |
| 48 | void Compile() { |
| 49 | m2l_->ResetRegPool(); |
| 50 | m2l_->ResetDefTracking(); |
Mingyao Yang | 6ffcfa0 | 2014-04-25 11:06:00 -0700 | [diff] [blame] | 51 | GenerateTargetLabel(kPseudoIntrinsicRetry); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 52 | // NOTE: GenInvokeNoInline() handles MarkSafepointPC. |
| 53 | m2l_->GenInvokeNoInline(info_); |
| 54 | if (cont_ != nullptr) { |
| 55 | m2l_->OpUnconditionalBranch(cont_); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | private: |
| 60 | CallInfo* const info_; |
| 61 | }; |
| 62 | |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 63 | AddSlowPath(new (arena_) IntrinsicSlowPathPath(this, info, branch, resume)); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 66 | // Macro to help instantiate. |
| 67 | // TODO: This might be used to only instantiate <4> on pure 32b systems. |
| 68 | #define INSTANTIATE(sig_part1, ...) \ |
| 69 | template sig_part1(ThreadOffset<4>, __VA_ARGS__); \ |
| 70 | template sig_part1(ThreadOffset<8>, __VA_ARGS__); \ |
| 71 | |
| 72 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 73 | /* |
| 74 | * To save scheduling time, helper calls are broken into two parts: generation of |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame] | 75 | * the helper target address, and the actual call to the helper. Because x86 |
| 76 | * has a memory call operation, part 1 is a NOP for x86. For other targets, |
| 77 | * load arguments between the two parts. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 78 | */ |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 79 | // template <size_t pointer_size> |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 80 | RegStorage Mir2Lir::CallHelperSetup(ThreadOffset<4> helper_offset) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 81 | // All CallRuntimeHelperXXX call this first. So make a central check here. |
| 82 | DCHECK_EQ(4U, GetInstructionSetPointerSize(cu_->instruction_set)); |
| 83 | |
| 84 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
| 85 | return RegStorage::InvalidReg(); |
| 86 | } else { |
| 87 | return LoadHelper(helper_offset); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | RegStorage Mir2Lir::CallHelperSetup(ThreadOffset<8> helper_offset) { |
| 92 | // All CallRuntimeHelperXXX call this first. So make a central check here. |
| 93 | DCHECK_EQ(8U, GetInstructionSetPointerSize(cu_->instruction_set)); |
| 94 | |
| 95 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
| 96 | return RegStorage::InvalidReg(); |
| 97 | } else { |
| 98 | return LoadHelper(helper_offset); |
| 99 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* NOTE: if r_tgt is a temp, it will be freed following use */ |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 103 | template <size_t pointer_size> |
| 104 | LIR* Mir2Lir::CallHelper(RegStorage r_tgt, ThreadOffset<pointer_size> helper_offset, |
| 105 | bool safepoint_pc, bool use_link) { |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame] | 106 | LIR* call_inst; |
Brian Carlstrom | 60d7a65 | 2014-03-13 18:10:08 -0700 | [diff] [blame] | 107 | OpKind op = use_link ? kOpBlx : kOpBx; |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame] | 108 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
| 109 | call_inst = OpThreadMem(op, helper_offset); |
| 110 | } else { |
| 111 | call_inst = OpReg(op, r_tgt); |
| 112 | FreeTemp(r_tgt); |
| 113 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 114 | if (safepoint_pc) { |
| 115 | MarkSafepointPC(call_inst); |
| 116 | } |
| 117 | return call_inst; |
| 118 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 119 | template LIR* Mir2Lir::CallHelper(RegStorage r_tgt, ThreadOffset<4> helper_offset, |
| 120 | bool safepoint_pc, bool use_link); |
| 121 | template LIR* Mir2Lir::CallHelper(RegStorage r_tgt, ThreadOffset<8> helper_offset, |
| 122 | bool safepoint_pc, bool use_link); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 123 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 124 | template <size_t pointer_size> |
| 125 | void Mir2Lir::CallRuntimeHelper(ThreadOffset<pointer_size> helper_offset, bool safepoint_pc) { |
Mingyao Yang | 4289456 | 2014-04-07 12:42:16 -0700 | [diff] [blame] | 126 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
| 127 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 128 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Mingyao Yang | 4289456 | 2014-04-07 12:42:16 -0700 | [diff] [blame] | 129 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 130 | INSTANTIATE(void Mir2Lir::CallRuntimeHelper, bool safepoint_pc) |
Mingyao Yang | 4289456 | 2014-04-07 12:42:16 -0700 | [diff] [blame] | 131 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 132 | template <size_t pointer_size> |
| 133 | void Mir2Lir::CallRuntimeHelperImm(ThreadOffset<pointer_size> helper_offset, int arg0, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 134 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 135 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 136 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 137 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 138 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 139 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImm, int arg0, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 140 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 141 | template <size_t pointer_size> |
| 142 | void Mir2Lir::CallRuntimeHelperReg(ThreadOffset<pointer_size> helper_offset, RegStorage arg0, |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 143 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 144 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 145 | OpRegCopy(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 146 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 147 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 148 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 149 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperReg, RegStorage arg0, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 150 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 151 | template <size_t pointer_size> |
| 152 | void Mir2Lir::CallRuntimeHelperRegLocation(ThreadOffset<pointer_size> helper_offset, |
| 153 | RegLocation arg0, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 154 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
| 155 | if (arg0.wide == 0) { |
| 156 | LoadValueDirectFixed(arg0, TargetReg(kArg0)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 157 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 158 | RegStorage r_tmp = RegStorage::MakeRegPair(TargetReg(kArg0), TargetReg(kArg1)); |
| 159 | LoadValueDirectWideFixed(arg0, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 160 | } |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 161 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 162 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 163 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 164 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegLocation, RegLocation arg0, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 165 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 166 | template <size_t pointer_size> |
| 167 | void Mir2Lir::CallRuntimeHelperImmImm(ThreadOffset<pointer_size> helper_offset, int arg0, int arg1, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 168 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 169 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 170 | LoadConstant(TargetReg(kArg0), arg0); |
| 171 | LoadConstant(TargetReg(kArg1), arg1); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 172 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 173 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 174 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 175 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmImm, int arg0, int arg1, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 176 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 177 | template <size_t pointer_size> |
| 178 | void Mir2Lir::CallRuntimeHelperImmRegLocation(ThreadOffset<pointer_size> helper_offset, int arg0, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 179 | RegLocation arg1, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 180 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 181 | if (arg1.wide == 0) { |
| 182 | LoadValueDirectFixed(arg1, TargetReg(kArg1)); |
| 183 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 184 | RegStorage r_tmp = RegStorage::MakeRegPair(TargetReg(kArg1), TargetReg(kArg2)); |
| 185 | LoadValueDirectWideFixed(arg1, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 186 | } |
| 187 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 188 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 189 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 190 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 191 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmRegLocation, int arg0, RegLocation arg1, |
| 192 | bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 193 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 194 | template <size_t pointer_size> |
| 195 | void Mir2Lir::CallRuntimeHelperRegLocationImm(ThreadOffset<pointer_size> helper_offset, |
| 196 | RegLocation arg0, int arg1, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 197 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 198 | LoadValueDirectFixed(arg0, TargetReg(kArg0)); |
| 199 | LoadConstant(TargetReg(kArg1), arg1); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 200 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 201 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 202 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 203 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegLocationImm, RegLocation arg0, int arg1, |
| 204 | bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 205 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 206 | template <size_t pointer_size> |
| 207 | void Mir2Lir::CallRuntimeHelperImmReg(ThreadOffset<pointer_size> helper_offset, int arg0, |
| 208 | RegStorage arg1, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 209 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 210 | OpRegCopy(TargetReg(kArg1), arg1); |
| 211 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 212 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 213 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 214 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 215 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmReg, int arg0, RegStorage arg1, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 216 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 217 | template <size_t pointer_size> |
| 218 | void Mir2Lir::CallRuntimeHelperRegImm(ThreadOffset<pointer_size> helper_offset, RegStorage arg0, |
| 219 | int arg1, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 220 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 221 | OpRegCopy(TargetReg(kArg0), arg0); |
| 222 | LoadConstant(TargetReg(kArg1), arg1); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 223 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 224 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 225 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 226 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegImm, RegStorage arg0, int arg1, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 227 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 228 | template <size_t pointer_size> |
| 229 | void Mir2Lir::CallRuntimeHelperImmMethod(ThreadOffset<pointer_size> helper_offset, int arg0, |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 230 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 231 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 232 | LoadCurrMethodDirect(TargetReg(kArg1)); |
| 233 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 234 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 235 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 236 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 237 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmMethod, int arg0, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 238 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 239 | template <size_t pointer_size> |
| 240 | void Mir2Lir::CallRuntimeHelperRegMethod(ThreadOffset<pointer_size> helper_offset, RegStorage arg0, |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 241 | bool safepoint_pc) { |
| 242 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
| 243 | DCHECK_NE(TargetReg(kArg1).GetReg(), arg0.GetReg()); |
Hiroshi Yamauchi | be1ca55 | 2014-01-15 11:46:48 -0800 | [diff] [blame] | 244 | if (TargetReg(kArg0) != arg0) { |
| 245 | OpRegCopy(TargetReg(kArg0), arg0); |
| 246 | } |
| 247 | LoadCurrMethodDirect(TargetReg(kArg1)); |
| 248 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 249 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Hiroshi Yamauchi | be1ca55 | 2014-01-15 11:46:48 -0800 | [diff] [blame] | 250 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 251 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegMethod, RegStorage arg0, bool safepoint_pc) |
Hiroshi Yamauchi | be1ca55 | 2014-01-15 11:46:48 -0800 | [diff] [blame] | 252 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 253 | template <size_t pointer_size> |
| 254 | void Mir2Lir::CallRuntimeHelperRegMethodRegLocation(ThreadOffset<pointer_size> helper_offset, |
| 255 | RegStorage arg0, RegLocation arg2, |
| 256 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 257 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
| 258 | DCHECK_NE(TargetReg(kArg1).GetReg(), arg0.GetReg()); |
Hiroshi Yamauchi | bb8f0ab | 2014-01-27 16:50:29 -0800 | [diff] [blame] | 259 | if (TargetReg(kArg0) != arg0) { |
| 260 | OpRegCopy(TargetReg(kArg0), arg0); |
| 261 | } |
| 262 | LoadCurrMethodDirect(TargetReg(kArg1)); |
| 263 | LoadValueDirectFixed(arg2, TargetReg(kArg2)); |
| 264 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 265 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Hiroshi Yamauchi | bb8f0ab | 2014-01-27 16:50:29 -0800 | [diff] [blame] | 266 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 267 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegMethodRegLocation, RegStorage arg0, RegLocation arg2, |
| 268 | bool safepoint_pc) |
Hiroshi Yamauchi | bb8f0ab | 2014-01-27 16:50:29 -0800 | [diff] [blame] | 269 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 270 | template <size_t pointer_size> |
| 271 | void Mir2Lir::CallRuntimeHelperRegLocationRegLocation(ThreadOffset<pointer_size> helper_offset, |
Ian Rogers | dd7624d | 2014-03-14 17:43:00 -0700 | [diff] [blame] | 272 | RegLocation arg0, RegLocation arg1, |
| 273 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 274 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 275 | if (arg0.wide == 0) { |
| 276 | LoadValueDirectFixed(arg0, arg0.fp ? TargetReg(kFArg0) : TargetReg(kArg0)); |
| 277 | if (arg1.wide == 0) { |
| 278 | if (cu_->instruction_set == kMips) { |
| 279 | LoadValueDirectFixed(arg1, arg1.fp ? TargetReg(kFArg2) : TargetReg(kArg1)); |
| 280 | } else { |
| 281 | LoadValueDirectFixed(arg1, TargetReg(kArg1)); |
| 282 | } |
| 283 | } else { |
| 284 | if (cu_->instruction_set == kMips) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 285 | RegStorage r_tmp; |
| 286 | if (arg1.fp) { |
| 287 | r_tmp = RegStorage::MakeRegPair(TargetReg(kFArg2), TargetReg(kFArg3)); |
| 288 | } else { |
| 289 | r_tmp = RegStorage::MakeRegPair(TargetReg(kArg1), TargetReg(kArg2)); |
| 290 | } |
| 291 | LoadValueDirectWideFixed(arg1, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 292 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 293 | RegStorage r_tmp = RegStorage::MakeRegPair(TargetReg(kArg1), TargetReg(kArg2)); |
| 294 | LoadValueDirectWideFixed(arg1, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 298 | RegStorage r_tmp; |
| 299 | if (arg0.fp) { |
| 300 | r_tmp = RegStorage::MakeRegPair(TargetReg(kFArg0), TargetReg(kFArg1)); |
| 301 | } else { |
| 302 | r_tmp = RegStorage::MakeRegPair(TargetReg(kArg0), TargetReg(kArg1)); |
| 303 | } |
| 304 | LoadValueDirectWideFixed(arg0, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 305 | if (arg1.wide == 0) { |
| 306 | LoadValueDirectFixed(arg1, arg1.fp ? TargetReg(kFArg2) : TargetReg(kArg2)); |
| 307 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 308 | RegStorage r_tmp; |
| 309 | if (arg1.fp) { |
| 310 | r_tmp = RegStorage::MakeRegPair(TargetReg(kFArg2), TargetReg(kFArg3)); |
| 311 | } else { |
| 312 | r_tmp = RegStorage::MakeRegPair(TargetReg(kArg2), TargetReg(kArg3)); |
| 313 | } |
| 314 | LoadValueDirectWideFixed(arg1, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 315 | } |
| 316 | } |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 317 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 318 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 319 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 320 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegLocationRegLocation, RegLocation arg0, |
| 321 | RegLocation arg1, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 322 | |
Mingyao Yang | 80365d9 | 2014-04-18 12:10:58 -0700 | [diff] [blame] | 323 | void Mir2Lir::CopyToArgumentRegs(RegStorage arg0, RegStorage arg1) { |
| 324 | if (arg1.GetReg() == TargetReg(kArg0).GetReg()) { |
| 325 | if (arg0.GetReg() == TargetReg(kArg1).GetReg()) { |
| 326 | // Swap kArg0 and kArg1 with kArg2 as temp. |
| 327 | OpRegCopy(TargetReg(kArg2), arg1); |
| 328 | OpRegCopy(TargetReg(kArg0), arg0); |
| 329 | OpRegCopy(TargetReg(kArg1), TargetReg(kArg2)); |
| 330 | } else { |
| 331 | OpRegCopy(TargetReg(kArg1), arg1); |
| 332 | OpRegCopy(TargetReg(kArg0), arg0); |
| 333 | } |
| 334 | } else { |
| 335 | OpRegCopy(TargetReg(kArg0), arg0); |
| 336 | OpRegCopy(TargetReg(kArg1), arg1); |
| 337 | } |
| 338 | } |
| 339 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 340 | template <size_t pointer_size> |
| 341 | void Mir2Lir::CallRuntimeHelperRegReg(ThreadOffset<pointer_size> helper_offset, RegStorage arg0, |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 342 | RegStorage arg1, bool safepoint_pc) { |
| 343 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Mingyao Yang | 80365d9 | 2014-04-18 12:10:58 -0700 | [diff] [blame] | 344 | CopyToArgumentRegs(arg0, arg1); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 345 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 346 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 347 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 348 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegReg, RegStorage arg0, RegStorage arg1, |
| 349 | bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 350 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 351 | template <size_t pointer_size> |
| 352 | void Mir2Lir::CallRuntimeHelperRegRegImm(ThreadOffset<pointer_size> helper_offset, RegStorage arg0, |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 353 | RegStorage arg1, int arg2, bool safepoint_pc) { |
| 354 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Mingyao Yang | 80365d9 | 2014-04-18 12:10:58 -0700 | [diff] [blame] | 355 | CopyToArgumentRegs(arg0, arg1); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 356 | LoadConstant(TargetReg(kArg2), arg2); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 357 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 358 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 359 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 360 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegRegImm, RegStorage arg0, RegStorage arg1, int arg2, |
| 361 | bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 362 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 363 | template <size_t pointer_size> |
| 364 | void Mir2Lir::CallRuntimeHelperImmMethodRegLocation(ThreadOffset<pointer_size> helper_offset, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 365 | int arg0, RegLocation arg2, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 366 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 367 | LoadValueDirectFixed(arg2, TargetReg(kArg2)); |
| 368 | LoadCurrMethodDirect(TargetReg(kArg1)); |
| 369 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 370 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 371 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 372 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 373 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmMethodRegLocation, int arg0, RegLocation arg2, |
| 374 | bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 375 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 376 | template <size_t pointer_size> |
| 377 | void Mir2Lir::CallRuntimeHelperImmMethodImm(ThreadOffset<pointer_size> helper_offset, int arg0, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 378 | int arg2, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 379 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 380 | LoadCurrMethodDirect(TargetReg(kArg1)); |
| 381 | LoadConstant(TargetReg(kArg2), arg2); |
| 382 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 383 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 384 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 385 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 386 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmMethodImm, int arg0, int arg2, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 387 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 388 | template <size_t pointer_size> |
| 389 | void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation(ThreadOffset<pointer_size> helper_offset, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 390 | int arg0, RegLocation arg1, |
| 391 | RegLocation arg2, bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 392 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 393 | DCHECK_EQ(static_cast<unsigned int>(arg1.wide), 0U); // The static_cast works around an |
| 394 | // instantiation bug in GCC. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 395 | LoadValueDirectFixed(arg1, TargetReg(kArg1)); |
| 396 | if (arg2.wide == 0) { |
| 397 | LoadValueDirectFixed(arg2, TargetReg(kArg2)); |
| 398 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 399 | RegStorage r_tmp = RegStorage::MakeRegPair(TargetReg(kArg2), TargetReg(kArg3)); |
| 400 | LoadValueDirectWideFixed(arg2, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 401 | } |
| 402 | LoadConstant(TargetReg(kArg0), arg0); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 403 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 404 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 405 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 406 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperImmRegLocationRegLocation, int arg0, RegLocation arg1, |
| 407 | RegLocation arg2, bool safepoint_pc) |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 408 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 409 | template <size_t pointer_size> |
| 410 | void Mir2Lir::CallRuntimeHelperRegLocationRegLocationRegLocation(ThreadOffset<pointer_size> helper_offset, |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 411 | RegLocation arg0, RegLocation arg1, |
| 412 | RegLocation arg2, |
| 413 | bool safepoint_pc) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 414 | RegStorage r_tgt = CallHelperSetup(helper_offset); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 415 | DCHECK_EQ(static_cast<unsigned int>(arg0.wide), 0U); |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 416 | LoadValueDirectFixed(arg0, TargetReg(kArg0)); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 417 | DCHECK_EQ(static_cast<unsigned int>(arg1.wide), 0U); |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 418 | LoadValueDirectFixed(arg1, TargetReg(kArg1)); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 419 | DCHECK_EQ(static_cast<unsigned int>(arg1.wide), 0U); |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 420 | LoadValueDirectFixed(arg2, TargetReg(kArg2)); |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 421 | ClobberCallerSave(); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 422 | CallHelper<pointer_size>(r_tgt, helper_offset, safepoint_pc); |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 423 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 424 | INSTANTIATE(void Mir2Lir::CallRuntimeHelperRegLocationRegLocationRegLocation, RegLocation arg0, |
| 425 | RegLocation arg1, RegLocation arg2, bool safepoint_pc) |
Ian Rogers | a9a8254 | 2013-10-04 11:17:26 -0700 | [diff] [blame] | 426 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 427 | /* |
| 428 | * If there are any ins passed in registers that have not been promoted |
Matteo Franchin | e45fb9e | 2014-05-06 10:10:30 +0100 | [diff] [blame] | 429 | * to a callee-save register, flush them to the frame. Perform initial |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 430 | * assignment of promoted arguments. |
| 431 | * |
| 432 | * ArgLocs is an array of location records describing the incoming arguments |
| 433 | * with one location record per word of argument. |
| 434 | */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 435 | void Mir2Lir::FlushIns(RegLocation* ArgLocs, RegLocation rl_method) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 436 | /* |
| 437 | * Dummy up a RegLocation for the incoming Method* |
| 438 | * It will attempt to keep kArg0 live (or copy it to home location |
| 439 | * if promoted). |
| 440 | */ |
| 441 | RegLocation rl_src = rl_method; |
| 442 | rl_src.location = kLocPhysReg; |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 443 | rl_src.reg = TargetReg(kArg0); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 444 | rl_src.home = false; |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 445 | MarkLive(rl_src); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 446 | if (rl_method.wide) { |
| 447 | StoreValueWide(rl_method, rl_src); |
| 448 | } else { |
| 449 | StoreValue(rl_method, rl_src); |
| 450 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 451 | // If Method* has been promoted, explicitly flush |
| 452 | if (rl_method.location == kLocPhysReg) { |
| 453 | StoreWordDisp(TargetReg(kSp), 0, TargetReg(kArg0)); |
| 454 | } |
| 455 | |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame] | 456 | if (cu_->num_ins == 0) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 457 | return; |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame] | 458 | } |
| 459 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 460 | int start_vreg = cu_->num_dalvik_registers - cu_->num_ins; |
| 461 | /* |
| 462 | * Copy incoming arguments to their proper home locations. |
| 463 | * NOTE: an older version of dx had an issue in which |
| 464 | * it would reuse static method argument registers. |
| 465 | * This could result in the same Dalvik virtual register |
| 466 | * being promoted to both core and fp regs. To account for this, |
| 467 | * we only copy to the corresponding promoted physical register |
| 468 | * if it matches the type of the SSA name for the incoming |
| 469 | * argument. It is also possible that long and double arguments |
| 470 | * end up half-promoted. In those cases, we must flush the promoted |
| 471 | * half to memory as well. |
| 472 | */ |
| 473 | for (int i = 0; i < cu_->num_ins; i++) { |
| 474 | PromotionMap* v_map = &promotion_map_[start_vreg + i]; |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 475 | RegStorage reg = GetArgMappingToPhysicalReg(i); |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame] | 476 | |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 477 | if (reg.Valid()) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 478 | // If arriving in register |
| 479 | bool need_flush = true; |
| 480 | RegLocation* t_loc = &ArgLocs[i]; |
| 481 | if ((v_map->core_location == kLocPhysReg) && !t_loc->fp) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 482 | OpRegCopy(RegStorage::Solo32(v_map->core_reg), reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 483 | need_flush = false; |
| 484 | } else if ((v_map->fp_location == kLocPhysReg) && t_loc->fp) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 485 | OpRegCopy(RegStorage::Solo32(v_map->FpReg), reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 486 | need_flush = false; |
| 487 | } else { |
| 488 | need_flush = true; |
| 489 | } |
| 490 | |
buzbee | d0a03b8 | 2013-09-14 08:21:05 -0700 | [diff] [blame] | 491 | // For wide args, force flush if not fully promoted |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 492 | if (t_loc->wide) { |
| 493 | PromotionMap* p_map = v_map + (t_loc->high_word ? -1 : +1); |
buzbee | d0a03b8 | 2013-09-14 08:21:05 -0700 | [diff] [blame] | 494 | // Is only half promoted? |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 495 | need_flush |= (p_map->core_location != v_map->core_location) || |
| 496 | (p_map->fp_location != v_map->fp_location); |
buzbee | d0a03b8 | 2013-09-14 08:21:05 -0700 | [diff] [blame] | 497 | if ((cu_->instruction_set == kThumb2) && t_loc->fp && !need_flush) { |
| 498 | /* |
| 499 | * In Arm, a double is represented as a pair of consecutive single float |
| 500 | * registers starting at an even number. It's possible that both Dalvik vRegs |
| 501 | * representing the incoming double were independently promoted as singles - but |
| 502 | * not in a form usable as a double. If so, we need to flush - even though the |
| 503 | * incoming arg appears fully in register. At this point in the code, both |
| 504 | * halves of the double are promoted. Make sure they are in a usable form. |
| 505 | */ |
| 506 | int lowreg_index = start_vreg + i + (t_loc->high_word ? -1 : 0); |
| 507 | int low_reg = promotion_map_[lowreg_index].FpReg; |
| 508 | int high_reg = promotion_map_[lowreg_index + 1].FpReg; |
| 509 | if (((low_reg & 0x1) != 0) || (high_reg != (low_reg + 1))) { |
| 510 | need_flush = true; |
| 511 | } |
| 512 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 513 | } |
| 514 | if (need_flush) { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 515 | Store32Disp(TargetReg(kSp), SRegOffset(start_vreg + i), reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 516 | } |
| 517 | } else { |
| 518 | // If arriving in frame & promoted |
| 519 | if (v_map->core_location == kLocPhysReg) { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 520 | Load32Disp(TargetReg(kSp), SRegOffset(start_vreg + i), RegStorage::Solo32(v_map->core_reg)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 521 | } |
| 522 | if (v_map->fp_location == kLocPhysReg) { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 523 | Load32Disp(TargetReg(kSp), SRegOffset(start_vreg + i), RegStorage::Solo32(v_map->FpReg)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | /* |
| 530 | * Bit of a hack here - in the absence of a real scheduling pass, |
| 531 | * emit the next instruction in static & direct invoke sequences. |
| 532 | */ |
| 533 | static int NextSDCallInsn(CompilationUnit* cu, CallInfo* info, |
| 534 | int state, const MethodReference& target_method, |
| 535 | uint32_t unused, |
| 536 | uintptr_t direct_code, uintptr_t direct_method, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 537 | InvokeType type) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 538 | Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 539 | if (direct_code != 0 && direct_method != 0) { |
| 540 | switch (state) { |
| 541 | case 0: // Get the current Method* [sets kArg0] |
Ian Rogers | ff093b3 | 2014-04-30 19:04:27 -0700 | [diff] [blame] | 542 | if (direct_code != static_cast<uintptr_t>(-1)) { |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 543 | if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Ian Rogers | 83883d7 | 2013-10-21 21:07:24 -0700 | [diff] [blame] | 544 | cg->LoadConstant(cg->TargetReg(kInvokeTgt), direct_code); |
| 545 | } |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 546 | } else if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Jeff Hao | 49161ce | 2014-03-12 11:05:25 -0700 | [diff] [blame] | 547 | cg->LoadCodeAddress(target_method, type, kInvokeTgt); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 548 | } |
Ian Rogers | ff093b3 | 2014-04-30 19:04:27 -0700 | [diff] [blame] | 549 | if (direct_method != static_cast<uintptr_t>(-1)) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 550 | cg->LoadConstant(cg->TargetReg(kArg0), direct_method); |
| 551 | } else { |
Jeff Hao | 49161ce | 2014-03-12 11:05:25 -0700 | [diff] [blame] | 552 | cg->LoadMethodAddress(target_method, type, kArg0); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 553 | } |
| 554 | break; |
| 555 | default: |
| 556 | return -1; |
| 557 | } |
| 558 | } else { |
| 559 | switch (state) { |
| 560 | case 0: // Get the current Method* [sets kArg0] |
| 561 | // TUNING: we can save a reg copy if Method* has been promoted. |
| 562 | cg->LoadCurrMethodDirect(cg->TargetReg(kArg0)); |
| 563 | break; |
| 564 | case 1: // Get method->dex_cache_resolved_methods_ |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 565 | cg->LoadRefDisp(cg->TargetReg(kArg0), |
| 566 | mirror::ArtMethod::DexCacheResolvedMethodsOffset().Int32Value(), |
| 567 | cg->TargetReg(kArg0)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 568 | // Set up direct code if known. |
| 569 | if (direct_code != 0) { |
Ian Rogers | ff093b3 | 2014-04-30 19:04:27 -0700 | [diff] [blame] | 570 | if (direct_code != static_cast<uintptr_t>(-1)) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 571 | cg->LoadConstant(cg->TargetReg(kInvokeTgt), direct_code); |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 572 | } else if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Ian Rogers | 83883d7 | 2013-10-21 21:07:24 -0700 | [diff] [blame] | 573 | CHECK_LT(target_method.dex_method_index, target_method.dex_file->NumMethodIds()); |
Jeff Hao | 49161ce | 2014-03-12 11:05:25 -0700 | [diff] [blame] | 574 | cg->LoadCodeAddress(target_method, type, kInvokeTgt); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 575 | } |
| 576 | } |
| 577 | break; |
| 578 | case 2: // Grab target method* |
| 579 | CHECK_EQ(cu->dex_file, target_method.dex_file); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 580 | cg->LoadRefDisp(cg->TargetReg(kArg0), |
Dmitry Petrochenko | 37498b6 | 2014-05-05 20:33:38 +0700 | [diff] [blame] | 581 | ObjArray::OffsetOfElement(target_method.dex_method_index).Int32Value(), |
| 582 | cg->TargetReg(kArg0)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 583 | break; |
| 584 | case 3: // Grab the code from the method* |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 585 | if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 586 | if (direct_code == 0) { |
| 587 | cg->LoadWordDisp(cg->TargetReg(kArg0), |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 588 | mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value(), |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 589 | cg->TargetReg(kInvokeTgt)); |
| 590 | } |
| 591 | break; |
| 592 | } |
| 593 | // Intentional fallthrough for x86 |
| 594 | default: |
| 595 | return -1; |
| 596 | } |
| 597 | } |
| 598 | return state + 1; |
| 599 | } |
| 600 | |
| 601 | /* |
| 602 | * Bit of a hack here - in the absence of a real scheduling pass, |
| 603 | * emit the next instruction in a virtual invoke sequence. |
| 604 | * We can use kLr as a temp prior to target address loading |
| 605 | * Note also that we'll load the first argument ("this") into |
| 606 | * kArg1 here rather than the standard LoadArgRegs. |
| 607 | */ |
| 608 | static int NextVCallInsn(CompilationUnit* cu, CallInfo* info, |
| 609 | int state, const MethodReference& target_method, |
| 610 | uint32_t method_idx, uintptr_t unused, uintptr_t unused2, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 611 | InvokeType unused3) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 612 | Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); |
| 613 | /* |
| 614 | * This is the fast path in which the target virtual method is |
| 615 | * fully resolved at compile time. |
| 616 | */ |
| 617 | switch (state) { |
| 618 | case 0: { // Get "this" [set kArg1] |
| 619 | RegLocation rl_arg = info->args[0]; |
| 620 | cg->LoadValueDirectFixed(rl_arg, cg->TargetReg(kArg1)); |
| 621 | break; |
| 622 | } |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 623 | case 1: // Is "this" null? [use kArg1] |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 624 | cg->GenNullCheck(cg->TargetReg(kArg1), info->opt_flags); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 625 | // get this->klass_ [use kArg1, set kInvokeTgt] |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 626 | cg->LoadRefDisp(cg->TargetReg(kArg1), mirror::Object::ClassOffset().Int32Value(), |
| 627 | cg->TargetReg(kInvokeTgt)); |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 628 | cg->MarkPossibleNullPointerException(info->opt_flags); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 629 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 630 | case 2: // Get this->klass_->vtable [usr kInvokeTgt, set kInvokeTgt] |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 631 | cg->LoadRefDisp(cg->TargetReg(kInvokeTgt), mirror::Class::VTableOffset().Int32Value(), |
| 632 | cg->TargetReg(kInvokeTgt)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 633 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 634 | case 3: // Get target method [use kInvokeTgt, set kArg0] |
Dmitry Petrochenko | 37498b6 | 2014-05-05 20:33:38 +0700 | [diff] [blame] | 635 | cg->LoadRefDisp(cg->TargetReg(kInvokeTgt), |
| 636 | ObjArray::OffsetOfElement(method_idx).Int32Value(), |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 637 | cg->TargetReg(kArg0)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 638 | break; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 639 | case 4: // Get the compiled code address [uses kArg0, sets kInvokeTgt] |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 640 | if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 641 | cg->LoadWordDisp(cg->TargetReg(kArg0), |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 642 | mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value(), |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 643 | cg->TargetReg(kInvokeTgt)); |
| 644 | break; |
| 645 | } |
| 646 | // Intentional fallthrough for X86 |
| 647 | default: |
| 648 | return -1; |
| 649 | } |
| 650 | return state + 1; |
| 651 | } |
| 652 | |
| 653 | /* |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 654 | * Emit the next instruction in an invoke interface sequence. This will do a lookup in the |
| 655 | * class's IMT, calling either the actual method or art_quick_imt_conflict_trampoline if |
| 656 | * more than one interface method map to the same index. Note also that we'll load the first |
| 657 | * argument ("this") into kArg1 here rather than the standard LoadArgRegs. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 658 | */ |
| 659 | static int NextInterfaceCallInsn(CompilationUnit* cu, CallInfo* info, int state, |
| 660 | const MethodReference& target_method, |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 661 | uint32_t method_idx, uintptr_t unused, |
| 662 | uintptr_t direct_method, InvokeType unused2) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 663 | Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 664 | |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 665 | switch (state) { |
| 666 | case 0: // Set target method index in case of conflict [set kHiddenArg, kHiddenFpArg (x86)] |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 667 | CHECK_LT(target_method.dex_method_index, target_method.dex_file->NumMethodIds()); |
| 668 | cg->LoadConstant(cg->TargetReg(kHiddenArg), target_method.dex_method_index); |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 669 | if (cu->instruction_set == kX86 || cu->instruction_set == kX86_64) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 670 | cg->OpRegCopy(cg->TargetReg(kHiddenFpArg), cg->TargetReg(kHiddenArg)); |
| 671 | } |
| 672 | break; |
| 673 | case 1: { // Get "this" [set kArg1] |
| 674 | RegLocation rl_arg = info->args[0]; |
| 675 | cg->LoadValueDirectFixed(rl_arg, cg->TargetReg(kArg1)); |
| 676 | break; |
| 677 | } |
| 678 | case 2: // Is "this" null? [use kArg1] |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 679 | cg->GenNullCheck(cg->TargetReg(kArg1), info->opt_flags); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 680 | // Get this->klass_ [use kArg1, set kInvokeTgt] |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 681 | cg->LoadRefDisp(cg->TargetReg(kArg1), mirror::Object::ClassOffset().Int32Value(), |
| 682 | cg->TargetReg(kInvokeTgt)); |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 683 | cg->MarkPossibleNullPointerException(info->opt_flags); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 684 | break; |
| 685 | case 3: // Get this->klass_->imtable [use kInvokeTgt, set kInvokeTgt] |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 686 | // NOTE: native pointer. |
| 687 | cg->LoadRefDisp(cg->TargetReg(kInvokeTgt), mirror::Class::ImTableOffset().Int32Value(), |
| 688 | cg->TargetReg(kInvokeTgt)); |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 689 | break; |
| 690 | case 4: // Get target method [use kInvokeTgt, set kArg0] |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 691 | // NOTE: native pointer. |
Dmitry Petrochenko | 37498b6 | 2014-05-05 20:33:38 +0700 | [diff] [blame] | 692 | cg->LoadRefDisp(cg->TargetReg(kInvokeTgt), |
| 693 | ObjArray::OffsetOfElement(method_idx % ClassLinker::kImtSize).Int32Value(), |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 694 | cg->TargetReg(kArg0)); |
| 695 | break; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 696 | case 5: // Get the compiled code address [use kArg0, set kInvokeTgt] |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 697 | if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 698 | cg->LoadWordDisp(cg->TargetReg(kArg0), |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 699 | mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value(), |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 700 | cg->TargetReg(kInvokeTgt)); |
| 701 | break; |
| 702 | } |
| 703 | // Intentional fallthrough for X86 |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 704 | default: |
| 705 | return -1; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 706 | } |
| 707 | return state + 1; |
| 708 | } |
| 709 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 710 | template <size_t pointer_size> |
| 711 | static int NextInvokeInsnSP(CompilationUnit* cu, CallInfo* info, ThreadOffset<pointer_size> trampoline, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 712 | int state, const MethodReference& target_method, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 713 | uint32_t method_idx) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 714 | Mir2Lir* cg = static_cast<Mir2Lir*>(cu->cg.get()); |
| 715 | /* |
| 716 | * This handles the case in which the base method is not fully |
| 717 | * resolved at compile time, we bail to a runtime helper. |
| 718 | */ |
| 719 | if (state == 0) { |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 720 | if (cu->instruction_set != kX86 && cu->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 721 | // Load trampoline target |
Ian Rogers | 848871b | 2013-08-05 10:56:33 -0700 | [diff] [blame] | 722 | cg->LoadWordDisp(cg->TargetReg(kSelf), trampoline.Int32Value(), cg->TargetReg(kInvokeTgt)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 723 | } |
| 724 | // Load kArg0 with method index |
| 725 | CHECK_EQ(cu->dex_file, target_method.dex_file); |
| 726 | cg->LoadConstant(cg->TargetReg(kArg0), target_method.dex_method_index); |
| 727 | return 1; |
| 728 | } |
| 729 | return -1; |
| 730 | } |
| 731 | |
| 732 | static int NextStaticCallInsnSP(CompilationUnit* cu, CallInfo* info, |
| 733 | int state, |
| 734 | const MethodReference& target_method, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 735 | uint32_t unused, uintptr_t unused2, |
| 736 | uintptr_t unused3, InvokeType unused4) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 737 | if (Is64BitInstructionSet(cu->instruction_set)) { |
| 738 | ThreadOffset<8> trampoline = QUICK_ENTRYPOINT_OFFSET(8, pInvokeStaticTrampolineWithAccessCheck); |
| 739 | return NextInvokeInsnSP<8>(cu, info, trampoline, state, target_method, 0); |
| 740 | } else { |
| 741 | ThreadOffset<4> trampoline = QUICK_ENTRYPOINT_OFFSET(4, pInvokeStaticTrampolineWithAccessCheck); |
| 742 | return NextInvokeInsnSP<4>(cu, info, trampoline, state, target_method, 0); |
| 743 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | static int NextDirectCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, |
| 747 | const MethodReference& target_method, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 748 | uint32_t unused, uintptr_t unused2, |
| 749 | uintptr_t unused3, InvokeType unused4) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 750 | if (Is64BitInstructionSet(cu->instruction_set)) { |
| 751 | ThreadOffset<8> trampoline = QUICK_ENTRYPOINT_OFFSET(8, pInvokeDirectTrampolineWithAccessCheck); |
| 752 | return NextInvokeInsnSP<8>(cu, info, trampoline, state, target_method, 0); |
| 753 | } else { |
| 754 | ThreadOffset<4> trampoline = QUICK_ENTRYPOINT_OFFSET(4, pInvokeDirectTrampolineWithAccessCheck); |
| 755 | return NextInvokeInsnSP<4>(cu, info, trampoline, state, target_method, 0); |
| 756 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 757 | } |
| 758 | |
| 759 | static int NextSuperCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, |
| 760 | const MethodReference& target_method, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 761 | uint32_t unused, uintptr_t unused2, |
| 762 | uintptr_t unused3, InvokeType unused4) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 763 | if (Is64BitInstructionSet(cu->instruction_set)) { |
| 764 | ThreadOffset<8> trampoline = QUICK_ENTRYPOINT_OFFSET(8, pInvokeSuperTrampolineWithAccessCheck); |
| 765 | return NextInvokeInsnSP<8>(cu, info, trampoline, state, target_method, 0); |
| 766 | } else { |
| 767 | ThreadOffset<4> trampoline = QUICK_ENTRYPOINT_OFFSET(4, pInvokeSuperTrampolineWithAccessCheck); |
| 768 | return NextInvokeInsnSP<4>(cu, info, trampoline, state, target_method, 0); |
| 769 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | static int NextVCallInsnSP(CompilationUnit* cu, CallInfo* info, int state, |
| 773 | const MethodReference& target_method, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 774 | uint32_t unused, uintptr_t unused2, |
| 775 | uintptr_t unused3, InvokeType unused4) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 776 | if (Is64BitInstructionSet(cu->instruction_set)) { |
| 777 | ThreadOffset<8> trampoline = QUICK_ENTRYPOINT_OFFSET(8, pInvokeVirtualTrampolineWithAccessCheck); |
| 778 | return NextInvokeInsnSP<8>(cu, info, trampoline, state, target_method, 0); |
| 779 | } else { |
| 780 | ThreadOffset<4> trampoline = QUICK_ENTRYPOINT_OFFSET(4, pInvokeVirtualTrampolineWithAccessCheck); |
| 781 | return NextInvokeInsnSP<4>(cu, info, trampoline, state, target_method, 0); |
| 782 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | static int NextInterfaceCallInsnWithAccessCheck(CompilationUnit* cu, |
| 786 | CallInfo* info, int state, |
| 787 | const MethodReference& target_method, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 788 | uint32_t unused, uintptr_t unused2, |
| 789 | uintptr_t unused3, InvokeType unused4) { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 790 | if (Is64BitInstructionSet(cu->instruction_set)) { |
| 791 | ThreadOffset<8> trampoline = QUICK_ENTRYPOINT_OFFSET(8, pInvokeInterfaceTrampolineWithAccessCheck); |
| 792 | return NextInvokeInsnSP<8>(cu, info, trampoline, state, target_method, 0); |
| 793 | } else { |
| 794 | ThreadOffset<4> trampoline = QUICK_ENTRYPOINT_OFFSET(4, pInvokeInterfaceTrampolineWithAccessCheck); |
| 795 | return NextInvokeInsnSP<4>(cu, info, trampoline, state, target_method, 0); |
| 796 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | int Mir2Lir::LoadArgRegs(CallInfo* info, int call_state, |
| 800 | NextCallInsn next_call_insn, |
| 801 | const MethodReference& target_method, |
| 802 | uint32_t vtable_idx, uintptr_t direct_code, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 803 | uintptr_t direct_method, InvokeType type, bool skip_this) { |
Dmitry Petrochenko | 26ee07a | 2014-05-13 12:58:19 +0700 | [diff] [blame] | 804 | int last_arg_reg = 3 - 1; |
| 805 | int arg_regs[3] = {TargetReg(kArg1).GetReg(), TargetReg(kArg2).GetReg(), TargetReg(kArg3).GetReg()}; |
| 806 | |
| 807 | int next_reg = 0; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 808 | int next_arg = 0; |
| 809 | if (skip_this) { |
| 810 | next_reg++; |
| 811 | next_arg++; |
| 812 | } |
| 813 | for (; (next_reg <= last_arg_reg) && (next_arg < info->num_arg_words); next_reg++) { |
| 814 | RegLocation rl_arg = info->args[next_arg++]; |
| 815 | rl_arg = UpdateRawLoc(rl_arg); |
Dmitry Petrochenko | 26ee07a | 2014-05-13 12:58:19 +0700 | [diff] [blame] | 816 | if (rl_arg.wide && (next_reg <= last_arg_reg - 1)) { |
| 817 | RegStorage r_tmp(RegStorage::k64BitPair, arg_regs[next_reg], arg_regs[next_reg + 1]); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 818 | LoadValueDirectWideFixed(rl_arg, r_tmp); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 819 | next_reg++; |
| 820 | next_arg++; |
| 821 | } else { |
| 822 | if (rl_arg.wide) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 823 | rl_arg = NarrowRegLoc(rl_arg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 824 | rl_arg.is_const = false; |
| 825 | } |
Dmitry Petrochenko | 26ee07a | 2014-05-13 12:58:19 +0700 | [diff] [blame] | 826 | LoadValueDirectFixed(rl_arg, RegStorage::Solo32(arg_regs[next_reg])); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 827 | } |
| 828 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 829 | direct_code, direct_method, type); |
| 830 | } |
| 831 | return call_state; |
| 832 | } |
| 833 | |
| 834 | /* |
| 835 | * Load up to 5 arguments, the first three of which will be in |
| 836 | * kArg1 .. kArg3. On entry kArg0 contains the current method pointer, |
| 837 | * and as part of the load sequence, it must be replaced with |
| 838 | * the target method pointer. Note, this may also be called |
| 839 | * for "range" variants if the number of arguments is 5 or fewer. |
| 840 | */ |
| 841 | int Mir2Lir::GenDalvikArgsNoRange(CallInfo* info, |
| 842 | int call_state, LIR** pcrLabel, NextCallInsn next_call_insn, |
| 843 | const MethodReference& target_method, |
| 844 | uint32_t vtable_idx, uintptr_t direct_code, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 845 | uintptr_t direct_method, InvokeType type, bool skip_this) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 846 | RegLocation rl_arg; |
| 847 | |
| 848 | /* If no arguments, just return */ |
| 849 | if (info->num_arg_words == 0) |
| 850 | return call_state; |
| 851 | |
| 852 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 853 | direct_code, direct_method, type); |
| 854 | |
| 855 | DCHECK_LE(info->num_arg_words, 5); |
| 856 | if (info->num_arg_words > 3) { |
| 857 | int32_t next_use = 3; |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 858 | // Detect special case of wide arg spanning arg3/arg4 |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 859 | RegLocation rl_use0 = info->args[0]; |
| 860 | RegLocation rl_use1 = info->args[1]; |
| 861 | RegLocation rl_use2 = info->args[2]; |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 862 | if (((!rl_use0.wide && !rl_use1.wide) || rl_use0.wide) && rl_use2.wide) { |
| 863 | RegStorage reg; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 864 | // Wide spans, we need the 2nd half of uses[2]. |
| 865 | rl_arg = UpdateLocWide(rl_use2); |
| 866 | if (rl_arg.location == kLocPhysReg) { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 867 | // NOTE: not correct for 64-bit core regs, but this needs rewriting for hard-float. |
| 868 | reg = rl_arg.reg.IsPair() ? rl_arg.reg.GetHigh() : rl_arg.reg.DoubleToHighSingle(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 869 | } else { |
| 870 | // kArg2 & rArg3 can safely be used here |
| 871 | reg = TargetReg(kArg3); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 872 | Load32Disp(TargetReg(kSp), SRegOffset(rl_arg.s_reg_low) + 4, reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 873 | call_state = next_call_insn(cu_, info, call_state, target_method, |
| 874 | vtable_idx, direct_code, direct_method, type); |
| 875 | } |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 876 | Store32Disp(TargetReg(kSp), (next_use + 1) * 4, reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 877 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 878 | direct_code, direct_method, type); |
| 879 | next_use++; |
| 880 | } |
| 881 | // Loop through the rest |
| 882 | while (next_use < info->num_arg_words) { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 883 | RegStorage arg_reg; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 884 | rl_arg = info->args[next_use]; |
| 885 | rl_arg = UpdateRawLoc(rl_arg); |
| 886 | if (rl_arg.location == kLocPhysReg) { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 887 | arg_reg = rl_arg.reg; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 888 | } else { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 889 | arg_reg = rl_arg.wide ? RegStorage::MakeRegPair(TargetReg(kArg2), TargetReg(kArg3)) : |
| 890 | TargetReg(kArg2); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 891 | if (rl_arg.wide) { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 892 | LoadValueDirectWideFixed(rl_arg, arg_reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 893 | } else { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 894 | LoadValueDirectFixed(rl_arg, arg_reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 895 | } |
| 896 | call_state = next_call_insn(cu_, info, call_state, target_method, |
| 897 | vtable_idx, direct_code, direct_method, type); |
| 898 | } |
| 899 | int outs_offset = (next_use + 1) * 4; |
| 900 | if (rl_arg.wide) { |
Vladimir Marko | 455759b | 2014-05-06 20:49:36 +0100 | [diff] [blame] | 901 | StoreBaseDisp(TargetReg(kSp), outs_offset, arg_reg, k64); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 902 | next_use += 2; |
| 903 | } else { |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 904 | Store32Disp(TargetReg(kSp), outs_offset, arg_reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 905 | next_use++; |
| 906 | } |
| 907 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 908 | direct_code, direct_method, type); |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | call_state = LoadArgRegs(info, call_state, next_call_insn, |
| 913 | target_method, vtable_idx, direct_code, direct_method, |
| 914 | type, skip_this); |
| 915 | |
| 916 | if (pcrLabel) { |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 917 | if (Runtime::Current()->ExplicitNullChecks()) { |
| 918 | *pcrLabel = GenExplicitNullCheck(TargetReg(kArg1), info->opt_flags); |
| 919 | } else { |
| 920 | *pcrLabel = nullptr; |
| 921 | // In lieu of generating a check for kArg1 being null, we need to |
| 922 | // perform a load when doing implicit checks. |
| 923 | RegStorage tmp = AllocTemp(); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 924 | Load32Disp(TargetReg(kArg1), 0, tmp); |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 925 | MarkPossibleNullPointerException(info->opt_flags); |
| 926 | FreeTemp(tmp); |
| 927 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 928 | } |
| 929 | return call_state; |
| 930 | } |
| 931 | |
| 932 | /* |
| 933 | * May have 0+ arguments (also used for jumbo). Note that |
| 934 | * source virtual registers may be in physical registers, so may |
| 935 | * need to be flushed to home location before copying. This |
| 936 | * applies to arg3 and above (see below). |
| 937 | * |
| 938 | * Two general strategies: |
| 939 | * If < 20 arguments |
| 940 | * Pass args 3-18 using vldm/vstm block copy |
| 941 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
| 942 | * If 20+ arguments |
| 943 | * Pass args arg19+ using memcpy block copy |
| 944 | * Pass arg0, arg1 & arg2 in kArg1-kArg3 |
| 945 | * |
| 946 | */ |
| 947 | int Mir2Lir::GenDalvikArgsRange(CallInfo* info, int call_state, |
| 948 | LIR** pcrLabel, NextCallInsn next_call_insn, |
| 949 | const MethodReference& target_method, |
| 950 | uint32_t vtable_idx, uintptr_t direct_code, uintptr_t direct_method, |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 951 | InvokeType type, bool skip_this) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 952 | // If we can treat it as non-range (Jumbo ops will use range form) |
| 953 | if (info->num_arg_words <= 5) |
| 954 | return GenDalvikArgsNoRange(info, call_state, pcrLabel, |
| 955 | next_call_insn, target_method, vtable_idx, |
| 956 | direct_code, direct_method, type, skip_this); |
| 957 | /* |
| 958 | * First load the non-register arguments. Both forms expect all |
| 959 | * of the source arguments to be in their home frame location, so |
| 960 | * scan the s_reg names and flush any that have been promoted to |
| 961 | * frame backing storage. |
| 962 | */ |
| 963 | // Scan the rest of the args - if in phys_reg flush to memory |
| 964 | for (int next_arg = 0; next_arg < info->num_arg_words;) { |
| 965 | RegLocation loc = info->args[next_arg]; |
| 966 | if (loc.wide) { |
| 967 | loc = UpdateLocWide(loc); |
| 968 | if ((next_arg >= 2) && (loc.location == kLocPhysReg)) { |
Vladimir Marko | 455759b | 2014-05-06 20:49:36 +0100 | [diff] [blame] | 969 | StoreBaseDisp(TargetReg(kSp), SRegOffset(loc.s_reg_low), loc.reg, k64); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 970 | } |
| 971 | next_arg += 2; |
| 972 | } else { |
| 973 | loc = UpdateLoc(loc); |
| 974 | if ((next_arg >= 3) && (loc.location == kLocPhysReg)) { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 975 | Store32Disp(TargetReg(kSp), SRegOffset(loc.s_reg_low), loc.reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 976 | } |
| 977 | next_arg++; |
| 978 | } |
| 979 | } |
| 980 | |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 981 | // Logic below assumes that Method pointer is at offset zero from SP. |
| 982 | DCHECK_EQ(VRegOffset(static_cast<int>(kVRegMethodPtrBaseReg)), 0); |
| 983 | |
| 984 | // The first 3 arguments are passed via registers. |
| 985 | // TODO: For 64-bit, instead of hardcoding 4 for Method* size, we should either |
| 986 | // get size of uintptr_t or size of object reference according to model being used. |
| 987 | int outs_offset = 4 /* Method* */ + (3 * sizeof(uint32_t)); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 988 | int start_offset = SRegOffset(info->args[3].s_reg_low); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 989 | int regs_left_to_pass_via_stack = info->num_arg_words - 3; |
| 990 | DCHECK_GT(regs_left_to_pass_via_stack, 0); |
| 991 | |
| 992 | if (cu_->instruction_set == kThumb2 && regs_left_to_pass_via_stack <= 16) { |
| 993 | // Use vldm/vstm pair using kArg3 as a temp |
| 994 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 995 | direct_code, direct_method, type); |
| 996 | OpRegRegImm(kOpAdd, TargetReg(kArg3), TargetReg(kSp), start_offset); |
| 997 | LIR* ld = OpVldm(TargetReg(kArg3), regs_left_to_pass_via_stack); |
| 998 | // TUNING: loosen barrier |
| 999 | ld->u.m.def_mask = ENCODE_ALL; |
| 1000 | SetMemRefType(ld, true /* is_load */, kDalvikReg); |
| 1001 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 1002 | direct_code, direct_method, type); |
| 1003 | OpRegRegImm(kOpAdd, TargetReg(kArg3), TargetReg(kSp), 4 /* Method* */ + (3 * 4)); |
| 1004 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 1005 | direct_code, direct_method, type); |
| 1006 | LIR* st = OpVstm(TargetReg(kArg3), regs_left_to_pass_via_stack); |
| 1007 | SetMemRefType(st, false /* is_load */, kDalvikReg); |
| 1008 | st->u.m.def_mask = ENCODE_ALL; |
| 1009 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 1010 | direct_code, direct_method, type); |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1011 | } else if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1012 | int current_src_offset = start_offset; |
| 1013 | int current_dest_offset = outs_offset; |
| 1014 | |
| 1015 | while (regs_left_to_pass_via_stack > 0) { |
| 1016 | // This is based on the knowledge that the stack itself is 16-byte aligned. |
| 1017 | bool src_is_16b_aligned = (current_src_offset & 0xF) == 0; |
| 1018 | bool dest_is_16b_aligned = (current_dest_offset & 0xF) == 0; |
| 1019 | size_t bytes_to_move; |
| 1020 | |
| 1021 | /* |
| 1022 | * The amount to move defaults to 32-bit. If there are 4 registers left to move, then do a |
| 1023 | * a 128-bit move because we won't get the chance to try to aligned. If there are more than |
| 1024 | * 4 registers left to move, consider doing a 128-bit only if either src or dest are aligned. |
| 1025 | * We do this because we could potentially do a smaller move to align. |
| 1026 | */ |
| 1027 | if (regs_left_to_pass_via_stack == 4 || |
| 1028 | (regs_left_to_pass_via_stack > 4 && (src_is_16b_aligned || dest_is_16b_aligned))) { |
| 1029 | // Moving 128-bits via xmm register. |
| 1030 | bytes_to_move = sizeof(uint32_t) * 4; |
| 1031 | |
| 1032 | // Allocate a free xmm temp. Since we are working through the calling sequence, |
| 1033 | // we expect to have an xmm temporary available. |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1034 | RegStorage temp = AllocTempDouble(); |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 1035 | DCHECK(temp.Valid()); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1036 | |
| 1037 | LIR* ld1 = nullptr; |
| 1038 | LIR* ld2 = nullptr; |
| 1039 | LIR* st1 = nullptr; |
| 1040 | LIR* st2 = nullptr; |
| 1041 | |
| 1042 | /* |
| 1043 | * The logic is similar for both loads and stores. If we have 16-byte alignment, |
| 1044 | * do an aligned move. If we have 8-byte alignment, then do the move in two |
| 1045 | * parts. This approach prevents possible cache line splits. Finally, fall back |
| 1046 | * to doing an unaligned move. In most cases we likely won't split the cache |
| 1047 | * line but we cannot prove it and thus take a conservative approach. |
| 1048 | */ |
| 1049 | bool src_is_8b_aligned = (current_src_offset & 0x7) == 0; |
| 1050 | bool dest_is_8b_aligned = (current_dest_offset & 0x7) == 0; |
| 1051 | |
| 1052 | if (src_is_16b_aligned) { |
| 1053 | ld1 = OpMovRegMem(temp, TargetReg(kSp), current_src_offset, kMovA128FP); |
| 1054 | } else if (src_is_8b_aligned) { |
| 1055 | ld1 = OpMovRegMem(temp, TargetReg(kSp), current_src_offset, kMovLo128FP); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1056 | ld2 = OpMovRegMem(temp, TargetReg(kSp), current_src_offset + (bytes_to_move >> 1), |
| 1057 | kMovHi128FP); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1058 | } else { |
| 1059 | ld1 = OpMovRegMem(temp, TargetReg(kSp), current_src_offset, kMovU128FP); |
| 1060 | } |
| 1061 | |
| 1062 | if (dest_is_16b_aligned) { |
| 1063 | st1 = OpMovMemReg(TargetReg(kSp), current_dest_offset, temp, kMovA128FP); |
| 1064 | } else if (dest_is_8b_aligned) { |
| 1065 | st1 = OpMovMemReg(TargetReg(kSp), current_dest_offset, temp, kMovLo128FP); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1066 | st2 = OpMovMemReg(TargetReg(kSp), current_dest_offset + (bytes_to_move >> 1), |
| 1067 | temp, kMovHi128FP); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1068 | } else { |
| 1069 | st1 = OpMovMemReg(TargetReg(kSp), current_dest_offset, temp, kMovU128FP); |
| 1070 | } |
| 1071 | |
| 1072 | // TODO If we could keep track of aliasing information for memory accesses that are wider |
| 1073 | // than 64-bit, we wouldn't need to set up a barrier. |
| 1074 | if (ld1 != nullptr) { |
| 1075 | if (ld2 != nullptr) { |
| 1076 | // For 64-bit load we can actually set up the aliasing information. |
| 1077 | AnnotateDalvikRegAccess(ld1, current_src_offset >> 2, true, true); |
| 1078 | AnnotateDalvikRegAccess(ld2, (current_src_offset + (bytes_to_move >> 1)) >> 2, true, true); |
| 1079 | } else { |
| 1080 | // Set barrier for 128-bit load. |
| 1081 | SetMemRefType(ld1, true /* is_load */, kDalvikReg); |
| 1082 | ld1->u.m.def_mask = ENCODE_ALL; |
| 1083 | } |
| 1084 | } |
| 1085 | if (st1 != nullptr) { |
| 1086 | if (st2 != nullptr) { |
| 1087 | // For 64-bit store we can actually set up the aliasing information. |
| 1088 | AnnotateDalvikRegAccess(st1, current_dest_offset >> 2, false, true); |
| 1089 | AnnotateDalvikRegAccess(st2, (current_dest_offset + (bytes_to_move >> 1)) >> 2, false, true); |
| 1090 | } else { |
| 1091 | // Set barrier for 128-bit store. |
| 1092 | SetMemRefType(st1, false /* is_load */, kDalvikReg); |
| 1093 | st1->u.m.def_mask = ENCODE_ALL; |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | // Free the temporary used for the data movement. |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 1098 | FreeTemp(temp); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1099 | } else { |
| 1100 | // Moving 32-bits via general purpose register. |
| 1101 | bytes_to_move = sizeof(uint32_t); |
| 1102 | |
| 1103 | // Instead of allocating a new temp, simply reuse one of the registers being used |
| 1104 | // for argument passing. |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1105 | RegStorage temp = TargetReg(kArg3); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1106 | |
| 1107 | // Now load the argument VR and store to the outs. |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1108 | Load32Disp(TargetReg(kSp), current_src_offset, temp); |
| 1109 | Store32Disp(TargetReg(kSp), current_dest_offset, temp); |
Razvan A Lupusoru | 2c498d1 | 2014-01-29 16:02:57 -0800 | [diff] [blame] | 1110 | } |
| 1111 | |
| 1112 | current_src_offset += bytes_to_move; |
| 1113 | current_dest_offset += bytes_to_move; |
| 1114 | regs_left_to_pass_via_stack -= (bytes_to_move >> 2); |
| 1115 | } |
| 1116 | } else { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1117 | // Generate memcpy |
| 1118 | OpRegRegImm(kOpAdd, TargetReg(kArg0), TargetReg(kSp), outs_offset); |
| 1119 | OpRegRegImm(kOpAdd, TargetReg(kArg1), TargetReg(kSp), start_offset); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1120 | if (Is64BitInstructionSet(cu_->instruction_set)) { |
| 1121 | CallRuntimeHelperRegRegImm(QUICK_ENTRYPOINT_OFFSET(8, pMemcpy), TargetReg(kArg0), |
| 1122 | TargetReg(kArg1), (info->num_arg_words - 3) * 4, false); |
| 1123 | } else { |
| 1124 | CallRuntimeHelperRegRegImm(QUICK_ENTRYPOINT_OFFSET(4, pMemcpy), TargetReg(kArg0), |
| 1125 | TargetReg(kArg1), (info->num_arg_words - 3) * 4, false); |
| 1126 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
| 1129 | call_state = LoadArgRegs(info, call_state, next_call_insn, |
| 1130 | target_method, vtable_idx, direct_code, direct_method, |
| 1131 | type, skip_this); |
| 1132 | |
| 1133 | call_state = next_call_insn(cu_, info, call_state, target_method, vtable_idx, |
| 1134 | direct_code, direct_method, type); |
| 1135 | if (pcrLabel) { |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 1136 | if (Runtime::Current()->ExplicitNullChecks()) { |
| 1137 | *pcrLabel = GenExplicitNullCheck(TargetReg(kArg1), info->opt_flags); |
| 1138 | } else { |
| 1139 | *pcrLabel = nullptr; |
| 1140 | // In lieu of generating a check for kArg1 being null, we need to |
| 1141 | // perform a load when doing implicit checks. |
| 1142 | RegStorage tmp = AllocTemp(); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1143 | Load32Disp(TargetReg(kArg1), 0, tmp); |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 1144 | MarkPossibleNullPointerException(info->opt_flags); |
| 1145 | FreeTemp(tmp); |
| 1146 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1147 | } |
| 1148 | return call_state; |
| 1149 | } |
| 1150 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1151 | RegLocation Mir2Lir::InlineTarget(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1152 | RegLocation res; |
| 1153 | if (info->result.location == kLocInvalid) { |
| 1154 | res = GetReturn(false); |
| 1155 | } else { |
| 1156 | res = info->result; |
| 1157 | } |
| 1158 | return res; |
| 1159 | } |
| 1160 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1161 | RegLocation Mir2Lir::InlineTargetWide(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1162 | RegLocation res; |
| 1163 | if (info->result.location == kLocInvalid) { |
| 1164 | res = GetReturnWide(false); |
| 1165 | } else { |
| 1166 | res = info->result; |
| 1167 | } |
| 1168 | return res; |
| 1169 | } |
| 1170 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1171 | bool Mir2Lir::GenInlinedCharAt(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1172 | if (cu_->instruction_set == kMips) { |
| 1173 | // TODO - add Mips implementation |
| 1174 | return false; |
| 1175 | } |
| 1176 | // Location of reference to data array |
| 1177 | int value_offset = mirror::String::ValueOffset().Int32Value(); |
| 1178 | // Location of count |
| 1179 | int count_offset = mirror::String::CountOffset().Int32Value(); |
| 1180 | // Starting offset within data array |
| 1181 | int offset_offset = mirror::String::OffsetOffset().Int32Value(); |
| 1182 | // Start of char data with array_ |
| 1183 | int data_offset = mirror::Array::DataOffset(sizeof(uint16_t)).Int32Value(); |
| 1184 | |
| 1185 | RegLocation rl_obj = info->args[0]; |
| 1186 | RegLocation rl_idx = info->args[1]; |
| 1187 | rl_obj = LoadValue(rl_obj, kCoreReg); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1188 | // X86 wants to avoid putting a constant index into a register. |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1189 | if (!((cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64)&& rl_idx.is_const)) { |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1190 | rl_idx = LoadValue(rl_idx, kCoreReg); |
| 1191 | } |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1192 | RegStorage reg_max; |
| 1193 | GenNullCheck(rl_obj.reg, info->opt_flags); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1194 | bool range_check = (!(info->opt_flags & MIR_IGNORE_RANGE_CHECK)); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1195 | LIR* range_check_branch = nullptr; |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1196 | RegStorage reg_off; |
| 1197 | RegStorage reg_ptr; |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1198 | if (cu_->instruction_set != kX86 && cu_->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1199 | reg_off = AllocTemp(); |
| 1200 | reg_ptr = AllocTemp(); |
| 1201 | if (range_check) { |
| 1202 | reg_max = AllocTemp(); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1203 | Load32Disp(rl_obj.reg, count_offset, reg_max); |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 1204 | MarkPossibleNullPointerException(info->opt_flags); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1205 | } |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1206 | Load32Disp(rl_obj.reg, offset_offset, reg_off); |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 1207 | MarkPossibleNullPointerException(info->opt_flags); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1208 | Load32Disp(rl_obj.reg, value_offset, reg_ptr); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1209 | if (range_check) { |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 1210 | // Set up a slow path to allow retry in case of bounds violation */ |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1211 | OpRegReg(kOpCmp, rl_idx.reg, reg_max); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1212 | FreeTemp(reg_max); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1213 | range_check_branch = OpCondBranch(kCondUge, nullptr); |
Brian Carlstrom | 6f485c6 | 2013-07-18 15:35:35 -0700 | [diff] [blame] | 1214 | } |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1215 | OpRegImm(kOpAdd, reg_ptr, data_offset); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1216 | } else { |
| 1217 | if (range_check) { |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1218 | // On x86, we can compare to memory directly |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1219 | // Set up a launch pad to allow retry in case of bounds violation */ |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1220 | if (rl_idx.is_const) { |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1221 | range_check_branch = OpCmpMemImmBranch( |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1222 | kCondUlt, RegStorage::InvalidReg(), rl_obj.reg, count_offset, |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1223 | mir_graph_->ConstantValue(rl_idx.orig_sreg), nullptr); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1224 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1225 | OpRegMem(kOpCmp, rl_idx.reg, rl_obj.reg, count_offset); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1226 | range_check_branch = OpCondBranch(kCondUge, nullptr); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1227 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1228 | } |
| 1229 | reg_off = AllocTemp(); |
| 1230 | reg_ptr = AllocTemp(); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1231 | Load32Disp(rl_obj.reg, offset_offset, reg_off); |
| 1232 | Load32Disp(rl_obj.reg, value_offset, reg_ptr); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1233 | } |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1234 | if (rl_idx.is_const) { |
| 1235 | OpRegImm(kOpAdd, reg_off, mir_graph_->ConstantValue(rl_idx.orig_sreg)); |
| 1236 | } else { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1237 | OpRegReg(kOpAdd, reg_off, rl_idx.reg); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1238 | } |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1239 | FreeTemp(rl_obj.reg); |
Bill Buzbee | 00e1ec6 | 2014-02-27 23:44:13 +0000 | [diff] [blame] | 1240 | if (rl_idx.location == kLocPhysReg) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1241 | FreeTemp(rl_idx.reg); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1242 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1243 | RegLocation rl_dest = InlineTarget(info); |
| 1244 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1245 | if (cu_->instruction_set != kX86 && cu_->instruction_set != kX86_64) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1246 | LoadBaseIndexed(reg_ptr, reg_off, rl_result.reg, 1, kUnsignedHalf); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1247 | } else { |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 1248 | LoadBaseIndexedDisp(reg_ptr, reg_off, 1, data_offset, rl_result.reg, kUnsignedHalf); |
Mark Mendell | 2b724cb | 2014-02-06 05:24:20 -0800 | [diff] [blame] | 1249 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1250 | FreeTemp(reg_off); |
| 1251 | FreeTemp(reg_ptr); |
| 1252 | StoreValue(rl_dest, rl_result); |
| 1253 | if (range_check) { |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1254 | DCHECK(range_check_branch != nullptr); |
| 1255 | info->opt_flags |= MIR_IGNORE_NULL_CHECK; // Record that we've already null checked. |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 1256 | AddIntrinsicSlowPath(info, range_check_branch); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1257 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1258 | return true; |
| 1259 | } |
| 1260 | |
| 1261 | // Generates an inlined String.is_empty or String.length. |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1262 | bool Mir2Lir::GenInlinedStringIsEmptyOrLength(CallInfo* info, bool is_empty) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1263 | if (cu_->instruction_set == kMips) { |
| 1264 | // TODO - add Mips implementation |
| 1265 | return false; |
| 1266 | } |
| 1267 | // dst = src.length(); |
| 1268 | RegLocation rl_obj = info->args[0]; |
| 1269 | rl_obj = LoadValue(rl_obj, kCoreReg); |
| 1270 | RegLocation rl_dest = InlineTarget(info); |
| 1271 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1272 | GenNullCheck(rl_obj.reg, info->opt_flags); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1273 | Load32Disp(rl_obj.reg, mirror::String::CountOffset().Int32Value(), rl_result.reg); |
Dave Allison | b373e09 | 2014-02-20 16:06:36 -0800 | [diff] [blame] | 1274 | MarkPossibleNullPointerException(info->opt_flags); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1275 | if (is_empty) { |
| 1276 | // dst = (dst == 0); |
| 1277 | if (cu_->instruction_set == kThumb2) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1278 | RegStorage t_reg = AllocTemp(); |
| 1279 | OpRegReg(kOpNeg, t_reg, rl_result.reg); |
| 1280 | OpRegRegReg(kOpAdc, rl_result.reg, rl_result.reg, t_reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1281 | } else { |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1282 | DCHECK(cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1283 | OpRegImm(kOpSub, rl_result.reg, 1); |
| 1284 | OpRegImm(kOpLsr, rl_result.reg, 31); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1285 | } |
| 1286 | } |
| 1287 | StoreValue(rl_dest, rl_result); |
| 1288 | return true; |
| 1289 | } |
| 1290 | |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1291 | bool Mir2Lir::GenInlinedReverseBytes(CallInfo* info, OpSize size) { |
| 1292 | if (cu_->instruction_set == kMips) { |
| 1293 | // TODO - add Mips implementation |
| 1294 | return false; |
| 1295 | } |
| 1296 | RegLocation rl_src_i = info->args[0]; |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1297 | RegLocation rl_dest = (size == k64) ? InlineTargetWide(info) : InlineTarget(info); // result reg |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1298 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1299 | if (size == k64) { |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1300 | RegLocation rl_i = LoadValueWide(rl_src_i, kCoreReg); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1301 | RegStorage r_i_low = rl_i.reg.GetLow(); |
| 1302 | if (rl_i.reg.GetLowReg() == rl_result.reg.GetLowReg()) { |
Bill Buzbee | 00e1ec6 | 2014-02-27 23:44:13 +0000 | [diff] [blame] | 1303 | // First REV shall clobber rl_result.reg.GetReg(), save the value in a temp for the second REV. |
Vladimir Marko | f246af2 | 2013-11-27 12:30:15 +0000 | [diff] [blame] | 1304 | r_i_low = AllocTemp(); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1305 | OpRegCopy(r_i_low, rl_i.reg); |
Vladimir Marko | f246af2 | 2013-11-27 12:30:15 +0000 | [diff] [blame] | 1306 | } |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1307 | OpRegReg(kOpRev, rl_result.reg.GetLow(), rl_i.reg.GetHigh()); |
| 1308 | OpRegReg(kOpRev, rl_result.reg.GetHigh(), r_i_low); |
| 1309 | if (rl_i.reg.GetLowReg() == rl_result.reg.GetLowReg()) { |
Vladimir Marko | f246af2 | 2013-11-27 12:30:15 +0000 | [diff] [blame] | 1310 | FreeTemp(r_i_low); |
| 1311 | } |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1312 | StoreValueWide(rl_dest, rl_result); |
| 1313 | } else { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1314 | DCHECK(size == k32 || size == kSignedHalf); |
| 1315 | OpKind op = (size == k32) ? kOpRev : kOpRevsh; |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1316 | RegLocation rl_i = LoadValue(rl_src_i, kCoreReg); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1317 | OpRegReg(op, rl_result.reg, rl_i.reg); |
Vladimir Marko | 6bdf1ff | 2013-10-29 17:40:46 +0000 | [diff] [blame] | 1318 | StoreValue(rl_dest, rl_result); |
| 1319 | } |
| 1320 | return true; |
| 1321 | } |
| 1322 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1323 | bool Mir2Lir::GenInlinedAbsInt(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1324 | if (cu_->instruction_set == kMips) { |
| 1325 | // TODO - add Mips implementation |
| 1326 | return false; |
| 1327 | } |
| 1328 | RegLocation rl_src = info->args[0]; |
| 1329 | rl_src = LoadValue(rl_src, kCoreReg); |
| 1330 | RegLocation rl_dest = InlineTarget(info); |
| 1331 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1332 | RegStorage sign_reg = AllocTemp(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1333 | // abs(x) = y<=x>>31, (x+y)^y. |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1334 | OpRegRegImm(kOpAsr, sign_reg, rl_src.reg, 31); |
| 1335 | OpRegRegReg(kOpAdd, rl_result.reg, rl_src.reg, sign_reg); |
| 1336 | OpRegReg(kOpXor, rl_result.reg, sign_reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1337 | StoreValue(rl_dest, rl_result); |
| 1338 | return true; |
| 1339 | } |
| 1340 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1341 | bool Mir2Lir::GenInlinedAbsLong(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1342 | if (cu_->instruction_set == kMips) { |
| 1343 | // TODO - add Mips implementation |
| 1344 | return false; |
| 1345 | } |
Vladimir Marko | b982331 | 2014-03-20 17:38:43 +0000 | [diff] [blame] | 1346 | RegLocation rl_src = info->args[0]; |
| 1347 | rl_src = LoadValueWide(rl_src, kCoreReg); |
| 1348 | RegLocation rl_dest = InlineTargetWide(info); |
| 1349 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
| 1350 | |
| 1351 | // If on x86 or if we would clobber a register needed later, just copy the source first. |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1352 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64 || rl_result.reg.GetLowReg() == rl_src.reg.GetHighReg()) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1353 | OpRegCopyWide(rl_result.reg, rl_src.reg); |
| 1354 | if (rl_result.reg.GetLowReg() != rl_src.reg.GetLowReg() && |
| 1355 | rl_result.reg.GetLowReg() != rl_src.reg.GetHighReg() && |
| 1356 | rl_result.reg.GetHighReg() != rl_src.reg.GetLowReg() && |
Vladimir Marko | b982331 | 2014-03-20 17:38:43 +0000 | [diff] [blame] | 1357 | rl_result.reg.GetHighReg() != rl_src.reg.GetHighReg()) { |
| 1358 | // Reuse source registers to avoid running out of temps. |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1359 | FreeTemp(rl_src.reg); |
Vladimir Marko | b982331 | 2014-03-20 17:38:43 +0000 | [diff] [blame] | 1360 | } |
| 1361 | rl_src = rl_result; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1362 | } |
Vladimir Marko | b982331 | 2014-03-20 17:38:43 +0000 | [diff] [blame] | 1363 | |
| 1364 | // abs(x) = y<=x>>31, (x+y)^y. |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1365 | RegStorage sign_reg = AllocTemp(); |
| 1366 | OpRegRegImm(kOpAsr, sign_reg, rl_src.reg.GetHigh(), 31); |
| 1367 | OpRegRegReg(kOpAdd, rl_result.reg.GetLow(), rl_src.reg.GetLow(), sign_reg); |
| 1368 | OpRegRegReg(kOpAdc, rl_result.reg.GetHigh(), rl_src.reg.GetHigh(), sign_reg); |
| 1369 | OpRegReg(kOpXor, rl_result.reg.GetLow(), sign_reg); |
| 1370 | OpRegReg(kOpXor, rl_result.reg.GetHigh(), sign_reg); |
buzbee | 082833c | 2014-05-17 23:16:26 -0700 | [diff] [blame] | 1371 | FreeTemp(sign_reg); |
Vladimir Marko | b982331 | 2014-03-20 17:38:43 +0000 | [diff] [blame] | 1372 | StoreValueWide(rl_dest, rl_result); |
| 1373 | return true; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
Yixin Shou | dbb17e3 | 2014-02-07 05:09:30 -0800 | [diff] [blame] | 1376 | bool Mir2Lir::GenInlinedAbsFloat(CallInfo* info) { |
| 1377 | if (cu_->instruction_set == kMips) { |
| 1378 | // TODO - add Mips implementation |
| 1379 | return false; |
| 1380 | } |
| 1381 | RegLocation rl_src = info->args[0]; |
| 1382 | rl_src = LoadValue(rl_src, kCoreReg); |
| 1383 | RegLocation rl_dest = InlineTarget(info); |
| 1384 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1385 | OpRegRegImm(kOpAnd, rl_result.reg, rl_src.reg, 0x7fffffff); |
Yixin Shou | dbb17e3 | 2014-02-07 05:09:30 -0800 | [diff] [blame] | 1386 | StoreValue(rl_dest, rl_result); |
| 1387 | return true; |
| 1388 | } |
| 1389 | |
| 1390 | bool Mir2Lir::GenInlinedAbsDouble(CallInfo* info) { |
| 1391 | if (cu_->instruction_set == kMips) { |
| 1392 | // TODO - add Mips implementation |
| 1393 | return false; |
| 1394 | } |
| 1395 | RegLocation rl_src = info->args[0]; |
| 1396 | rl_src = LoadValueWide(rl_src, kCoreReg); |
| 1397 | RegLocation rl_dest = InlineTargetWide(info); |
| 1398 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1399 | OpRegCopyWide(rl_result.reg, rl_src.reg); |
| 1400 | OpRegImm(kOpAnd, rl_result.reg.GetHigh(), 0x7fffffff); |
Yixin Shou | dbb17e3 | 2014-02-07 05:09:30 -0800 | [diff] [blame] | 1401 | StoreValueWide(rl_dest, rl_result); |
| 1402 | return true; |
| 1403 | } |
| 1404 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1405 | bool Mir2Lir::GenInlinedFloatCvt(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1406 | if (cu_->instruction_set == kMips) { |
| 1407 | // TODO - add Mips implementation |
| 1408 | return false; |
| 1409 | } |
| 1410 | RegLocation rl_src = info->args[0]; |
| 1411 | RegLocation rl_dest = InlineTarget(info); |
| 1412 | StoreValue(rl_dest, rl_src); |
| 1413 | return true; |
| 1414 | } |
| 1415 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1416 | bool Mir2Lir::GenInlinedDoubleCvt(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1417 | if (cu_->instruction_set == kMips) { |
| 1418 | // TODO - add Mips implementation |
| 1419 | return false; |
| 1420 | } |
| 1421 | RegLocation rl_src = info->args[0]; |
| 1422 | RegLocation rl_dest = InlineTargetWide(info); |
| 1423 | StoreValueWide(rl_dest, rl_src); |
| 1424 | return true; |
| 1425 | } |
| 1426 | |
| 1427 | /* |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1428 | * Fast String.indexOf(I) & (II). Tests for simple case of char <= 0xFFFF, |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1429 | * otherwise bails to standard library code. |
| 1430 | */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1431 | bool Mir2Lir::GenInlinedIndexOf(CallInfo* info, bool zero_based) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1432 | if (cu_->instruction_set == kMips) { |
| 1433 | // TODO - add Mips implementation |
| 1434 | return false; |
| 1435 | } |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1436 | RegLocation rl_obj = info->args[0]; |
| 1437 | RegLocation rl_char = info->args[1]; |
| 1438 | if (rl_char.is_const && (mir_graph_->ConstantValue(rl_char) & ~0xFFFF) != 0) { |
| 1439 | // Code point beyond 0xFFFF. Punt to the real String.indexOf(). |
| 1440 | return false; |
| 1441 | } |
| 1442 | |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 1443 | ClobberCallerSave(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1444 | LockCallTemps(); // Using fixed registers |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1445 | RegStorage reg_ptr = TargetReg(kArg0); |
| 1446 | RegStorage reg_char = TargetReg(kArg1); |
| 1447 | RegStorage reg_start = TargetReg(kArg2); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1448 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1449 | LoadValueDirectFixed(rl_obj, reg_ptr); |
| 1450 | LoadValueDirectFixed(rl_char, reg_char); |
| 1451 | if (zero_based) { |
| 1452 | LoadConstant(reg_start, 0); |
| 1453 | } else { |
buzbee | a44d4f5 | 2014-03-05 11:26:39 -0800 | [diff] [blame] | 1454 | RegLocation rl_start = info->args[2]; // 3rd arg only present in III flavor of IndexOf. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1455 | LoadValueDirectFixed(rl_start, reg_start); |
| 1456 | } |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1457 | RegStorage r_tgt = Is64BitInstructionSet(cu_->instruction_set) ? |
| 1458 | LoadHelper(QUICK_ENTRYPOINT_OFFSET(8, pIndexOf)) : |
| 1459 | LoadHelper(QUICK_ENTRYPOINT_OFFSET(4, pIndexOf)); |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 1460 | GenExplicitNullCheck(reg_ptr, info->opt_flags); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1461 | LIR* high_code_point_branch = |
| 1462 | rl_char.is_const ? nullptr : OpCmpImmBranch(kCondGt, reg_char, 0xFFFF, nullptr); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1463 | // NOTE: not a safepoint |
Mark Mendell | 4028a6c | 2014-02-19 20:06:20 -0800 | [diff] [blame] | 1464 | OpReg(kOpBlx, r_tgt); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1465 | if (!rl_char.is_const) { |
| 1466 | // Add the slow path for code points beyond 0xFFFF. |
| 1467 | DCHECK(high_code_point_branch != nullptr); |
| 1468 | LIR* resume_tgt = NewLIR0(kPseudoTargetLabel); |
| 1469 | info->opt_flags |= MIR_IGNORE_NULL_CHECK; // Record that we've null checked. |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 1470 | AddIntrinsicSlowPath(info, high_code_point_branch, resume_tgt); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1471 | } else { |
| 1472 | DCHECK_EQ(mir_graph_->ConstantValue(rl_char) & ~0xFFFF, 0); |
| 1473 | DCHECK(high_code_point_branch == nullptr); |
| 1474 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1475 | RegLocation rl_return = GetReturn(false); |
| 1476 | RegLocation rl_dest = InlineTarget(info); |
| 1477 | StoreValue(rl_dest, rl_return); |
| 1478 | return true; |
| 1479 | } |
| 1480 | |
| 1481 | /* Fast string.compareTo(Ljava/lang/string;)I. */ |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1482 | bool Mir2Lir::GenInlinedStringCompareTo(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1483 | if (cu_->instruction_set == kMips) { |
| 1484 | // TODO - add Mips implementation |
| 1485 | return false; |
| 1486 | } |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 1487 | ClobberCallerSave(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1488 | LockCallTemps(); // Using fixed registers |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1489 | RegStorage reg_this = TargetReg(kArg0); |
| 1490 | RegStorage reg_cmp = TargetReg(kArg1); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1491 | |
| 1492 | RegLocation rl_this = info->args[0]; |
| 1493 | RegLocation rl_cmp = info->args[1]; |
| 1494 | LoadValueDirectFixed(rl_this, reg_this); |
| 1495 | LoadValueDirectFixed(rl_cmp, reg_cmp); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1496 | RegStorage r_tgt; |
| 1497 | if (cu_->instruction_set != kX86 && cu_->instruction_set != kX86_64) { |
| 1498 | if (Is64BitInstructionSet(cu_->instruction_set)) { |
| 1499 | r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(8, pStringCompareTo)); |
| 1500 | } else { |
| 1501 | r_tgt = LoadHelper(QUICK_ENTRYPOINT_OFFSET(4, pStringCompareTo)); |
| 1502 | } |
| 1503 | } else { |
| 1504 | r_tgt = RegStorage::InvalidReg(); |
| 1505 | } |
Dave Allison | f943914 | 2014-03-27 15:10:22 -0700 | [diff] [blame] | 1506 | GenExplicitNullCheck(reg_this, info->opt_flags); |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1507 | info->opt_flags |= MIR_IGNORE_NULL_CHECK; // Record that we've null checked. |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 1508 | // TUNING: check if rl_cmp.s_reg_low is already null checked |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1509 | LIR* cmp_null_check_branch = OpCmpImmBranch(kCondEq, reg_cmp, 0, nullptr); |
Mingyao Yang | 3a74d15 | 2014-04-21 15:39:44 -0700 | [diff] [blame] | 1510 | AddIntrinsicSlowPath(info, cmp_null_check_branch); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1511 | // NOTE: not a safepoint |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1512 | if (cu_->instruction_set != kX86 && cu_->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1513 | OpReg(kOpBlx, r_tgt); |
| 1514 | } else { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1515 | if (Is64BitInstructionSet(cu_->instruction_set)) { |
| 1516 | OpThreadMem(kOpBlx, QUICK_ENTRYPOINT_OFFSET(8, pStringCompareTo)); |
| 1517 | } else { |
| 1518 | OpThreadMem(kOpBlx, QUICK_ENTRYPOINT_OFFSET(4, pStringCompareTo)); |
| 1519 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1520 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1521 | RegLocation rl_return = GetReturn(false); |
| 1522 | RegLocation rl_dest = InlineTarget(info); |
| 1523 | StoreValue(rl_dest, rl_return); |
| 1524 | return true; |
| 1525 | } |
| 1526 | |
| 1527 | bool Mir2Lir::GenInlinedCurrentThread(CallInfo* info) { |
| 1528 | RegLocation rl_dest = InlineTarget(info); |
| 1529 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1530 | |
| 1531 | switch (cu_->instruction_set) { |
| 1532 | case kArm: |
| 1533 | // Fall-through. |
| 1534 | case kThumb2: |
| 1535 | // Fall-through. |
| 1536 | case kMips: |
| 1537 | Load32Disp(TargetReg(kSelf), Thread::PeerOffset<4>().Int32Value(), rl_result.reg); |
| 1538 | break; |
| 1539 | |
| 1540 | case kArm64: |
| 1541 | Load32Disp(TargetReg(kSelf), Thread::PeerOffset<8>().Int32Value(), rl_result.reg); |
| 1542 | break; |
| 1543 | |
| 1544 | case kX86: |
| 1545 | reinterpret_cast<X86Mir2Lir*>(this)->OpRegThreadMem(kOpMov, rl_result.reg, |
| 1546 | Thread::PeerOffset<4>()); |
| 1547 | break; |
| 1548 | |
| 1549 | case kX86_64: |
| 1550 | reinterpret_cast<X86Mir2Lir*>(this)->OpRegThreadMem(kOpMov, rl_result.reg, |
| 1551 | Thread::PeerOffset<8>()); |
| 1552 | break; |
| 1553 | |
| 1554 | default: |
| 1555 | LOG(FATAL) << "Unexpected isa " << cu_->instruction_set; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1556 | } |
| 1557 | StoreValue(rl_dest, rl_result); |
| 1558 | return true; |
| 1559 | } |
| 1560 | |
| 1561 | bool Mir2Lir::GenInlinedUnsafeGet(CallInfo* info, |
| 1562 | bool is_long, bool is_volatile) { |
| 1563 | if (cu_->instruction_set == kMips) { |
| 1564 | // TODO - add Mips implementation |
| 1565 | return false; |
| 1566 | } |
| 1567 | // Unused - RegLocation rl_src_unsafe = info->args[0]; |
| 1568 | RegLocation rl_src_obj = info->args[1]; // Object |
| 1569 | RegLocation rl_src_offset = info->args[2]; // long low |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1570 | rl_src_offset = NarrowRegLoc(rl_src_offset); // ignore high half in info->args[3] |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 1571 | RegLocation rl_dest = is_long ? InlineTargetWide(info) : InlineTarget(info); // result reg |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 1572 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1573 | RegLocation rl_object = LoadValue(rl_src_obj, kCoreReg); |
| 1574 | RegLocation rl_offset = LoadValue(rl_src_offset, kCoreReg); |
| 1575 | RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); |
| 1576 | if (is_long) { |
Dmitry Petrochenko | 9bf549d | 2014-05-12 11:14:46 +0700 | [diff] [blame] | 1577 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 1578 | LoadBaseIndexedDisp(rl_object.reg, rl_offset.reg, 0, 0, rl_result.reg, k64); |
Mathieu Chartier | 7c95cef | 2014-04-02 17:09:17 -0700 | [diff] [blame] | 1579 | } else { |
| 1580 | RegStorage rl_temp_offset = AllocTemp(); |
| 1581 | OpRegRegReg(kOpAdd, rl_temp_offset, rl_object.reg, rl_offset.reg); |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 1582 | LoadBaseDisp(rl_temp_offset, 0, rl_result.reg, k64); |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 1583 | FreeTemp(rl_temp_offset); |
Mathieu Chartier | 7c95cef | 2014-04-02 17:09:17 -0700 | [diff] [blame] | 1584 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1585 | } else { |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1586 | LoadBaseIndexed(rl_object.reg, rl_offset.reg, rl_result.reg, 0, k32); |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | if (is_volatile) { |
| 1590 | // Without context sensitive analysis, we must issue the most conservative barriers. |
| 1591 | // In this case, either a load or store may follow so we issue both barriers. |
| 1592 | GenMemBarrier(kLoadLoad); |
| 1593 | GenMemBarrier(kLoadStore); |
| 1594 | } |
| 1595 | |
| 1596 | if (is_long) { |
| 1597 | StoreValueWide(rl_dest, rl_result); |
| 1598 | } else { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1599 | StoreValue(rl_dest, rl_result); |
| 1600 | } |
| 1601 | return true; |
| 1602 | } |
| 1603 | |
| 1604 | bool Mir2Lir::GenInlinedUnsafePut(CallInfo* info, bool is_long, |
| 1605 | bool is_object, bool is_volatile, bool is_ordered) { |
| 1606 | if (cu_->instruction_set == kMips) { |
| 1607 | // TODO - add Mips implementation |
| 1608 | return false; |
| 1609 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1610 | // Unused - RegLocation rl_src_unsafe = info->args[0]; |
| 1611 | RegLocation rl_src_obj = info->args[1]; // Object |
| 1612 | RegLocation rl_src_offset = info->args[2]; // long low |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1613 | rl_src_offset = NarrowRegLoc(rl_src_offset); // ignore high half in info->args[3] |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1614 | RegLocation rl_src_value = info->args[4]; // value to store |
| 1615 | if (is_volatile || is_ordered) { |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 1616 | // There might have been a store before this volatile one so insert StoreStore barrier. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1617 | GenMemBarrier(kStoreStore); |
| 1618 | } |
| 1619 | RegLocation rl_object = LoadValue(rl_src_obj, kCoreReg); |
| 1620 | RegLocation rl_offset = LoadValue(rl_src_offset, kCoreReg); |
| 1621 | RegLocation rl_value; |
| 1622 | if (is_long) { |
| 1623 | rl_value = LoadValueWide(rl_src_value, kCoreReg); |
Dmitry Petrochenko | 9bf549d | 2014-05-12 11:14:46 +0700 | [diff] [blame] | 1624 | if (cu_->instruction_set == kX86 || cu_->instruction_set == kX86_64) { |
Vladimir Marko | 3bf7c60 | 2014-05-07 14:55:43 +0100 | [diff] [blame] | 1625 | StoreBaseIndexedDisp(rl_object.reg, rl_offset.reg, 0, 0, rl_value.reg, k64); |
Mathieu Chartier | 7c95cef | 2014-04-02 17:09:17 -0700 | [diff] [blame] | 1626 | } else { |
| 1627 | RegStorage rl_temp_offset = AllocTemp(); |
| 1628 | OpRegRegReg(kOpAdd, rl_temp_offset, rl_object.reg, rl_offset.reg); |
Vladimir Marko | 455759b | 2014-05-06 20:49:36 +0100 | [diff] [blame] | 1629 | StoreBaseDisp(rl_temp_offset, 0, rl_value.reg, k64); |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 1630 | FreeTemp(rl_temp_offset); |
Mathieu Chartier | 7c95cef | 2014-04-02 17:09:17 -0700 | [diff] [blame] | 1631 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1632 | } else { |
| 1633 | rl_value = LoadValue(rl_src_value, kCoreReg); |
buzbee | 695d13a | 2014-04-19 13:32:20 -0700 | [diff] [blame] | 1634 | StoreBaseIndexed(rl_object.reg, rl_offset.reg, rl_value.reg, 0, k32); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1635 | } |
Mark Mendell | df8ee2e | 2014-01-27 16:37:47 -0800 | [diff] [blame] | 1636 | |
| 1637 | // Free up the temp early, to ensure x86 doesn't run out of temporaries in MarkGCCard. |
buzbee | 091cc40 | 2014-03-31 10:14:40 -0700 | [diff] [blame] | 1638 | FreeTemp(rl_offset.reg); |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 1639 | |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1640 | if (is_volatile) { |
Razvan A Lupusoru | 99ad723 | 2014-02-25 17:41:08 -0800 | [diff] [blame] | 1641 | // A load might follow the volatile store so insert a StoreLoad barrier. |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1642 | GenMemBarrier(kStoreLoad); |
| 1643 | } |
| 1644 | if (is_object) { |
buzbee | 2700f7e | 2014-03-07 09:46:20 -0800 | [diff] [blame] | 1645 | MarkGCCard(rl_value.reg, rl_object.reg); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1646 | } |
| 1647 | return true; |
| 1648 | } |
| 1649 | |
Brian Carlstrom | 2ce745c | 2013-07-17 17:44:30 -0700 | [diff] [blame] | 1650 | void Mir2Lir::GenInvoke(CallInfo* info) { |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 1651 | if ((info->opt_flags & MIR_INLINED) != 0) { |
| 1652 | // Already inlined but we may still need the null check. |
| 1653 | if (info->type != kStatic && |
| 1654 | ((cu_->disable_opt & (1 << kNullCheckElimination)) != 0 || |
| 1655 | (info->opt_flags & MIR_IGNORE_NULL_CHECK) == 0)) { |
| 1656 | RegLocation rl_obj = LoadValue(info->args[0], kCoreReg); |
Mingyao Yang | e643a17 | 2014-04-08 11:02:52 -0700 | [diff] [blame] | 1657 | GenNullCheck(rl_obj.reg); |
Vladimir Marko | 9820b7c | 2014-01-02 16:40:37 +0000 | [diff] [blame] | 1658 | } |
| 1659 | return; |
| 1660 | } |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1661 | DCHECK(cu_->compiler_driver->GetMethodInlinerMap() != nullptr); |
| 1662 | if (cu_->compiler_driver->GetMethodInlinerMap()->GetMethodInliner(cu_->dex_file) |
| 1663 | ->GenIntrinsic(this, info)) { |
| 1664 | return; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1665 | } |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1666 | GenInvokeNoInline(info); |
| 1667 | } |
| 1668 | |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1669 | template <size_t pointer_size> |
| 1670 | static LIR* GenInvokeNoInlineCall(Mir2Lir* mir_to_lir, InvokeType type) { |
| 1671 | ThreadOffset<pointer_size> trampoline(-1); |
| 1672 | switch (type) { |
| 1673 | case kInterface: |
| 1674 | trampoline = QUICK_ENTRYPOINT_OFFSET(pointer_size, pInvokeInterfaceTrampolineWithAccessCheck); |
| 1675 | break; |
| 1676 | case kDirect: |
| 1677 | trampoline = QUICK_ENTRYPOINT_OFFSET(pointer_size, pInvokeDirectTrampolineWithAccessCheck); |
| 1678 | break; |
| 1679 | case kStatic: |
| 1680 | trampoline = QUICK_ENTRYPOINT_OFFSET(pointer_size, pInvokeStaticTrampolineWithAccessCheck); |
| 1681 | break; |
| 1682 | case kSuper: |
| 1683 | trampoline = QUICK_ENTRYPOINT_OFFSET(pointer_size, pInvokeSuperTrampolineWithAccessCheck); |
| 1684 | break; |
| 1685 | case kVirtual: |
| 1686 | trampoline = QUICK_ENTRYPOINT_OFFSET(pointer_size, pInvokeVirtualTrampolineWithAccessCheck); |
| 1687 | break; |
| 1688 | default: |
| 1689 | LOG(FATAL) << "Unexpected invoke type"; |
| 1690 | } |
| 1691 | return mir_to_lir->OpThreadMem(kOpBlx, trampoline); |
| 1692 | } |
| 1693 | |
Vladimir Marko | 3bc8615 | 2014-03-13 14:11:28 +0000 | [diff] [blame] | 1694 | void Mir2Lir::GenInvokeNoInline(CallInfo* info) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1695 | int call_state = 0; |
| 1696 | LIR* null_ck; |
| 1697 | LIR** p_null_ck = NULL; |
| 1698 | NextCallInsn next_call_insn; |
| 1699 | FlushAllRegs(); /* Everything to home location */ |
| 1700 | // Explicit register usage |
| 1701 | LockCallTemps(); |
| 1702 | |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1703 | const MirMethodLoweringInfo& method_info = mir_graph_->GetMethodLoweringInfo(info->mir); |
| 1704 | cu_->compiler_driver->ProcessedInvoke(method_info.GetInvokeType(), method_info.StatsFlags()); |
| 1705 | InvokeType original_type = static_cast<InvokeType>(method_info.GetInvokeType()); |
| 1706 | info->type = static_cast<InvokeType>(method_info.GetSharpType()); |
| 1707 | bool fast_path = method_info.FastPath(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1708 | bool skip_this; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1709 | if (info->type == kInterface) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1710 | next_call_insn = fast_path ? NextInterfaceCallInsn : NextInterfaceCallInsnWithAccessCheck; |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1711 | skip_this = fast_path; |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1712 | } else if (info->type == kDirect) { |
| 1713 | if (fast_path) { |
| 1714 | p_null_ck = &null_ck; |
| 1715 | } |
| 1716 | next_call_insn = fast_path ? NextSDCallInsn : NextDirectCallInsnSP; |
| 1717 | skip_this = false; |
| 1718 | } else if (info->type == kStatic) { |
| 1719 | next_call_insn = fast_path ? NextSDCallInsn : NextStaticCallInsnSP; |
| 1720 | skip_this = false; |
| 1721 | } else if (info->type == kSuper) { |
| 1722 | DCHECK(!fast_path); // Fast path is a direct call. |
| 1723 | next_call_insn = NextSuperCallInsnSP; |
| 1724 | skip_this = false; |
| 1725 | } else { |
| 1726 | DCHECK_EQ(info->type, kVirtual); |
| 1727 | next_call_insn = fast_path ? NextVCallInsn : NextVCallInsnSP; |
| 1728 | skip_this = fast_path; |
| 1729 | } |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1730 | MethodReference target_method = method_info.GetTargetMethod(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1731 | if (!info->is_range) { |
| 1732 | call_state = GenDalvikArgsNoRange(info, call_state, p_null_ck, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1733 | next_call_insn, target_method, method_info.VTableIndex(), |
| 1734 | method_info.DirectCode(), method_info.DirectMethod(), |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1735 | original_type, skip_this); |
| 1736 | } else { |
| 1737 | call_state = GenDalvikArgsRange(info, call_state, p_null_ck, |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1738 | next_call_insn, target_method, method_info.VTableIndex(), |
| 1739 | method_info.DirectCode(), method_info.DirectMethod(), |
| 1740 | original_type, skip_this); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1741 | } |
| 1742 | // Finish up any of the call sequence not interleaved in arg loading |
| 1743 | while (call_state >= 0) { |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1744 | call_state = next_call_insn(cu_, info, call_state, target_method, method_info.VTableIndex(), |
| 1745 | method_info.DirectCode(), method_info.DirectMethod(), original_type); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1746 | } |
| 1747 | LIR* call_inst; |
Dmitry Petrochenko | 6a58cb1 | 2014-04-02 17:27:59 +0700 | [diff] [blame] | 1748 | if (cu_->instruction_set != kX86 && cu_->instruction_set != kX86_64) { |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1749 | call_inst = OpReg(kOpBlx, TargetReg(kInvokeTgt)); |
| 1750 | } else { |
Jeff Hao | 88474b4 | 2013-10-23 16:24:40 -0700 | [diff] [blame] | 1751 | if (fast_path) { |
Vladimir Marko | f096aad | 2014-01-23 15:51:58 +0000 | [diff] [blame] | 1752 | if (method_info.DirectCode() == static_cast<uintptr_t>(-1)) { |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 1753 | // We can have the linker fixup a call relative. |
| 1754 | call_inst = |
Jeff Hao | 49161ce | 2014-03-12 11:05:25 -0700 | [diff] [blame] | 1755 | reinterpret_cast<X86Mir2Lir*>(this)->CallWithLinkerFixup(target_method, info->type); |
Mark Mendell | 55d0eac | 2014-02-06 11:02:52 -0800 | [diff] [blame] | 1756 | } else { |
| 1757 | call_inst = OpMem(kOpBlx, TargetReg(kArg0), |
| 1758 | mirror::ArtMethod::EntryPointFromQuickCompiledCodeOffset().Int32Value()); |
| 1759 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1760 | } else { |
Andreas Gampe | 2f244e9 | 2014-05-08 03:35:25 -0700 | [diff] [blame] | 1761 | // TODO: Extract? |
| 1762 | if (Is64BitInstructionSet(cu_->instruction_set)) { |
| 1763 | call_inst = GenInvokeNoInlineCall<8>(this, info->type); |
| 1764 | } else { |
Andreas Gampe | 3ec5da2 | 2014-05-12 18:43:28 -0700 | [diff] [blame] | 1765 | call_inst = GenInvokeNoInlineCall<4>(this, info->type); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1766 | } |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1767 | } |
| 1768 | } |
| 1769 | MarkSafepointPC(call_inst); |
| 1770 | |
Vladimir Marko | 31c2aac | 2013-12-09 16:31:19 +0000 | [diff] [blame] | 1771 | ClobberCallerSave(); |
Brian Carlstrom | 7940e44 | 2013-07-12 13:46:57 -0700 | [diff] [blame] | 1772 | if (info->result.location != kLocInvalid) { |
| 1773 | // We have a following MOVE_RESULT - do it now. |
| 1774 | if (info->result.wide) { |
| 1775 | RegLocation ret_loc = GetReturnWide(info->result.fp); |
| 1776 | StoreValueWide(info->result, ret_loc); |
| 1777 | } else { |
| 1778 | RegLocation ret_loc = GetReturn(info->result.fp); |
| 1779 | StoreValue(info->result, ret_loc); |
| 1780 | } |
| 1781 | } |
| 1782 | } |
| 1783 | |
| 1784 | } // namespace art |