blob: 20a697977b60f74c481dc111448fa39540eb91a2 [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"
Andreas Gampe70f5fd02018-10-24 19:58:37 -070021#include "mirror/class-alloc-inl.h"
Mathieu Chartierfc58af42015-04-16 18:00:39 -070022#include "mirror/object-inl.h"
Vladimir Markod93e3742018-07-18 10:58:13 +010023#include "obj_ptr-inl.h"
Mathieu Chartierfc58af42015-04-16 18:00:39 -070024
25namespace art {
26namespace mirror {
27
Andreas Gampe542451c2016-07-26 09:02:02 -070028template <PointerSize kPointerSize, bool kTransactionActive>
Vladimir Markod93e3742018-07-18 10:58:13 +010029ObjPtr<Method> 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)) {
Vladimir Markod7e9bbf2019-03-28 13:18:57 +000033 ret->Executable::CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070034 }
Vladimir Markod93e3742018-07-18 10:58:13 +010035 return ret;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070036}
37
Vladimir Markod93e3742018-07-18 10:58:13 +010038template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, false>(
39 Thread* self, ArtMethod* method);
40template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, true>(
41 Thread* self, ArtMethod* method);
42template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, false>(
43 Thread* self, ArtMethod* method);
44template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, true>(
45 Thread* self, ArtMethod* method);
Andreas Gampebc4d2182016-02-22 10:03:12 -080046
Andreas Gampe542451c2016-07-26 09:02:02 -070047template <PointerSize kPointerSize, bool kTransactionActive>
Vladimir Markod93e3742018-07-18 10:58:13 +010048ObjPtr<Constructor> Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) {
David Sehr709b0702016-10-13 09:12:37 -070049 DCHECK(method->IsConstructor()) << method->PrettyMethod();
Vladimir Marko679730e2018-05-25 15:06:48 +010050 ObjPtr<Constructor> ret =
51 ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self));
Mathieu Chartierfc58af42015-04-16 18:00:39 -070052 if (LIKELY(ret != nullptr)) {
Vladimir Markod7e9bbf2019-03-28 13:18:57 +000053 ret->Executable::CreateFromArtMethod<kPointerSize, kTransactionActive>(method);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070054 }
Vladimir Markod93e3742018-07-18 10:58:13 +010055 return ret;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070056}
57
Vladimir Markod93e3742018-07-18 10:58:13 +010058template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, false>(
Andreas Gampe542451c2016-07-26 09:02:02 -070059 Thread* self, ArtMethod* method);
Vladimir Markod93e3742018-07-18 10:58:13 +010060template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, true>(
Andreas Gampe542451c2016-07-26 09:02:02 -070061 Thread* self, ArtMethod* method);
Vladimir Markod93e3742018-07-18 10:58:13 +010062template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, false>(
Andreas Gampe542451c2016-07-26 09:02:02 -070063 Thread* self, ArtMethod* method);
Vladimir Markod93e3742018-07-18 10:58:13 +010064template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, true>(
Andreas Gampe542451c2016-07-26 09:02:02 -070065 Thread* self, ArtMethod* method);
Andreas Gampe6039e562016-04-05 18:18:43 -070066
Mathieu Chartierfc58af42015-04-16 18:00:39 -070067} // namespace mirror
68} // namespace art