diff --git a/build.sc b/build.sc index 476d4196..d8fdce3d 100644 --- a/build.sc +++ b/build.sc @@ -22,7 +22,7 @@ object v { object scoverage extends BaseModule with ScoverageReport trait BaseModule extends ScoverageModule with ScalafmtModule { - def scalaVersion = "3.2.2" + def scalaVersion = "3.3.0-RC2" def scoverageVersion = "2.0.7" val munitVersion = "1.0.0-M6" @@ -46,7 +46,6 @@ trait BaseModule extends ScoverageModule with ScalafmtModule { "-source:future", "-Ykind-projector", "-Vprofile" - //"-Ycc" ) trait BaseTest extends ScoverageTests with TestModule.Munit { diff --git a/core/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarkShape.scala b/core/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarkShape.scala index 3ec22112..89dcacb6 100644 --- a/core/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarkShape.scala +++ b/core/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarkShape.scala @@ -1,12 +1,13 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} +import org.openjdk.jmh.annotations.{Scope as _, *} import java.util.concurrent.TimeUnit -import fr.hammons.slinc.Scope import scala.util.Random +import scala.annotation.nowarn case class div_t(quot: Int, rem: Int) + +@nowarn("msg=unused explicit parameter") trait BindingsBenchmarkShape(val s: Slinc): import scala.language.unsafeNulls import s.{given, *} diff --git a/core/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarkShape.scala b/core/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarkShape.scala index 7acc6d9a..ec431f4b 100644 --- a/core/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarkShape.scala +++ b/core/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarkShape.scala @@ -1,10 +1,6 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} -import java.util.concurrent.TimeUnit -import fr.hammons.slinc.Scope -import scala.annotation.experimental +import org.openjdk.jmh.annotations.{Scope as _, *} case class A(a: Int, b: B, c: Int) case class B(a: Int, b: Int) diff --git a/core/src/fr/hammons/slinc/Allocator.scala b/core/src/fr/hammons/slinc/Allocator.scala index 074e744a..c639e52a 100644 --- a/core/src/fr/hammons/slinc/Allocator.scala +++ b/core/src/fr/hammons/slinc/Allocator.scala @@ -1,6 +1,5 @@ package fr.hammons.slinc -import fr.hammons.slinc.ScopeI.PlatformSpecific import java.lang.invoke.{MethodHandle, MethodType, MethodHandles} import fr.hammons.slinc.modules.DescriptorModule diff --git a/core/src/fr/hammons/slinc/Bytes.scala b/core/src/fr/hammons/slinc/Bytes.scala index fff1275f..a9076973 100644 --- a/core/src/fr/hammons/slinc/Bytes.scala +++ b/core/src/fr/hammons/slinc/Bytes.scala @@ -1,6 +1,6 @@ package fr.hammons.slinc -import scala.quoted.{ToExpr, Expr, Quotes} +import scala.quoted.{ToExpr, Quotes} opaque type Bytes = Long diff --git a/core/src/fr/hammons/slinc/DescriptorOf.scala b/core/src/fr/hammons/slinc/DescriptorOf.scala index 3a5b1e69..5ea5e4c9 100644 --- a/core/src/fr/hammons/slinc/DescriptorOf.scala +++ b/core/src/fr/hammons/slinc/DescriptorOf.scala @@ -2,6 +2,7 @@ package fr.hammons.slinc import fr.hammons.slinc.container.* import scala.quoted.* +import scala.annotation.nowarn /** Typeclass that summons TypeDescriptors */ @@ -51,6 +52,8 @@ object DescriptorOf: given [A]: DescriptorOf[Ptr[A]] = ptrDescriptor.asInstanceOf[DescriptorOf[Ptr[A]]] + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def getDescriptorFor[A](using Quotes, Type[A]) = import quotes.reflect.* val expr = Expr diff --git a/core/src/fr/hammons/slinc/Fn.scala b/core/src/fr/hammons/slinc/Fn.scala index 39d7a832..a4fca9da 100644 --- a/core/src/fr/hammons/slinc/Fn.scala +++ b/core/src/fr/hammons/slinc/Fn.scala @@ -1,12 +1,9 @@ package fr.hammons.slinc -import scala.annotation.targetName import scala.quoted.* -import scala.util.TupledFunction -import scala.annotation.experimental import scala.util.chaining.* import fr.hammons.slinc.modules.TransitionModule -import java.lang.invoke.TypeDescriptor +import scala.annotation.nowarn trait Fn[F, Inputs <: Tuple, Output]: type Function = F @@ -28,6 +25,7 @@ object Fn: toNativeCompatibleImpl('a) } + @nowarn def toNativeCompatibleImpl[A](a: Expr[A])(using Quotes, Type[A]): Expr[A] = import quotes.reflect.* val typeArgs = TypeRepr.of[A].typeArgs diff --git a/core/src/fr/hammons/slinc/FunctionDescriptor.scala b/core/src/fr/hammons/slinc/FunctionDescriptor.scala index dd073086..ee104f1f 100644 --- a/core/src/fr/hammons/slinc/FunctionDescriptor.scala +++ b/core/src/fr/hammons/slinc/FunctionDescriptor.scala @@ -3,6 +3,7 @@ package fr.hammons.slinc import scala.quoted.* import fr.hammons.slinc.modules.DescriptorModule import java.lang.invoke.MethodType +import scala.annotation.nowarn final case class FunctionDescriptor( inputDescriptors: Seq[TypeDescriptor], @@ -41,6 +42,9 @@ final case class FunctionDescriptor( object FunctionDescriptor: // grabs a description of a method from its definition. Ignores Seq[Variadic] arguments. + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") def fromDefDef(using q: Quotes)(symbol: q.reflect.Symbol) = import quotes.reflect.* val (inputRefs, outputType) = MacroHelpers.getInputsAndOutputType(symbol) @@ -70,6 +74,9 @@ object FunctionDescriptor: fromFunctionImpl[A] } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") private[slinc] def fromFunctionImpl[A](using Quotes, Type[A]) = val (inputTypes, outputType) = MacroHelpers.getInputTypesAndOutputTypes[A] diff --git a/core/src/fr/hammons/slinc/JitManager.scala b/core/src/fr/hammons/slinc/JitManager.scala index cec46f33..83166325 100644 --- a/core/src/fr/hammons/slinc/JitManager.scala +++ b/core/src/fr/hammons/slinc/JitManager.scala @@ -1,29 +1,24 @@ package fr.hammons.slinc import Fn.andThen -import scala.compiletime.uninitialized import java.util.concurrent.atomic.AtomicReference import scala.quoted.staging.* import java.util.concurrent.Executors -import scala.concurrent.Promise import java.util.concurrent.atomic.AtomicBoolean import scala.concurrent.ExecutionContext import scala.quoted.{Quotes, Expr} import scala.concurrent.Future import scala.concurrent.duration.* -import scala.util.Failure.apply import scala.util.Failure -import java.util.concurrent.atomic.AtomicMarkableReference import java.util.concurrent.atomic.AtomicInteger -import scala.reflect.ClassTag type JitCompiler = [A] => ((Quotes) ?=> Expr[A]) => A object NoJitManager extends JitManager: - def jitc[F, Input <: Tuple, Output]( + override def jitc[F, Input <: Tuple, Output]( lowSpeed: F, highSpeed: JitCompiler => F, atomicRef: F => Unit - )(using f: Fn[F, Input, Output]): Unit = atomicRef(lowSpeed) + )(using Fn[F, Input, Output]): Unit = atomicRef(lowSpeed) def jitNow(): Unit = () @@ -32,11 +27,11 @@ class InstantJitManager(compiler: Compiler) extends JitManager: override def jitNow(): Unit = ??? given Compiler = compiler - def jitc[F, Input <: Tuple, Output]( + override def jitc[F, Input <: Tuple, Output]( lowSpeed: F, highSpeed: JitCompiler => F, atomicRef: F => Unit - )(using f: Fn[F, Input, Output]): Unit = atomicRef( + )(using Fn[F, Input, Output]): Unit = atomicRef( highSpeed([A] => (fn: ((Quotes) ?=> Expr[A])) => run(fn)) ) trait JitManager: diff --git a/core/src/fr/hammons/slinc/LibraryI.scala b/core/src/fr/hammons/slinc/LibraryI.scala index 9906407d..a108491f 100644 --- a/core/src/fr/hammons/slinc/LibraryI.scala +++ b/core/src/fr/hammons/slinc/LibraryI.scala @@ -2,8 +2,9 @@ package fr.hammons.slinc import scala.quoted.* import java.lang.invoke.MethodHandle -import scala.annotation.nowarn import fr.hammons.slinc.modules.TransitionModule +import scala.compiletime.asMatchable +import scala.annotation.nowarn class LibraryI(platformSpecific: LibraryI.PlatformSpecific): trait Library[+L]: @@ -35,6 +36,8 @@ object LibraryI: def getStandardLibLookup: Lookup def getResourceLibLookup(location: String): Lookup + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused local definition") def checkMethodIsCompatible(using q: Quotes)(s: q.reflect.Symbol): Unit = import quotes.reflect.* @@ -84,15 +87,16 @@ object LibraryI: } - @nowarn def getReturnType(using q: Quotes)(s: quotes.reflect.Symbol) = import quotes.reflect.* if s.isDefDef then - s.typeRef.translucentSuperType match + s.typeRef.translucentSuperType.asMatchable match case TypeLambda(_, _, ret: LambdaType) => ret.resType case ret: LambdaType => ret.resType else report.errorAndAbort("This symbol isn't a method!") + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused local definition") def needsAllocator(using q: Quotes)(s: q.reflect.Symbol): Boolean = import quotes.reflect.* @@ -101,6 +105,10 @@ object LibraryI: true case _ => false + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") + @nowarn("msg=unused explicit parameter") def bindingImpl[R, L[_] <: LibraryI#Library[?]](using q: Quotes)(using Type[R], Type[L] @@ -160,7 +168,6 @@ object LibraryI: $transitionModule.methodArgument($desc.descriptor, $expr, alloc) } } - val rTransition: Expr[Object | Null => R] = Type.of[R] match case '[Unit] => '{ (obj: Object | Null) => () }.asExprOf[Object | Null => R] @@ -245,6 +252,8 @@ object LibraryI: ) code + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused local definition") def getLibrary[L[_]](using q: Quotes)(using Type[L])( owningClass: q.reflect.Symbol ): Expr[L[Any]] = @@ -263,10 +272,11 @@ object LibraryI: getLookupImpl[L]('platformSpecific) } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def getLookupImpl[L]( platformSpecificExpr: Expr[PlatformSpecific] )(using Quotes, Type[L]) = - import quotes.reflect.* val name: LibraryLocation = LibraryName.libraryName[L] name match case LibraryLocation.Standardard => @@ -282,6 +292,8 @@ object LibraryI: getMethodAddressImpl[L]('l) } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def getMethodAddressImpl[L](l: Expr[Lookup])(using Quotes, Type[L]) = import quotes.reflect.* diff --git a/core/src/fr/hammons/slinc/Lookup.scala b/core/src/fr/hammons/slinc/Lookup.scala index dfd2d7f9..7fa2c7cc 100644 --- a/core/src/fr/hammons/slinc/Lookup.scala +++ b/core/src/fr/hammons/slinc/Lookup.scala @@ -1,6 +1,5 @@ package fr.hammons.slinc -import java.nio.file.Path import java.nio.file.Paths trait Lookup(libraryLocation: LibraryLocation): diff --git a/core/src/fr/hammons/slinc/MethodHandleTools.scala b/core/src/fr/hammons/slinc/MethodHandleTools.scala index 808cc66f..2665558e 100644 --- a/core/src/fr/hammons/slinc/MethodHandleTools.scala +++ b/core/src/fr/hammons/slinc/MethodHandleTools.scala @@ -3,8 +3,8 @@ package fr.hammons.slinc import scala.quoted.* import java.lang.invoke.MethodHandle import scala.compiletime.asMatchable -import fr.hammons.slinc.modules.DescriptorModule import fr.hammons.slinc.modules.TransitionModule +import scala.annotation.nowarn object MethodHandleTools: def exprNameMapping(expr: Expr[Any])(using Quotes): String = @@ -30,6 +30,8 @@ object MethodHandleTools: case '[Object] => "O" case _ => "O" + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def invokeVariadicArguments( mhGen: Expr[Seq[TypeDescriptor] => MethodHandle], exprs: Expr[Seq[Any]], @@ -42,6 +44,8 @@ object MethodHandleTools: ) } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def invokeArguments[R]( mh: Expr[MethodHandle], exprs: Seq[Expr[Any]] @@ -52,13 +56,6 @@ object MethodHandleTools: import quotes.reflect.* val arity = exprs.size - val callName = (exprs.map(exprNameMapping) :+ returnMapping[R]).mkString - - val mod = Symbol - .requiredPackage("fr.hammons.slinc") - .declarations - .find(_.name == s"MethodHandleArity$arity") - .map(_.companionModule) val backupMod = TypeRepr .of[MethodHandleFacade] @@ -91,6 +88,8 @@ object MethodHandleTools: ) ) + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") def calculateMethodHandleImplementation[L]( platformExpr: Expr[LibraryI.PlatformSpecific], addresses: Expr[IArray[Object]] @@ -162,6 +161,9 @@ object MethodHandleTools: wrappedMHImpl[A]('methodHandle) } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") private def wrappedMHImpl[A]( methodHandleExpr: Expr[MethodHandle] )(using Quotes, Type[A]) = diff --git a/core/src/fr/hammons/slinc/Receive.scala b/core/src/fr/hammons/slinc/Receive.scala index 3a5817d7..0f3c4098 100644 --- a/core/src/fr/hammons/slinc/Receive.scala +++ b/core/src/fr/hammons/slinc/Receive.scala @@ -1,19 +1,18 @@ package fr.hammons.slinc -import java.lang.reflect.Modifier - -import scala.annotation.targetName import scala.quoted.* import scala.compiletime.{erasedValue, summonInline} import scala.util.chaining.* import scala.deriving.Mirror import container.{ContextProof, *:::, End} import fr.hammons.slinc.modules.DescriptorModule +import scala.annotation.nowarn class ReceiveI(val libraryPs: LibraryI.PlatformSpecific): + @nowarn("msg=unused implicit parameter") inline given fnReceive[A](using Fn[A, ?, ?]): Receive[A] = new Receive[A]: - def from(mem: Mem, offset: Bytes): A = + override def from(mem: Mem, offset: Bytes): A = val descriptor = FunctionDescriptor.fromFunction[A] MethodHandleTools.wrappedMH[A]( @@ -81,6 +80,8 @@ object Receive: }(transformsArray).asInstanceOf[Receive[A]] end staged + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") private def stagedHelper( layout: TypeDescriptor, transformIndices: Map[String, Int], @@ -139,6 +140,8 @@ object Receive: .flatMap(getTransforms) case _ => Seq.empty + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused local definition") private def constructFromTarget(clazz: Class[?], members: List[Expr[Any]])( using Quotes ) = diff --git a/core/src/fr/hammons/slinc/Scope.scala b/core/src/fr/hammons/slinc/Scope.scala index edb773b9..0c7f6758 100644 --- a/core/src/fr/hammons/slinc/Scope.scala +++ b/core/src/fr/hammons/slinc/Scope.scala @@ -1,5 +1,7 @@ package fr.hammons.slinc +import scala.annotation.experimental + sealed trait Scope: def apply[A](fn: Allocator ?=> A): A diff --git a/core/src/fr/hammons/slinc/Slinc.scala b/core/src/fr/hammons/slinc/Slinc.scala index e421f474..1c8a3761 100644 --- a/core/src/fr/hammons/slinc/Slinc.scala +++ b/core/src/fr/hammons/slinc/Slinc.scala @@ -1,12 +1,6 @@ package fr.hammons.slinc -import scala.concurrent.ExecutionContext -import scala.quoted.staging.Compiler -import java.util.concurrent.Executor -import java.util.concurrent.Executors -import java.util.concurrent.ThreadFactory import scala.util.chaining.* -import java.util.concurrent.atomic.AtomicReference import scala.compiletime.uninitialized import modules.{DescriptorModule, TransitionModule} @@ -19,9 +13,6 @@ trait Slinc: given dm: DescriptorModule given tm: TransitionModule - private val useJit = Option(System.getProperty("sffi-jit")) - .flatMap(_.nn.toBooleanOption) - .getOrElse(true) protected val structI = StructI(jitManager) val typesI = types.TypesI.platformTypes protected val scopeI = ScopeI(scopePlatformSpecific) diff --git a/core/src/fr/hammons/slinc/SlincImpl.scala b/core/src/fr/hammons/slinc/SlincImpl.scala index cbbfb29a..33fbf877 100644 --- a/core/src/fr/hammons/slinc/SlincImpl.scala +++ b/core/src/fr/hammons/slinc/SlincImpl.scala @@ -2,13 +2,17 @@ package fr.hammons.slinc import scala.annotation.StaticAnnotation import scala.quoted.* +import scala.annotation.nowarn +@nowarn("msg=unused explicit parameter") class SlincImpl(version: Int) extends StaticAnnotation object SlincImpl: inline def findImpls(): Map[Int, () => Slinc] = ${ findImplsImpl } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") private def findImplsImpl(using q: Quotes): Expr[Map[Int, () => Slinc]] = import quotes.reflect.* val syms = Symbol diff --git a/core/src/fr/hammons/slinc/StaticArray.scala b/core/src/fr/hammons/slinc/StaticArray.scala deleted file mode 100644 index c7ce5a56..00000000 --- a/core/src/fr/hammons/slinc/StaticArray.scala +++ /dev/null @@ -1,11 +0,0 @@ -package fr.hammons.slinc - -import scala.reflect.ClassTag -import scala.compiletime.constValue - -class StaticArray[A <: Int, B](a: Array[B])(using ClassTag[B]) - -object StaticArray: - inline def ofDim[A, Size <: Int](using ClassTag[A]) = StaticArray( - Array.ofDim[A](constValue[Size]) - ) diff --git a/core/src/fr/hammons/slinc/container/Container.scala b/core/src/fr/hammons/slinc/container/Container.scala index 01bbf07a..25b097c6 100644 --- a/core/src/fr/hammons/slinc/container/Container.scala +++ b/core/src/fr/hammons/slinc/container/Container.scala @@ -1,11 +1,10 @@ package fr.hammons.slinc.container import scala.reflect.ClassTag -import scala.util.Try -import scala.util.Success import scala.compiletime.erasedValue import scala.compiletime.error import scala.quoted.* +import scala.annotation.nowarn class Data[A](a: A): type B = A @@ -51,6 +50,9 @@ object Container: applyImpl[A]('data) } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") private def getEvidences[A <: Tuple](using Type[A], Quotes @@ -73,6 +75,9 @@ object Container: case '[EmptyTuple] => '{ Vector.empty } + // todo: get rid of this once bug https://github.com/lampepfl/dotty/issues/16863 is fixed + @nowarn("msg=unused implicit parameter") + @nowarn("msg=unused local definition") private def applyImpl[A <: Capabilities]( data: Expr[Any] )(using Quotes, Type[A]) = diff --git a/core/src/fr/hammons/slinc/modules/DescriptorModule.scala b/core/src/fr/hammons/slinc/modules/DescriptorModule.scala index 7e00accd..79927483 100644 --- a/core/src/fr/hammons/slinc/modules/DescriptorModule.scala +++ b/core/src/fr/hammons/slinc/modules/DescriptorModule.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc.modules import fr.hammons.slinc.{StructDescriptor, Bytes, TypeDescriptor} -import java.lang.invoke.MethodType /** A module used to perform Platform dependent work with a descriptor */ diff --git a/core/src/fr/hammons/slinc/types/TypesI.scala b/core/src/fr/hammons/slinc/types/TypesI.scala index 7fd386cb..9324bffe 100644 --- a/core/src/fr/hammons/slinc/types/TypesI.scala +++ b/core/src/fr/hammons/slinc/types/TypesI.scala @@ -1,10 +1,7 @@ package fr.hammons.slinc.types -import scala.annotation.targetName -import scala.compiletime.constValue import fr.hammons.slinc.* import fr.hammons.slinc.container.* -import dotty.tools.dotc.config.Platform class TypesI protected[slinc] ( protected val platformSpecific: TypesI.PlatformSpecific diff --git a/core/test/src/fr/hammons/slinc/StdlibSpec.scala b/core/test/src/fr/hammons/slinc/StdlibSpec.scala index fa42208b..8e978830 100644 --- a/core/test/src/fr/hammons/slinc/StdlibSpec.scala +++ b/core/test/src/fr/hammons/slinc/StdlibSpec.scala @@ -1,13 +1,16 @@ package fr.hammons.slinc -import fr.hammons.slinc.StdlibSpec.{div_t, ldiv_t, lldiv_t} +import fr.hammons.slinc.StdlibSpec.div_t import scala.util.Random import munit.ScalaCheckSuite import org.scalacheck.Prop.* import org.scalacheck.Gen import org.scalacheck.Arbitrary import fr.hammons.slinc.types.OS +import scala.annotation.nowarn +@nowarn("msg=unused explicit parameter") +@nowarn("msg=unused implicit parameter") trait StdlibSpec(val slinc: Slinc) extends ScalaCheckSuite: import slinc.{given, *} diff --git a/j17/src/fr/hammons/slinc/Allocator17.scala b/j17/src/fr/hammons/slinc/Allocator17.scala index 4eeab175..05ec65e4 100644 --- a/j17/src/fr/hammons/slinc/Allocator17.scala +++ b/j17/src/fr/hammons/slinc/Allocator17.scala @@ -6,9 +6,6 @@ import jdk.incubator.foreign.{ CLinker, FunctionDescriptor as JFunctionDescriptor }, CLinker.C_POINTER -import java.lang.invoke.MethodHandles -import java.lang.invoke.MethodType -import java.lang.invoke.MethodHandle import fr.hammons.slinc.modules.descriptorModule17 class Allocator17( @@ -18,7 +15,6 @@ class Allocator17( ) extends Allocator: override def upcall[Fn](descriptor: FunctionDescriptor, target: Fn): Mem = - val size = descriptor.inputDescriptors.size val mh = methodHandleFromFn(descriptor, target) val fd = descriptor.outputDescriptor match case Some(r) => diff --git a/j17/src/fr/hammons/slinc/Library17.scala b/j17/src/fr/hammons/slinc/Library17.scala index 1c829e0d..3dbebf10 100644 --- a/j17/src/fr/hammons/slinc/Library17.scala +++ b/j17/src/fr/hammons/slinc/Library17.scala @@ -2,15 +2,9 @@ package fr.hammons.slinc import java.lang.invoke.MethodHandle import jdk.incubator.foreign.{FunctionDescriptor as JFunctionDescriptor} -import jdk.incubator.foreign.MemorySegment -import jdk.incubator.foreign.MemoryAddress -import java.lang.invoke.MethodType import jdk.incubator.foreign.CLinker import jdk.incubator.foreign.SymbolLookup import jdk.incubator.foreign.Addressable -import java.nio.file.Paths -import java.nio.file.Files -import fr.hammons.slinc.modules.DescriptorModule import modules.descriptorModule17 class Library17(linker: CLinker) extends LibraryI.PlatformSpecific: diff --git a/j17/src/fr/hammons/slinc/Mem17.scala b/j17/src/fr/hammons/slinc/Mem17.scala index 91aba826..ccfec4a8 100644 --- a/j17/src/fr/hammons/slinc/Mem17.scala +++ b/j17/src/fr/hammons/slinc/Mem17.scala @@ -3,7 +3,7 @@ package fr.hammons.slinc import jdk.incubator.foreign.MemorySegment import jdk.incubator.foreign.MemoryAccess import jdk.incubator.foreign.ResourceScope -import jdk.incubator.foreign.CLinker.{C_CHAR, C_INT, C_POINTER} +import jdk.incubator.foreign.CLinker.{C_INT, C_POINTER} import jdk.incubator.foreign.Addressable import jdk.incubator.foreign.MemoryAddress @@ -84,7 +84,7 @@ class Mem17(private[slinc] val mem: MemorySegment) extends Mem: if to.toLong == 0 then mem else mem.address().nn.asSegment(to.toLong, mem.scope().nn).nn - def readIntArray(offset: Bytes, size: Int): Array[Int] = + override def readIntArray(offset: Bytes, size: Int): Array[Int] = val arr = Array.ofDim[Int](size) val resizedMem = resizeSegment(Bytes(size * C_INT.nn.byteSize())) MemorySegment.ofArray(arr).nn.copyFrom(resizedMem) diff --git a/j17/src/fr/hammons/slinc/Scope17.scala b/j17/src/fr/hammons/slinc/Scope17.scala index 19dc8361..6b6cbf3e 100644 --- a/j17/src/fr/hammons/slinc/Scope17.scala +++ b/j17/src/fr/hammons/slinc/Scope17.scala @@ -4,10 +4,8 @@ import jdk.incubator.foreign.CLinker import jdk.incubator.foreign.ResourceScope import jdk.incubator.foreign.SegmentAllocator import jdk.incubator.foreign.MemoryAddress -import fr.hammons.slinc.modules.DescriptorModule -class Scope17(linker: CLinker)(using DescriptorModule) - extends ScopeI.PlatformSpecific: +class Scope17(linker: CLinker) extends ScopeI.PlatformSpecific: private val baseNull = Ptr[Nothing]( Mem17(MemoryAddress.NULL.nn.asSegment(1, ResourceScope.globalScope).nn), diff --git a/j17/src/fr/hammons/slinc/Slinc17.scala b/j17/src/fr/hammons/slinc/Slinc17.scala index 259752ff..4429bf53 100644 --- a/j17/src/fr/hammons/slinc/Slinc17.scala +++ b/j17/src/fr/hammons/slinc/Slinc17.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc import jdk.incubator.foreign.CLinker -import fr.hammons.slinc.ScopeI.PlatformSpecific import fr.hammons.slinc.modules.{DescriptorModule, TransitionModule} import fr.hammons.slinc.modules.given diff --git a/j17/src/fr/hammons/slinc/TempAllocator.scala b/j17/src/fr/hammons/slinc/TempAllocator.scala index 600bea8c..e85661d8 100644 --- a/j17/src/fr/hammons/slinc/TempAllocator.scala +++ b/j17/src/fr/hammons/slinc/TempAllocator.scala @@ -4,8 +4,7 @@ import jdk.incubator.foreign.{ CLinker, ResourceScope, MemoryAddress, - MemorySegment, - SegmentAllocator + MemorySegment } final class TempAllocator17: diff --git a/j17/src/fr/hammons/slinc/modules/DescriptorModule17.scala b/j17/src/fr/hammons/slinc/modules/DescriptorModule17.scala index d64f603a..ae322e06 100644 --- a/j17/src/fr/hammons/slinc/modules/DescriptorModule17.scala +++ b/j17/src/fr/hammons/slinc/modules/DescriptorModule17.scala @@ -126,7 +126,6 @@ given descriptorModule17: DescriptorModule with sd, { val originalMembers = sd.members.map(toMemoryLayout) val alignment = alignmentOf(sd) - val offsets = memberOffsets(sd) MemoryLayout .structLayout(genLayoutList(originalMembers, alignment)*) .nn diff --git a/j17/src/fr/hammons/slinc/modules/TransitionModule17.scala b/j17/src/fr/hammons/slinc/modules/TransitionModule17.scala index c7f08314..7552debf 100644 --- a/j17/src/fr/hammons/slinc/modules/TransitionModule17.scala +++ b/j17/src/fr/hammons/slinc/modules/TransitionModule17.scala @@ -5,7 +5,7 @@ import fr.hammons.slinc.TypeDescriptor import scala.collection.concurrent.TrieMap import fr.hammons.slinc.* -import jdk.incubator.foreign.{MemoryAddress, ResourceScope, MemorySegment} +import jdk.incubator.foreign.{MemoryAddress, MemorySegment} given transitionModule17: TransitionModule with diff --git a/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksNoJIT.scala b/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksNoJIT.scala index 418183d4..2eb6beac 100644 --- a/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksNoJIT.scala +++ b/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksNoJIT.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} +import org.openjdk.jmh.annotations.*, Mode.{SingleShotTime, Throughput} import java.util.concurrent.TimeUnit @State(Scope.Thread) diff --git a/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksStandard.scala b/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksStandard.scala index 79fc64f8..1772a014 100644 --- a/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksStandard.scala +++ b/j19/benchmarks/test/src/fr/hammons/slinc/BindingsBenchmarksStandard.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} +import org.openjdk.jmh.annotations.*, Mode.{SingleShotTime, Throughput} import java.util.concurrent.TimeUnit @State(Scope.Thread) diff --git a/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksNoJIT.scala b/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksNoJIT.scala index 26d45003..9c6f83b5 100644 --- a/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksNoJIT.scala +++ b/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksNoJIT.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} +import org.openjdk.jmh.annotations.*, Mode.{SingleShotTime, Throughput} import java.util.concurrent.TimeUnit @State(Scope.Thread) diff --git a/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksStandard.scala b/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksStandard.scala index b2a29d82..7c5ce7b9 100644 --- a/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksStandard.scala +++ b/j19/benchmarks/test/src/fr/hammons/slinc/TransferBenchmarksStandard.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc -import org.openjdk.jmh.annotations.*, - Mode.{SampleTime, SingleShotTime, Throughput} +import org.openjdk.jmh.annotations.*, Mode.{SingleShotTime, Throughput} import java.util.concurrent.TimeUnit @State(Scope.Thread) diff --git a/j19/src/fr/hammons/slinc/Allocator19.scala b/j19/src/fr/hammons/slinc/Allocator19.scala index 0a9f768d..949a6180 100644 --- a/j19/src/fr/hammons/slinc/Allocator19.scala +++ b/j19/src/fr/hammons/slinc/Allocator19.scala @@ -13,8 +13,6 @@ class Allocator19( ) extends Allocator: override def upcall[Fn](descriptor: FunctionDescriptor, target: Fn): Mem = - val size = descriptor.inputDescriptors.size - val mh = this.methodHandleFromFn(descriptor, target) val fd = descriptor.outputDescriptor match diff --git a/j19/src/fr/hammons/slinc/Library19.scala b/j19/src/fr/hammons/slinc/Library19.scala index 79b000b0..61cb15f0 100644 --- a/j19/src/fr/hammons/slinc/Library19.scala +++ b/j19/src/fr/hammons/slinc/Library19.scala @@ -4,10 +4,7 @@ import java.lang.foreign.Linker import java.lang.invoke.MethodHandle import java.lang.foreign.{FunctionDescriptor as JFunctionDescriptor} import java.lang.foreign.Addressable -import dotty.tools.dotc.core.SymbolLoader import java.lang.foreign.SymbolLookup -import java.nio.file.Paths -import java.nio.file.Files import fr.hammons.slinc.modules.descriptorModule19 class Library19(linker: Linker) extends LibraryI.PlatformSpecific: @@ -45,8 +42,6 @@ class Library19(linker: Linker) extends LibraryI.PlatformSpecific: .toSeq* ) - val md = descriptor.toMethodType - linker.downcallHandle(address.asInstanceOf[Addressable], fd).nn class J19Lookup(s: SymbolLookup, l: LibraryLocation) extends Lookup(l): diff --git a/j19/src/fr/hammons/slinc/TempAllocator19.scala b/j19/src/fr/hammons/slinc/TempAllocator19.scala index 441aafee..9e490fe6 100644 --- a/j19/src/fr/hammons/slinc/TempAllocator19.scala +++ b/j19/src/fr/hammons/slinc/TempAllocator19.scala @@ -1,7 +1,6 @@ package fr.hammons.slinc import java.lang.foreign.{MemorySession, MemorySegment} -import java.lang.foreign.MemoryAddress import java.lang.foreign.SegmentAllocator final class TempAllocator19: @@ -46,4 +45,3 @@ object TempAllocator19: val localAllocator: SegmentAllocator = (bytesNeeded, alignment) => allocator.get.nn.allocate(bytesNeeded, alignment) - private val powersOf2 = LazyList.iterate(1L)(_ << 1) diff --git a/j19/test/src/fr/hammons/slinc/StdlibSpec.scala b/j19/test/src/fr/hammons/slinc/StdlibSpec.scala index 758596d5..2937ec62 100644 --- a/j19/test/src/fr/hammons/slinc/StdlibSpec.scala +++ b/j19/test/src/fr/hammons/slinc/StdlibSpec.scala @@ -1,8 +1,3 @@ package fr.hammons.slinc -import java.lang.foreign.Linker -import java.lang.foreign.SymbolLookup -import java.lang.foreign.FunctionDescriptor -import java.lang.foreign.ValueLayout.* - class StdlibSpec19 extends StdlibSpec(Slinc19.default)