-
Notifications
You must be signed in to change notification settings - Fork 68
7903933: Move sharable items from different generations to a common file #278
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
base: master
Are you sure you want to change the base?
Changes from all commits
583bcf6
fa41fe8
d427310
748bcc9
736ccfb
69d4647
09c7fca
01c8205
532ee1a
5c8802a
e3b9ae2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ final class FunctionalInterfaceBuilder extends ClassSourceBuilder { | |
|
||
private FunctionalInterfaceBuilder(SourceFileBuilder builder, String className, ClassSourceBuilder enclosing, | ||
String runtimeHelperName, Type.Function funcType, boolean isNested) { | ||
super(builder, isNested ? "public static" : "public", Kind.CLASS, className, null, enclosing, runtimeHelperName); | ||
super(builder, isNested ? "public final static" : "public final", Kind.CLASS, className, null, enclosing, runtimeHelperName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in this file seem unrelated? Leftover from other work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was to make the utility classes final, it's somewhat unrelated to this patch but it didn't seem to be worth a separate PR. |
||
this.parameterNames = funcType.parameterNames().map(NameMangler::javaSafeIdentifiers); | ||
this.funcType = funcType; | ||
this.methodType = Utils.methodTypeFor(funcType); | ||
|
@@ -55,7 +55,7 @@ public static void generate(SourceFileBuilder builder, String className, ClassSo | |
fib.appendBlankLine(); | ||
fib.emitDocComment(parentDecl); | ||
fib.classBegin(); | ||
fib.emitDefaultConstructor(); | ||
fib.emitPrivateConstructor(); | ||
String fiName = fib.emitFunctionalInterface(); | ||
fib.emitDescriptorDecl(); | ||
fib.emitFunctionalFactory(fiName); | ||
|
@@ -99,7 +99,7 @@ private void emitInvoke() { | |
boolean needsAllocator = Utils.isStructOrUnion(funcType.returnType()); | ||
String allocParam = needsAllocator ? ", SegmentAllocator alloc" : ""; | ||
String allocArg = needsAllocator ? ", alloc" : ""; | ||
String paramStr = methodType.parameterCount() != 0 ? String.format(",%1$s", paramExprs()) : ""; | ||
String paramStr = methodType.parameterCount() != 0 ? String.format(", %1$s", paramExprs()) : ""; | ||
appendIndentedLines(""" | ||
|
||
private static final MethodHandle DOWN$MH = Linker.nativeLinker().downcallHandle($DESC); | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -351,10 +351,14 @@ void emitFirstHeaderPreamble(List<Options.Library> libraries, boolean useSystemL | |||||||||||||||||
.collect(Collectors.joining(String.format("\n%1$s", indentString(2)), "static final SymbolLookup SYMBOL_LOOKUP = ", ";"))); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
void emitLibaryArena(){appendIndentedLines(""" | ||||||||||||||||||
|
||||||||||||||||||
static final Arena LIBRARY_ARENA = Arena.ofAuto();"""); | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
+354
to
+357
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
void emitRuntimeHelperMethods() { | ||||||||||||||||||
appendIndentedLines(""" | ||||||||||||||||||
|
||||||||||||||||||
static final Arena LIBRARY_ARENA = Arena.ofAuto(); | ||||||||||||||||||
static final boolean TRACE_DOWNCALLS = Boolean.getBoolean("jextract.trace.downcalls"); | ||||||||||||||||||
|
||||||||||||||||||
static void traceDowncall(String name, Object... args) { | ||||||||||||||||||
|
@@ -388,6 +392,26 @@ static MemoryLayout align(MemoryLayout layout, long align) { | |||||||||||||||||
"""); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
void emitBasicPrimitiveTypes(){ | ||||||||||||||||||
appendIndentedLines(""" | ||||||||||||||||||
|
||||||||||||||||||
public static final ValueLayout.OfBoolean C_BOOL = (ValueLayout.OfBoolean) Linker.nativeLinker().canonicalLayouts().get("bool"); | ||||||||||||||||||
public static final ValueLayout.OfByte C_CHAR =(ValueLayout.OfByte)Linker.nativeLinker().canonicalLayouts().get("char"); | ||||||||||||||||||
public static final ValueLayout.OfShort C_SHORT = (ValueLayout.OfShort) Linker.nativeLinker().canonicalLayouts().get("short"); | ||||||||||||||||||
public static final ValueLayout.OfInt C_INT = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get("int"); | ||||||||||||||||||
public static final ValueLayout.OfLong C_LONG_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get("long long"); | ||||||||||||||||||
public static final ValueLayout.OfFloat C_FLOAT = (ValueLayout.OfFloat) Linker.nativeLinker().canonicalLayouts().get("float"); | ||||||||||||||||||
public static final ValueLayout.OfDouble C_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get("double"); | ||||||||||||||||||
public static final AddressLayout C_POINTER = ((AddressLayout) Linker.nativeLinker().canonicalLayouts().get("void*")) | ||||||||||||||||||
.withTargetLayout(MemoryLayout.sequenceLayout(java.lang.Long.MAX_VALUE, C_CHAR)); | ||||||||||||||||||
"""); | ||||||||||||||||||
if (TypeImpl.IS_WINDOWS) { | ||||||||||||||||||
appendIndentedLines("public static final ValueLayout.OfInt C_LONG = (ValueLayout.OfInt) Linker.nativeLinker().canonicalLayouts().get(\"long\");"); | ||||||||||||||||||
appendIndentedLines("public static final ValueLayout.OfDouble C_LONG_DOUBLE = (ValueLayout.OfDouble) Linker.nativeLinker().canonicalLayouts().get(\"double\");"); | ||||||||||||||||||
} else { | ||||||||||||||||||
appendIndentedLines("public static final ValueLayout.OfLong C_LONG = (ValueLayout.OfLong) Linker.nativeLinker().canonicalLayouts().get(\"long\");"); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
private void emitGlobalGetter(String holderClass, String javaName, | ||||||||||||||||||
Declaration.Variable decl, String docHeader) { | ||||||||||||||||||
appendBlankLine(); | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. | ||
* Copyright (c) 2021, 2025, 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 | ||
|
@@ -84,6 +84,11 @@ static IncludeKind fromScoped(Declaration.Scoped scoped) { | |
private final EnumMap<IncludeKind, Set<String>> includesSymbolNamesByKind = new EnumMap<>(IncludeKind.class); | ||
private final Set<Declaration> usedDeclarations = new HashSet<>(); | ||
public String dumpIncludesFile; | ||
public String sharedSymbolsFile; | ||
|
||
public String getSharedSymbolsFile() { | ||
return sharedSymbolsFile; | ||
} | ||
Comment on lines
+87
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhm, I think this should just be in |
||
|
||
public void addSymbol(IncludeKind kind, String symbolName) { | ||
Set<String> names = includesSymbolNamesByKind.computeIfAbsent(kind, (_unused) -> new HashSet<>()); | ||
|
@@ -122,7 +127,7 @@ private boolean isIncludedInternal(IncludeKind kind, Declaration declaration) { | |
if (!isEnabled()) { | ||
return true; | ||
} else { | ||
Set<String> names = includesSymbolNamesByKind.computeIfAbsent(kind, (_unused) -> new HashSet<>()); | ||
Set<String> names = includesSymbolNamesByKind.computeIfAbsent(kind, _unused -> new HashSet<>()); | ||
return names.contains(declaration.name()); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.