blob: f83f03c2961593a64f807b6877d56f0e4a5de381 [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 Marko5868ada2020-05-12 11:50:34 +010020#include "class_root-inl.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
Vladimir Markob6f4c792020-05-04 15:37:29 +010028template <PointerSize kPointerSize>
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 Markob6f4c792020-05-04 15:37:29 +010033 ret->InitializeFromArtMethod<kPointerSize>(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 Markob6f4c792020-05-04 15:37:29 +010038template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k32>(
Vladimir Markod93e3742018-07-18 10:58:13 +010039 Thread* self, ArtMethod* method);
Vladimir Markob6f4c792020-05-04 15:37:29 +010040template ObjPtr<Method> Method::CreateFromArtMethod<PointerSize::k64>(
Vladimir Markod93e3742018-07-18 10:58:13 +010041 Thread* self, ArtMethod* method);
Andreas Gampebc4d2182016-02-22 10:03:12 -080042
Vladimir Markob6f4c792020-05-04 15:37:29 +010043template <PointerSize kPointerSize>
Vladimir Markod93e3742018-07-18 10:58:13 +010044ObjPtr<Constructor> Constructor::CreateFromArtMethod(Thread* self, ArtMethod* method) {
David Sehr709b0702016-10-13 09:12:37 -070045 DCHECK(method->IsConstructor()) << method->PrettyMethod();
Vladimir Marko679730e2018-05-25 15:06:48 +010046 ObjPtr<Constructor> ret =
47 ObjPtr<Constructor>::DownCast(GetClassRoot<Constructor>()->AllocObject(self));
Mathieu Chartierfc58af42015-04-16 18:00:39 -070048 if (LIKELY(ret != nullptr)) {
Vladimir Markob6f4c792020-05-04 15:37:29 +010049 ret->InitializeFromArtMethod<kPointerSize>(method);
Mathieu Chartierfc58af42015-04-16 18:00:39 -070050 }
Vladimir Markod93e3742018-07-18 10:58:13 +010051 return ret;
Mathieu Chartierfc58af42015-04-16 18:00:39 -070052}
53
Vladimir Markob6f4c792020-05-04 15:37:29 +010054template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k32>(
Andreas Gampe542451c2016-07-26 09:02:02 -070055 Thread* self, ArtMethod* method);
Vladimir Markob6f4c792020-05-04 15:37:29 +010056template ObjPtr<Constructor> Constructor::CreateFromArtMethod<PointerSize::k64>(
Andreas Gampe542451c2016-07-26 09:02:02 -070057 Thread* self, ArtMethod* method);
Andreas Gampe6039e562016-04-05 18:18:43 -070058
Mathieu Chartierfc58af42015-04-16 18:00:39 -070059} // namespace mirror
60} // namespace art