Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8261030: Avoid loading GenerateJLIClassesHelper at runtime #2376

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, 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
Expand Down Expand Up @@ -46,7 +46,6 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;

import static java.lang.invoke.GenerateJLIClassesHelper.traceSpeciesType;
import static java.lang.invoke.LambdaForm.*;
import static java.lang.invoke.MethodHandleNatives.Constants.REF_getStatic;
import static java.lang.invoke.MethodHandleNatives.Constants.REF_putStatic;
Expand Down Expand Up @@ -476,8 +475,10 @@ S loadSpecies(S speciesData) {
Class<?> salvage = null;
try {
salvage = BootLoader.loadClassOrNull(className);
traceSpeciesType(className, salvage);
} catch (Error ex) {
// ignore
} finally {
traceSpeciesType(className, salvage);
}
final Class<? extends T> speciesCode;
if (salvage != null) {
Expand All @@ -488,7 +489,6 @@ S loadSpecies(S speciesData) {
// Not pregenerated, generate the class
try {
speciesCode = generateConcreteSpeciesCode(className, speciesData);
traceSpeciesType(className, salvage);
// This operation causes a lot of churn:
linkSpeciesDataToCode(speciesData, speciesCode);
// This operation commits the relation, but causes little churn:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, 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
Expand All @@ -25,7 +25,6 @@

package java.lang.invoke;

import jdk.internal.misc.CDS;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.Opcodes;
import sun.invoke.util.Wrapper;
Expand All @@ -39,10 +38,9 @@
import java.util.TreeSet;
import java.util.stream.Stream;

import static java.lang.invoke.LambdaForm.basicTypeSignature;
import static java.lang.invoke.LambdaForm.shortenSignature;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.MethodHandleStatics.TRACE_RESOLVE;
import static java.lang.invoke.MethodHandleStatics.LF_RESOLVE;
import static java.lang.invoke.MethodHandleStatics.SPECIES_RESOLVE;
import static java.lang.invoke.MethodTypeForm.*;
import static java.lang.invoke.LambdaForm.Kind.*;

Expand All @@ -51,29 +49,6 @@
* generate classes ahead of time.
*/
class GenerateJLIClassesHelper {
private static final String LF_RESOLVE = "[LF_RESOLVE]";
private static final String SPECIES_RESOLVE = "[SPECIES_RESOLVE]";

static void traceLambdaForm(String name, MethodType type, Class<?> holder, MemberName resolvedMember) {
if (TRACE_RESOLVE) {
System.out.println(LF_RESOLVE + " " + holder.getName() + " " + name + " " +
shortenSignature(basicTypeSignature(type)) +
(resolvedMember != null ? " (success)" : " (fail)"));
}
if (CDS.isDumpingClassList()) {
CDS.traceLambdaFormInvoker(LF_RESOLVE, holder.getName(), name, shortenSignature(basicTypeSignature(type)));
}
}

static void traceSpeciesType(String cn, Class<?> salvage) {
if (TRACE_RESOLVE) {
System.out.println(SPECIES_RESOLVE + " " + cn + (salvage != null ? " (salvaged)" : " (generated)"));
}
if (CDS.isDumpingClassList()) {
CDS.traceSpeciesType(SPECIES_RESOLVE, cn);
}
}

// Map from DirectMethodHandle method type name to index to LambdForms
static final Map<String, Integer> DMH_METHOD_TYPE_MAP =
Map.of(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2021, 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
Expand Down Expand Up @@ -46,7 +46,6 @@
import java.util.List;
import java.util.stream.Stream;

import static java.lang.invoke.GenerateJLIClassesHelper.traceLambdaForm;
import static java.lang.invoke.LambdaForm.BasicType;
import static java.lang.invoke.LambdaForm.BasicType.*;
import static java.lang.invoke.LambdaForm.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, 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
Expand All @@ -25,11 +25,15 @@

package java.lang.invoke;

import jdk.internal.misc.CDS;
import jdk.internal.misc.Unsafe;
import sun.security.action.GetPropertyAction;

import java.util.Properties;

import static java.lang.invoke.LambdaForm.basicTypeSignature;
import static java.lang.invoke.LambdaForm.shortenSignature;

/**
* This class consists exclusively of static names internal to the
* method handle implementation.
Expand Down Expand Up @@ -58,6 +62,11 @@ private MethodHandleStatics() { } // do not instantiate
static final int MAX_ARITY;
static final boolean VAR_HANDLE_IDENTITY_ADAPT;

// Markers used by LambdaForm and Species resolution code to communicate
// classes that have been or could have be pre-generated
static final String LF_RESOLVE = "[LF_RESOLVE]";
static final String SPECIES_RESOLVE = "[SPECIES_RESOLVE]";
cl4es marked this conversation as resolved.
Show resolved Hide resolved

static {
Properties props = GetPropertyAction.privilegedGetProperties();
DEBUG_METHOD_HANDLE_NAMES = Boolean.parseBoolean(
Expand Down Expand Up @@ -108,6 +117,27 @@ static boolean debugEnabled() {
LOG_LF_COMPILATION_FAILURE);
}

/*non-public*/
static void traceLambdaForm(String name, MethodType type, Class<?> holder, MemberName resolvedMember) {
cl4es marked this conversation as resolved.
Show resolved Hide resolved
if (TRACE_RESOLVE) {
System.out.println(LF_RESOLVE + " " + holder.getName() + " " + name + " " +
shortenSignature(basicTypeSignature(type)) +
(resolvedMember != null ? " (success)" : " (fail)"));
}
if (CDS.isDumpingClassList()) {
CDS.traceLambdaFormInvoker(LF_RESOLVE, holder.getName(), name, shortenSignature(basicTypeSignature(type)));
}
}

/*non-public*/
static void traceSpeciesType(String cn, Class<?> salvage) {
if (TRACE_RESOLVE) {
System.out.println(SPECIES_RESOLVE + " " + cn + (salvage != null ? " (salvaged)" : " (generated)"));
}
if (CDS.isDumpingClassList()) {
CDS.traceSpeciesType(SPECIES_RESOLVE, cn);
}
}
// handy shared exception makers (they simplify the common case code)
/*non-public*/
static InternalError newInternalError(String message) {
Expand Down