From 9d135027091d7d8d6d318ba917e7072b47d241b1 Mon Sep 17 00:00:00 2001 From: "Keith W. Campbell" Date: Tue, 26 Nov 2024 17:53:58 -0500 Subject: [PATCH] Remove stale, unused getConstantPool tests The source files are effectively mostly empty due to `#if 0`, and don't compile if that is changed to `#if 1`. They've essentially been this way since the initial commit of OpenJ9. Signed-off-by: Keith W. Campbell --- runtime/tests/jvmtitests/src/CMakeLists.txt | 3 - .../ibm/jvmti/tests/getConstantPool/gcp001.c | 908 ------------------ .../jvmti/tests/getConstantPool/gcp_bcdump.c | 707 -------------- 3 files changed, 1618 deletions(-) delete mode 100644 runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp001.c delete mode 100644 runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp_bcdump.c diff --git a/runtime/tests/jvmtitests/src/CMakeLists.txt b/runtime/tests/jvmtitests/src/CMakeLists.txt index cf1620b06e5..746eddba73f 100644 --- a/runtime/tests/jvmtitests/src/CMakeLists.txt +++ b/runtime/tests/jvmtitests/src/CMakeLists.txt @@ -73,9 +73,6 @@ j9vm_add_library(jvmti_test_src STATIC com/ibm/jvmti/tests/getClassVersionNumbers/gcvn001.c - com/ibm/jvmti/tests/getConstantPool/gcp001.c - com/ibm/jvmti/tests/getConstantPool/gcp_bcdump.c - com/ibm/jvmti/tests/getCurrentThreadCpuTimerInfo/gctcti001.c com/ibm/jvmti/tests/getHeapFreeTotalMemory/ghftm001.c diff --git a/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp001.c b/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp001.c deleted file mode 100644 index bc0f3a756c1..00000000000 --- a/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp001.c +++ /dev/null @@ -1,908 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 1991 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include - -#if 0 - -#include "j9cfg.h" -#include "j9.h" -#include "j9comp.h" -#include "jbcmap.h" -#include "bcsizes.h" -#include "bcnames.h" -#include "j9port.h" -#include "cfr.h" -#include "cfreader.h" -#include "j9stdarg.h" - -#include "ibmjvmti.h" -#include "rommeth.h" -#include "pcstack.h" - -extern jboolean jvmti11; -J9PortLibrary * PORTLIB = NULL; - -#ifdef J9VM_ENV_LITTLE_ENDIAN -static BOOLEAN bigEndian = FALSE; -#else -static BOOLEAN bigEndian = TRUE; -#endif - - -typedef struct testClassCPDescriptor { - J9CfrConstantPoolInfo *constantPool; - U_16 constantPoolCount; - U_8 * utf8Buf; -} testClassCPDescriptor; - - -typedef struct jvmtiTst_Error { - U_8 * errorMessage; - va_list errorMessageFormat; -} jvmtiTst_Error; - - - -static void JNICALL testGetConstantPool_classLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass); -static I_32 testGetConstantPool_readPool(testClassCPDescriptor *cpDescriptor, U_8* constantPoolBuf, UDATA constantPoolBufSize); -static I_32 testGetConstantPool_checkPool(testClassCPDescriptor *cpDescriptor, U_8* constantPoolBuf); -static I_32 testGetConstantPool_verifyCanonisizeAndCopyUTF8 (U_8 *dest, U_8 *source, U_32 length); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants(testClassCPDescriptor *cpDescriptor, U_8 *bytecodes, U_32 size); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedClass(testClassCPDescriptor *cpDescriptor, U_16 classCpIndex, const char *expectedClassName); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedString(testClassCPDescriptor *cpDescriptor, U_16 stringCpIndex, const char *expectedString); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedUtf8(testClassCPDescriptor *cpDescriptor, U_16 utf8CpIndex, const char *expectedString); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedNameAndSig(testClassCPDescriptor *cpDescriptor, U_16 nasCpIndex, const char *expectedName, const char *expectedSignature); -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedReference(testClassCPDescriptor *cpDescriptor, U_16 refCpIndex, U_8 expectedReferenceType, const char *expectedClassName, const char *expectedName, const char *expectedSignature); - -static jvmtiTst_Error * testGetConstantPool_checkStaticConstants_referedDoubleLong(testClassCPDescriptor *cpDescriptor, U_8 cpItemType, U_16 cpIndex, U_32 expectedValue_hi, U_32 expectedValue_lo); - -#define CHECK_FOR_EOF(nextRead) \ - if((index + (nextRead)) > dataEnd) \ - { \ - errorCode = (U_32)J9NLS_CFR_ERR_UNEXPECTED_EOF__ID; \ - goto _errorFound; \ - } - - -jvmtiTst_Error * -jvmtiTst_ErrorCreate(char *format, ...) -{ - va_list args; - jvmtiTst_Error * error; - - error = j9mem_allocate_memory(sizeof(jvmtiTst_Error), J9MEM_CATEGORY_VM); - if (NULL == error) { - return (jvmtiTst_Error *) 0x1; // TODO: fix this to return a static out of mem struct - } - - error->errorMessage = j9mem_allocate_memory(strlen(format), J9MEM_CATEGORY_VM); - if (NULL == error->errorMessage) { - return (jvmtiTst_Error *) 0x2; // TODO: fix this to return a static out of mem struct - } - - strcpy((char *) error->errorMessage, format); - - va_start(args, format); - COPY_VA_LIST(error->errorMessageFormat, args); - va_end(args); - - - return error; -} - - -void -jvmtiTst_ErrorPrint(jvmtiTst_Error *error) -{ - j9tty_vprintf((const char *) error->errorMessage, error->errorMessageFormat); - j9tty_printf(PORTLIB, "\n"); -} - - -jint -testGetConstantPool (JavaVM * vm, jvmtiEnv * jvmti_env, char *args) -{ - jvmtiEventCallbacks callbacks; - jvmtiCapabilities capabilities; - jvmtiError err; - - if (!jvmti11) { - j9tty_printf(PORTLIB, "Test requires JVMTI 1.1\n"); - return JNI_ERR; - } - - memset(&capabilities, 0, sizeof(jvmtiCapabilities)); - capabilities.can_get_constant_pool = 1; - capabilities.can_get_bytecodes = 1; - err = (*jvmti_env)->AddCapabilities(jvmti_env, &capabilities); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "%s\n", errorName(jvmti_env, NULL, err, "Failed to add capabilities")); - } - - memset(&callbacks, 0, sizeof(jvmtiEventCallbacks)); - callbacks.ClassLoad = testGetConstantPool_classLoad; - err = (*jvmti_env)->SetEventCallbacks(jvmti_env, &callbacks, sizeof(jvmtiEventCallbacks)); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "%s\n", errorName(jvmti_env, NULL, err, "Failed to set callbacks")); - } - - err = (*jvmti_env)->SetEventNotificationMode(jvmti_env, JVMTI_ENABLE, JVMTI_EVENT_CLASS_LOAD, NULL); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "%s\n", errorName(jvmti_env, NULL, err, "Failed to enable class load event notification")); - } - - return JNI_OK; -} - - -/** - * \brief classLoad handler used to intercept loading of the 'testGetConstantPool' test class - * \ingroup GetConstantPool - * - * @param jvmti_env - * @param jni_env - * @param thread - * @param klass - */ -static void JNICALL -testGetConstantPool_classLoad(jvmtiEnv *jvmti_env, JNIEnv* jni_env, jthread thread, jclass klass) -{ - jvmtiError err; - - jint i; - jint constant_pool_count_ptr; - jint constant_pool_byte_count_ptr; - unsigned char* constant_pool_bytes_ptr; - jint methodCount; - jmethodID * methods = NULL; - J9UTF8 *className; - testClassCPDescriptor cpDescriptor; - - jvmtiTst_Error *error; - - /* Ignore all class load events except testGetConstantPool */ - className = J9ROMCLASS_CLASSNAME((*(J9Class **) klass)->romClass); - if (strncmp((const char *) className->data, "testGetConstantPool", className->length)) { - return; - } - - - err = (*jvmti_env)->GetConstantPool(jvmti_env, klass, &constant_pool_count_ptr, &constant_pool_byte_count_ptr, &constant_pool_bytes_ptr); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "%s\n", errorName(jvmti_env, NULL, err, "Failed to obtain constant pool.")); - } - - j9tty_printf(PORTLIB, "\t\t\tConstant Pool [items: %d bytes: %d]:\n" , constant_pool_count_ptr, constant_pool_byte_count_ptr); - /* - for (i = 0; i < constant_pool_byte_count_ptr; ++i) { - j9tty_printf(PORTLIB, " %02X", constant_pool_bytes_ptr[i]); - } - */ - - cpDescriptor.constantPool = j9mem_allocate_memory(constant_pool_count_ptr * sizeof(J9CfrConstantPoolInfo), J9MEM_CATEGORY_VM); - cpDescriptor.constantPoolCount = constant_pool_count_ptr; - cpDescriptor.utf8Buf = j9mem_allocate_memory(constant_pool_byte_count_ptr, J9MEM_CATEGORY_VM); - - - /* Check whether the constant pool is parsable */ - if (testGetConstantPool_readPool(&cpDescriptor, constant_pool_bytes_ptr, constant_pool_byte_count_ptr) != 0) - return; - - /* Check whether the constant pool is logically valid */ - if (testGetConstantPool_checkPool(&cpDescriptor, constant_pool_bytes_ptr) != 0) - return; - - /* Check the method for specific constant initialization bytecodes */ - err = (*jvmti_env)->GetClassMethods(jvmti_env, klass, &methodCount, &methods); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "\t\t%s\n", errorName(jvmti_env, thread, err, "!!! Failed to get methods")); - } else { - jint i; - - for (i = 0; i < methodCount; ++i) { - char *methodName = NULL; - jmethodID method = methods[i]; - jlocation start; - jlocation end; - jint size; - jint bcIndex; - jboolean isNative; - unsigned char * bytecodes; - - err = (*jvmti_env)->GetMethodLocation(jvmti_env, method, &start, &end); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "\t\t\t%s\n", errorName(jvmti_env, thread, err, "!!! Failed to get location")); - goto done; - } - - if (start == -1 || end == -1) - continue; - - err = (*jvmti_env)->IsMethodNative(jvmti_env, method, &isNative); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "\t%s\n", errorName(jvmti_env, thread, err, "!!! Failed to get nativeness")); - goto done; - } - - if (isNative) { - continue; - } - - err = (*jvmti_env)->GetMethodName(jvmti_env, method, &methodName, NULL, NULL); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "\t%s\n", errorName(jvmti_env, thread, err, "!!! Failed to get method name")); - goto done; - } - - if (0 != strcmp(methodName, "")) { - continue; - } - - err = (*jvmti_env)->GetBytecodes(jvmti_env, method, &size, &bytecodes); - if (err != JVMTI_ERROR_NONE) { - j9tty_printf(PORTLIB, "\t\t\t%s\n", errorName(jvmti_env, thread, err, "!!! Failed to get bytecodes")); - goto done; - } - - - error = testGetConstantPool_checkStaticConstants(&cpDescriptor, bytecodes, size); - if (error) { - jvmtiTst_ErrorPrint(error); - goto done; - } - - - j9tty_printf(PORTLIB, "\t\t\tPC range: %d...%d\n", (int) start, (int) end); - j9tty_printf(PORTLIB, "\t\t\tBytecodes [%d]:", size); - for (bcIndex = 0; bcIndex < size; ++bcIndex) { - j9tty_printf(PORTLIB, " %02X", bytecodes[bcIndex]); - } - j9tty_printf(PORTLIB, "\n"); - - maciek_dumpBytecodes(PORTLIB, bytecodes, (int) start, (int) end, BCT_BigEndianOutput); - - (*jvmti_env)->Deallocate(jvmti_env, bytecodes); - } - - } - -done: - if (NULL != constant_pool_bytes_ptr) { - (*jvmti_env)->Deallocate(jvmti_env, (unsigned char *) constant_pool_bytes_ptr); - } - -} - - - -static J9CfrConstantPoolInfo * -getCPInfo(testClassCPDescriptor *cpDescriptor, U_16 cpIndex) -{ - J9CfrConstantPoolInfo *info; - - if (cpIndex > cpDescriptor->constantPoolCount) { - return NULL; - } - - return &cpDescriptor->constantPool[cpIndex]; -} - - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants(testClassCPDescriptor *cpDescriptor, U_8 *bytecodes, U_32 size) -{ - jvmtiTst_Error *error; - J9CfrConstantPoolInfo *info, *info1, *info2; - U_8 *index = bytecodes; - UDATA bytecodeSize; - U_8 bc; - U_8 u8; - U_16 u16; - - /* Expect a load of a Double constant */ - bc = *index++; - if (bc != JBldc2lw) { - return jvmtiTst_ErrorCreate("Expected a ldc2lw bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedDoubleLong(cpDescriptor, CFR_CONSTANT_Double, u16, 0xc28f5c29, 0x3ff028f5); - if (NULL != error) - return error; - - - /* Expect a putstatic of the loaded constant */ - bc = *index++; - if (bc != JBputstatic) { - return jvmtiTst_ErrorCreate("Expected a putstatic bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedReference(cpDescriptor, u16, CFR_CONSTANT_Fieldref, "testGetConstantPool", "testDouble1", "D"); - if (NULL != error) - return error; - - - /* Expect a load of a Double constant */ - bc = *index++; - if (bc != JBldc2lw) { - return jvmtiTst_ErrorCreate("Expected a ldc2lw bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedDoubleLong(cpDescriptor, CFR_CONSTANT_Double, u16, 0xe147ae14, 0x4000147a); - if (NULL != error) - return error; - - - /* Expect a putstatic of the loaded constant */ - bc = *index++; - if (bc != JBputstatic) { - return jvmtiTst_ErrorCreate("Expected a putstatic bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedReference(cpDescriptor, u16, CFR_CONSTANT_Fieldref, "testGetConstantPool", "testDouble2", "D"); - if (NULL != error) - return error; - - - /* Expect a BIPUSH #20 */ - bc = *index++; - if (bc != JBbipush) { - return jvmtiTst_ErrorCreate("Expected a bipush bytecode. Got BC [%d]", bc); - } - NEXT_U8(u8, index); - - if (u8 != 20) { - return jvmtiTst_ErrorCreate("Expected a bipush bytecode that pushes a value of 20. Got [%s]", u8); - } - - /* Expect a putstatic into a field reference */ - NEXT_U8(bc, index); - if (bc != JBputstatic) { - return jvmtiTst_ErrorCreate("Expected a putstatic bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedReference(cpDescriptor, u16, CFR_CONSTANT_Fieldref, "testGetConstantPool", "testInt", "I"); - if (NULL != error) - return error; - - /* Expect a ldc of a String */ - NEXT_U8(bc, index); - if (bc != JBldc) { - return jvmtiTst_ErrorCreate("Expected a ldc bytecode. Got BC [%d]", bc); - } - NEXT_U8(u8, index); - error = testGetConstantPool_checkStaticConstants_referedString(cpDescriptor, (U_16) u8, "testStringContent"); - if (NULL != error) - return error; - - - /* Expect a putstatic into a field reference */ - NEXT_U8(bc, index); - if (bc != JBputstatic) { - return jvmtiTst_ErrorCreate("Expected a putstatic bytecode. Got BC [%d]", bc); - } - NEXT_U16(u16, index); - error = testGetConstantPool_checkStaticConstants_referedReference(cpDescriptor, u16, CFR_CONSTANT_Fieldref, "testGetConstantPool", "testString", "Ljava/lang/String;"); - if (NULL != error) - return error; - - - return NULL; -} - - - - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedClass(testClassCPDescriptor *cpDescriptor, - U_16 classCpIndex, - const char *expectedClassName) -{ - jvmtiTst_Error *error; - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, classCpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a Class constant.", classCpIndex); - } - - if (info->tag != CFR_CONSTANT_Class) { - return jvmtiTst_ErrorCreate("Expected a Class constant type. Got type [%d]", info->tag); - } - - error = testGetConstantPool_checkStaticConstants_referedUtf8(cpDescriptor, info->slot1, expectedClassName); - - return error; -} - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedString(testClassCPDescriptor *cpDescriptor, - U_16 stringCpIndex, - const char *expectedString) -{ - jvmtiTst_Error *error; - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, stringCpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a String constant.", stringCpIndex); - } - - if (info->tag != CFR_CONSTANT_String) { - return jvmtiTst_ErrorCreate("Expected a String constant type. Got type [%d]", info->tag); - } - - error = testGetConstantPool_checkStaticConstants_referedUtf8(cpDescriptor, info->slot1, expectedString); - - return error; -} - - - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedReference(testClassCPDescriptor *cpDescriptor, - U_16 refCpIndex, - U_8 expectedReferenceType, - const char *expectedClassName, - const char *expectedName, - const char *expectedSignature) -{ - jvmtiTst_Error *error; - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, refCpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a Reference constant.", refCpIndex); - } - - if (info->tag != expectedReferenceType) { - return jvmtiTst_ErrorCreate("Expected a Reference constant of type [%d]. Got type [%d]", expectedReferenceType, info->tag); - } - - - error = testGetConstantPool_checkStaticConstants_referedClass(cpDescriptor, info->slot1, expectedClassName); - if (NULL != error) { - return error; - } - - error = testGetConstantPool_checkStaticConstants_referedNameAndSig(cpDescriptor, info->slot2, expectedName, expectedSignature); - if (NULL != error) { - return error; - } - - return NULL; -} - - - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedNameAndSig(testClassCPDescriptor *cpDescriptor, - U_16 nasCpIndex, - const char *expectedName, - const char *expectedSignature) -{ - jvmtiTst_Error *error; - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, nasCpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a NameAndType constant.", nasCpIndex); - } - - error = testGetConstantPool_checkStaticConstants_referedUtf8(cpDescriptor, info->slot1, expectedName); - if (NULL != error) { - return error; - } - - error = testGetConstantPool_checkStaticConstants_referedUtf8(cpDescriptor, info->slot2, expectedSignature); - if (NULL != error) { - return error; - } - - return NULL; -} - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedUtf8(testClassCPDescriptor *cpDescriptor, - U_16 utf8CpIndex, - const char *expectedString) -{ - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, utf8CpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a UTF8 constant.", utf8CpIndex); - } - - if (info->tag != CFR_CONSTANT_Utf8) { - return jvmtiTst_ErrorCreate("Expected a UTF8 constant type. Got type [%d]", info->tag); - } - - if (strcmp((const char *) info->bytes, (const char *) expectedString)) { // info->slot1)) { - return jvmtiTst_ErrorCreate("Expected a UTF8 containing [%s]. Got [%*s]", expectedString, info->slot1, info->bytes); - } - - return NULL; -} - -static jvmtiTst_Error * -testGetConstantPool_checkStaticConstants_referedDoubleLong(testClassCPDescriptor *cpDescriptor, - U_8 cpItemType, - U_16 cpIndex, - U_32 expectedValue_hi, - U_32 expectedValue_lo) -{ - J9CfrConstantPoolInfo *info; - - info = getCPInfo(cpDescriptor, cpIndex); - if (NULL == info) { - return jvmtiTst_ErrorCreate("Invalid Constant Pool index [%d]. Expected a %s constant.", cpIndex, - (cpItemType == CFR_CONSTANT_Double) ? "Double" : "Long"); - } - - if (info->tag != cpItemType) { - return jvmtiTst_ErrorCreate("Expected a %s constant type. Got type [%d]", - (cpItemType == CFR_CONSTANT_Double) ? "Double" : "Long", info->tag); - } - -#ifdef J9VM_ENV_LITTLE_ENDIAN - if (info->slot1 != expectedValue_hi || info->slot2 != expectedValue_lo) { - return jvmtiTst_ErrorCreate("Expected a double value with slot1 [0x%08x] slot2 [0x%08x]. Got slot1: [0x%08x] slot2: [0x%08x]", - expectedValue_hi, expectedValue_lo, - info->slot1, info->slot2); - } -#else - if (info->slot1 != expectedValue_lo || info->slot2 != expectedValue_hi) { - return jvmtiTst_ErrorCreate("Expected a double value with slot1 [0x%08x] slot2 [0x%08x]. Got slot1: [0x%08x] slot2: [0x%08x]", - expectedValue_lo, expectedValue_hi, - info->slot2, info->slot1); - } -#endif - - return NULL; -} - - - - - -static I_32 -testGetConstantPool_readPool(testClassCPDescriptor *cpDescriptor, - U_8* constantPoolBuf, - UDATA constantPoolBufSize) -{ - U_8* dataEnd = constantPoolBuf + constantPoolBufSize; - U_8* index = constantPoolBuf; - U_8* freePointer = cpDescriptor->utf8Buf; - J9CfrConstantPoolInfo* info; - U_32 size, errorCode, offset; - U_32 i; - - /* Explicitly zero the null entry */ - info = &(cpDescriptor->constantPool[0]); - info->tag = CFR_CONSTANT_Null; - info->flags1 = info->flags2 = info->flags3 = 0; - info->slot1 = 0; - info->slot2 = 0; - info->bytes = 0; - info->romAddress = 0; - - /* Read each entry. */ - for (i = 1; i < cpDescriptor->constantPoolCount;) { -// printf("INDEX: 0x%x\n", i); - info = &(cpDescriptor->constantPool[i]); - CHECK_FOR_EOF(1); - NEXT_U8(info->tag, index); - info->flags1 = info->flags2 = info->flags3 = 0; - info->romAddress = 0; - switch (info->tag) { - case CFR_CONSTANT_Utf8: - CHECK_FOR_EOF(2); - NEXT_U16(size, index); - info->slot2 = 0; - - info->bytes = freePointer; - freePointer += size + 1; - - CHECK_FOR_EOF(size); - info->slot1 = (U_32) testGetConstantPool_verifyCanonisizeAndCopyUTF8(info->bytes, index, size); - if ((I_32)info->slot1 < 0) { - errorCode = J9NLS_CFR_ERR_BAD_UTF8__ID; - offset = (U_32) (index - 1); - goto _errorFound; - } - info->bytes[info->slot1] = (U_8) '\0'; -// printf(" utf8: [%*s]\n", size, info->bytes); - /* correct for compression */ - freePointer -= (size - info->slot1); - index += size; - i++; - break; - - case CFR_CONSTANT_Integer: - case CFR_CONSTANT_Float: - CHECK_FOR_EOF(4); - NEXT_U32(info->slot1, index); -// printf(" int/float: 0x%x\n", info->slot1); - info->slot2 = 0; - i++; - break; - - case CFR_CONSTANT_Long: - case CFR_CONSTANT_Double: - CHECK_FOR_EOF(8); -#ifdef J9VM_ENV_LITTLE_ENDIAN - NEXT_U32(info->slot2, index); - NEXT_U32(info->slot1, index); -#else - NEXT_U32(info->slot1, index); - NEXT_U32(info->slot2, index); -#endif - i++; - cpDescriptor->constantPool[i].tag = CFR_CONSTANT_Null; - i++; -// printf(" Long/Double: 0x%x%x\n", info->slot1, info->slot2); - if (i > cpDescriptor->constantPoolCount) { - /* Incomplete long or double constant. This means that n+1 is out of range. */ - errorCode = J9NLS_CFR_ERR_BAD_INDEX__ID; - offset = (U_32) (index - 1); - goto _errorFound; - } - break; - - case CFR_CONSTANT_Class: - case CFR_CONSTANT_String: - CHECK_FOR_EOF(2); - NEXT_U16(info->slot1, index); -// printf(" Class/String: 0x%x\n", info->slot1); - info->slot2 = 0; - i++; - break; - - case CFR_CONSTANT_Fieldref: - case CFR_CONSTANT_Methodref: - case CFR_CONSTANT_InterfaceMethodref: - case CFR_CONSTANT_NameAndType: - CHECK_FOR_EOF(4); - NEXT_U16(info->slot1, index); - NEXT_U16(info->slot2, index); -// printf(" Ref: 0x%04x 0x%04x\n", info->slot1, info->slot2); - i++; - break; - - default: - errorCode = J9NLS_CFR_ERR_UNKNOWN_CONSTANT__ID; - offset = (U_32) (index - 1); - goto _errorFound; - } - } - return 0; - -_errorFound: - - return -1; -} - -static I_32 -testGetConstantPool_checkPool(testClassCPDescriptor *cpDescriptor, U_8* constantPoolBuf) -{ - J9CfrConstantPoolInfo* info; - J9CfrConstantPoolInfo* utf8; - J9CfrConstantPoolInfo* cpBase; - U_32 count, i, errorCode; - U_8* index; - - cpBase = cpDescriptor->constantPool; - count = cpDescriptor->constantPoolCount; - index = constantPoolBuf; - - info = &cpBase[1]; - - for (i = 1; i < count; i++, info++) { - - switch (info->tag) { - - case CFR_CONSTANT_Utf8: - /* Check format? */ - index += info->slot1 + 3; - break; - - case CFR_CONSTANT_Integer: - case CFR_CONSTANT_Float: - index += 5; - break; - - case CFR_CONSTANT_Long: - case CFR_CONSTANT_Double: - index += 9; - i++; - info++; - break; - - case CFR_CONSTANT_Class: - /* Must be a UTF8. */ - if ((!(info->slot1)) || (info->slot1 > count)) { - errorCode = J9NLS_CFR_ERR_BAD_INDEX__ID; - goto _errorFound; - } - - utf8 = &cpBase[info->slot1]; - if (utf8->tag != CFR_CONSTANT_Utf8) { - errorCode = J9NLS_CFR_ERR_BAD_NAME_INDEX__ID; - goto _errorFound; - } - - index += 3; - break; - - case CFR_CONSTANT_String: - /* Must be a UTF8. */ - if ((!(info->slot1)) || (info->slot1 > count)) { - errorCode = CFR_ERR_BAD_INDEX; - goto _errorFound; - } - if (cpBase[info->slot1].tag != CFR_CONSTANT_Utf8) { - errorCode = CFR_ERR_BAD_STRING_INDEX; - goto _errorFound; - } - index += 3; - break; - - case CFR_CONSTANT_Fieldref: - case CFR_CONSTANT_Methodref: - case CFR_CONSTANT_InterfaceMethodref: - if (!(info->slot1) || (info->slot1 > count)) { - errorCode = CFR_ERR_BAD_INDEX; - goto _errorFound; - } - if (cpBase[info->slot1].tag != CFR_CONSTANT_Class) { - errorCode = CFR_ERR_BAD_CLASS_INDEX; - goto _errorFound; - } - - if (!(info->slot1) || (info->slot2 > count)) { - errorCode = CFR_ERR_BAD_INDEX; - goto _errorFound; - } - if (cpBase[info->slot2].tag != CFR_CONSTANT_NameAndType) { - errorCode = CFR_ERR_BAD_NAME_AND_TYPE_INDEX; - goto _errorFound; - } - index += 5; - break; - - case CFR_CONSTANT_NameAndType: - if ((!(info->slot1)) || (info->slot1 > count)) { - errorCode = CFR_ERR_BAD_INDEX; - goto _errorFound; - } - if (cpBase[info->slot1].tag != CFR_CONSTANT_Utf8) { - errorCode = CFR_ERR_BAD_NAME_INDEX; - goto _errorFound; - } - - if ((!(info->slot2)) || (info->slot2 > count)) { - errorCode = CFR_ERR_BAD_INDEX; - goto _errorFound; - } - if (cpBase[info->slot2].tag != CFR_CONSTANT_Utf8) { - errorCode = CFR_ERR_BAD_DESCRIPTOR_INDEX; - goto _errorFound; - } - index += 5; - break; - - default: - errorCode = CFR_ERR_UNKNOWN_CONSTANT; - goto _errorFound; - } - } - - return 0; - -_errorFound: - -// buildError((J9CfrError *) segment, errorCode, CFR_ThrowClassFormatError, (UDATA) (index - poolStart + 10)); - return -1; -} - - -static I_32 -testGetConstantPool_verifyCanonisizeAndCopyUTF8 (U_8 *dest, U_8 *source, U_32 length) -{ - U_8 *originalDest = dest; - U_8 *originalSource = source; - U_8 *sourceEnd = source + length; - UDATA firstByte, nextByte, outWord, charLength, compression = 0; - I_32 result = 0; - - /* Assumes success */ - memcpy (dest, source, length); - - while (source != sourceEnd) { - - /* Handle multibyte */ - if (((UDATA) ((*source++) - 1)) < 0x7F) { - continue; - } - - firstByte = source[-1]; - if (firstByte == 0) { - return -1; - } - - /* if multi-byte then first byte must be 11xxxxxx and more to come */ - if (((firstByte & 0x40) == 0) || (source == sourceEnd)) { - return -1; - } - - charLength = 2; - - nextByte = *source++; - if ((nextByte & 0xC0) != 0x80) { - return -1; - } - - /* Assemble first two bytes */ - /* 0x1F mask is okay for 3-byte codes as legal ones have a 0 bit at 0x10 */ - outWord = ((firstByte & 0x1F) << 6) | (nextByte & 0x3F); - - if ((firstByte & 0x20) != 0) { - /* three bytes */ - if (((firstByte & 0x10) != 0) || (source == sourceEnd)) { - return -1; - } - - charLength = 3; - - nextByte = *source++; - if ((nextByte & 0xC0) != 0x80) { - return -1; - } - - /* Add the third byte */ - outWord = (outWord << 6) | (nextByte & 0x3F); - } - - /* Overwrite the multibyte UTF8 character only if shorter */ - if ((outWord != 0) && (outWord < 0x80)) { - /* One byte must be shorter in here */ - dest = originalDest + (source - originalSource - charLength - compression); - *dest++ = (U_8) outWord; - compression += charLength - 1; - memcpy (dest, source, (UDATA) (sourceEnd - source)); - - } else if ((outWord < 0x800) && (charLength == 3)) { - dest = originalDest + (source - originalSource - charLength - compression); - *dest++ = (U_8) ((outWord >> 6) | 0xC0); - *dest++ = (U_8) ((outWord & 0x3F) | 0x80); - compression++; - memcpy (dest, source, (UDATA) (sourceEnd - source)); - } - } - - result = (I_32) (length - compression); - - return result; -} - -#endif diff --git a/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp_bcdump.c b/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp_bcdump.c deleted file mode 100644 index fa05962e184..00000000000 --- a/runtime/tests/jvmtitests/src/com/ibm/jvmti/tests/getConstantPool/gcp_bcdump.c +++ /dev/null @@ -1,707 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 1991 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ -#if 0 - -#include -#include -#include -#include "cfreader.h" -#include "j9.h" - -#include "pcstack.h" -#include "jbcmap.h" -#include "bcsizes.h" -#include "bcnames.h" -#include "j9port.h" -#include "j9protos.h" -#include "rommeth.h" -//#include "util_internal.h" -//#include "bcdump.h" - - -const char * const maciek_JavaBCNames[] = { -"JBnop" /* 0 */, -"JBaconstnull" /* 1 */, -"JBiconstm1" /* 2 */, -"JBiconst0" /* 3 */, -"JBiconst1" /* 4 */, -"JBiconst2" /* 5 */, -"JBiconst3" /* 6 */, -"JBiconst4" /* 7 */, -"JBiconst5" /* 8 */, -"JBlconst0" /* 9 */, -"JBlconst1" /* 10 */, -"JBfconst0" /* 11 */, -"JBfconst1" /* 12 */, -"JBfconst2" /* 13 */, -"JBdconst0" /* 14 */, -"JBdconst1" /* 15 */, -"JBbipush" /* 16 */, -"JBsipush" /* 17 */, -"JBldc" /* 18 */, -"JBldcw" /* 19 */, -"JBldc2lw" /* 20 */, -"JBiload" /* 21 */, -"JBlload" /* 22 */, -"JBfload" /* 23 */, -"JBdload" /* 24 */, -"JBaload" /* 25 */, -"JBiload0" /* 26 */, -"JBiload1" /* 27 */, -"JBiload2" /* 28 */, -"JBiload3" /* 29 */, -"JBlload0" /* 30 */, -"JBlload1" /* 31 */, -"JBlload2" /* 32 */, -"JBlload3" /* 33 */, -"JBfload0" /* 34 */, -"JBfload1" /* 35 */, -"JBfload2" /* 36 */, -"JBfload3" /* 37 */, -"JBdload0" /* 38 */, -"JBdload1" /* 39 */, -"JBdload2" /* 40 */, -"JBdload3" /* 41 */, -"JBaload0" /* 42 */, -"JBaload1" /* 43 */, -"JBaload2" /* 44 */, -"JBaload3" /* 45 */, -"JBiaload" /* 46 */, -"JBlaload" /* 47 */, -"JBfaload" /* 48 */, -"JBdaload" /* 49 */, -"JBaaload" /* 50 */, -"JBbaload" /* 51 */, -"JBcaload" /* 52 */, -"JBsaload" /* 53 */, -"JBistore" /* 54 */, -"JBlstore" /* 55 */, -"JBfstore" /* 56 */, -"JBdstore" /* 57 */, -"JBastore" /* 58 */, -"JBistore0" /* 59 */, -"JBistore1" /* 60 */, -"JBistore2" /* 61 */, -"JBistore3" /* 62 */, -"JBlstore0" /* 63 */, -"JBlstore1" /* 64 */, -"JBlstore2" /* 65 */, -"JBlstore3" /* 66 */, -"JBfstore0" /* 67 */, -"JBfstore1" /* 68 */, -"JBfstore2" /* 69 */, -"JBfstore3" /* 70 */, -"JBdstore0" /* 71 */, -"JBdstore1" /* 72 */, -"JBdstore2" /* 73 */, -"JBdstore3" /* 74 */, -"JBastore0" /* 75 */, -"JBastore1" /* 76 */, -"JBastore2" /* 77 */, -"JBastore3" /* 78 */, -"JBiastore" /* 79 */, -"JBlastore" /* 80 */, -"JBfastore" /* 81 */, -"JBdastore" /* 82 */, -"JBaastore" /* 83 */, -"JBbastore" /* 84 */, -"JBcastore" /* 85 */, -"JBsastore" /* 86 */, -"JBpop" /* 87 */, -"JBpop2" /* 88 */, -"JBdup" /* 89 */, -"JBdupx1" /* 90 */, -"JBdupx2" /* 91 */, -"JBdup2" /* 92 */, -"JBdup2x1" /* 93 */, -"JBdup2x2" /* 94 */, -"JBswap" /* 95 */, -"JBiadd" /* 96 */, -"JBladd" /* 97 */, -"JBfadd" /* 98 */, -"JBdadd" /* 99 */, -"JBisub" /* 100 */, -"JBlsub" /* 101 */, -"JBfsub" /* 102 */, -"JBdsub" /* 103 */, -"JBimul" /* 104 */, -"JBlmul" /* 105 */, -"JBfmul" /* 106 */, -"JBdmul" /* 107 */, -"JBidiv" /* 108 */, -"JBldiv" /* 109 */, -"JBfdiv" /* 110 */, -"JBddiv" /* 111 */, -"JBirem" /* 112 */, -"JBlrem" /* 113 */, -"JBfrem" /* 114 */, -"JBdrem" /* 115 */, -"JBineg" /* 116 */, -"JBlneg" /* 117 */, -"JBfneg" /* 118 */, -"JBdneg" /* 119 */, -"JBishl" /* 120 */, -"JBlshl" /* 121 */, -"JBishr" /* 122 */, -"JBlshr" /* 123 */, -"JBiushr" /* 124 */, -"JBlushr" /* 125 */, -"JBiand" /* 126 */, -"JBland" /* 127 */, -"JBior" /* 128 */, -"JBlor" /* 129 */, -"JBixor" /* 130 */, -"JBlxor" /* 131 */, -"JBiinc" /* 132 */, -"JBi2l" /* 133 */, -"JBi2f" /* 134 */, -"JBi2d" /* 135 */, -"JBl2i" /* 136 */, -"JBl2f" /* 137 */, -"JBl2d" /* 138 */, -"JBf2i" /* 139 */, -"JBf2l" /* 140 */, -"JBf2d" /* 141 */, -"JBd2i" /* 142 */, -"JBd2l" /* 143 */, -"JBd2f" /* 144 */, -"JBi2b" /* 145 */, -"JBi2c" /* 146 */, -"JBi2s" /* 147 */, -"JBlcmp" /* 148 */, -"JBfcmpl" /* 149 */, -"JBfcmpg" /* 150 */, -"JBdcmpl" /* 151 */, -"JBdcmpg" /* 152 */, -"JBifeq" /* 153 */, -"JBifne" /* 154 */, -"JBiflt" /* 155 */, -"JBifge" /* 156 */, -"JBifgt" /* 157 */, -"JBifle" /* 158 */, -"JBificmpeq" /* 159 */, -"JBificmpne" /* 160 */, -"JBificmplt" /* 161 */, -"JBificmpge" /* 162 */, -"JBificmpgt" /* 163 */, -"JBificmple" /* 164 */, -"JBifacmpeq" /* 165 */, -"JBifacmpne" /* 166 */, -"JBgoto" /* 167 */, -"JBunimplemented" /* 168 */, -"JBunimplemented" /* 169 */, -"JBtableswitch" /* 170 */, -"JBlookupswitch" /* 171 */, -"JBreturn0" /* 172 */, -"JBreturn1" /* 173 */, -"JBreturn2" /* 174 */, -"JBsyncReturn0" /* 175 */, -"JBsyncReturn1" /* 176 */, -"JBsyncReturn2" /* 177 */, -"JBgetstatic" /* 178 */, -"JBputstatic" /* 179 */, -"JBgetfield" /* 180 */, -"JBputfield" /* 181 */, -"JBinvokevirtual" /* 182 */, -"JBinvokespecial" /* 183 */, -"JBinvokestatic" /* 184 */, -"JBinvokeinterface" /* 185 */, -"JBunimplemented" /* 186 */, -"JBnew" /* 187 */, -"JBnewarray" /* 188 */, -"JBanewarray" /* 189 */, -"JBarraylength" /* 190 */, -"JBathrow" /* 191 */, -"JBcheckcast" /* 192 */, -"JBinstanceof" /* 193 */, -"JBmonitorenter" /* 194 */, -"JBmonitorexit" /* 195 */, -"JBunimplemented" /* 196 */, -"JBmultianewarray" /* 197 */, -"JBifnull" /* 198 */, -"JBifnonnull" /* 199 */, -"JBgotow" /* 200 */, -"JBunimplemented" /* 201 */, -"JBbreakpoint" /* 202 */, -"JBiloadw" /* 203 */, -"JBlloadw" /* 204 */, -"JBfloadw" /* 205 */, -"JBdloadw" /* 206 */, -"JBaloadw" /* 207 */, -"JBistorew" /* 208 */, -"JBlstorew" /* 209 */, -"JBfstorew" /* 210 */, -"JBdstorew" /* 211 */, -"JBastorew" /* 212 */, -"JBiincw" /* 213 */, -"JBunimplemented" /* 214 */, -"JBaload0getfield" /* 215 */, -"JBunimplemented" /* 216 */, -"JBunimplemented" /* 217 */, -"JBunimplemented" /* 218 */, -"JBunimplemented" /* 219 */, -"JBunimplemented" /* 220 */, -"JBunimplemented" /* 221 */, -"JBunimplemented" /* 222 */, -"JBunimplemented" /* 223 */, -"JBunimplemented" /* 224 */, -"JBunimplemented" /* 225 */, -"JBunimplemented" /* 226 */, -"JBunimplemented" /* 227 */, -"JBreturnFromConstructor" /* 228 */, -"JBgenericReturn" /* 229 */, -"JBunimplemented" /* 230 */, -"JBinvokeinterface2" /* 231 */, -"JBunimplemented" /* 232 */, -"JBunimplemented" /* 233 */, -"JBunimplemented" /* 234 */, -"JBunimplemented" /* 235 */, -"JBreturnC" /* 236 */, -"JBreturnS" /* 237 */, -"JBreturnB" /* 238 */, -"JBreturnZ" /* 239 */, -"JBunimplemented" /* 240 */, -"JBunimplemented" /* 241 */, -"JBunimplemented" /* 242 */, -"JBreturnToMicroJIT" /* 243 */, -"JBretFromNative0" /* 244 */, -"JBretFromNative1" /* 245 */, -"JBretFromNativeF" /* 246 */, -"JBretFromNativeD" /* 247 */, -"JBretFromNativeJ" /* 248 */, -"JBldc2dw" /* 249 */, -"JBasyncCheck" /* 250 */, -"JBunimplemented" /* 251 */, -"JBunimplemented" /* 252 */, -"JBunimplemented" /* 253 */, -"JBimpdep1" /* 254 */, -"JBimpdep2" /* 255 */ -}; - -#define CF_ALLOC_INCREMENT 4096 -#define OPCODE_RELATIVE_BRANCHES 1 - -typedef void (*DISASSEMBLY_PRINT_FN)(void *userData, char *format, ...); - -static void maciek_cfdumpBytecodePrintFunction(void *userData, char *format, ...); - - - -#define _NEXT_LE_U16(value, index) ((value = (U_16)index[0] | ((U_16)index[1] << 8)), index += 2, value) -#define _NEXT_LE_U32(value, index) ((value = (U_32)index[0] | ((U_32)index[1] << 8) | ((U_32)index[2] << 16) | ((U_32)index[3] << 24)), index += 4, value) -#define _NEXT_BE_U16(value, index) ((value = ((U_16)index[0] << 8) | index[1]), index += 2, value) -#define _NEXT_BE_U32(value, index) ((value = ((U_32)index[0] << 24) | ((U_32)index[1] << 16) | ((U_32)index[2] << 8) | (U_32)index[3]), index += 4, value) - -#define _GETNEXT_U8(value, index) (value = *(index++)) - -#define _GETNEXT_U16(value, index) \ - if (bigEndian) { \ - _NEXT_BE_U16(value, index); \ - } else { \ - _NEXT_LE_U16(value, index); \ - } \ - -#define _GETNEXT_U32(value, index) \ - if (bigEndian) { \ - _NEXT_BE_U32(value, index); \ - } else { \ - _NEXT_LE_U32(value, index); \ - } \ - -#define UTF_MAX_LENGTH 128 -#define DUMP_UTF(val) \ - outputFunction(userData, \ - ((((J9UTF8*)(val))->length > UTF_MAX_LENGTH) ? "%.*s..." : "%.*s"), \ - ((((J9UTF8*)(val))->length > UTF_MAX_LENGTH) ? UTF_MAX_LENGTH : ((J9UTF8*)(val))->length), \ - (((char *)(val))+2)) - - -IDATA -maciek_j9bcutil_dumpBytecodes(J9PortLibrary * portLib, U_8 * bytecodes, UDATA walkStartPC, UDATA walkEndPC, - UDATA flags, void *printFunction, void *userData, char *indent) -{ - PORT_ACCESS_FROM_PORT(portLib); - DISASSEMBLY_PRINT_FN outputFunction = (DISASSEMBLY_PRINT_FN) printFunction; - - I_32 i; - U_8 *bcIndex; - I_32 pc, index, target, start; - I_32 low, high; - U_32 npairs; - U_8 bc; - U_32 bigEndian = flags & BCT_BigEndianOutput; - - pc = walkStartPC; - - - bcIndex = &bytecodes[pc]; - while ((U_32) pc <= walkEndPC) { - _GETNEXT_U8(bc, bcIndex); - outputFunction(userData, "%s%5i %s ", indent, pc, maciek_JavaBCNames[bc]); - start = pc; - pc++; - switch (bc) { - case JBbipush: - _GETNEXT_U8(index, bcIndex); - outputFunction(userData, "%i\n", (I_8) index); - pc++; - break; - - case JBsipush: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i\n", (I_16) index); - pc += 2; - break; - - case JBldc: - case JBldcw: - if (bc == JBldc) { - _GETNEXT_U8(index, bcIndex); - pc++; - } else { - _GETNEXT_U16(index, bcIndex); - pc += 2; - } - outputFunction(userData, "%i \n", index); - break; - - case JBldc2lw: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i \n", index); -#if 0 - info = &constantPool[index]; - outputFunction(userData, "(long) 0x%08X%08X\n", - bigEndian ? info->slot1 : info->slot2, - bigEndian ? info->slot2 : info->slot1); -#endif - pc += 2; - break; - - case JBldc2dw: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i \n", index); -#if 0 - info = &constantPool[index]; - /* this will print incorrectly on Linux ARM! FIX ME! */ - outputFunction(userData, "(double) 0x%08X%08X\n", - bigEndian ? info->slot1 : info->slot2, - bigEndian ? info->slot2 : info->slot1); -#endif - pc += 2; - break; - - case JBiload: - case JBlload: - case JBfload: - case JBdload: - case JBaload: - case JBistore: - case JBlstore: - case JBfstore: - case JBdstore: - case JBastore: - _GETNEXT_U8(index, bcIndex); - pc++; - outputFunction(userData, "%i\n", index); - break; - - case JBiloadw: - case JBlloadw: - case JBfloadw: - case JBdloadw: - case JBaloadw: - case JBistorew: - case JBlstorew: - case JBfstorew: - case JBdstorew: - case JBastorew: - _GETNEXT_U16(index, bcIndex); - bcIndex++; - pc += 3; - outputFunction(userData, "%i\n", index); - break; - - case JBiinc: - _GETNEXT_U8(index, bcIndex); - outputFunction(userData, "%i ", index); - _GETNEXT_U8(target, bcIndex); - outputFunction(userData, "%i\n", (I_8) target); - pc += 2; - break; - - case JBiincw: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i ", index); - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i\n", (I_16) index); - bcIndex++; - pc += 5; - break; - - case JBifeq: - case JBifne: - case JBiflt: - case JBifge: - case JBifgt: - case JBifle: - case JBificmpeq: - case JBificmpne: - case JBificmplt: - case JBificmpge: - case JBificmpgt: - case JBificmple: - case JBifacmpeq: - case JBifacmpne: - case JBgoto: - case JBifnull: - case JBifnonnull: - _GETNEXT_U16(index, bcIndex); - pc += 2; -#if OPCODE_RELATIVE_BRANCHES - target = start + (I_16) index; -#else - target = pc + (I_16) index; -#endif - outputFunction(userData, "%i\n", target); - break; - - case JBtableswitch: - switch (start % 4) { - case 0: - bcIndex++; - pc++; - case 1: - bcIndex++; - pc++; - case 2: - bcIndex++; - pc++; - case 3: - break; - } - _GETNEXT_U32(index, bcIndex); - target = start + index; - _GETNEXT_U32(index, bcIndex); - low = (I_32) index; - _GETNEXT_U32(index, bcIndex); - high = (I_32) index; - pc += 12; - outputFunction(userData, "low %i high %i\n", low, high); - outputFunction(userData, " default %10i\n", target); - npairs = high - low + 1; - for (i = 0; i < (I_32) npairs; i++) { - _GETNEXT_U32(index, bcIndex); - target = start + index; - outputFunction(userData, " %10i %10i\n", i + low, target); - pc += 4; - } - break; - - case JBlookupswitch: - switch (start % 4) { - case 0: - bcIndex++; - pc++; - case 1: - bcIndex++; - pc++; - case 2: - bcIndex++; - pc++; - case 3: - break; - } - _GETNEXT_U32(index, bcIndex); - target = start + index; - _GETNEXT_U32(npairs, bcIndex); - outputFunction(userData, "pairs %i\n", npairs); - outputFunction(userData, " default %10i\n", target); - pc += 8; - for (i = 0; i < (I_32) npairs; i++) { - _GETNEXT_U32(index, bcIndex); - outputFunction(userData, " %10i", index); - _GETNEXT_U32(index, bcIndex); - target = start + index; - outputFunction(userData, " %10i\n", target); - pc += 8; - } - break; - - case JBgetstatic: - case JBputstatic: - case JBgetfield: - case JBputfield: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i \n", index); -#if 0 - info = &constantPool[index]; - DUMP_UTF(J9ROMCLASSREF_NAME((J9ROMClassRef *) &constantPool[((J9ROMFieldRef *) info)->classRefCPIndex])); /* dump declaringClassName */ - nameAndSig = J9ROMFIELDREF_NAMEANDSIGNATURE((J9ROMFieldRef *) info); - outputFunction(userData, "."); - DUMP_UTF(J9ROMNAMEANDSIGNATURE_NAME(nameAndSig)); /* dump name */ - outputFunction(userData, " "); - DUMP_UTF(J9ROMNAMEANDSIGNATURE_SIGNATURE(nameAndSig)); /* dump signature */ - outputFunction(userData, "\n"); -#endif - pc += 2; - break; - - case JBinvokevirtual: - case JBinvokespecial: - case JBinvokestatic: - case JBinvokeinterface: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i \n", index); -#if 0 - info = &constantPool[index]; - DUMP_UTF(J9ROMCLASSREF_NAME((J9ROMClassRef *) &constantPool[((J9ROMMethodRef *) info)->classRefCPIndex])); /* dump declaringClassName */ - nameAndSig = J9ROMMETHODREF_NAMEANDSIGNATURE((J9ROMMethodRef *) info); - outputFunction(userData, "."); - DUMP_UTF(J9ROMNAMEANDSIGNATURE_NAME(nameAndSig)); /* dump name */ - DUMP_UTF(J9ROMNAMEANDSIGNATURE_SIGNATURE(nameAndSig)); /* dump signature */ - outputFunction(userData, "\n"); -#endif - pc += 2; - break; - - case JBnew: - case JBanewarray: - case JBcheckcast: - case JBinstanceof: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i \n", index); -#if 0 - info = &constantPool[index]; - DUMP_UTF(J9ROMSTRINGREF_UTF8DATA((J9ROMStringRef *) info)); /* dump name */ - outputFunction(userData, "\n"); -#endif - pc += 2; - break; - - case JBnewarray: - _GETNEXT_U8(index, bcIndex); - switch (index) { - case /* T_BOOLEAN */ 4: - outputFunction(userData, "boolean\n"); - break; - case /* T_CHAR */ 5: - outputFunction(userData, "char\n"); - break; - case /* T_FLOAT */ 6: - outputFunction(userData, "float\n"); - break; - case /* T_DOUBLE */ 7: - outputFunction(userData, "double\n"); - break; - case /* T_BYTE */ 8: - outputFunction(userData, "byte\n"); - break; - case /* T_SHORT */ 9: - outputFunction(userData, "short\n"); - break; - case /* T_INT */ 10: - outputFunction(userData, "int\n"); - break; - case /* T_LONG */ 11: - outputFunction(userData, "long\n"); - break; - default: - outputFunction(userData, "(unknown type %i)\n", index); - break; - } - pc++; - break; - - case JBmultianewarray: - _GETNEXT_U16(index, bcIndex); - outputFunction(userData, "%i ", index); - _GETNEXT_U8(index, bcIndex); - outputFunction(userData, "dims %i \n", index); -#if 0 - info = &constantPool[index]; - DUMP_UTF(J9ROMSTRINGREF_UTF8DATA((J9ROMStringRef *) info)); /* dump name */ - outputFunction(userData, "\n"); -#endif - pc += 3; - break; - - case JBgotow: - _GETNEXT_U32(index, bcIndex); - pc += 4; -#if OPCODE_RELATIVE_BRANCHES - target = start + index; -#else - target = pc + index; -#endif - outputFunction(userData, "%i\n", target); - break; - - default: - outputFunction(userData, "\n"); - break; - } - } - return BCT_ERR_NO_ERROR; - -#undef _NEXT_U8 -#undef _NEXT_LE_U16 -#undef _NEXT_LE_U32 -#undef _NEXT_BE_U16 -#undef _NEXT_BE_U32 -#undef _GETNEXT_U8 -#undef _GETNEXT_U16 -#undef _GETNEXT_U32 -#undef DUMP_UTF8 -#undef UTF_MAX_LENGTH -} - - - -I_32 maciek_dumpBytecodes(J9PortLibrary * portLib, U_8 * bytecodes, UDATA walkStartPC, UDATA walkEndPC, UDATA flags) -{ - return maciek_j9bcutil_dumpBytecodes(portLib, bytecodes, walkStartPC, walkEndPC, - flags, (void *) maciek_cfdumpBytecodePrintFunction, portLib, ""); -} - - - -static void maciek_cfdumpBytecodePrintFunction(void *userData, char *format, ...) -{ - J9PortLibrary *portLib = (J9PortLibrary *) userData; - va_list args; - char outputBuffer[512]; - PORT_ACCESS_FROM_PORT(portLib); - - va_start(args, format); - j9str_vprintf(PORTLIB, outputBuffer, 512, format, args); - va_end(args); - - j9tty_printf(PORTLIB, "%s", outputBuffer); -} - -#else - -/* to avoid warnings */ -void gcp_bcdump_stub(void) { -} - -#endif