blob: e5d3403107f452bc28d8465a4981e47e9a5ab7e9 [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
17#include "method.h"
18
Mathieu Chartiere401d142015-04-22 13:56:20 -070019#include "art_method.h"
Vladimir Marko679730e2018-05-25 15:06:48 +010020#include "class_root.h"
Mathieu Chartiere401d142015-04-22 13:56:20 -070021#include "gc_root-inl.h"
22#include "mirror/class-inl.h"
Mathieu Chartierfc58af42015-04-16 18:00:39 -070023#include "mirror/object-inl.h"
24
25namespace art {
26namespace mirror {
27
Andreas Gampe542451c2016-07-26 09:02:02 -070028template <PointerSize kPointerSize, bool kTransactionActive>
Mathieu Chartiere401d142015-04-22 13:56:20 -070029Method* Method::CreateFromArtMethod(Thread* self, ArtMethod* method) {
David Sehr709b0702016-10-13 09:12:37 -070030 DCHECK(!method->IsConstructor()) << method->PrettyMethod();
Vladimir Marko679730e2018-05-25 15:06:48 +010031 ObjPtr<Method> ret = ObjPtr<Method>::DownCast(GetClassRoot<Method>()->AllocObject(self));
Mathieu Chartierfc58af42015-04-16 18:00:39 -070032 if (LIKELY(ret != nullptr)) {
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070033 ObjPtr<Executable>(ret)->
Andreas Gampee01e3642016-07-25 13:06:04 -070034 CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070035 }
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070036 return ret.Ptr();
Mathieu Chartierfc58af42015-04-16 18:00:39 -070037}
38
Andreas Gampe542451c2016-07-26 09:02:02 -070039template Method* Method::CreateFromArtMethod<PointerSize::k32, false>(Thread* self,
40 ArtMethod* method);
41template Method* Method::CreateFromArtMethod<PointerSize::k32, true>(Thread* self,
42 ArtMethod* method);
43template Method* Method::CreateFromArtMethod<PointerSize::k64, false>(Thread* self,
44 ArtMethod* method);
45template Method* Method::CreateFromArtMethod<PointerSize::k64, true>(Thread* self,
46 ArtMethod* method);
Andreas Gampebc4d2182016-02-22 10:03:12 -080047
Andreas Gampe542451c2016-07-26 09:02:02 -070048template <PointerSize kPointerSize, bool kTransactionActive>
Mathieu Chartiere401d142015-04-22 13:56:20 -070049Constructor* Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) {
David Sehr709b0702016-10-13 09:12:37 -070050 DCHECK(method->IsConstructor()) << method->PrettyMethod();
Vladimir Marko679730e2018-05-25 15:06:48 +010051 ObjPtr<Constructor> ret =
52 ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self));
Mathieu Chartierfc58af42015-04-16 18:00:39 -070053 if (LIKELY(ret != nullptr)) {
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070054 ObjPtr<Executable>(ret)->
Andreas Gampee01e3642016-07-25 13:06:04 -070055 CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070056 }
Mathieu Chartier28bd2e42016-10-04 13:54:57 -070057 return ret.Ptr();
Mathieu Chartierfc58af42015-04-16 18:00:39 -070058}
59
Andreas Gampe542451c2016-07-26 09:02:02 -070060template Constructor* Constructor::CreateFromArtMethod<PointerSize::k32, false>(
61 Thread* self, ArtMethod* method);
62template Constructor* Constructor::CreateFromArtMethod<PointerSize::k32, true>(
63 Thread* self, ArtMethod* method);
64template Constructor* Constructor::CreateFromArtMethod<PointerSize::k64, false>(
65 Thread* self, ArtMethod* method);
66template Constructor* Constructor::CreateFromArtMethod<PointerSize::k64, true>(
67 Thread* self, ArtMethod* method);
Andreas Gampe6039e562016-04-05 18:18:43 -070068
Mathieu Chartierfc58af42015-04-16 18:00:39 -070069} // namespace mirror
70} // namespace art