mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-01 19:50:05 +00:00
8378715: Use early field initialization for java.lang.invoke generated code
Reviewed-by: jvernee
This commit is contained in:
parent
aa6c06e166
commit
5e85d99c36
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -746,15 +746,7 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
|
||||
new Consumer<>() {
|
||||
@Override
|
||||
public void accept(CodeBuilder cob) {
|
||||
cob.aload(0); // this
|
||||
|
||||
final List<Var> ctorArgs = AFTER_THIS.fromTypes(superCtorType.parameterList());
|
||||
for (Var ca : ctorArgs) {
|
||||
ca.emitLoadInstruction(cob);
|
||||
}
|
||||
|
||||
// super(ca...)
|
||||
cob.invokespecial(superClassDesc, INIT_NAME, methodDesc(superCtorType));
|
||||
|
||||
// store down fields
|
||||
Var lastFV = AFTER_THIS.lastOf(ctorArgs);
|
||||
@ -766,6 +758,12 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
|
||||
cob.putfield(classDesc, f.name, f.desc);
|
||||
}
|
||||
|
||||
// super(ca...)
|
||||
cob.aload(0); // this
|
||||
for (Var ca : ctorArgs) {
|
||||
ca.emitLoadInstruction(cob);
|
||||
}
|
||||
cob.invokespecial(superClassDesc, INIT_NAME, methodDesc(superCtorType));
|
||||
cob.return_();
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -391,15 +391,15 @@ import sun.invoke.util.Wrapper;
|
||||
new Consumer<>() {
|
||||
@Override
|
||||
public void accept(CodeBuilder cob) {
|
||||
cob.aload(0)
|
||||
.invokespecial(CD_Object, INIT_NAME, MTD_void);
|
||||
int parameterCount = factoryType.parameterCount();
|
||||
for (int i = 0; i < parameterCount; i++) {
|
||||
cob.aload(0)
|
||||
.loadLocal(TypeKind.from(factoryType.parameterType(i)), cob.parameterSlot(i))
|
||||
.putfield(pool.fieldRefEntry(lambdaClassEntry, pool.nameAndTypeEntry(argName(i), argDescs[i])));
|
||||
}
|
||||
cob.return_();
|
||||
cob.aload(0)
|
||||
.invokespecial(CD_Object, INIT_NAME, MTD_void)
|
||||
.return_();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -362,10 +362,8 @@ public final class MethodHandleProxies {
|
||||
|
||||
// <init>(Lookup, MethodHandle target, MethodHandle callerBoundTarget)
|
||||
clb.withMethodBody(INIT_NAME, MTD_void_Lookup_MethodHandle_MethodHandle, 0, cob -> {
|
||||
cob.aload(0)
|
||||
.invokespecial(CD_Object, INIT_NAME, MTD_void)
|
||||
// call ensureOriginalLookup to verify the given Lookup has access
|
||||
.aload(1)
|
||||
// call ensureOriginalLookup to verify the given Lookup has access
|
||||
cob.aload(1)
|
||||
.invokestatic(proxyDesc, ENSURE_ORIGINAL_LOOKUP, MTD_void_Lookup)
|
||||
// this.target = target;
|
||||
.aload(0)
|
||||
@ -383,7 +381,9 @@ public final class MethodHandleProxies {
|
||||
}
|
||||
|
||||
// complete
|
||||
cob.return_();
|
||||
cob.aload(0)
|
||||
.invokespecial(CD_Object, INIT_NAME, MTD_void)
|
||||
.return_();
|
||||
});
|
||||
|
||||
// private static void ensureOriginalLookup(Lookup) checks if the given Lookup
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user