P_CurrentTimeMilliseconds

object P_CurrentTimeMilliseconds : Primitive

Primitive: Get the current time as milliseconds since the Unix Epoch (00:00:00 UTC, Thursday, 1 January 1970).

Functions

Link copied to clipboard
fun addNanosecondsCheckingResultType(deltaNanoseconds: Long, interpreterIndex: Int)

Record that some number of nanoseconds were just expended checking the type of the value returned by this primitive.

Link copied to clipboard
fun addNanosecondsRunning(deltaNanoseconds: Long, interpreterIndex: Int)

Record that some number of nanoseconds were just expended running this primitive.

Link copied to clipboard
open override fun attempt(interpreter: Interpreter): Primitive.Result

Attempt this primitive with the given Interpreter. The interpreter's argument list must be set up prior to this call. If the primitive fails, it should set the primitive failure code by calling Interpreter.primitiveFailure and returning its result from the primitive. Otherwise it should set the interpreter's primitive result by calling Interpreter.primitiveSuccess and then return its result from the primitive. For unusual primitives that replace the current continuation, Result.CONTINUATION_CHANGED is more appropriate, and the latestResult need not be set. For primitives that need to cause a context switch, Result.FIBER_SUSPENDED should be returned.

Link copied to clipboard
open fun attemptToGenerateSimpleInvocation(    simpleTranslator: L2SimpleTranslator,     functionIfKnown: A_Function?,     rawFunction: A_RawFunction,     argRestrictions: List<TypeRestriction>,     expectedType: A_Type): TypeRestriction?

Attempt to generate a simplified, faster invocation of the given constant function, with the given argument restrictions. The arguments will be on the stack, the last-pushed one at stackp. If this code generation attempt is successful, code will be generated to invoke the given function, and if it completes without reification, to check the return result if it's not already guaranteed correct. Note that the call and the return type check can't be in separate instructions, since there's nowhere to store the unchecked return value to compare it against the expected type. We can't just clobber the expected type (that was pushed at the start of the call), since that would

Link copied to clipboard
fun blockTypeRestriction(): A_Type

Return a function type that restricts actual primitive blocks defined using that primitive. The actual block's argument types must be at least as specific as this function type's argument types, and the actual block's return type must be at least as general as this function type's return type. That's equivalent to the condition that the actual block's type is a subtype of this function type.

Link copied to clipboard
open fun bootstrapStyler(): Primitive?

To simplify styling during bootstrapping, a method defined by the pragma mechanism can have its primitive declare a styler primitive to plug in as that method definition's styler.

Link copied to clipboard
fun canHaveNybblecodes(): Boolean

Answer whether a raw function using this primitive can/should have nybblecode instructions.

Link copied to clipboard
open fun fallibilityForArgumentTypes(argumentTypes: List<A_Type>): Primitive.Fallibility

Answer the fallibility of the primitive for a call site with the given argument types.

Link copied to clipboard
fun generateJvmCode(    translator: JVMTranslator,     method: MethodVisitor,     arguments: L2ReadBoxedVectorOperand,     result: L2WriteBoxedOperand)

Write a JVM invocation of this primitive. This sets up the interpreter, calls Interpreter.beforeAttemptPrimitive, calls Primitive.attempt, calls Interpreter.afterAttemptPrimitive, and records statistics as needed. It also deals with primitive failures, suspensions, and reifications.

Link copied to clipboard
fun hasFlag(flag: Primitive.Flag): Boolean

Test whether the specified Flag is set for this primitive.

Link copied to clipboard
open fun returnTypeGuaranteedByVM(rawFunction: A_RawFunction, argumentTypes: List<A_Type>): A_Type

Answer the type of the result that will be produced by a call site with the given argument types. Don't include semantic restrictions defined in the Avail code, but if convenient answer something stronger than the return type in the primitive's basic function type.

Link copied to clipboard
fun tryToGenerateGeneralPrimitiveInvocation(    rawFunction: A_RawFunction,     arguments: List<L2ReadBoxedOperand>,     argumentTypes: List<A_Type>,     translator: L1Translator,     callSiteHelper: L1Translator.CallSiteHelper): Boolean

The primitive couldn't be folded out, and the primitive failed to produce specialized L2 instructions for itself. If the primitive is still known to be infallible (and does not affect the continuation stack) at this site, generate an L2_RUN_INFALLIBLE_PRIMITIVE for it and answer true, ensuring control flow will go to the appropriate CallSiteHelper exit point, and leave the translator NOT at a currentReachable() point.

Link copied to clipboard
open fun tryToGenerateSpecialPrimitiveInvocation(    functionToCallReg: L2ReadBoxedOperand,     rawFunction: A_RawFunction,     arguments: List<L2ReadBoxedOperand>,     argumentTypes: List<A_Type>,     translator: L1Translator,     callSiteHelper: L1Translator.CallSiteHelper): Boolean

The primitive couldn't be folded out, so see if alternative instructions can be generated for its invocation. If so, answer true, ensure control flow will go to the appropriate CallSiteHelper exit point, and leave the translator NOT at a currentReachable() point. If the alternative instructions could not be generated for this primitive, answer false, and generate nothing.

Link copied to clipboard
open fun writeDefaultFailureCode(    lineNumber: Int,     writer: L1InstructionWriter,     numArgs: Int)

Generate suitable primitive failure code on the given L1InstructionWriter. Some primitives may have special requirements, but most (fallible) primitives follow the same pattern.

Properties

Link copied to clipboard
val argCount: Int

The number of arguments the primitive expects. The value -1 is used by the special primitive P_PushConstant to indicate it may have any number of arguments. However, note that that primitive cannot be used explicitly in Avail code.

Link copied to clipboard
val failureVariableType: AvailObject

A type to constrain the A_Type.writeType of the variable declaration within the primitive declaration of a block. The actual variable's inner type must be this or a supertype.

Link copied to clipboard
val name: String

Capture the name of the primitive class once for performance.

Link copied to clipboard
var reificationAbandonmentStat: Statistic? = null

The Statistic for abandoning the stack due to a primitive attempt answering Result.CONTINUATION_CHANGED.

Link copied to clipboard
var reificationForNoninlineStat: Statistic? = null

The Statistic for reification prior to invoking a primitive that does not have Flag.CanInline set.