| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 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 | |
| Vladimir Marko | 0eefb9b | 2019-03-27 15:04:31 +0000 | [diff] [blame] | 17 | #include "executable-inl.h" |
| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 18 | |
| Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 19 | #include "art_method-inl.h" |
| Vladimir Marko | 0eefb9b | 2019-03-27 15:04:31 +0000 | [diff] [blame] | 20 | #include "object-inl.h" |
| Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 21 | |
| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 22 | namespace art { |
| 23 | namespace mirror { |
| 24 | |
| Vladimir Marko | b6f4c79 | 2020-05-04 15:37:29 +0100 | [diff] [blame] | 25 | template <PointerSize kPointerSize> |
| 26 | void Executable::InitializeFromArtMethod(ArtMethod* method) { |
| 27 | // We're initializing a newly allocated object, so we do not need to record that under |
| 28 | // a transaction. If the transaction is aborted, the whole object shall be unreachable. |
| Andreas Gampe | e01e364 | 2016-07-25 13:06:04 -0700 | [diff] [blame] | 29 | auto* interface_method = method->GetInterfaceMethodIfProxy(kPointerSize); |
| Vladimir Marko | b6f4c79 | 2020-05-04 15:37:29 +0100 | [diff] [blame] | 30 | SetArtMethod</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(method); |
| 31 | SetFieldObject</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>( |
| 32 | DeclaringClassOffset(), method->GetDeclaringClass()); |
| 33 | SetFieldObject</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>( |
| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 34 | DeclaringClassOfOverriddenMethodOffset(), interface_method->GetDeclaringClass()); |
| Vladimir Marko | b6f4c79 | 2020-05-04 15:37:29 +0100 | [diff] [blame] | 35 | SetField32</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>( |
| 36 | AccessFlagsOffset(), method->GetAccessFlags()); |
| 37 | SetField32</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>( |
| 38 | DexMethodIndexOffset(), method->GetDexMethodIndex()); |
| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| Vladimir Marko | b6f4c79 | 2020-05-04 15:37:29 +0100 | [diff] [blame] | 41 | template void Executable::InitializeFromArtMethod<PointerSize::k32>(ArtMethod* method); |
| 42 | template void Executable::InitializeFromArtMethod<PointerSize::k64>(ArtMethod* method); |
| Andreas Gampe | bc4d218 | 2016-02-22 10:03:12 -0800 | [diff] [blame] | 43 | |
| Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 44 | } // namespace mirror |
| 45 | } // namespace art |