blob: 3996f49e1a043a1223aa24c45dd317a3138e37b4 [file] [log] [blame]
Mathieu Chartierfc58af42015-04-16 18:00:39 -07001/*
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 Marko0eefb9b2019-03-27 15:04:31 +000017#include "executable-inl.h"
Mathieu Chartierfc58af42015-04-16 18:00:39 -070018
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070019#include "art_method-inl.h"
Vladimir Marko0eefb9b2019-03-27 15:04:31 +000020#include "object-inl.h"
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070021
Mathieu Chartierfc58af42015-04-16 18:00:39 -070022namespace art {
23namespace mirror {
24
Vladimir Markob6f4c792020-05-04 15:37:29 +010025template <PointerSize kPointerSize>
26void 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 Gampee01e3642016-07-25 13:06:04 -070029 auto* interface_method = method->GetInterfaceMethodIfProxy(kPointerSize);
Vladimir Markob6f4c792020-05-04 15:37:29 +010030 SetArtMethod</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(method);
31 SetFieldObject</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(
32 DeclaringClassOffset(), method->GetDeclaringClass());
33 SetFieldObject</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(
Mathieu Chartierfc58af42015-04-16 18:00:39 -070034 DeclaringClassOfOverriddenMethodOffset(), interface_method->GetDeclaringClass());
Vladimir Markob6f4c792020-05-04 15:37:29 +010035 SetField32</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(
36 AccessFlagsOffset(), method->GetAccessFlags());
37 SetField32</*kTransactionActive=*/ false, /*kCheckTransaction=*/ false>(
38 DexMethodIndexOffset(), method->GetDexMethodIndex());
Mathieu Chartierfc58af42015-04-16 18:00:39 -070039}
40
Vladimir Markob6f4c792020-05-04 15:37:29 +010041template void Executable::InitializeFromArtMethod<PointerSize::k32>(ArtMethod* method);
42template void Executable::InitializeFromArtMethod<PointerSize::k64>(ArtMethod* method);
Andreas Gampebc4d2182016-02-22 10:03:12 -080043
Mathieu Chartierfc58af42015-04-16 18:00:39 -070044} // namespace mirror
45} // namespace art