Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8247532: Records deserialization is slow
8248135: Build microbenchmarks with --enable-preview

Test contributed by Chris Hegarty <chris.hegarty@oracle.com>

Reviewed-by: chegar, psandoz, redestad, ihse
  • Loading branch information
Peter Levart committed Jun 24, 2020
1 parent 4bcd70a commit 2f09989ec07f5e857c52e5bd2ce67aac1526fe61
Show file tree
Hide file tree
Showing 5 changed files with 970 additions and 68 deletions.
@@ -90,10 +90,11 @@ $(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
TARGET_RELEASE := $(TARGET_RELEASE_NEWJDK_UPGRADED), \
SMALL_JAVA := false, \
CLASSPATH := $(MICROBENCHMARK_CLASSPATH), \
DISABLED_WARNINGS := processing rawtypes cast serial, \
DISABLED_WARNINGS := processing rawtypes cast serial preview, \
SRC := $(MICROBENCHMARK_SRC), \
BIN := $(MICROBENCHMARK_CLASSES), \
JAVA_FLAGS := --add-modules jdk.unsupported --limit-modules java.management, \
JAVAC_FLAGS := --enable-preview, \
))

$(BUILD_JDK_MICROBENCHMARK): $(JMH_COMPILE_JARS)
@@ -2182,7 +2182,7 @@ private Object readOrdinaryObject(boolean unshared)
handles.markException(passHandle, resolveEx);
}

final boolean isRecord = cl != null && isRecord(cl) ? true : false;
final boolean isRecord = cl != null && isRecord(cl);
if (isRecord) {
assert obj == null;
obj = readRecord(desc);
@@ -2289,14 +2289,14 @@ private Object readRecord(ObjectStreamClass desc) throws IOException {

FieldValues fieldValues = defaultReadFields(null, desc);

// retrieve the canonical constructor
MethodHandle ctrMH = desc.getRecordConstructor();

// bind the stream field values
ctrMH = RecordSupport.bindCtrValues(ctrMH, desc, fieldValues);
// get canonical record constructor adapted to take two arguments:
// - byte[] primValues
// - Object[] objValues
// and return Object
MethodHandle ctrMH = RecordSupport.deserializationCtr(desc);

try {
return ctrMH.invoke();
return (Object) ctrMH.invokeExact(fieldValues.primValues, fieldValues.objValues);
} catch (Exception e) {
InvalidObjectException ioe = new InvalidObjectException(e.getMessage());
ioe.initCause(e);

0 comments on commit 2f09989

Please sign in to comment.