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 | |
| 17 | #include "method.h" |
| 18 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 19 | #include "art_method.h" |
Vladimir Marko | 679730e | 2018-05-25 15:06:48 +0100 | [diff] [blame] | 20 | #include "class_root.h" |
Andreas Gampe | 70f5fd0 | 2018-10-24 19:58:37 -0700 | [diff] [blame] | 21 | #include "mirror/class-alloc-inl.h" |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 22 | #include "mirror/object-inl.h" |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 23 | #include "obj_ptr-inl.h" |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 24 | |
| 25 | namespace art { |
| 26 | namespace mirror { |
| 27 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 28 | template <PointerSize kPointerSize, bool kTransactionActive> |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 29 | ObjPtr<Method> Method::CreateFromArtMethod(Thread* self, ArtMethod* method) { |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 30 | DCHECK(!method->IsConstructor()) << method->PrettyMethod(); |
Vladimir Marko | 679730e | 2018-05-25 15:06:48 +0100 | [diff] [blame] | 31 | ObjPtr<Method> ret = ObjPtr<Method>::DownCast(GetClassRoot<Method>()->AllocObject(self)); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 32 | if (LIKELY(ret != nullptr)) { |
Vladimir Marko | d7e9bbf | 2019-03-28 13:18:57 +0000 | [diff] [blame^] | 33 | ret->Executable::CreateFromArtMethod<kPointerSize, kTransactionActive>(method); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 34 | } |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 35 | return ret; |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 38 | template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, false>( |
| 39 | Thread* self, ArtMethod* method); |
| 40 | template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32, true>( |
| 41 | Thread* self, ArtMethod* method); |
| 42 | template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, false>( |
| 43 | Thread* self, ArtMethod* method); |
| 44 | template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64, true>( |
| 45 | Thread* self, ArtMethod* method); |
Andreas Gampe | bc4d218 | 2016-02-22 10:03:12 -0800 | [diff] [blame] | 46 | |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 47 | template <PointerSize kPointerSize, bool kTransactionActive> |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 48 | ObjPtr<Constructor> Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) { |
David Sehr | 709b070 | 2016-10-13 09:12:37 -0700 | [diff] [blame] | 49 | DCHECK(method->IsConstructor()) << method->PrettyMethod(); |
Vladimir Marko | 679730e | 2018-05-25 15:06:48 +0100 | [diff] [blame] | 50 | ObjPtr<Constructor> ret = |
| 51 | ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self)); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 52 | if (LIKELY(ret != nullptr)) { |
Vladimir Marko | d7e9bbf | 2019-03-28 13:18:57 +0000 | [diff] [blame^] | 53 | ret->Executable::CreateFromArtMethod<kPointerSize, kTransactionActive>(method); |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 54 | } |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 55 | return ret; |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 58 | template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, false>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 59 | Thread* self, ArtMethod* method); |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 60 | template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32, true>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 61 | Thread* self, ArtMethod* method); |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 62 | template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, false>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 63 | Thread* self, ArtMethod* method); |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 64 | template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64, true>( |
Andreas Gampe | 542451c | 2016-07-26 09:02:02 -0700 | [diff] [blame] | 65 | Thread* self, ArtMethod* method); |
Andreas Gampe | 6039e56 | 2016-04-05 18:18:43 -0700 | [diff] [blame] | 66 | |
Mathieu Chartier | fc58af4 | 2015-04-16 18:00:39 -0700 | [diff] [blame] | 67 | } // namespace mirror |
| 68 | } // namespace art |