1 /*
2 * Copyright (C) 2016 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 "jni.h"
18
19 #include "gc/gc_cause.h"
20 #include "gc/scoped_gc_critical_section.h"
21 #include "mirror/class-inl.h"
22 #include "runtime.h"
23 #include "scoped_thread_state_change-inl.h"
24 #include "thread_list.h"
25 #include "thread_state.h"
26
27 namespace art {
28
Java_Main_deoptimizeAll(JNIEnv * env,jclass cls)29 extern "C" JNIEXPORT void JNICALL Java_Main_deoptimizeAll(
30 JNIEnv* env,
31 [[maybe_unused]] jclass cls) {
32 ScopedObjectAccess soa(env);
33 ScopedThreadSuspension sts(Thread::Current(), ThreadState::kWaitingForDeoptimization);
34 gc::ScopedGCCriticalSection gcs(Thread::Current(),
35 gc::kGcCauseInstrumentation,
36 gc::kCollectorTypeInstrumentation);
37 // We need to suspend mutator threads first.
38 ScopedSuspendAll ssa(__FUNCTION__);
39 Runtime::Current()->GetInstrumentation()->DeoptimizeEverything("test");
40 }
41
Java_Main_undeoptimizeAll(JNIEnv * env,jclass cls)42 extern "C" JNIEXPORT void JNICALL Java_Main_undeoptimizeAll(
43 JNIEnv* env,
44 [[maybe_unused]] jclass cls) {
45 ScopedObjectAccess soa(env);
46 ScopedThreadSuspension sts(Thread::Current(), ThreadState::kWaitingForDeoptimization);
47 gc::ScopedGCCriticalSection gcs(Thread::Current(),
48 gc::kGcCauseInstrumentation,
49 gc::kCollectorTypeInstrumentation);
50 // We need to suspend mutator threads first.
51 ScopedSuspendAll ssa(__FUNCTION__);
52 Runtime::Current()->GetInstrumentation()->UndeoptimizeEverything("test");
53 }
54
55 } // namespace art
56