blob: f9b33a2874ff58f3822edbbcfabe6fe0ea073dd5 [file] [log] [blame]
Nicolas Geoffray32c9ea52015-06-12 14:52:33 +01001/*
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 "art_method-inl.h"
18#include "jni.h"
19#include "scoped_thread_state_change.h"
20#include "stack.h"
21#include "thread.h"
22
23namespace art {
24
25namespace {
26
27extern "C" JNIEXPORT jobject JNICALL Java_Main_cloneResolvedMethods(JNIEnv*, jclass, jclass cls) {
28 ScopedObjectAccess soa(Thread::Current());
29 return soa.Vm()->AddGlobalRef(
30 soa.Self(),
31 soa.Decode<mirror::Class*>(cls)->GetDexCache()->GetResolvedMethods()->Clone(soa.Self()));
32}
33
34extern "C" JNIEXPORT void JNICALL Java_Main_restoreResolvedMethods(
35 JNIEnv*, jclass, jclass cls, jobject old_cache) {
36 ScopedObjectAccess soa(Thread::Current());
37 mirror::PointerArray* now = soa.Decode<mirror::Class*>(cls)->GetDexCache()->GetResolvedMethods();
38 mirror::PointerArray* old = soa.Decode<mirror::PointerArray*>(old_cache);
39 for (size_t i = 0, e = old->GetLength(); i < e; ++i) {
40 now->SetElementPtrSize(i, old->GetElementPtrSize<void*>(i, sizeof(void*)), sizeof(void*));
41 }
42}
43
44} // namespace
45
46} // namespace art