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

8294560: assertion raised in newBuiltinSwitchPoint #18

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -2945,10 +2945,7 @@ private List<org.openjdk.nashorn.internal.runtime.Property> extractBuiltinProper
* @param func builtin script object
*/
private void tagBuiltinProperties(final String name, final ScriptObject func) {
SwitchPoint sp = context.getBuiltinSwitchPoint(name);
if (sp == null) {
sp = context.newBuiltinSwitchPoint(name);
}
final SwitchPoint sp = context.getBuiltinSwitchPoint(name);

//get all builtin properties in this builtin object and register switchpoints keyed on the propery name,
//one overwrite destroys all for now, e.g. Function.prototype.apply = 17; also destroys Function.prototype.call etc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static enum FieldMode {
* ever needs this, given the very rare occurrence of swapping out only parts of
* a builtin v.s. the entire builtin object
*/
private final Map<String, SwitchPoint> builtinSwitchPoints = new HashMap<>();
private final Map<String, SwitchPoint> builtinSwitchPoints = new ConcurrentHashMap<>();

/* Force DebuggerSupport to be loaded. */
static {
Expand Down Expand Up @@ -1729,24 +1729,13 @@ public static final class BuiltinSwitchPoint extends SwitchPoint {
}

/**
* Create a new builtin switchpoint and return it
* Return the builtin switchpoint for a particular key name. A new switchpoint
* is atomically created if it doesn't exist yet.
* @param name key name
* @return new builtin switchpoint
*/
public SwitchPoint newBuiltinSwitchPoint(final String name) {
assert builtinSwitchPoints.get(name) == null;
final SwitchPoint sp = new BuiltinSwitchPoint();
builtinSwitchPoints.put(name, sp);
return sp;
}

/**
* Return the builtin switchpoint for a particular key name
* @param name key name
* @return builtin switchpoint or null if none
* @return builtin switchpoint
*/
public SwitchPoint getBuiltinSwitchPoint(final String name) {
return builtinSwitchPoints.get(name);
return builtinSwitchPoints.computeIfAbsent(name, n -> new BuiltinSwitchPoint());
}

private static ClassLoader createModuleLoader(final ClassLoader cl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,6 @@ public static boolean GE(final Object x, final Object y) {
public static void invalidateReservedBuiltinName(final String name) {
final Context context = Context.getContextTrusted();
final SwitchPoint sp = context.getBuiltinSwitchPoint(name);
assert sp != null;
context.getLogger(ApplySpecialization.class).info("Overwrote special name '" + name +"' - invalidating switchpoint");
SwitchPoint.invalidateAll(new SwitchPoint[] { sp });
}
Expand Down