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