unison icon indicating copy to clipboard operation
unison copied to clipboard

All builtins needed for first release of Unison Cloud JIT

Open pchiusano opened this issue 2 years ago • 3 comments

Ultimately we want to have the JIT support the full language, but for a first milestone, we're trying to get it to compile all the things needed for Unison Cloud so we can run the JIT on all the cloud nodes. The cloud nodes don't allow arbitrary I/O so there's some builtins (particularly STM) that we can get away with not implementing for now.

Once we do a first release, we'll go back and implement STM and probably will do our own threading and async I/O implementations.

Here's primops that have not yet been implemented:

  • [x] ABSF
  • [x] ACOS
  • [x] ACSH
  • [x] ADDF
  • [x] ADDI
  • [x] ASIN
  • [x] ASNH
  • [x] ATAN
  • [x] ATN2
  • [x] ATNH
  • [x] CACH
  • [x] CATB
  • [x] CEIL
  • [x] CMPU
  • [x] COSF
  • [x] COSH
  • [x] CVLD
  • [x] DECN
  • [x] DIVF
  • [x] DIVI
  • [x] DRPT
  • [x] EQLF
  • [x] EQLI
  • [x] EQLU
  • [x] EXPF
  • [x] FLOR
  • [x] FLTB
  • [x] FORK
  • [x] INCI
  • [x] INCN
  • [x] INFO
  • [x] ITOF
  • [x] LEQF
  • [x] LEQI
  • [x] LEQT
  • [x] LKUP
  • [x] LOAD
  • [x] LOGB
  • [x] LOGF
  • [x] MAXF
  • [x] MINF
  • [x] MISS
  • [x] MODI
  • [x] MULF
  • [x] MULI
  • [x] NEGI
  • [x] NTOF
  • [x] PAKB
  • [x] POPC
  • [x] POWF
  • [x] POWI
  • [x] POWN
  • [x] PRNT
  • [x] RNDF
  • [x] SDBX
  • [x] SGNI
  • [x] SINF
  • [x] SINH
  • [x] SIZB
  • [x] SPLL
  • [x] SPLR
  • [x] SQRT
  • [x] SUBF
  • [x] SUBI
  • [x] TAKB
  • [x] TANF
  • [x] TANH
  • [x] TLTT
  • [x] TRNF
  • [x] TTOF
  • [x] TTOI
  • [x] TZRO
  • [x] UCNS
  • [x] UPKB
  • [x] USNC
  • [x] VWRS

Note, things like Nat.+ are wrappers around primop instructions. The wrapper code gets compiled to scheme just like any other unison (intermediate) function, so the primops are what need to be implemented (unless the builtin corresponding to a primop is being replaced completely, but that is a separate mechanism).

I might come back and annotate these with their meanings later, and possibly delete some as irrelevant.

Must have

  • [x] Universal.murmurHash : a -> Nat
  • [x] Code.validateLinks
  • [x] Text.indexOf
  • [x] Bytes.indexOf
  • [x] tryEval.impl
  • [x] Pattern.isMatch
  • [x] Pattern.run
  • [x] Pattern.replicate
  • [x] Pattern.or
  • [x] Pattern.join
  • [x] Pattern.capture
  • [x] Pattern.many
  • [x] Text.patterns.notCharIn
  • [x] Text.patterns.charIn
  • [x] Text.patterns.notCharRange
  • [x] Text.patterns.charRange
  • [x] Text.patterns.eof
  • [x] Text.patterns.anyChar
  • [x] Text.patterns.punctuation
  • [x] Text.patterns.space
  • [x] Text.patterns.letter
  • [x] Text.patterns.digit
  • [x] Text.patterns.literal
  • [x] Scope.bytearrayOf
  • [x] Scope.bytearray
  • [x] Scope.arrayOf
  • [x] Scope.array
  • [x] IO.bytearrayOf
  • [x] IO.bytearray
  • [x] IO.arrayOf
  • [x] IO.array
  • [x] ImmutableByteArray.length
  • [x] MutableByteArray.length
  • [x] MutableArray.freeze
  • [x] MutableByteArray.freeze
  • [x] MutableArray.freeze!
  • [x] MutableByteArray.freeze!
  • [x] ImmutableByteArray.read64be
  • [x] ImmutableByteArray.read40be
  • [x] ImmutableByteArray.read32be
  • [x] ImmutableByteArray.read24be
  • [x] ImmutableByteArray.read16be
  • [x] ImmutableByteArray.read8
  • [x] ImmutableArray.read
  • [x] MutableByteArray.write64be
  • [x] MutableByteArray.write32be
  • [x] MutableByteArray.write16be
  • [x] MutableByteArray.write8
  • [x] MutableArray.write
  • [x] MutableByteArray.read64be
  • [x] MutableByteArray.read40be
  • [x] MutableByteArray.read32be
  • [x] MutableByteArray.read24be
  • [x] MutableByteArray.read16be
  • [x] MutableByteArray.read8
  • [x] MutableArray.read
  • [x] ImmutableByteArray.copyTo!
  • [x] MutableByteArray.size
  • [x] ImmutableByteArray.size
  • [x] MutableArray.size
  • [x] ImmutableArray.size
  • [x] ImmutableArray.copyTo!
  • [x] MutableByteArray.copyTo!
  • [x] MutableArray.copyTo!
  • [x] Bytes.encodeNat16le
  • [x] Bytes.encodeNat16be
  • [x] Bytes.encodeNat32le
  • [x] Bytes.encodeNat32be
  • [x] Bytes.encodeNat64le
  • [x] Bytes.encodeNat64be
  • [x] Bytes.decodeNat16le
  • [x] Bytes.decodeNat16be
  • [x] Bytes.decodeNat32le
  • [x] Bytes.decodeNat32be
  • [x] Bytes.decodeNat64le
  • [x] Bytes.decodeNat64be
  • [x] Bytes.fromBase64UrlUnpadded
  • [x] Bytes.fromBase64
  • [x] Bytes.fromBase32
  • [x] Bytes.fromBase16
  • [x] Bytes.toBase64UrlUnpadded
  • [x] Bytes.toBase64
  • [x] Bytes.toBase32
  • [x] Bytes.toBase16
  • [x] Bytes.gzip.decompress
  • [x] Bytes.zlib.decompress
  • [x] Bytes.gzip.compress
  • [x] Bytes.zlib.compress
  • [x] Value.deserialize
  • [x] Value.serialize
  • [x] Value.dependencies
  • [x] Code.deserialize
  • [x] Code.serialize
  • [x] Code.dependencies
  • [x] Debug.trace
  • [x] Debug.toText
  • [x] Ref.write
  • [x] Ref.read
  • [x] IO.ref
  • [x] Scope.ref
  • [x] Text.fromUtf8.impl.v3
  • [x] Text.toUtf8
  • [x] Text.toLowercase
  • [x] Text.toUppercase
  • [x] Text.reverse
  • [x] Text.repeat
  • [x] Char.toText
  • [x] IO.stdHandle
  • [x] IO.delay.impl.v3
  • [x] IO.kill.impl.v3
  • [x] IO.socketReceive.impl.v3
  • [x] IO.socketSend.impl.v3
  • [x] IO.socketAccept.impl.v3
  • [x] IO.closeSocket.impl.v3
  • [x] IO.clientSocket.impl.v3
  • [x] IO.listen.impl.v3
  • [x] IO.socketPort.impl.v3
  • [x] ThreadId.toText
  • [x] Handle.toText
  • [x] Socket.toText
  • [x] IO.serverSocket.impl.v3
  • [x] IO.getFileSize.impl.v3
  • [x] IO.getFileTimestamp.impl.v3
  • [x] IO.removeFile.impl.v3
  • [x] IO.directoryContents.impl.v3
  • [x] IO.getArgs.impl.v1
  • [x] IO.getEnv.impl.v1
  • [x] IO.fileExists.impl.v3
  • [x] IO.getCurrentDirectory.impl.v3
  • [x] Clock.internals.nsec.v1
  • [x] Clock.internals.sec.v1
  • [x] Clock.internals.threadCPUTime.v1
  • [x] Clock.internals.processCPUTime.v1
  • [x] Clock.internals.realtime.v1
  • [x] Clock.internals.monotonic.v1
  • [x] IO.systemTimeMicroseconds.v1
  • [x] IO.putBytes.impl.v3
  • [x] IO.getSomeBytes.impl.v1
  • [x] IO.getBytes.impl.v3
  • [x] IO.getLine.impl.v1
  • [x] IO.setBuffering.impl.v3
  • [x] IO.getBuffering.impl.v3
  • [x] IO.getChar.impl.v1
  • [x] IO.getEcho.impl.v1
  • [x] IO.isFileEOF.impl.v3
  • [x] IO.closeFile.impl.v3
  • [x] IO.openFile.impl.v3
  • [x] Ref.readForCas
  • [x] Ref.cas
  • [x] Ticket.read
  • [x] Promise.new
  • [x] Promise.write
  • [x] Promise.read
  • [x] Promise.tryRead

Needs research

  • [x] Tls.ServerConfig.certificates.set
  • [x] Tls.ClientConfig.certificates.set
  • [x] Tls.ServerConfig.default
  • [x] Tls.ClientConfig.default
  • [x] Tls.terminate.impl.v3
  • [x] Tls.receive.impl.v3
  • [x] Tls.encodePrivateKey
  • [x] Tls.decodePrivateKey
  • [x] Tls.encodeCert
  • [x] Tls.decodeCert.impl.v3
  • [x] Tls.send.impl.v3
  • [x] Tls.handshake.impl.v3
  • [x] Tls.newServer.impl.v3
  • [x] Tls.newClient.impl.v3
  • [x] crypto.hmac
  • [x] crypto.hash
  • [x] crypto.hmacBytes
  • [x] crypto.hashBytes
  • [x] HashAlgorithm.Blake2b_256 : HashAlgorithm
  • [x] HashAlgorithm.Blake2b_512 : HashAlgorithm
  • [x] HashAlgorithm.Blake2s_256 : HashAlgorithm
  • [x] HashAlgorithm.Sha1 : HashAlgorithm
  • [x] HashAlgorithm.Sha2_256 : HashAlgorithm
  • [x] HashAlgorithm.Sha2_512 : HashAlgorithm
  • [x] HashAlgorithm.Sha3_256 : HashAlgorithm
  • [x] HashAlgorithm.Sha3_512 : HashAlgorithm

Not needed for now:

  • [x] IO.setCurrentDirectory.impl.v3
  • [x] Link.Term.toText
  • [x] IO.getTempDirectory.impl.v3
  • [x] IO.createTempDirectory.impl.v3
  • [x] IO.isFileOpen.impl.v3
  • [x] IO.ready.impl.v1
  • [x] IO.setEcho.impl.v1
  • [x] IO.handlePosition.impl.v3
  • [x] IO.seekHandle.impl.v3
  • [x] IO.isSeekable.impl.v3
  • [x] IO.isDirectory.impl.v3
  • [x] IO.systemTime.impl.v3
  • [x] IO.createDirectory.impl.v3
  • [x] IO.removeDirectory.impl.v3
  • [x] IO.renameFile.impl.v3
  • [x] IO.renameDirectory.impl.v3
  • [ ] Code.display
  • [ ] STM.retry
  • [ ] TVar.swap
  • [ ] TVar.readIO
  • [ ] TVar.newIO
  • [ ] TVar.write
  • [ ] TVar.read
  • [ ] TVar.new
  • [ ] MVar.tryRead.impl.v3
  • [ ] MVar.read.impl.v3
  • [ ] MVar.isEmpty
  • [ ] MVar.swap.impl.v3
  • [ ] MVar.tryPut.impl.v3
  • [ ] MVar.put.impl.v3
  • [ ] MVar.tryTake
  • [ ] MVar.take.impl.v3
  • [ ] MVar.newEmpty.v2
  • [ ] MVar.new

pchiusano avatar Jan 12 '23 18:01 pchiusano

Link.Term.toText is another primop that this list seems to be missing.

ceedubs avatar May 01 '23 17:05 ceedubs

Everything on the necessary list is now checked off.

dolio avatar Nov 07 '23 16:11 dolio

  • [x] HashAlgorithm.Blake2b_256 : HashAlgorithm
  • [x] HashAlgorithm.Blake2b_512 : HashAlgorithm
  • [x] HashAlgorithm.Blake2s_256 : HashAlgorithm

Question: Why do we need HashAlgorithm.Blake2b_256 if we have the other two?

aryairani avatar Apr 20 '24 12:04 aryairani