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
19 #include "art_method.h"
20 #include "class_root-inl.h"
21 #include "mirror/class-alloc-inl.h"
22 #include "mirror/object-inl.h"
23 #include "obj_ptr-inl.h"
24
25 namespace art {
26 namespace mirror {
27
28 template <PointerSize kPointerSize>
CreateFromArtMethod(Thread * self,ArtMethod * method)29 ObjPtr<Method> Method::CreateFromArtMethod(Thread* self, ArtMethod* method) {
30 DCHECK(!method->IsConstructor()) << method->PrettyMethod();
31 ObjPtr<Method> ret = ObjPtr<Method>::DownCast(GetClassRoot<Method>()->AllocObject(self));
32 if (LIKELY(ret != nullptr)) {
33 ret->InitializeFromArtMethod<kPointerSize>(method);
34 }
35 return ret;
36 }
37
38 template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32>(
39 Thread* self, ArtMethod* method);
40 template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64>(
41 Thread* self, ArtMethod* method);
42
43 template <PointerSize kPointerSize>
CreateFromArtMethod(Thread * self,ArtMethod * method)44 ObjPtr<Constructor> Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) {
45 DCHECK(method->IsConstructor()) << method->PrettyMethod();
46 ObjPtr<Constructor> ret =
47 ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self));
48 if (LIKELY(ret != nullptr)) {
49 ret->InitializeFromArtMethod<kPointerSize>(method);
50 }
51 return ret;
52 }
53
54 template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32>(
55 Thread* self, ArtMethod* method);
56 template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64>(
57 Thread* self, ArtMethod* method);
58
59 } // namespace mirror
60 } // namespace art
61