1 /* 2 * Copyright (C) 2023 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 package dalvik.system; 17 18 // [ravenwood] It's in libart, so until we get ART to work, we need to use a fake. 19 // The original is here: 20 // $ANDROID_BUILD_TOP/libcore/libart/src/main/java/dalvik/system/VMRuntime.java 21 22 import com.android.ravenwood.RavenwoodRuntimeState; 23 import com.android.ravenwood.common.JvmWorkaround; 24 25 import java.lang.reflect.Array; 26 27 public class VMRuntime { 28 private static final VMRuntime THE_ONE = new VMRuntime(); 29 VMRuntime()30 private VMRuntime() { 31 } 32 getRuntime()33 public static VMRuntime getRuntime() { 34 return THE_ONE; 35 } 36 is64Bit()37 public boolean is64Bit() { 38 return "amd64".equals(System.getProperty("os.arch")); 39 } 40 is64BitAbi(String abi)41 public static boolean is64BitAbi(String abi) { 42 return abi.contains("64"); 43 } 44 newUnpaddedArray(Class<?> componentType, int minLength)45 public Object newUnpaddedArray(Class<?> componentType, int minLength) { 46 return Array.newInstance(componentType, minLength); 47 } 48 newNonMovableArray(Class<?> componentType, int length)49 public Object newNonMovableArray(Class<?> componentType, int length) { 50 return Array.newInstance(componentType, length); 51 } 52 addressOf(Object obj)53 public long addressOf(Object obj) { 54 return JvmWorkaround.getInstance().addressOf(obj); 55 } 56 getTargetSdkVersion()57 public int getTargetSdkVersion() { 58 return RavenwoodRuntimeState.sTargetSdkLevel; 59 } 60 61 /** Ignored on ravenwood. */ registerNativeAllocation(long bytes)62 public void registerNativeAllocation(long bytes) { 63 } 64 65 /** Ignored on ravenwood. */ registerNativeFree(long bytes)66 public void registerNativeFree(long bytes) { 67 } 68 } 69