/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {

    public static native void deoptimizeAll();
    public static native void undeoptimizeAll();
    public static native void assertIsInterpreted();
    public static native void assertIsManaged();
    private static native void ensureJitCompiled(Class<?> cls, String methodName);

    public static void main(String[] args) throws Exception {
        System.loadLibrary(args[0]);

        ensureJitCompiled(SimpleLoop.class, "$noinline$busyLoop");
        SimpleLoop.main();

        undeoptimizeAll();
        ensureJitCompiled(FloatLoop.class, "$noinline$busyLoop");
        FloatLoop.main();

        undeoptimizeAll();
        ensureJitCompiled(SimdLoop.class, "$noinline$busyLoop");
        SimdLoop.main();
    }
}
