diff --git a/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp b/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp index 773bf20..94a8753 100644 --- a/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp +++ b/vm/jitrino/src/translator/java/JavaByteCodeTranslator.cpp @@ -3271,12 +3271,12 @@ uint32 JavaByteCodeTranslator::checkForA if (off >= byteCodeLength) break; // Get array element index - tmpOff = getNumericValue(byteCodes, off, byteCodeLength, newIndex); + tmpOff = getArrayInitValue(byteCodes, off, byteCodeLength, newIndex); if (!tmpOff || ((off += tmpOff) >= byteCodeLength)) break; if (newIndex != (oldIndex++)) break; // Get array element value - tmpOff = getNumericValue(byteCodes, off, byteCodeLength, value); + tmpOff = getArrayInitValue(byteCodes, off, byteCodeLength, value); if (!tmpOff || ((off += tmpOff) >= byteCodeLength)) break; // Store array element @@ -3355,7 +3355,7 @@ uint32 JavaByteCodeTranslator::checkForA return predoff - offset; } -uint32 JavaByteCodeTranslator::getNumericValue(const uint8* byteCodes, uint32 offset, const uint32 byteCodeLength, uint64& value) { +uint32 JavaByteCodeTranslator::getArrayInitValue(const uint8* byteCodes, uint32 offset, const uint32 byteCodeLength, uint64& value) { assert(offset < byteCodeLength); uint32 off = offset; switch (byteCodes[off++]) { @@ -3427,14 +3427,14 @@ uint32 JavaByteCodeTranslator::getNumeri uint32 constPoolIndex = su8(byteCodes + (off++)); // load 32-bit quantity from constant pool Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + if ( !(constantType->isInt4() || constantType->isSingle()) ) { + // only integer and floating-point types + // are implemented for streamed array loads + return 0; + } const void* constantAddress = compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); - if (constantType->isInt4() || constantType->isSingle()) { - value = *(uint32*)constantAddress; - } else { - // Invalid type! - assert(0); - } + value = *(uint32*)constantAddress; } break; case 0x13: // ldc_w @@ -3443,14 +3443,14 @@ uint32 JavaByteCodeTranslator::getNumeri uint32 constPoolIndex = su16(byteCodes + off); // load 32-bit quantity from constant pool Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + if ( !(constantType->isInt4() || constantType->isSingle()) ) { + // only integer and floating-point types + // are implemented for streamed array loads + return 0; + } const void* constantAddress = compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); - if (constantType->isInt4() || constantType->isSingle()) { - value = *(uint32*)constantAddress; - } else { - // Invalid type! - assert(0); - } + value = *(uint32*)constantAddress; } off += 2; break; @@ -3458,16 +3458,16 @@ uint32 JavaByteCodeTranslator::getNumeri { if ((off + 1) >= byteCodeLength) return 0; uint32 constPoolIndex = su16(byteCodes + off); - // load 32-bit quantity from constant pool + // load 64-bit quantity from constant pool Type* constantType = compilationInterface.getConstantType(&methodToCompile,constPoolIndex); + if ( !(constantType->isInt8() || constantType->isDouble()) ) { + // only integer and floating-point types + // are implemented for streamed array loads + return 0; + } const void* constantAddress = compilationInterface.getConstantValue(&methodToCompile,constPoolIndex); - if (constantType->isInt8() || constantType->isDouble()) { - value = *(uint64*)constantAddress; - } else { - // Invalid type! - assert(0); - } + value = *(uint64*)constantAddress; } off += 2; break; diff --git a/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h b/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h index 19b9eca..e26d9ae 100644 --- a/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h +++ b/vm/jitrino/src/translator/java/JavaByteCodeTranslator.h @@ -388,9 +388,9 @@ private: // If they are then substitute array initializers with jit helper array copy instruction. // Returns the length of bytecodes converted by this routine. uint32 checkForArrayInitializer(Opnd* arrayOpnd, const uint8* byteCodes, uint32 offset, const uint32 byteCodeLength); - // Obtain the next numeric value from the bytecode. + // Obtain the next numeric value from the bytecode in array initialization sequence // Returns number of bytes read from the byteCodes array. - uint32 getNumericValue(const uint8* byteCodes, uint32 offset, const uint32 byteCodeLength, uint64& value); + uint32 getArrayInitValue(const uint8* byteCodes, uint32 offset, const uint32 byteCodeLength, uint64& value); // // private fields