Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4598bff98 | ||
|
|
fd1548c86c | ||
|
|
9c56cf751b | ||
|
|
8ae6eb8d69 | ||
|
|
3d9170d677 | ||
|
|
c8a8b12dfc | ||
|
|
6560457e3d | ||
|
|
ea877748e5 | ||
|
|
d8b00a805c | ||
|
|
f42ea0a04c | ||
|
|
bc9e557814 | ||
|
|
b674ee7c18 | ||
|
|
a4f41f17bf | ||
|
|
96947aac50 | ||
|
|
98d6ffe998 | ||
|
|
74d73540c6 | ||
|
|
9b580bafb6 | ||
|
|
062f9e7866 | ||
|
|
717a79aca2 |
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
# AI Agent Notes
|
||||||
|
|
||||||
|
## Kotlin/Wasm generation guardrails
|
||||||
|
- Avoid creating suspend lambdas for compiler runtime statements. Prefer explicit `object : Statement()` with `override suspend fun execute(...)`.
|
||||||
|
- Do not use `statement { ... }` or other inline suspend lambdas in compiler hot paths (e.g., parsing/var declarations, initializer thunks).
|
||||||
|
- If you need a wrapper for delegated properties, check for `getValue` explicitly and return a concrete `Statement` object when missing; avoid `onNotFoundResult` lambdas.
|
||||||
|
- If wasmJs browser tests hang, first run `:lynglib:wasmJsNodeTest` and look for wasm compilation errors; hangs usually mean module instantiation failed.
|
||||||
|
- Do not increase test timeouts to mask wasm generation errors; fix the invalid IR instead.
|
||||||
@@ -45,6 +45,7 @@ fun swapEnds(first, args..., last, f) {
|
|||||||
- [Samples directory](docs/samples)
|
- [Samples directory](docs/samples)
|
||||||
- [Formatter (core + CLI + IDE)](docs/formatter.md)
|
- [Formatter (core + CLI + IDE)](docs/formatter.md)
|
||||||
- [Books directory](docs)
|
- [Books directory](docs)
|
||||||
|
- [AI agent guidance](AGENTS.md)
|
||||||
|
|
||||||
## Integration in Kotlin multiplatform
|
## Integration in Kotlin multiplatform
|
||||||
|
|
||||||
@@ -231,4 +232,4 @@ __Sergey Chernov__ @sergeych: Initial idea and architecture, language concept, d
|
|||||||
|
|
||||||
__Yulia Nezhinskaya__ @AlterEgoJuliaN: System analysis, math and features design.
|
__Yulia Nezhinskaya__ @AlterEgoJuliaN: System analysis, math and features design.
|
||||||
|
|
||||||
[parallelism]: docs/parallelism.md
|
[parallelism]: docs/parallelism.md
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
# Lyng Bytecode VM Spec v0 (Draft)
|
||||||
|
|
||||||
|
This document describes a register-like (3-address) bytecode for Lyng with
|
||||||
|
dynamic slot width (8/16/32-bit slot IDs), a slot-tail argument model, and
|
||||||
|
typed lanes for Obj/Int/Real/Bool. The VM is intended to run as a suspendable
|
||||||
|
interpreter and fall back to the existing AST execution when needed.
|
||||||
|
|
||||||
|
## 1) Frame & Slot Model
|
||||||
|
|
||||||
|
### Frame metadata
|
||||||
|
- localCount: number of local slots for this function (fixed at compile time).
|
||||||
|
- argCount: number of arguments passed at call time.
|
||||||
|
- argBase = localCount.
|
||||||
|
|
||||||
|
### Slot layout
|
||||||
|
slots[0 .. localCount-1] locals
|
||||||
|
slots[localCount .. localCount+argCount-1] arguments
|
||||||
|
|
||||||
|
### Typed lanes
|
||||||
|
- slotType[]: UNKNOWN/OBJ/INT/REAL/BOOL
|
||||||
|
- objSlots[], intSlots[], realSlots[], boolSlots[]
|
||||||
|
- A slot is a logical index; active lane is selected by slotType.
|
||||||
|
|
||||||
|
### Parameter access
|
||||||
|
- param i => slot localCount + i
|
||||||
|
- variadic extra => slot localCount + declaredParamCount + k
|
||||||
|
|
||||||
|
## 2) Slot ID Width
|
||||||
|
|
||||||
|
Per frame, select:
|
||||||
|
- 8-bit if localCount + argCount < 256
|
||||||
|
- 16-bit if < 65536
|
||||||
|
- 32-bit otherwise
|
||||||
|
|
||||||
|
The decoder uses a dedicated loop per width. All slot operands are expanded to
|
||||||
|
Int internally.
|
||||||
|
|
||||||
|
## 3) CALL Semantics (Model A)
|
||||||
|
|
||||||
|
Instruction:
|
||||||
|
CALL_DIRECT fnId, argBase, argCount, dst
|
||||||
|
|
||||||
|
Behavior:
|
||||||
|
- Allocate a callee frame sized localCount + argCount.
|
||||||
|
- Copy caller slots [argBase .. argBase+argCount-1] into callee slots
|
||||||
|
[localCount .. localCount+argCount-1].
|
||||||
|
- Callee returns via RET slot or RET_VOID.
|
||||||
|
- Caller stores return value to dst.
|
||||||
|
|
||||||
|
Other calls:
|
||||||
|
- CALL_VIRTUAL recvSlot, methodId, argBase, argCount, dst
|
||||||
|
- CALL_FALLBACK stmtId, argBase, argCount, dst
|
||||||
|
|
||||||
|
## 4) Binary Encoding Layout
|
||||||
|
|
||||||
|
All instructions are:
|
||||||
|
[opcode:U8] [operands...]
|
||||||
|
|
||||||
|
Operand widths:
|
||||||
|
- slotId: S = 1/2/4 bytes (per frame slot width)
|
||||||
|
- constId: K = 2 bytes (U16), extend to 4 if needed
|
||||||
|
- ip: I = 2 bytes (U16) or 4 bytes (U32) per function size
|
||||||
|
- fnId/methodId/stmtId: F/M/T = 2 bytes (U16) unless extended
|
||||||
|
- argCount: C = 2 bytes (U16), extend to 4 if needed
|
||||||
|
|
||||||
|
Endianness: little-endian for multi-byte operands.
|
||||||
|
|
||||||
|
Common operand patterns:
|
||||||
|
- S: one slot
|
||||||
|
- SS: two slots
|
||||||
|
- SSS: three slots
|
||||||
|
- K S: constId + dst slot
|
||||||
|
- S I: slot + jump target
|
||||||
|
- I: jump target
|
||||||
|
- F S C S: fnId, argBase slot, argCount, dst slot
|
||||||
|
|
||||||
|
## 5) Opcode Table
|
||||||
|
|
||||||
|
Note: Any opcode can be compiled to FALLBACK if not implemented in a VM pass.
|
||||||
|
|
||||||
|
### Data movement
|
||||||
|
- NOP
|
||||||
|
- MOVE_OBJ S -> S
|
||||||
|
- MOVE_INT S -> S
|
||||||
|
- MOVE_REAL S -> S
|
||||||
|
- MOVE_BOOL S -> S
|
||||||
|
- CONST_OBJ K -> S
|
||||||
|
- CONST_INT K -> S
|
||||||
|
- CONST_REAL K -> S
|
||||||
|
- CONST_BOOL K -> S
|
||||||
|
- CONST_NULL -> S
|
||||||
|
|
||||||
|
### Numeric conversions
|
||||||
|
- INT_TO_REAL S -> S
|
||||||
|
- REAL_TO_INT S -> S
|
||||||
|
- BOOL_TO_INT S -> S
|
||||||
|
- INT_TO_BOOL S -> S
|
||||||
|
|
||||||
|
### Arithmetic: INT
|
||||||
|
- ADD_INT S, S -> S
|
||||||
|
- SUB_INT S, S -> S
|
||||||
|
- MUL_INT S, S -> S
|
||||||
|
- DIV_INT S, S -> S
|
||||||
|
- MOD_INT S, S -> S
|
||||||
|
- NEG_INT S -> S
|
||||||
|
- INC_INT S
|
||||||
|
- DEC_INT S
|
||||||
|
|
||||||
|
### Arithmetic: REAL
|
||||||
|
- ADD_REAL S, S -> S
|
||||||
|
- SUB_REAL S, S -> S
|
||||||
|
- MUL_REAL S, S -> S
|
||||||
|
- DIV_REAL S, S -> S
|
||||||
|
- NEG_REAL S -> S
|
||||||
|
|
||||||
|
### Bitwise: INT
|
||||||
|
- AND_INT S, S -> S
|
||||||
|
- OR_INT S, S -> S
|
||||||
|
- XOR_INT S, S -> S
|
||||||
|
- SHL_INT S, S -> S
|
||||||
|
- SHR_INT S, S -> S
|
||||||
|
- USHR_INT S, S -> S
|
||||||
|
- INV_INT S -> S
|
||||||
|
|
||||||
|
### Comparisons (typed)
|
||||||
|
- CMP_EQ_INT S, S -> S
|
||||||
|
- CMP_NEQ_INT S, S -> S
|
||||||
|
- CMP_LT_INT S, S -> S
|
||||||
|
- CMP_LTE_INT S, S -> S
|
||||||
|
- CMP_GT_INT S, S -> S
|
||||||
|
- CMP_GTE_INT S, S -> S
|
||||||
|
- CMP_EQ_REAL S, S -> S
|
||||||
|
- CMP_NEQ_REAL S, S -> S
|
||||||
|
- CMP_LT_REAL S, S -> S
|
||||||
|
- CMP_LTE_REAL S, S -> S
|
||||||
|
- CMP_GT_REAL S, S -> S
|
||||||
|
- CMP_GTE_REAL S, S -> S
|
||||||
|
- CMP_EQ_BOOL S, S -> S
|
||||||
|
- CMP_NEQ_BOOL S, S -> S
|
||||||
|
|
||||||
|
### Mixed numeric comparisons
|
||||||
|
- CMP_EQ_INT_REAL S, S -> S
|
||||||
|
- CMP_EQ_REAL_INT S, S -> S
|
||||||
|
- CMP_LT_INT_REAL S, S -> S
|
||||||
|
- CMP_LT_REAL_INT S, S -> S
|
||||||
|
- CMP_LTE_INT_REAL S, S -> S
|
||||||
|
- CMP_LTE_REAL_INT S, S -> S
|
||||||
|
- CMP_GT_INT_REAL S, S -> S
|
||||||
|
- CMP_GT_REAL_INT S, S -> S
|
||||||
|
- CMP_GTE_INT_REAL S, S -> S
|
||||||
|
- CMP_GTE_REAL_INT S, S -> S
|
||||||
|
- CMP_NEQ_INT_REAL S, S -> S
|
||||||
|
- CMP_NEQ_REAL_INT S, S -> S
|
||||||
|
- CMP_EQ_OBJ S, S -> S
|
||||||
|
- CMP_NEQ_OBJ S, S -> S
|
||||||
|
- CMP_REF_EQ_OBJ S, S -> S
|
||||||
|
- CMP_REF_NEQ_OBJ S, S -> S
|
||||||
|
- CMP_LT_OBJ S, S -> S
|
||||||
|
- CMP_LTE_OBJ S, S -> S
|
||||||
|
- CMP_GT_OBJ S, S -> S
|
||||||
|
- CMP_GTE_OBJ S, S -> S
|
||||||
|
|
||||||
|
### Boolean ops
|
||||||
|
- NOT_BOOL S -> S
|
||||||
|
- AND_BOOL S, S -> S
|
||||||
|
- OR_BOOL S, S -> S
|
||||||
|
|
||||||
|
### Control flow
|
||||||
|
- JMP I
|
||||||
|
- JMP_IF_TRUE S, I
|
||||||
|
- JMP_IF_FALSE S, I
|
||||||
|
- RET S
|
||||||
|
- RET_VOID
|
||||||
|
|
||||||
|
### Calls
|
||||||
|
- CALL_DIRECT F, S, C, S
|
||||||
|
- CALL_VIRTUAL S, M, S, C, S
|
||||||
|
- CALL_FALLBACK T, S, C, S
|
||||||
|
|
||||||
|
### Object access (optional, later)
|
||||||
|
- GET_FIELD S, M -> S
|
||||||
|
- SET_FIELD S, M, S
|
||||||
|
- GET_INDEX S, S -> S
|
||||||
|
- SET_INDEX S, S, S
|
||||||
|
|
||||||
|
### Fallback
|
||||||
|
- EVAL_FALLBACK T -> S
|
||||||
|
|
||||||
|
## 6) Const Pool Encoding (v0)
|
||||||
|
|
||||||
|
Each const entry is encoded as:
|
||||||
|
[tag:U8] [payload...]
|
||||||
|
|
||||||
|
Tags:
|
||||||
|
- 0x00: NULL
|
||||||
|
- 0x01: BOOL (payload: U8 0/1)
|
||||||
|
- 0x02: INT (payload: S64, little-endian)
|
||||||
|
- 0x03: REAL (payload: F64, IEEE-754, little-endian)
|
||||||
|
- 0x04: STRING (payload: U32 length + UTF-8 bytes)
|
||||||
|
- 0x05: OBJ_REF (payload: U32 index into external Obj table)
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- OBJ_REF is reserved for embedding prebuilt Obj handles if needed.
|
||||||
|
- Strings use UTF-8; length is bytes, not chars.
|
||||||
|
|
||||||
|
## 7) Function Header (binary container)
|
||||||
|
|
||||||
|
Suggested layout for a bytecode function blob:
|
||||||
|
- magic: U32 ("LYBC")
|
||||||
|
- version: U16 (0x0001)
|
||||||
|
- slotWidth: U8 (1,2,4)
|
||||||
|
- ipWidth: U8 (2,4)
|
||||||
|
- constIdWidth: U8 (2,4)
|
||||||
|
- localCount: U32
|
||||||
|
- codeSize: U32 (bytes)
|
||||||
|
- constCount: U32
|
||||||
|
- constPool: [const entries...]
|
||||||
|
- code: [bytecode...]
|
||||||
|
|
||||||
|
Const pool entries use the encoding described in section 6.
|
||||||
|
|
||||||
|
## 8) Sample Bytecode (illustrative)
|
||||||
|
|
||||||
|
Example Lyng:
|
||||||
|
val x = 2
|
||||||
|
val y = 3
|
||||||
|
val z = x + y
|
||||||
|
|
||||||
|
Assume:
|
||||||
|
- localCount = 3 (x,y,z)
|
||||||
|
- argCount = 0
|
||||||
|
- slot width = 1 byte
|
||||||
|
- const pool: [INT 2, INT 3]
|
||||||
|
|
||||||
|
Bytecode:
|
||||||
|
CONST_INT k0 -> s0
|
||||||
|
CONST_INT k1 -> s1
|
||||||
|
ADD_INT s0, s1 -> s2
|
||||||
|
RET_VOID
|
||||||
|
|
||||||
|
Encoded (opcode values symbolic):
|
||||||
|
[OP_CONST_INT][k0][s0]
|
||||||
|
[OP_CONST_INT][k1][s1]
|
||||||
|
[OP_ADD_INT][s0][s1][s2]
|
||||||
|
[OP_RET_VOID]
|
||||||
|
|
||||||
|
## 9) Notes
|
||||||
|
|
||||||
|
- Mixed-mode is allowed: compiler can emit FALLBACK ops for unsupported nodes.
|
||||||
|
- The VM must be suspendable; on suspension, store ip + minimal operand state.
|
||||||
|
- Source mapping uses a separate ip->Pos table, not part of core bytecode.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# AI notes: avoid Kotlin/Wasm invalid IR with suspend lambdas
|
||||||
|
|
||||||
|
## Do
|
||||||
|
- Prefer explicit `object : Statement()` with `override suspend fun execute(...)` when building compiler statements.
|
||||||
|
- Keep `Statement` objects non-lambda, especially in compiler hot paths like parsing/var declarations.
|
||||||
|
- If you need conditional behavior, return early in `execute` instead of wrapping `parseExpression()` with `statement(...) { ... }`.
|
||||||
|
- When wasmJs tests hang in the browser, first check `wasmJsNodeTest` for a compile error; hangs often mean module instantiation failed.
|
||||||
|
|
||||||
|
## Don't
|
||||||
|
- Do not create suspend lambdas inside `Statement` factories (`statement { ... }`) for wasm targets.
|
||||||
|
- Do not "fix" hangs by increasing browser timeouts; it masks invalid wasm generation.
|
||||||
|
|
||||||
|
## Debugging tips
|
||||||
|
- Look for `$invokeCOROUTINE$` in wasm function names when mapping failures.
|
||||||
|
- If node test logs a wasm compile error, the browser hang is likely the same root cause.
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Wasm generation hang in wasmJs browser tests
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
The wasmJs browser test runner hung after commit 5f819dc. The root cause was invalid WebAssembly generated by the Kotlin/Wasm backend when certain compiler paths emitted suspend lambdas for `Statement` execution. The invalid module failed to instantiate in the browser, and Karma kept the browser connected but never ran tests.
|
||||||
|
|
||||||
|
## Symptoms
|
||||||
|
- `:lynglib:wasmJsBrowserTest` hangs indefinitely in ChromeHeadless.
|
||||||
|
- `:lynglib:wasmJsNodeTest` fails with a WebAssembly compile error similar to:
|
||||||
|
- `struct.set expected type (ref null XXXX), found global.get of type (ref null YYYY)`
|
||||||
|
- The failing function name in the wasm name section looks like:
|
||||||
|
- `net.sergeych.lyng.$invokeCOROUTINE$.doResume`
|
||||||
|
|
||||||
|
## Root cause
|
||||||
|
The delegation/var-declaration changes introduced compiler-generated suspend lambdas inside `Statement` construction (e.g., `statement { ... }` wrappers). Kotlin/Wasm generates extra coroutine state for those suspend lambdas, which in this case produced invalid wasm IR (mismatched GC reference types). The browser loader then waits forever because the module fails to instantiate.
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
Avoid suspend-lambda `Statement` construction in compiler code paths. Replace `statement { ... }` and other anonymous suspend lambdas with explicit `object : Statement()` implementations and move logic into `override suspend fun execute(...)`. This keeps the resulting wasm IR valid while preserving behavior.
|
||||||
|
|
||||||
|
## Where it was fixed
|
||||||
|
- `lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt`
|
||||||
|
- `lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt`
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- `./gradlew :lynglib:wasmJsNodeTest --info`
|
||||||
|
- `./gradlew :lynglib:wasmJsBrowserTest --info`
|
||||||
|
|
||||||
|
Both tests finish quickly after the change.
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
actual object Benchmarks {
|
||||||
|
actual val enabled: Boolean = run {
|
||||||
|
val p = System.getProperty("LYNG_BENCHMARKS")?.lowercase()
|
||||||
|
val e = System.getenv("BENCHMARKS")?.lowercase()
|
||||||
|
fun parse(v: String?): Boolean =
|
||||||
|
v == "true" || v == "1" || v == "yes"
|
||||||
|
parse(p) || parse(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ data class ParsedArgument(
|
|||||||
count++
|
count++
|
||||||
if (count > limit) break
|
if (count > limit) break
|
||||||
}
|
}
|
||||||
if (!hasSplatOrNamed && count == this.size) {
|
if (!hasSplatOrNamed && count == this.size) {
|
||||||
val quick = when (count) {
|
val quick = when (count) {
|
||||||
0 -> Arguments.EMPTY
|
0 -> Arguments.EMPTY
|
||||||
1 -> Arguments(listOf(this.elementAt(0).value.execute(scope)), tailBlockMode)
|
1 -> Arguments(listOf(this.elementAt(0).value.execute(scope)), tailBlockMode)
|
||||||
@@ -154,11 +154,11 @@ data class ParsedArgument(
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
if (quick != null) return quick
|
if (quick != null) return quick
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// General path: build positional list and named map, enforcing ordering rules
|
// General path: build positional list and named map, enforcing ordering rules
|
||||||
val positional: MutableList<Obj> = mutableListOf()
|
val positional: MutableList<Obj> = mutableListOf()
|
||||||
var named: MutableMap<String, Obj>? = null
|
var named: MutableMap<String, Obj>? = null
|
||||||
var namedSeen = false
|
var namedSeen = false
|
||||||
for ((idx, x) in this.withIndex()) {
|
for ((idx, x) in this.withIndex()) {
|
||||||
@@ -254,4 +254,3 @@ data class ParsedArgument(
|
|||||||
fun from(values: Collection<Obj>) = Arguments(values.toList())
|
fun from(values: Collection<Obj>) = Arguments(values.toList())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
expect object Benchmarks {
|
||||||
|
val enabled: Boolean
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -392,6 +392,24 @@ open class Scope(
|
|||||||
nameToSlot[name]?.let { slots[it] = record }
|
nameToSlot[name]?.let { slots[it] = record }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply a precomputed slot plan (name -> slot index) for this scope.
|
||||||
|
* This enables direct slot references to bypass name-based lookup.
|
||||||
|
*/
|
||||||
|
fun applySlotPlan(plan: Map<String, Int>) {
|
||||||
|
if (plan.isEmpty()) return
|
||||||
|
val maxIndex = plan.values.maxOrNull() ?: return
|
||||||
|
if (slots.size <= maxIndex) {
|
||||||
|
val targetSize = maxIndex + 1
|
||||||
|
while (slots.size < targetSize) {
|
||||||
|
slots.add(ObjRecord(ObjUnset, isMutable = true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ((name, idx) in plan) {
|
||||||
|
nameToSlot[name] = idx
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear all references and maps to prevent memory leaks when pooled.
|
* Clear all references and maps to prevent memory leaks when pooled.
|
||||||
*/
|
*/
|
||||||
@@ -503,6 +521,7 @@ open class Scope(
|
|||||||
if (this is ClosureScope) {
|
if (this is ClosureScope) {
|
||||||
callScope.localBindings[name] = it
|
callScope.localBindings[name] = it
|
||||||
}
|
}
|
||||||
|
bumpClassLayoutIfNeeded(name, value, recordType)
|
||||||
it
|
it
|
||||||
} ?: addItem(name, true, value, visibility, writeVisibility, recordType, isAbstract = isAbstract, isClosed = isClosed, isOverride = isOverride)
|
} ?: addItem(name, true, value, visibility, writeVisibility, recordType, isAbstract = isAbstract, isClosed = isClosed, isOverride = isOverride)
|
||||||
|
|
||||||
@@ -529,6 +548,24 @@ open class Scope(
|
|||||||
isTransient = isTransient
|
isTransient = isTransient
|
||||||
)
|
)
|
||||||
objects[name] = rec
|
objects[name] = rec
|
||||||
|
bumpClassLayoutIfNeeded(name, value, recordType)
|
||||||
|
if (recordType == ObjRecord.Type.Field || recordType == ObjRecord.Type.ConstructorField) {
|
||||||
|
val inst = thisObj as? net.sergeych.lyng.obj.ObjInstance
|
||||||
|
if (inst != null) {
|
||||||
|
val slot = inst.objClass.fieldSlotForKey(name)
|
||||||
|
if (slot != null) inst.setFieldSlotRecord(slot.slot, rec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value is Statement ||
|
||||||
|
recordType == ObjRecord.Type.Fun ||
|
||||||
|
recordType == ObjRecord.Type.Delegated ||
|
||||||
|
recordType == ObjRecord.Type.Property) {
|
||||||
|
val inst = thisObj as? net.sergeych.lyng.obj.ObjInstance
|
||||||
|
if (inst != null) {
|
||||||
|
val slot = inst.objClass.methodSlotForKey(name)
|
||||||
|
if (slot != null) inst.setMethodSlotRecord(slot.slot, rec)
|
||||||
|
}
|
||||||
|
}
|
||||||
// Index this binding within the current frame to help resolve locals across suspension
|
// Index this binding within the current frame to help resolve locals across suspension
|
||||||
localBindings[name] = rec
|
localBindings[name] = rec
|
||||||
// If we are a ClosureScope, mirror binding into the caller frame to keep it discoverable
|
// If we are a ClosureScope, mirror binding into the caller frame to keep it discoverable
|
||||||
@@ -558,6 +595,14 @@ open class Scope(
|
|||||||
return rec
|
return rec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun bumpClassLayoutIfNeeded(name: String, value: Obj, recordType: ObjRecord.Type) {
|
||||||
|
val cls = thisObj as? net.sergeych.lyng.obj.ObjClass ?: return
|
||||||
|
if (cls.classScope !== this) return
|
||||||
|
if (!(value is Statement || recordType == ObjRecord.Type.Fun || recordType == ObjRecord.Type.Delegated)) return
|
||||||
|
if (cls.members.containsKey(name)) return
|
||||||
|
cls.layoutVersion += 1
|
||||||
|
}
|
||||||
|
|
||||||
fun getOrCreateNamespace(name: String): ObjClass {
|
fun getOrCreateNamespace(name: String): ObjClass {
|
||||||
val ns = objects.getOrPut(name) { ObjRecord(ObjNamespace(name), isMutable = false) }.value
|
val ns = objects.getOrPut(name) { ObjRecord(ObjNamespace(name), isMutable = false) }.value
|
||||||
return ns.objClass
|
return ns.objClass
|
||||||
|
|||||||
@@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
class BytecodeBuilder {
|
||||||
|
sealed interface Operand {
|
||||||
|
data class IntVal(val value: Int) : Operand
|
||||||
|
data class LabelRef(val label: Label) : Operand
|
||||||
|
}
|
||||||
|
|
||||||
|
data class Label(val id: Int)
|
||||||
|
|
||||||
|
data class Instr(val op: Opcode, val operands: List<Operand>)
|
||||||
|
|
||||||
|
private val instructions = mutableListOf<Instr>()
|
||||||
|
private val constPool = mutableListOf<BytecodeConst>()
|
||||||
|
private val labelPositions = mutableMapOf<Label, Int>()
|
||||||
|
private var nextLabelId = 0
|
||||||
|
private val fallbackStatements = mutableListOf<net.sergeych.lyng.Statement>()
|
||||||
|
|
||||||
|
fun addConst(c: BytecodeConst): Int {
|
||||||
|
constPool += c
|
||||||
|
return constPool.lastIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
fun emit(op: Opcode, vararg operands: Int) {
|
||||||
|
instructions += Instr(op, operands.map { Operand.IntVal(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
fun emit(op: Opcode, operands: List<Operand>) {
|
||||||
|
instructions += Instr(op, operands)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun label(): Label = Label(nextLabelId++)
|
||||||
|
|
||||||
|
fun mark(label: Label) {
|
||||||
|
labelPositions[label] = instructions.size
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addFallback(stmt: net.sergeych.lyng.Statement): Int {
|
||||||
|
fallbackStatements += stmt
|
||||||
|
return fallbackStatements.lastIndex
|
||||||
|
}
|
||||||
|
|
||||||
|
fun build(name: String, localCount: Int): BytecodeFunction {
|
||||||
|
val slotWidth = when {
|
||||||
|
localCount < 256 -> 1
|
||||||
|
localCount < 65536 -> 2
|
||||||
|
else -> 4
|
||||||
|
}
|
||||||
|
val constIdWidth = if (constPool.size < 65536) 2 else 4
|
||||||
|
val ipWidth = 2
|
||||||
|
val instrOffsets = IntArray(instructions.size)
|
||||||
|
var currentIp = 0
|
||||||
|
for (i in instructions.indices) {
|
||||||
|
instrOffsets[i] = currentIp
|
||||||
|
val kinds = operandKinds(instructions[i].op)
|
||||||
|
currentIp += 1 + kinds.sumOf { operandWidth(it, slotWidth, constIdWidth, ipWidth) }
|
||||||
|
}
|
||||||
|
val labelIps = mutableMapOf<Label, Int>()
|
||||||
|
for ((label, idx) in labelPositions) {
|
||||||
|
labelIps[label] = instrOffsets.getOrNull(idx) ?: error("Invalid label index: $idx")
|
||||||
|
}
|
||||||
|
|
||||||
|
val code = ByteArrayOutput()
|
||||||
|
for (ins in instructions) {
|
||||||
|
code.writeU8(ins.op.code and 0xFF)
|
||||||
|
val kinds = operandKinds(ins.op)
|
||||||
|
if (kinds.size != ins.operands.size) {
|
||||||
|
error("Operand count mismatch for ${ins.op}: expected ${kinds.size}, got ${ins.operands.size}")
|
||||||
|
}
|
||||||
|
for (i in kinds.indices) {
|
||||||
|
val operand = ins.operands[i]
|
||||||
|
val v = when (operand) {
|
||||||
|
is Operand.IntVal -> operand.value
|
||||||
|
is Operand.LabelRef -> labelIps[operand.label]
|
||||||
|
?: error("Unknown label ${operand.label.id} for ${ins.op}")
|
||||||
|
}
|
||||||
|
when (kinds[i]) {
|
||||||
|
OperandKind.SLOT -> code.writeUInt(v, slotWidth)
|
||||||
|
OperandKind.CONST -> code.writeUInt(v, constIdWidth)
|
||||||
|
OperandKind.IP -> code.writeUInt(v, ipWidth)
|
||||||
|
OperandKind.COUNT -> code.writeUInt(v, 2)
|
||||||
|
OperandKind.ID -> code.writeUInt(v, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BytecodeFunction(
|
||||||
|
name = name,
|
||||||
|
localCount = localCount,
|
||||||
|
slotWidth = slotWidth,
|
||||||
|
ipWidth = ipWidth,
|
||||||
|
constIdWidth = constIdWidth,
|
||||||
|
constants = constPool.toList(),
|
||||||
|
fallbackStatements = fallbackStatements.toList(),
|
||||||
|
code = code.toByteArray()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun operandKinds(op: Opcode): List<OperandKind> {
|
||||||
|
return when (op) {
|
||||||
|
Opcode.NOP, Opcode.RET_VOID -> emptyList()
|
||||||
|
Opcode.MOVE_OBJ, Opcode.MOVE_INT, Opcode.MOVE_REAL, Opcode.MOVE_BOOL,
|
||||||
|
Opcode.INT_TO_REAL, Opcode.REAL_TO_INT, Opcode.BOOL_TO_INT, Opcode.INT_TO_BOOL,
|
||||||
|
Opcode.NEG_INT, Opcode.NEG_REAL, Opcode.NOT_BOOL, Opcode.INV_INT ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.CONST_NULL ->
|
||||||
|
listOf(OperandKind.SLOT)
|
||||||
|
Opcode.CONST_OBJ, Opcode.CONST_INT, Opcode.CONST_REAL, Opcode.CONST_BOOL ->
|
||||||
|
listOf(OperandKind.CONST, OperandKind.SLOT)
|
||||||
|
Opcode.ADD_INT, Opcode.SUB_INT, Opcode.MUL_INT, Opcode.DIV_INT, Opcode.MOD_INT,
|
||||||
|
Opcode.ADD_REAL, Opcode.SUB_REAL, Opcode.MUL_REAL, Opcode.DIV_REAL,
|
||||||
|
Opcode.AND_INT, Opcode.OR_INT, Opcode.XOR_INT, Opcode.SHL_INT, Opcode.SHR_INT, Opcode.USHR_INT,
|
||||||
|
Opcode.CMP_EQ_INT, Opcode.CMP_NEQ_INT, Opcode.CMP_LT_INT, Opcode.CMP_LTE_INT,
|
||||||
|
Opcode.CMP_GT_INT, Opcode.CMP_GTE_INT,
|
||||||
|
Opcode.CMP_EQ_REAL, Opcode.CMP_NEQ_REAL, Opcode.CMP_LT_REAL, Opcode.CMP_LTE_REAL,
|
||||||
|
Opcode.CMP_GT_REAL, Opcode.CMP_GTE_REAL,
|
||||||
|
Opcode.CMP_EQ_BOOL, Opcode.CMP_NEQ_BOOL,
|
||||||
|
Opcode.CMP_EQ_INT_REAL, Opcode.CMP_EQ_REAL_INT, Opcode.CMP_LT_INT_REAL, Opcode.CMP_LT_REAL_INT,
|
||||||
|
Opcode.CMP_LTE_INT_REAL, Opcode.CMP_LTE_REAL_INT, Opcode.CMP_GT_INT_REAL, Opcode.CMP_GT_REAL_INT,
|
||||||
|
Opcode.CMP_GTE_INT_REAL, Opcode.CMP_GTE_REAL_INT, Opcode.CMP_NEQ_INT_REAL, Opcode.CMP_NEQ_REAL_INT,
|
||||||
|
Opcode.CMP_EQ_OBJ, Opcode.CMP_NEQ_OBJ, Opcode.CMP_REF_EQ_OBJ, Opcode.CMP_REF_NEQ_OBJ,
|
||||||
|
Opcode.CMP_LT_OBJ, Opcode.CMP_LTE_OBJ, Opcode.CMP_GT_OBJ, Opcode.CMP_GTE_OBJ,
|
||||||
|
Opcode.AND_BOOL, Opcode.OR_BOOL ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.INC_INT, Opcode.DEC_INT, Opcode.RET ->
|
||||||
|
listOf(OperandKind.SLOT)
|
||||||
|
Opcode.JMP ->
|
||||||
|
listOf(OperandKind.IP)
|
||||||
|
Opcode.JMP_IF_TRUE, Opcode.JMP_IF_FALSE ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.IP)
|
||||||
|
Opcode.CALL_DIRECT, Opcode.CALL_FALLBACK ->
|
||||||
|
listOf(OperandKind.ID, OperandKind.SLOT, OperandKind.COUNT, OperandKind.SLOT)
|
||||||
|
Opcode.CALL_VIRTUAL ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT, OperandKind.COUNT, OperandKind.SLOT)
|
||||||
|
Opcode.GET_FIELD ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT)
|
||||||
|
Opcode.SET_FIELD ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT)
|
||||||
|
Opcode.GET_INDEX ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.SET_INDEX ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.EVAL_FALLBACK ->
|
||||||
|
listOf(OperandKind.ID, OperandKind.SLOT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun operandWidth(kind: OperandKind, slotWidth: Int, constIdWidth: Int, ipWidth: Int): Int {
|
||||||
|
return when (kind) {
|
||||||
|
OperandKind.SLOT -> slotWidth
|
||||||
|
OperandKind.CONST -> constIdWidth
|
||||||
|
OperandKind.IP -> ipWidth
|
||||||
|
OperandKind.COUNT -> 2
|
||||||
|
OperandKind.ID -> 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum class OperandKind {
|
||||||
|
SLOT,
|
||||||
|
CONST,
|
||||||
|
IP,
|
||||||
|
COUNT,
|
||||||
|
ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ByteArrayOutput {
|
||||||
|
private val data = ArrayList<Byte>(256)
|
||||||
|
|
||||||
|
fun writeU8(v: Int) {
|
||||||
|
data.add((v and 0xFF).toByte())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun writeUInt(v: Int, width: Int) {
|
||||||
|
var value = v
|
||||||
|
var remaining = width
|
||||||
|
while (remaining-- > 0) {
|
||||||
|
writeU8(value)
|
||||||
|
value = value ushr 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun toByteArray(): ByteArray = data.toByteArray()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,623 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
import net.sergeych.lyng.ExpressionStatement
|
||||||
|
import net.sergeych.lyng.IfStatement
|
||||||
|
import net.sergeych.lyng.Pos
|
||||||
|
import net.sergeych.lyng.Statement
|
||||||
|
import net.sergeych.lyng.ToBoolStatement
|
||||||
|
import net.sergeych.lyng.obj.*
|
||||||
|
|
||||||
|
class BytecodeCompiler {
|
||||||
|
private val builder = BytecodeBuilder()
|
||||||
|
private var nextSlot = 0
|
||||||
|
private val slotTypes = mutableMapOf<Int, SlotType>()
|
||||||
|
|
||||||
|
fun compileStatement(name: String, stmt: net.sergeych.lyng.Statement): BytecodeFunction? {
|
||||||
|
return when (stmt) {
|
||||||
|
is ExpressionStatement -> compileExpression(name, stmt)
|
||||||
|
is net.sergeych.lyng.IfStatement -> compileIf(name, stmt)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun compileExpression(name: String, stmt: ExpressionStatement): BytecodeFunction? {
|
||||||
|
val value = compileRefWithFallback(stmt.ref, null, stmt.pos) ?: return null
|
||||||
|
builder.emit(Opcode.RET, value.slot)
|
||||||
|
val localCount = maxOf(nextSlot, value.slot + 1)
|
||||||
|
return builder.build(name, localCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
private data class CompiledValue(val slot: Int, val type: SlotType)
|
||||||
|
|
||||||
|
private fun allocSlot(): Int = nextSlot++
|
||||||
|
|
||||||
|
private fun compileRef(ref: ObjRef): CompiledValue? {
|
||||||
|
return when (ref) {
|
||||||
|
is ConstRef -> compileConst(ref.constValue)
|
||||||
|
is LocalSlotRef -> {
|
||||||
|
if (ref.name.isEmpty()) return null
|
||||||
|
if (refDepth(ref) != 0) return null
|
||||||
|
CompiledValue(refSlot(ref), slotTypes[refSlot(ref)] ?: SlotType.UNKNOWN)
|
||||||
|
}
|
||||||
|
is BinaryOpRef -> compileBinary(ref)
|
||||||
|
is UnaryOpRef -> compileUnary(ref)
|
||||||
|
is AssignRef -> compileAssign(ref)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileConst(obj: Obj): CompiledValue? {
|
||||||
|
val slot = allocSlot()
|
||||||
|
when (obj) {
|
||||||
|
is ObjInt -> {
|
||||||
|
val id = builder.addConst(BytecodeConst.IntVal(obj.value))
|
||||||
|
builder.emit(Opcode.CONST_INT, id, slot)
|
||||||
|
return CompiledValue(slot, SlotType.INT)
|
||||||
|
}
|
||||||
|
is ObjReal -> {
|
||||||
|
val id = builder.addConst(BytecodeConst.RealVal(obj.value))
|
||||||
|
builder.emit(Opcode.CONST_REAL, id, slot)
|
||||||
|
return CompiledValue(slot, SlotType.REAL)
|
||||||
|
}
|
||||||
|
is ObjBool -> {
|
||||||
|
val id = builder.addConst(BytecodeConst.Bool(obj.value))
|
||||||
|
builder.emit(Opcode.CONST_BOOL, id, slot)
|
||||||
|
return CompiledValue(slot, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
is ObjString -> {
|
||||||
|
val id = builder.addConst(BytecodeConst.StringVal(obj.value))
|
||||||
|
builder.emit(Opcode.CONST_OBJ, id, slot)
|
||||||
|
return CompiledValue(slot, SlotType.OBJ)
|
||||||
|
}
|
||||||
|
ObjNull -> {
|
||||||
|
builder.emit(Opcode.CONST_NULL, slot)
|
||||||
|
return CompiledValue(slot, SlotType.OBJ)
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
val id = builder.addConst(BytecodeConst.ObjRef(obj))
|
||||||
|
builder.emit(Opcode.CONST_OBJ, id, slot)
|
||||||
|
return CompiledValue(slot, SlotType.OBJ)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileUnary(ref: UnaryOpRef): CompiledValue? {
|
||||||
|
val a = compileRef(unaryOperand(ref)) ?: return null
|
||||||
|
val out = allocSlot()
|
||||||
|
return when (unaryOp(ref)) {
|
||||||
|
UnaryOp.NEGATE -> when (a.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.NEG_INT, a.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.NEG_REAL, a.slot, out)
|
||||||
|
CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
UnaryOp.NOT -> {
|
||||||
|
if (a.type != SlotType.BOOL) return null
|
||||||
|
builder.emit(Opcode.NOT_BOOL, a.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
UnaryOp.BITNOT -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.INV_INT, a.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileBinary(ref: BinaryOpRef): CompiledValue? {
|
||||||
|
val op = binaryOp(ref)
|
||||||
|
if (op == BinOp.AND || op == BinOp.OR) {
|
||||||
|
return compileLogical(op, binaryLeft(ref), binaryRight(ref), refPos(ref))
|
||||||
|
}
|
||||||
|
val a = compileRef(binaryLeft(ref)) ?: return null
|
||||||
|
val b = compileRef(binaryRight(ref)) ?: return null
|
||||||
|
val typesMismatch = a.type != b.type && a.type != SlotType.UNKNOWN && b.type != SlotType.UNKNOWN
|
||||||
|
if (typesMismatch && op !in setOf(BinOp.EQ, BinOp.NEQ, BinOp.LT, BinOp.LTE, BinOp.GT, BinOp.GTE)) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
val out = allocSlot()
|
||||||
|
return when (op) {
|
||||||
|
BinOp.PLUS -> when (a.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.ADD_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
SlotType.REAL -> compileRealArithmeticWithCoercion(Opcode.ADD_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SlotType.REAL -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.ADD_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
SlotType.INT -> compileRealArithmeticWithCoercion(Opcode.ADD_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
BinOp.MINUS -> when (a.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.SUB_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
SlotType.REAL -> compileRealArithmeticWithCoercion(Opcode.SUB_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SlotType.REAL -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.SUB_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
SlotType.INT -> compileRealArithmeticWithCoercion(Opcode.SUB_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
BinOp.STAR -> when (a.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.MUL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
SlotType.REAL -> compileRealArithmeticWithCoercion(Opcode.MUL_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SlotType.REAL -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.MUL_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
SlotType.INT -> compileRealArithmeticWithCoercion(Opcode.MUL_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
BinOp.SLASH -> when (a.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.DIV_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
SlotType.REAL -> compileRealArithmeticWithCoercion(Opcode.DIV_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SlotType.REAL -> {
|
||||||
|
when (b.type) {
|
||||||
|
SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.DIV_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
SlotType.INT -> compileRealArithmeticWithCoercion(Opcode.DIV_REAL, a, b, out)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
BinOp.PERCENT -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.MOD_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
BinOp.EQ -> {
|
||||||
|
compileCompareEq(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.NEQ -> {
|
||||||
|
compileCompareNeq(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.LT -> {
|
||||||
|
compileCompareLt(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.LTE -> {
|
||||||
|
compileCompareLte(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.GT -> {
|
||||||
|
compileCompareGt(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.GTE -> {
|
||||||
|
compileCompareGte(a, b, out)
|
||||||
|
}
|
||||||
|
BinOp.REF_EQ -> {
|
||||||
|
if (a.type != SlotType.OBJ || b.type != SlotType.OBJ) return null
|
||||||
|
builder.emit(Opcode.CMP_REF_EQ_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
BinOp.REF_NEQ -> {
|
||||||
|
if (a.type != SlotType.OBJ || b.type != SlotType.OBJ) return null
|
||||||
|
builder.emit(Opcode.CMP_REF_NEQ_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
BinOp.AND -> {
|
||||||
|
if (a.type != SlotType.BOOL) return null
|
||||||
|
builder.emit(Opcode.AND_BOOL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
BinOp.OR -> {
|
||||||
|
if (a.type != SlotType.BOOL) return null
|
||||||
|
builder.emit(Opcode.OR_BOOL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
BinOp.BAND -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.AND_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
BinOp.BOR -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.OR_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
BinOp.BXOR -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.XOR_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
BinOp.SHL -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.SHL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
BinOp.SHR -> {
|
||||||
|
if (a.type != SlotType.INT) return null
|
||||||
|
builder.emit(Opcode.SHR_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.INT)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileRealArithmeticWithCoercion(
|
||||||
|
op: Opcode,
|
||||||
|
a: CompiledValue,
|
||||||
|
b: CompiledValue,
|
||||||
|
out: Int
|
||||||
|
): CompiledValue? {
|
||||||
|
if (a.type == SlotType.INT && b.type == SlotType.REAL) {
|
||||||
|
val left = allocSlot()
|
||||||
|
builder.emit(Opcode.INT_TO_REAL, a.slot, left)
|
||||||
|
builder.emit(op, left, b.slot, out)
|
||||||
|
return CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
if (a.type == SlotType.REAL && b.type == SlotType.INT) {
|
||||||
|
val right = allocSlot()
|
||||||
|
builder.emit(Opcode.INT_TO_REAL, b.slot, right)
|
||||||
|
builder.emit(op, a.slot, right, out)
|
||||||
|
return CompiledValue(out, SlotType.REAL)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareEq(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.BOOL && b.type == SlotType.BOOL -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_BOOL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_EQ_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareNeq(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.BOOL && b.type == SlotType.BOOL -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_BOOL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_NEQ_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareLt(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_LT_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_LT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_LT_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_LT_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_LT_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareLte(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_LTE_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_LTE_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_LTE_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_LTE_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_LTE_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareGt(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_GT_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_GT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_GT_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_GT_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_GT_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileCompareGte(a: CompiledValue, b: CompiledValue, out: Int): CompiledValue? {
|
||||||
|
if (a.type == SlotType.UNKNOWN || b.type == SlotType.UNKNOWN) return null
|
||||||
|
return when {
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_GTE_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_GTE_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.INT && b.type == SlotType.REAL -> {
|
||||||
|
builder.emit(Opcode.CMP_GTE_INT_REAL, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.REAL && b.type == SlotType.INT -> {
|
||||||
|
builder.emit(Opcode.CMP_GTE_REAL_INT, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
a.type == SlotType.OBJ && b.type == SlotType.OBJ -> {
|
||||||
|
builder.emit(Opcode.CMP_GTE_OBJ, a.slot, b.slot, out)
|
||||||
|
CompiledValue(out, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileLogical(op: BinOp, left: ObjRef, right: ObjRef, pos: Pos): CompiledValue? {
|
||||||
|
val leftValue = compileRefWithFallback(left, SlotType.BOOL, pos) ?: return null
|
||||||
|
if (leftValue.type != SlotType.BOOL) return null
|
||||||
|
val resultSlot = allocSlot()
|
||||||
|
val shortLabel = builder.label()
|
||||||
|
val endLabel = builder.label()
|
||||||
|
if (op == BinOp.AND) {
|
||||||
|
builder.emit(
|
||||||
|
Opcode.JMP_IF_FALSE,
|
||||||
|
listOf(BytecodeBuilder.Operand.IntVal(leftValue.slot), BytecodeBuilder.Operand.LabelRef(shortLabel))
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
builder.emit(
|
||||||
|
Opcode.JMP_IF_TRUE,
|
||||||
|
listOf(BytecodeBuilder.Operand.IntVal(leftValue.slot), BytecodeBuilder.Operand.LabelRef(shortLabel))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val rightValue = compileRefWithFallback(right, SlotType.BOOL, pos) ?: return null
|
||||||
|
emitMove(rightValue, resultSlot)
|
||||||
|
builder.emit(Opcode.JMP, listOf(BytecodeBuilder.Operand.LabelRef(endLabel)))
|
||||||
|
builder.mark(shortLabel)
|
||||||
|
val constId = builder.addConst(BytecodeConst.Bool(op == BinOp.OR))
|
||||||
|
builder.emit(Opcode.CONST_BOOL, constId, resultSlot)
|
||||||
|
builder.mark(endLabel)
|
||||||
|
return CompiledValue(resultSlot, SlotType.BOOL)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileAssign(ref: AssignRef): CompiledValue? {
|
||||||
|
val target = assignTarget(ref) ?: return null
|
||||||
|
if (refDepth(target) != 0) return null
|
||||||
|
val value = compileRef(assignValue(ref)) ?: return null
|
||||||
|
val slot = refSlot(target)
|
||||||
|
when (value.type) {
|
||||||
|
SlotType.INT -> builder.emit(Opcode.MOVE_INT, value.slot, slot)
|
||||||
|
SlotType.REAL -> builder.emit(Opcode.MOVE_REAL, value.slot, slot)
|
||||||
|
SlotType.BOOL -> builder.emit(Opcode.MOVE_BOOL, value.slot, slot)
|
||||||
|
else -> builder.emit(Opcode.MOVE_OBJ, value.slot, slot)
|
||||||
|
}
|
||||||
|
updateSlotType(slot, value.type)
|
||||||
|
return CompiledValue(slot, value.type)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileIf(name: String, stmt: IfStatement): BytecodeFunction? {
|
||||||
|
val conditionStmt = stmt.condition as? ExpressionStatement ?: return null
|
||||||
|
val condValue = compileRefWithFallback(conditionStmt.ref, SlotType.BOOL, stmt.pos) ?: return null
|
||||||
|
if (condValue.type != SlotType.BOOL) return null
|
||||||
|
|
||||||
|
val resultSlot = allocSlot()
|
||||||
|
val elseLabel = builder.label()
|
||||||
|
val endLabel = builder.label()
|
||||||
|
|
||||||
|
builder.emit(
|
||||||
|
Opcode.JMP_IF_FALSE,
|
||||||
|
listOf(BytecodeBuilder.Operand.IntVal(condValue.slot), BytecodeBuilder.Operand.LabelRef(elseLabel))
|
||||||
|
)
|
||||||
|
val thenValue = compileStatementValue(stmt.ifBody) ?: return null
|
||||||
|
emitMove(thenValue, resultSlot)
|
||||||
|
builder.emit(Opcode.JMP, listOf(BytecodeBuilder.Operand.LabelRef(endLabel)))
|
||||||
|
|
||||||
|
builder.mark(elseLabel)
|
||||||
|
if (stmt.elseBody != null) {
|
||||||
|
val elseValue = compileStatementValue(stmt.elseBody) ?: return null
|
||||||
|
emitMove(elseValue, resultSlot)
|
||||||
|
} else {
|
||||||
|
val id = builder.addConst(BytecodeConst.ObjRef(ObjVoid))
|
||||||
|
builder.emit(Opcode.CONST_OBJ, id, resultSlot)
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.mark(endLabel)
|
||||||
|
builder.emit(Opcode.RET, resultSlot)
|
||||||
|
val localCount = maxOf(nextSlot, resultSlot + 1)
|
||||||
|
return builder.build(name, localCount)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileStatementValue(stmt: Statement): CompiledValue? {
|
||||||
|
return when (stmt) {
|
||||||
|
is ExpressionStatement -> compileRefWithFallback(stmt.ref, null, stmt.pos)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun emitMove(value: CompiledValue, dstSlot: Int) {
|
||||||
|
when (value.type) {
|
||||||
|
SlotType.INT -> builder.emit(Opcode.MOVE_INT, value.slot, dstSlot)
|
||||||
|
SlotType.REAL -> builder.emit(Opcode.MOVE_REAL, value.slot, dstSlot)
|
||||||
|
SlotType.BOOL -> builder.emit(Opcode.MOVE_BOOL, value.slot, dstSlot)
|
||||||
|
else -> builder.emit(Opcode.MOVE_OBJ, value.slot, dstSlot)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun compileRefWithFallback(ref: ObjRef, forceType: SlotType?, pos: Pos): CompiledValue? {
|
||||||
|
val compiled = compileRef(ref)
|
||||||
|
if (compiled != null && (forceType == null || compiled.type == forceType || compiled.type == SlotType.UNKNOWN)) {
|
||||||
|
return if (forceType != null && compiled.type == SlotType.UNKNOWN) {
|
||||||
|
CompiledValue(compiled.slot, forceType)
|
||||||
|
} else compiled
|
||||||
|
}
|
||||||
|
val slot = allocSlot()
|
||||||
|
val stmt = if (forceType == SlotType.BOOL) {
|
||||||
|
ToBoolStatement(ExpressionStatement(ref, pos), pos)
|
||||||
|
} else {
|
||||||
|
ExpressionStatement(ref, pos)
|
||||||
|
}
|
||||||
|
val id = builder.addFallback(stmt)
|
||||||
|
builder.emit(Opcode.EVAL_FALLBACK, id, slot)
|
||||||
|
updateSlotType(slot, forceType ?: SlotType.OBJ)
|
||||||
|
return CompiledValue(slot, forceType ?: SlotType.OBJ)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun refSlot(ref: LocalSlotRef): Int = ref.slot
|
||||||
|
private fun refDepth(ref: LocalSlotRef): Int = ref.depth
|
||||||
|
private fun binaryLeft(ref: BinaryOpRef): ObjRef = ref.left
|
||||||
|
private fun binaryRight(ref: BinaryOpRef): ObjRef = ref.right
|
||||||
|
private fun binaryOp(ref: BinaryOpRef): BinOp = ref.op
|
||||||
|
private fun unaryOperand(ref: UnaryOpRef): ObjRef = ref.a
|
||||||
|
private fun unaryOp(ref: UnaryOpRef): UnaryOp = ref.op
|
||||||
|
private fun assignTarget(ref: AssignRef): LocalSlotRef? = ref.target as? LocalSlotRef
|
||||||
|
private fun assignValue(ref: AssignRef): ObjRef = ref.value
|
||||||
|
private fun refPos(ref: BinaryOpRef): Pos = Pos.builtIn
|
||||||
|
|
||||||
|
private fun updateSlotType(slot: Int, type: SlotType) {
|
||||||
|
if (type == SlotType.UNKNOWN) {
|
||||||
|
slotTypes.remove(slot)
|
||||||
|
} else {
|
||||||
|
slotTypes[slot] = type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
import net.sergeych.lyng.obj.Obj
|
||||||
|
|
||||||
|
sealed class BytecodeConst {
|
||||||
|
object Null : BytecodeConst()
|
||||||
|
data class Bool(val value: Boolean) : BytecodeConst()
|
||||||
|
data class IntVal(val value: Long) : BytecodeConst()
|
||||||
|
data class RealVal(val value: Double) : BytecodeConst()
|
||||||
|
data class StringVal(val value: String) : BytecodeConst()
|
||||||
|
data class ObjRef(val value: Obj) : BytecodeConst()
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
interface BytecodeDecoder {
|
||||||
|
fun readOpcode(code: ByteArray, ip: Int): Opcode
|
||||||
|
fun readSlot(code: ByteArray, ip: Int): Int
|
||||||
|
fun readConstId(code: ByteArray, ip: Int, width: Int): Int
|
||||||
|
fun readIp(code: ByteArray, ip: Int, width: Int): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
object Decoder8 : BytecodeDecoder {
|
||||||
|
override fun readOpcode(code: ByteArray, ip: Int): Opcode =
|
||||||
|
Opcode.fromCode(code[ip].toInt() and 0xFF) ?: error("Unknown opcode: ${code[ip]}")
|
||||||
|
|
||||||
|
override fun readSlot(code: ByteArray, ip: Int): Int = code[ip].toInt() and 0xFF
|
||||||
|
|
||||||
|
override fun readConstId(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
|
||||||
|
override fun readIp(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
}
|
||||||
|
|
||||||
|
object Decoder16 : BytecodeDecoder {
|
||||||
|
override fun readOpcode(code: ByteArray, ip: Int): Opcode =
|
||||||
|
Opcode.fromCode(code[ip].toInt() and 0xFF) ?: error("Unknown opcode: ${code[ip]}")
|
||||||
|
|
||||||
|
override fun readSlot(code: ByteArray, ip: Int): Int =
|
||||||
|
(code[ip].toInt() and 0xFF) or ((code[ip + 1].toInt() and 0xFF) shl 8)
|
||||||
|
|
||||||
|
override fun readConstId(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
|
||||||
|
override fun readIp(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
}
|
||||||
|
|
||||||
|
object Decoder32 : BytecodeDecoder {
|
||||||
|
override fun readOpcode(code: ByteArray, ip: Int): Opcode =
|
||||||
|
Opcode.fromCode(code[ip].toInt() and 0xFF) ?: error("Unknown opcode: ${code[ip]}")
|
||||||
|
|
||||||
|
override fun readSlot(code: ByteArray, ip: Int): Int = readUInt(code, ip, 4)
|
||||||
|
|
||||||
|
override fun readConstId(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
|
||||||
|
override fun readIp(code: ByteArray, ip: Int, width: Int): Int =
|
||||||
|
readUInt(code, ip, width)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readUInt(code: ByteArray, ip: Int, width: Int): Int {
|
||||||
|
var result = 0
|
||||||
|
var shift = 0
|
||||||
|
var idx = ip
|
||||||
|
var remaining = width
|
||||||
|
while (remaining-- > 0) {
|
||||||
|
result = result or ((code[idx].toInt() and 0xFF) shl shift)
|
||||||
|
shift += 8
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
object BytecodeDisassembler {
|
||||||
|
fun disassemble(fn: BytecodeFunction): String {
|
||||||
|
val decoder = when (fn.slotWidth) {
|
||||||
|
1 -> Decoder8
|
||||||
|
2 -> Decoder16
|
||||||
|
4 -> Decoder32
|
||||||
|
else -> error("Unsupported slot width: ${fn.slotWidth}")
|
||||||
|
}
|
||||||
|
val out = StringBuilder()
|
||||||
|
val code = fn.code
|
||||||
|
var ip = 0
|
||||||
|
while (ip < code.size) {
|
||||||
|
val op = decoder.readOpcode(code, ip)
|
||||||
|
val startIp = ip
|
||||||
|
ip += 1
|
||||||
|
val kinds = operandKinds(op)
|
||||||
|
val operands = ArrayList<String>(kinds.size)
|
||||||
|
for (kind in kinds) {
|
||||||
|
when (kind) {
|
||||||
|
OperandKind.SLOT -> {
|
||||||
|
val v = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
operands += "s$v"
|
||||||
|
}
|
||||||
|
OperandKind.CONST -> {
|
||||||
|
val v = decoder.readConstId(code, ip, fn.constIdWidth)
|
||||||
|
ip += fn.constIdWidth
|
||||||
|
operands += "k$v"
|
||||||
|
}
|
||||||
|
OperandKind.IP -> {
|
||||||
|
val v = decoder.readIp(code, ip, fn.ipWidth)
|
||||||
|
ip += fn.ipWidth
|
||||||
|
operands += "ip$v"
|
||||||
|
}
|
||||||
|
OperandKind.COUNT -> {
|
||||||
|
val v = decoder.readConstId(code, ip, 2)
|
||||||
|
ip += 2
|
||||||
|
operands += "n$v"
|
||||||
|
}
|
||||||
|
OperandKind.ID -> {
|
||||||
|
val v = decoder.readConstId(code, ip, 2)
|
||||||
|
ip += 2
|
||||||
|
operands += "#$v"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.append(startIp).append(": ").append(op.name)
|
||||||
|
if (operands.isNotEmpty()) {
|
||||||
|
out.append(' ').append(operands.joinToString(", "))
|
||||||
|
}
|
||||||
|
out.append('\n')
|
||||||
|
}
|
||||||
|
return out.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum class OperandKind {
|
||||||
|
SLOT,
|
||||||
|
CONST,
|
||||||
|
IP,
|
||||||
|
COUNT,
|
||||||
|
ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun operandKinds(op: Opcode): List<OperandKind> {
|
||||||
|
return when (op) {
|
||||||
|
Opcode.NOP, Opcode.RET_VOID -> emptyList()
|
||||||
|
Opcode.MOVE_OBJ, Opcode.MOVE_INT, Opcode.MOVE_REAL, Opcode.MOVE_BOOL,
|
||||||
|
Opcode.INT_TO_REAL, Opcode.REAL_TO_INT, Opcode.BOOL_TO_INT, Opcode.INT_TO_BOOL,
|
||||||
|
Opcode.NEG_INT, Opcode.NEG_REAL, Opcode.NOT_BOOL, Opcode.INV_INT ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.CONST_NULL ->
|
||||||
|
listOf(OperandKind.SLOT)
|
||||||
|
Opcode.CONST_OBJ, Opcode.CONST_INT, Opcode.CONST_REAL, Opcode.CONST_BOOL ->
|
||||||
|
listOf(OperandKind.CONST, OperandKind.SLOT)
|
||||||
|
Opcode.ADD_INT, Opcode.SUB_INT, Opcode.MUL_INT, Opcode.DIV_INT, Opcode.MOD_INT,
|
||||||
|
Opcode.ADD_REAL, Opcode.SUB_REAL, Opcode.MUL_REAL, Opcode.DIV_REAL,
|
||||||
|
Opcode.AND_INT, Opcode.OR_INT, Opcode.XOR_INT, Opcode.SHL_INT, Opcode.SHR_INT, Opcode.USHR_INT,
|
||||||
|
Opcode.CMP_EQ_INT, Opcode.CMP_NEQ_INT, Opcode.CMP_LT_INT, Opcode.CMP_LTE_INT,
|
||||||
|
Opcode.CMP_GT_INT, Opcode.CMP_GTE_INT,
|
||||||
|
Opcode.CMP_EQ_REAL, Opcode.CMP_NEQ_REAL, Opcode.CMP_LT_REAL, Opcode.CMP_LTE_REAL,
|
||||||
|
Opcode.CMP_GT_REAL, Opcode.CMP_GTE_REAL,
|
||||||
|
Opcode.CMP_EQ_BOOL, Opcode.CMP_NEQ_BOOL,
|
||||||
|
Opcode.CMP_EQ_INT_REAL, Opcode.CMP_EQ_REAL_INT, Opcode.CMP_LT_INT_REAL, Opcode.CMP_LT_REAL_INT,
|
||||||
|
Opcode.CMP_LTE_INT_REAL, Opcode.CMP_LTE_REAL_INT, Opcode.CMP_GT_INT_REAL, Opcode.CMP_GT_REAL_INT,
|
||||||
|
Opcode.CMP_GTE_INT_REAL, Opcode.CMP_GTE_REAL_INT, Opcode.CMP_NEQ_INT_REAL, Opcode.CMP_NEQ_REAL_INT,
|
||||||
|
Opcode.CMP_EQ_OBJ, Opcode.CMP_NEQ_OBJ, Opcode.CMP_REF_EQ_OBJ, Opcode.CMP_REF_NEQ_OBJ,
|
||||||
|
Opcode.CMP_LT_OBJ, Opcode.CMP_LTE_OBJ, Opcode.CMP_GT_OBJ, Opcode.CMP_GTE_OBJ,
|
||||||
|
Opcode.AND_BOOL, Opcode.OR_BOOL ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.INC_INT, Opcode.DEC_INT, Opcode.RET ->
|
||||||
|
listOf(OperandKind.SLOT)
|
||||||
|
Opcode.JMP ->
|
||||||
|
listOf(OperandKind.IP)
|
||||||
|
Opcode.JMP_IF_TRUE, Opcode.JMP_IF_FALSE ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.IP)
|
||||||
|
Opcode.CALL_DIRECT, Opcode.CALL_FALLBACK ->
|
||||||
|
listOf(OperandKind.ID, OperandKind.SLOT, OperandKind.COUNT, OperandKind.SLOT)
|
||||||
|
Opcode.CALL_VIRTUAL ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT, OperandKind.COUNT, OperandKind.SLOT)
|
||||||
|
Opcode.GET_FIELD ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT)
|
||||||
|
Opcode.SET_FIELD ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.ID, OperandKind.SLOT)
|
||||||
|
Opcode.GET_INDEX ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.SET_INDEX ->
|
||||||
|
listOf(OperandKind.SLOT, OperandKind.SLOT, OperandKind.SLOT)
|
||||||
|
Opcode.EVAL_FALLBACK ->
|
||||||
|
listOf(OperandKind.ID, OperandKind.SLOT)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
import net.sergeych.lyng.obj.Obj
|
||||||
|
import net.sergeych.lyng.obj.ObjNull
|
||||||
|
|
||||||
|
class BytecodeFrame(
|
||||||
|
val localCount: Int,
|
||||||
|
val argCount: Int,
|
||||||
|
) {
|
||||||
|
val slotCount: Int = localCount + argCount
|
||||||
|
val argBase: Int = localCount
|
||||||
|
|
||||||
|
private val slotTypes: ByteArray = ByteArray(slotCount) { SlotType.UNKNOWN.code }
|
||||||
|
private val objSlots: Array<Obj?> = arrayOfNulls(slotCount)
|
||||||
|
private val intSlots: LongArray = LongArray(slotCount)
|
||||||
|
private val realSlots: DoubleArray = DoubleArray(slotCount)
|
||||||
|
private val boolSlots: BooleanArray = BooleanArray(slotCount)
|
||||||
|
|
||||||
|
fun getSlotType(slot: Int): SlotType = SlotType.values().first { it.code == slotTypes[slot] }
|
||||||
|
fun getSlotTypeCode(slot: Int): Byte = slotTypes[slot]
|
||||||
|
fun setSlotType(slot: Int, type: SlotType) {
|
||||||
|
slotTypes[slot] = type.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getObj(slot: Int): Obj = objSlots[slot] ?: ObjNull
|
||||||
|
fun setObj(slot: Int, value: Obj) {
|
||||||
|
objSlots[slot] = value
|
||||||
|
slotTypes[slot] = SlotType.OBJ.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getInt(slot: Int): Long = intSlots[slot]
|
||||||
|
fun setInt(slot: Int, value: Long) {
|
||||||
|
intSlots[slot] = value
|
||||||
|
slotTypes[slot] = SlotType.INT.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getReal(slot: Int): Double = realSlots[slot]
|
||||||
|
fun setReal(slot: Int, value: Double) {
|
||||||
|
realSlots[slot] = value
|
||||||
|
slotTypes[slot] = SlotType.REAL.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBool(slot: Int): Boolean = boolSlots[slot]
|
||||||
|
fun setBool(slot: Int, value: Boolean) {
|
||||||
|
boolSlots[slot] = value
|
||||||
|
slotTypes[slot] = SlotType.BOOL.code
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearSlot(slot: Int) {
|
||||||
|
slotTypes[slot] = SlotType.UNKNOWN.code
|
||||||
|
objSlots[slot] = null
|
||||||
|
intSlots[slot] = 0L
|
||||||
|
realSlots[slot] = 0.0
|
||||||
|
boolSlots[slot] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
data class BytecodeFunction(
|
||||||
|
val name: String,
|
||||||
|
val localCount: Int,
|
||||||
|
val slotWidth: Int,
|
||||||
|
val ipWidth: Int,
|
||||||
|
val constIdWidth: Int,
|
||||||
|
val constants: List<BytecodeConst>,
|
||||||
|
val fallbackStatements: List<net.sergeych.lyng.Statement>,
|
||||||
|
val code: ByteArray,
|
||||||
|
) {
|
||||||
|
init {
|
||||||
|
require(slotWidth == 1 || slotWidth == 2 || slotWidth == 4) { "slotWidth must be 1,2,4" }
|
||||||
|
require(ipWidth == 2 || ipWidth == 4) { "ipWidth must be 2 or 4" }
|
||||||
|
require(constIdWidth == 2 || constIdWidth == 4) { "constIdWidth must be 2 or 4" }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,704 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
import net.sergeych.lyng.Scope
|
||||||
|
import net.sergeych.lyng.obj.*
|
||||||
|
|
||||||
|
class BytecodeVm {
|
||||||
|
suspend fun execute(fn: BytecodeFunction, scope: Scope, args: List<Obj>): Obj {
|
||||||
|
val frame = BytecodeFrame(fn.localCount, args.size)
|
||||||
|
for (i in args.indices) {
|
||||||
|
frame.setObj(frame.argBase + i, args[i])
|
||||||
|
}
|
||||||
|
val decoder = when (fn.slotWidth) {
|
||||||
|
1 -> Decoder8
|
||||||
|
2 -> Decoder16
|
||||||
|
4 -> Decoder32
|
||||||
|
else -> error("Unsupported slot width: ${fn.slotWidth}")
|
||||||
|
}
|
||||||
|
var ip = 0
|
||||||
|
val code = fn.code
|
||||||
|
while (ip < code.size) {
|
||||||
|
val op = decoder.readOpcode(code, ip)
|
||||||
|
ip += 1
|
||||||
|
when (op) {
|
||||||
|
Opcode.NOP -> {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
Opcode.CONST_INT -> {
|
||||||
|
val constId = decoder.readConstId(code, ip, fn.constIdWidth)
|
||||||
|
ip += fn.constIdWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val c = fn.constants[constId] as? BytecodeConst.IntVal
|
||||||
|
?: error("CONST_INT expects IntVal at $constId")
|
||||||
|
frame.setInt(dst, c.value)
|
||||||
|
}
|
||||||
|
Opcode.CONST_REAL -> {
|
||||||
|
val constId = decoder.readConstId(code, ip, fn.constIdWidth)
|
||||||
|
ip += fn.constIdWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val c = fn.constants[constId] as? BytecodeConst.RealVal
|
||||||
|
?: error("CONST_REAL expects RealVal at $constId")
|
||||||
|
frame.setReal(dst, c.value)
|
||||||
|
}
|
||||||
|
Opcode.CONST_BOOL -> {
|
||||||
|
val constId = decoder.readConstId(code, ip, fn.constIdWidth)
|
||||||
|
ip += fn.constIdWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val c = fn.constants[constId] as? BytecodeConst.Bool
|
||||||
|
?: error("CONST_BOOL expects Bool at $constId")
|
||||||
|
frame.setBool(dst, c.value)
|
||||||
|
}
|
||||||
|
Opcode.CONST_OBJ -> {
|
||||||
|
val constId = decoder.readConstId(code, ip, fn.constIdWidth)
|
||||||
|
ip += fn.constIdWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
when (val c = fn.constants[constId]) {
|
||||||
|
is BytecodeConst.ObjRef -> {
|
||||||
|
val obj = c.value
|
||||||
|
when (obj) {
|
||||||
|
is ObjInt -> frame.setInt(dst, obj.value)
|
||||||
|
is ObjReal -> frame.setReal(dst, obj.value)
|
||||||
|
is ObjBool -> frame.setBool(dst, obj.value)
|
||||||
|
else -> frame.setObj(dst, obj)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is BytecodeConst.StringVal -> frame.setObj(dst, ObjString(c.value))
|
||||||
|
else -> error("CONST_OBJ expects ObjRef/StringVal at $constId")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Opcode.CONST_NULL -> {
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setObj(dst, ObjNull)
|
||||||
|
}
|
||||||
|
Opcode.MOVE_INT -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(src))
|
||||||
|
}
|
||||||
|
Opcode.MOVE_REAL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getReal(src))
|
||||||
|
}
|
||||||
|
Opcode.MOVE_BOOL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getBool(src))
|
||||||
|
}
|
||||||
|
Opcode.MOVE_OBJ -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setObj(dst, frame.getObj(src))
|
||||||
|
}
|
||||||
|
Opcode.INT_TO_REAL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getInt(src).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.REAL_TO_INT -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getReal(src).toLong())
|
||||||
|
}
|
||||||
|
Opcode.BOOL_TO_INT -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, if (frame.getBool(src)) 1L else 0L)
|
||||||
|
}
|
||||||
|
Opcode.INT_TO_BOOL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(src) != 0L)
|
||||||
|
}
|
||||||
|
Opcode.ADD_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) + frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.SUB_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) - frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.MUL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) * frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.DIV_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) / frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.MOD_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) % frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.NEG_INT -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, -frame.getInt(src))
|
||||||
|
}
|
||||||
|
Opcode.INC_INT -> {
|
||||||
|
val slot = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(slot, frame.getInt(slot) + 1L)
|
||||||
|
}
|
||||||
|
Opcode.DEC_INT -> {
|
||||||
|
val slot = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(slot, frame.getInt(slot) - 1L)
|
||||||
|
}
|
||||||
|
Opcode.ADD_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getReal(a) + frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.SUB_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getReal(a) - frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.MUL_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getReal(a) * frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.DIV_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, frame.getReal(a) / frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.NEG_REAL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setReal(dst, -frame.getReal(src))
|
||||||
|
}
|
||||||
|
Opcode.AND_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) and frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.OR_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) or frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.XOR_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) xor frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.SHL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) shl frame.getInt(b).toInt())
|
||||||
|
}
|
||||||
|
Opcode.SHR_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) shr frame.getInt(b).toInt())
|
||||||
|
}
|
||||||
|
Opcode.USHR_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(a) ushr frame.getInt(b).toInt())
|
||||||
|
}
|
||||||
|
Opcode.INV_INT -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setInt(dst, frame.getInt(src).inv())
|
||||||
|
}
|
||||||
|
Opcode.CMP_LT_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) < frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LTE_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) <= frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GT_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) > frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GTE_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) >= frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) == frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a) != frame.getInt(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) == frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) != frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) < frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LTE_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) <= frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) > frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GTE_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) >= frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_BOOL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getBool(a) == frame.getBool(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_BOOL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getBool(a) != frame.getBool(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() == frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) == frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_LT_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() < frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LT_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) < frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_LTE_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() <= frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LTE_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) <= frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_GT_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() > frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GT_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) > frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_GTE_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() >= frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_GTE_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) >= frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_INT_REAL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getInt(a).toDouble() != frame.getReal(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_REAL_INT -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getReal(a) != frame.getInt(b).toDouble())
|
||||||
|
}
|
||||||
|
Opcode.CMP_EQ_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a).equals(scope, frame.getObj(b)))
|
||||||
|
}
|
||||||
|
Opcode.CMP_NEQ_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, !frame.getObj(a).equals(scope, frame.getObj(b)))
|
||||||
|
}
|
||||||
|
Opcode.CMP_REF_EQ_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a) === frame.getObj(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_REF_NEQ_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a) !== frame.getObj(b))
|
||||||
|
}
|
||||||
|
Opcode.CMP_LT_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a).compareTo(scope, frame.getObj(b)) < 0)
|
||||||
|
}
|
||||||
|
Opcode.CMP_LTE_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a).compareTo(scope, frame.getObj(b)) <= 0)
|
||||||
|
}
|
||||||
|
Opcode.CMP_GT_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a).compareTo(scope, frame.getObj(b)) > 0)
|
||||||
|
}
|
||||||
|
Opcode.CMP_GTE_OBJ -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getObj(a).compareTo(scope, frame.getObj(b)) >= 0)
|
||||||
|
}
|
||||||
|
Opcode.NOT_BOOL -> {
|
||||||
|
val src = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, !frame.getBool(src))
|
||||||
|
}
|
||||||
|
Opcode.AND_BOOL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getBool(a) && frame.getBool(b))
|
||||||
|
}
|
||||||
|
Opcode.OR_BOOL -> {
|
||||||
|
val a = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val b = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
frame.setBool(dst, frame.getBool(a) || frame.getBool(b))
|
||||||
|
}
|
||||||
|
Opcode.JMP -> {
|
||||||
|
val target = decoder.readIp(code, ip, fn.ipWidth)
|
||||||
|
ip = target
|
||||||
|
}
|
||||||
|
Opcode.JMP_IF_FALSE -> {
|
||||||
|
val cond = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val target = decoder.readIp(code, ip, fn.ipWidth)
|
||||||
|
ip += fn.ipWidth
|
||||||
|
if (!frame.getBool(cond)) {
|
||||||
|
ip = target
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Opcode.JMP_IF_TRUE -> {
|
||||||
|
val cond = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val target = decoder.readIp(code, ip, fn.ipWidth)
|
||||||
|
ip += fn.ipWidth
|
||||||
|
if (frame.getBool(cond)) {
|
||||||
|
ip = target
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Opcode.EVAL_FALLBACK -> {
|
||||||
|
val id = decoder.readConstId(code, ip, 2)
|
||||||
|
ip += 2
|
||||||
|
val dst = decoder.readSlot(code, ip)
|
||||||
|
ip += fn.slotWidth
|
||||||
|
val stmt = fn.fallbackStatements.getOrNull(id)
|
||||||
|
?: error("Fallback statement not found: $id")
|
||||||
|
val result = stmt.execute(scope)
|
||||||
|
when (result) {
|
||||||
|
is ObjInt -> frame.setInt(dst, result.value)
|
||||||
|
is ObjReal -> frame.setReal(dst, result.value)
|
||||||
|
is ObjBool -> frame.setBool(dst, result.value)
|
||||||
|
else -> frame.setObj(dst, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Opcode.RET -> {
|
||||||
|
val slot = decoder.readSlot(code, ip)
|
||||||
|
return slotToObj(frame, slot)
|
||||||
|
}
|
||||||
|
Opcode.RET_VOID -> return ObjVoid
|
||||||
|
else -> error("Opcode not implemented: $op")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ObjVoid
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun slotToObj(frame: BytecodeFrame, slot: Int): Obj {
|
||||||
|
return when (frame.getSlotTypeCode(slot)) {
|
||||||
|
SlotType.INT.code -> ObjInt.of(frame.getInt(slot))
|
||||||
|
SlotType.REAL.code -> ObjReal.of(frame.getReal(slot))
|
||||||
|
SlotType.BOOL.code -> if (frame.getBool(slot)) ObjTrue else ObjFalse
|
||||||
|
SlotType.OBJ.code -> frame.getObj(slot)
|
||||||
|
else -> ObjVoid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
enum class Opcode(val code: Int) {
|
||||||
|
NOP(0x00),
|
||||||
|
MOVE_OBJ(0x01),
|
||||||
|
MOVE_INT(0x02),
|
||||||
|
MOVE_REAL(0x03),
|
||||||
|
MOVE_BOOL(0x04),
|
||||||
|
CONST_OBJ(0x05),
|
||||||
|
CONST_INT(0x06),
|
||||||
|
CONST_REAL(0x07),
|
||||||
|
CONST_BOOL(0x08),
|
||||||
|
CONST_NULL(0x09),
|
||||||
|
|
||||||
|
INT_TO_REAL(0x10),
|
||||||
|
REAL_TO_INT(0x11),
|
||||||
|
BOOL_TO_INT(0x12),
|
||||||
|
INT_TO_BOOL(0x13),
|
||||||
|
|
||||||
|
ADD_INT(0x20),
|
||||||
|
SUB_INT(0x21),
|
||||||
|
MUL_INT(0x22),
|
||||||
|
DIV_INT(0x23),
|
||||||
|
MOD_INT(0x24),
|
||||||
|
NEG_INT(0x25),
|
||||||
|
INC_INT(0x26),
|
||||||
|
DEC_INT(0x27),
|
||||||
|
|
||||||
|
ADD_REAL(0x30),
|
||||||
|
SUB_REAL(0x31),
|
||||||
|
MUL_REAL(0x32),
|
||||||
|
DIV_REAL(0x33),
|
||||||
|
NEG_REAL(0x34),
|
||||||
|
|
||||||
|
AND_INT(0x40),
|
||||||
|
OR_INT(0x41),
|
||||||
|
XOR_INT(0x42),
|
||||||
|
SHL_INT(0x43),
|
||||||
|
SHR_INT(0x44),
|
||||||
|
USHR_INT(0x45),
|
||||||
|
INV_INT(0x46),
|
||||||
|
|
||||||
|
CMP_EQ_INT(0x50),
|
||||||
|
CMP_NEQ_INT(0x51),
|
||||||
|
CMP_LT_INT(0x52),
|
||||||
|
CMP_LTE_INT(0x53),
|
||||||
|
CMP_GT_INT(0x54),
|
||||||
|
CMP_GTE_INT(0x55),
|
||||||
|
CMP_EQ_REAL(0x56),
|
||||||
|
CMP_NEQ_REAL(0x57),
|
||||||
|
CMP_LT_REAL(0x58),
|
||||||
|
CMP_LTE_REAL(0x59),
|
||||||
|
CMP_GT_REAL(0x5A),
|
||||||
|
CMP_GTE_REAL(0x5B),
|
||||||
|
CMP_EQ_BOOL(0x5C),
|
||||||
|
CMP_NEQ_BOOL(0x5D),
|
||||||
|
|
||||||
|
CMP_EQ_INT_REAL(0x60),
|
||||||
|
CMP_EQ_REAL_INT(0x61),
|
||||||
|
CMP_LT_INT_REAL(0x62),
|
||||||
|
CMP_LT_REAL_INT(0x63),
|
||||||
|
CMP_LTE_INT_REAL(0x64),
|
||||||
|
CMP_LTE_REAL_INT(0x65),
|
||||||
|
CMP_GT_INT_REAL(0x66),
|
||||||
|
CMP_GT_REAL_INT(0x67),
|
||||||
|
CMP_GTE_INT_REAL(0x68),
|
||||||
|
CMP_GTE_REAL_INT(0x69),
|
||||||
|
CMP_NEQ_INT_REAL(0x6A),
|
||||||
|
CMP_NEQ_REAL_INT(0x6B),
|
||||||
|
CMP_EQ_OBJ(0x6C),
|
||||||
|
CMP_NEQ_OBJ(0x6D),
|
||||||
|
CMP_REF_EQ_OBJ(0x6E),
|
||||||
|
CMP_REF_NEQ_OBJ(0x6F),
|
||||||
|
|
||||||
|
NOT_BOOL(0x70),
|
||||||
|
AND_BOOL(0x71),
|
||||||
|
OR_BOOL(0x72),
|
||||||
|
CMP_LT_OBJ(0x73),
|
||||||
|
CMP_LTE_OBJ(0x74),
|
||||||
|
CMP_GT_OBJ(0x75),
|
||||||
|
CMP_GTE_OBJ(0x76),
|
||||||
|
|
||||||
|
JMP(0x80),
|
||||||
|
JMP_IF_TRUE(0x81),
|
||||||
|
JMP_IF_FALSE(0x82),
|
||||||
|
RET(0x83),
|
||||||
|
RET_VOID(0x84),
|
||||||
|
|
||||||
|
CALL_DIRECT(0x90),
|
||||||
|
CALL_VIRTUAL(0x91),
|
||||||
|
CALL_FALLBACK(0x92),
|
||||||
|
|
||||||
|
GET_FIELD(0xA0),
|
||||||
|
SET_FIELD(0xA1),
|
||||||
|
GET_INDEX(0xA2),
|
||||||
|
SET_INDEX(0xA3),
|
||||||
|
|
||||||
|
EVAL_FALLBACK(0xB0),
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private val byCode: Map<Int, Opcode> = values().associateBy { it.code }
|
||||||
|
fun fromCode(code: Int): Opcode? = byCode[code]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng.bytecode
|
||||||
|
|
||||||
|
enum class SlotType(val code: Byte) {
|
||||||
|
UNKNOWN(0),
|
||||||
|
OBJ(1),
|
||||||
|
INT(2),
|
||||||
|
REAL(3),
|
||||||
|
BOOL(4),
|
||||||
|
}
|
||||||
@@ -501,9 +501,8 @@ open class Obj {
|
|||||||
if (obj.type == ObjRecord.Type.Delegated) {
|
if (obj.type == ObjRecord.Type.Delegated) {
|
||||||
val del = obj.delegate ?: scope.raiseError("Internal error: delegated property $name has no delegate")
|
val del = obj.delegate ?: scope.raiseError("Internal error: delegated property $name has no delegate")
|
||||||
val th = if (this === ObjVoid) ObjNull else this
|
val th = if (this === ObjVoid) ObjNull else this
|
||||||
val res = del.invokeInstanceMethod(scope, "getValue", Arguments(th, ObjString(name)), onNotFoundResult = {
|
if (del.objClass.getInstanceMemberOrNull("getValue") == null) {
|
||||||
// If getValue not found, return a wrapper that calls invoke
|
val wrapper = object : Statement() {
|
||||||
object : Statement() {
|
|
||||||
override val pos: Pos = Pos.builtIn
|
override val pos: Pos = Pos.builtIn
|
||||||
override suspend fun execute(s: Scope): Obj {
|
override suspend fun execute(s: Scope): Obj {
|
||||||
val th2 = if (s.thisObj === ObjVoid) ObjNull else s.thisObj
|
val th2 = if (s.thisObj === ObjVoid) ObjNull else s.thisObj
|
||||||
@@ -511,7 +510,12 @@ open class Obj {
|
|||||||
return del.invokeInstanceMethod(s, "invoke", Arguments(*allArgs))
|
return del.invokeInstanceMethod(s, "invoke", Arguments(*allArgs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
return obj.copy(
|
||||||
|
value = wrapper,
|
||||||
|
type = ObjRecord.Type.Other
|
||||||
|
)
|
||||||
|
}
|
||||||
|
val res = del.invokeInstanceMethod(scope, "getValue", Arguments(th, ObjString(name)))
|
||||||
return obj.copy(
|
return obj.copy(
|
||||||
value = res,
|
value = res,
|
||||||
type = ObjRecord.Type.Other
|
type = ObjRecord.Type.Other
|
||||||
|
|||||||
@@ -114,8 +114,7 @@ open class ObjClass(
|
|||||||
val classId: Long = ClassIdGen.nextId()
|
val classId: Long = ClassIdGen.nextId()
|
||||||
var layoutVersion: Int = 0
|
var layoutVersion: Int = 0
|
||||||
|
|
||||||
private val mangledNameCache = mutableMapOf<String, String>()
|
fun mangledName(name: String): String = "$className::$name"
|
||||||
fun mangledName(name: String): String = mangledNameCache.getOrPut(name) { "$className::$name" }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of public member names to their effective storage keys in instanceScope.objects.
|
* Map of public member names to their effective storage keys in instanceScope.objects.
|
||||||
@@ -128,7 +127,7 @@ open class ObjClass(
|
|||||||
if (cls.className == "Obj") continue
|
if (cls.className == "Obj") continue
|
||||||
for ((name, rec) in cls.members) {
|
for ((name, rec) in cls.members) {
|
||||||
if (rec.visibility == Visibility.Public) {
|
if (rec.visibility == Visibility.Public) {
|
||||||
val key = if (rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.Delegated) cls.mangledName(name) else name
|
val key = if (rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField || rec.type == ObjRecord.Type.Delegated) cls.mangledName(name) else name
|
||||||
res[name] = key
|
res[name] = key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -267,6 +266,119 @@ open class ObjClass(
|
|||||||
*/
|
*/
|
||||||
internal val members = mutableMapOf<String, ObjRecord>()
|
internal val members = mutableMapOf<String, ObjRecord>()
|
||||||
|
|
||||||
|
internal data class FieldSlot(val slot: Int, val record: ObjRecord)
|
||||||
|
internal data class ResolvedMember(val record: ObjRecord, val declaringClass: ObjClass)
|
||||||
|
internal data class MethodSlot(val slot: Int, val record: ObjRecord)
|
||||||
|
private var fieldSlotLayoutVersion: Int = -1
|
||||||
|
private var fieldSlotMap: Map<String, FieldSlot> = emptyMap()
|
||||||
|
private var fieldSlotCount: Int = 0
|
||||||
|
private var instanceMemberLayoutVersion: Int = -1
|
||||||
|
private var instanceMemberCache: Map<String, ResolvedMember> = emptyMap()
|
||||||
|
private var methodSlotLayoutVersion: Int = -1
|
||||||
|
private var methodSlotMap: Map<String, MethodSlot> = emptyMap()
|
||||||
|
private var methodSlotCount: Int = 0
|
||||||
|
|
||||||
|
private fun ensureFieldSlots(): Map<String, FieldSlot> {
|
||||||
|
if (fieldSlotLayoutVersion == layoutVersion) return fieldSlotMap
|
||||||
|
val res = mutableMapOf<String, FieldSlot>()
|
||||||
|
var idx = 0
|
||||||
|
for (cls in mro) {
|
||||||
|
for ((name, rec) in cls.members) {
|
||||||
|
if (rec.isAbstract) continue
|
||||||
|
if (rec.type != ObjRecord.Type.Field && rec.type != ObjRecord.Type.ConstructorField) continue
|
||||||
|
val key = cls.mangledName(name)
|
||||||
|
if (res.containsKey(key)) continue
|
||||||
|
res[key] = FieldSlot(idx, rec)
|
||||||
|
idx += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldSlotMap = res
|
||||||
|
fieldSlotCount = idx
|
||||||
|
fieldSlotLayoutVersion = layoutVersion
|
||||||
|
return fieldSlotMap
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ensureInstanceMemberCache(): Map<String, ResolvedMember> {
|
||||||
|
if (instanceMemberLayoutVersion == layoutVersion) return instanceMemberCache
|
||||||
|
val res = mutableMapOf<String, ResolvedMember>()
|
||||||
|
for (cls in mro) {
|
||||||
|
if (cls.className == "Obj") break
|
||||||
|
for ((name, rec) in cls.members) {
|
||||||
|
if (rec.isAbstract) continue
|
||||||
|
if (res.containsKey(name)) continue
|
||||||
|
val decl = rec.declaringClass ?: cls
|
||||||
|
res[name] = ResolvedMember(rec, decl)
|
||||||
|
}
|
||||||
|
cls.classScope?.objects?.forEach { (name, rec) ->
|
||||||
|
if (rec.isAbstract) return@forEach
|
||||||
|
if (res.containsKey(name)) return@forEach
|
||||||
|
val decl = rec.declaringClass ?: cls
|
||||||
|
res[name] = ResolvedMember(rec, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
instanceMemberCache = res
|
||||||
|
instanceMemberLayoutVersion = layoutVersion
|
||||||
|
return instanceMemberCache
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ensureMethodSlots(): Map<String, MethodSlot> {
|
||||||
|
if (methodSlotLayoutVersion == layoutVersion) return methodSlotMap
|
||||||
|
val res = mutableMapOf<String, MethodSlot>()
|
||||||
|
var idx = 0
|
||||||
|
for (cls in mro) {
|
||||||
|
if (cls.className == "Obj") break
|
||||||
|
for ((name, rec) in cls.members) {
|
||||||
|
if (rec.isAbstract) continue
|
||||||
|
if (rec.value !is Statement &&
|
||||||
|
rec.type != ObjRecord.Type.Delegated &&
|
||||||
|
rec.type != ObjRecord.Type.Fun &&
|
||||||
|
rec.type != ObjRecord.Type.Property) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val key = if (rec.visibility == Visibility.Private || rec.type == ObjRecord.Type.Delegated) cls.mangledName(name) else name
|
||||||
|
if (res.containsKey(key)) continue
|
||||||
|
res[key] = MethodSlot(idx, rec)
|
||||||
|
idx += 1
|
||||||
|
}
|
||||||
|
cls.classScope?.objects?.forEach { (name, rec) ->
|
||||||
|
if (rec.isAbstract) return@forEach
|
||||||
|
if (rec.value !is Statement &&
|
||||||
|
rec.type != ObjRecord.Type.Delegated &&
|
||||||
|
rec.type != ObjRecord.Type.Property) return@forEach
|
||||||
|
val key = if (rec.visibility == Visibility.Private || rec.type == ObjRecord.Type.Delegated) cls.mangledName(name) else name
|
||||||
|
if (res.containsKey(key)) return@forEach
|
||||||
|
res[key] = MethodSlot(idx, rec)
|
||||||
|
idx += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodSlotMap = res
|
||||||
|
methodSlotCount = idx
|
||||||
|
methodSlotLayoutVersion = layoutVersion
|
||||||
|
return methodSlotMap
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun fieldSlotCount(): Int {
|
||||||
|
ensureFieldSlots()
|
||||||
|
return fieldSlotCount
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun fieldSlotForKey(key: String): FieldSlot? {
|
||||||
|
ensureFieldSlots()
|
||||||
|
return fieldSlotMap[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun fieldSlotMap(): Map<String, FieldSlot> = ensureFieldSlots()
|
||||||
|
internal fun resolveInstanceMember(name: String): ResolvedMember? = ensureInstanceMemberCache()[name]
|
||||||
|
internal fun methodSlotCount(): Int {
|
||||||
|
ensureMethodSlots()
|
||||||
|
return methodSlotCount
|
||||||
|
}
|
||||||
|
internal fun methodSlotForKey(key: String): MethodSlot? {
|
||||||
|
ensureMethodSlots()
|
||||||
|
return methodSlotMap[key]
|
||||||
|
}
|
||||||
|
internal fun methodSlotMap(): Map<String, MethodSlot> = ensureMethodSlots()
|
||||||
|
|
||||||
override fun toString(): String = className
|
override fun toString(): String = className
|
||||||
|
|
||||||
override suspend fun compareTo(scope: Scope, other: Obj): Int = if (other === this) 0 else -1
|
override suspend fun compareTo(scope: Scope, other: Obj): Int = if (other === this) 0 else -1
|
||||||
@@ -284,8 +396,8 @@ open class ObjClass(
|
|||||||
for (cls in mro) {
|
for (cls in mro) {
|
||||||
// 1) members-defined methods and fields
|
// 1) members-defined methods and fields
|
||||||
for ((k, v) in cls.members) {
|
for ((k, v) in cls.members) {
|
||||||
if (!v.isAbstract && (v.value is Statement || v.type == ObjRecord.Type.Delegated || v.type == ObjRecord.Type.Field)) {
|
if (!v.isAbstract && (v.value is Statement || v.type == ObjRecord.Type.Delegated || v.type == ObjRecord.Type.Field || v.type == ObjRecord.Type.ConstructorField)) {
|
||||||
val key = if (v.visibility == Visibility.Private || v.type == ObjRecord.Type.Field || v.type == ObjRecord.Type.Delegated) cls.mangledName(k) else k
|
val key = if (v.visibility == Visibility.Private || v.type == ObjRecord.Type.Field || v.type == ObjRecord.Type.ConstructorField || v.type == ObjRecord.Type.Delegated) cls.mangledName(k) else k
|
||||||
if (!res.containsKey(key)) {
|
if (!res.containsKey(key)) {
|
||||||
res[key] = v
|
res[key] = v
|
||||||
}
|
}
|
||||||
@@ -327,12 +439,47 @@ open class ObjClass(
|
|||||||
val stableParent = classScope ?: scope.parent
|
val stableParent = classScope ?: scope.parent
|
||||||
instance.instanceScope = Scope(stableParent, scope.args, scope.pos, instance)
|
instance.instanceScope = Scope(stableParent, scope.args, scope.pos, instance)
|
||||||
instance.instanceScope.currentClassCtx = null
|
instance.instanceScope.currentClassCtx = null
|
||||||
|
val fieldSlots = fieldSlotMap()
|
||||||
|
if (fieldSlots.isNotEmpty()) {
|
||||||
|
instance.initFieldSlots(fieldSlotCount())
|
||||||
|
}
|
||||||
|
val methodSlots = methodSlotMap()
|
||||||
|
if (methodSlots.isNotEmpty()) {
|
||||||
|
instance.initMethodSlots(methodSlotCount())
|
||||||
|
}
|
||||||
// Expose instance methods (and other callable members) directly in the instance scope for fast lookup
|
// Expose instance methods (and other callable members) directly in the instance scope for fast lookup
|
||||||
// This mirrors Obj.autoInstanceScope behavior for ad-hoc scopes and makes fb.method() resolution robust
|
// This mirrors Obj.autoInstanceScope behavior for ad-hoc scopes and makes fb.method() resolution robust
|
||||||
|
|
||||||
instance.instanceScope.objects.putAll(templateMethods)
|
instance.instanceScope.objects.putAll(templateMethods)
|
||||||
|
if (methodSlots.isNotEmpty()) {
|
||||||
|
for ((key, rec) in templateMethods) {
|
||||||
|
val slot = methodSlots[key]
|
||||||
|
if (slot != null) {
|
||||||
|
instance.setMethodSlotRecord(slot.slot, rec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for (p in templateOthers) {
|
for (p in templateOthers) {
|
||||||
instance.instanceScope.objects[p.first] = p.second.copy()
|
val rec = p.second.copy()
|
||||||
|
instance.instanceScope.objects[p.first] = rec
|
||||||
|
val slot = fieldSlots[p.first]
|
||||||
|
if (slot != null) {
|
||||||
|
instance.setFieldSlotRecord(slot.slot, rec)
|
||||||
|
}
|
||||||
|
if (methodSlots.isNotEmpty()) {
|
||||||
|
val mSlot = methodSlots[p.first]
|
||||||
|
if (mSlot != null) {
|
||||||
|
instance.setMethodSlotRecord(mSlot.slot, rec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (methodSlots.isNotEmpty()) {
|
||||||
|
for ((_, mSlot) in methodSlots) {
|
||||||
|
val idx = mSlot.slot
|
||||||
|
if (idx >= 0 && idx < instance.methodSlots.size && instance.methodSlots[idx] == null) {
|
||||||
|
instance.setMethodSlotRecord(idx, mSlot.record)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
@@ -417,6 +564,10 @@ open class ObjClass(
|
|||||||
if (rec != null) {
|
if (rec != null) {
|
||||||
val mangled = c.mangledName(p.name)
|
val mangled = c.mangledName(p.name)
|
||||||
instance.instanceScope.objects[mangled] = rec
|
instance.instanceScope.objects[mangled] = rec
|
||||||
|
val slot = instance.objClass.fieldSlotForKey(mangled)
|
||||||
|
if (slot != null) {
|
||||||
|
instance.setFieldSlotRecord(slot.slot, rec)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -738,5 +889,3 @@ open class ObjClass(
|
|||||||
scope.raiseNotImplemented()
|
scope.raiseNotImplemented()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -30,6 +30,36 @@ import net.sergeych.lynon.LynonType
|
|||||||
class ObjInstance(override val objClass: ObjClass) : Obj() {
|
class ObjInstance(override val objClass: ObjClass) : Obj() {
|
||||||
|
|
||||||
internal lateinit var instanceScope: Scope
|
internal lateinit var instanceScope: Scope
|
||||||
|
internal var fieldSlots: Array<ObjRecord?> = emptyArray()
|
||||||
|
internal var methodSlots: Array<ObjRecord?> = emptyArray()
|
||||||
|
|
||||||
|
internal fun initFieldSlots(size: Int) {
|
||||||
|
fieldSlots = arrayOfNulls(size)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun setFieldSlotRecord(slot: Int, rec: ObjRecord) {
|
||||||
|
if (slot >= 0 && slot < fieldSlots.size) fieldSlots[slot] = rec
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun initMethodSlots(size: Int) {
|
||||||
|
methodSlots = arrayOfNulls(size)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun setMethodSlotRecord(slot: Int, rec: ObjRecord) {
|
||||||
|
if (slot >= 0 && slot < methodSlots.size) methodSlots[slot] = rec
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun fieldRecordForKey(key: String): ObjRecord? {
|
||||||
|
val slot = objClass.fieldSlotForKey(key) ?: return null
|
||||||
|
val idx = slot.slot
|
||||||
|
return if (idx >= 0 && idx < fieldSlots.size) fieldSlots[idx] else null
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun methodRecordForKey(key: String): ObjRecord? {
|
||||||
|
val slot = objClass.methodSlotForKey(key) ?: return null
|
||||||
|
val idx = slot.slot
|
||||||
|
return if (idx >= 0 && idx < methodSlots.size) methodSlots[idx] else null
|
||||||
|
}
|
||||||
|
|
||||||
override suspend fun readField(scope: Scope, name: String): ObjRecord {
|
override suspend fun readField(scope: Scope, name: String): ObjRecord {
|
||||||
val caller = scope.currentClassCtx
|
val caller = scope.currentClassCtx
|
||||||
@@ -37,6 +67,16 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
// Fast path for public members when outside any class context
|
// Fast path for public members when outside any class context
|
||||||
if (caller == null) {
|
if (caller == null) {
|
||||||
objClass.publicMemberResolution[name]?.let { key ->
|
objClass.publicMemberResolution[name]?.let { key ->
|
||||||
|
fieldRecordForKey(key)?.let { rec ->
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: objClass.findDeclaringClassOf(name) ?: objClass
|
||||||
|
return resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[key]?.let { rec ->
|
instanceScope.objects[key]?.let { rec ->
|
||||||
// Directly return fields to bypass resolveRecord overhead
|
// Directly return fields to bypass resolveRecord overhead
|
||||||
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
||||||
@@ -56,6 +96,16 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
}
|
}
|
||||||
// Check for private fields (stored in instanceScope)
|
// Check for private fields (stored in instanceScope)
|
||||||
val mangled = c.mangledName(name)
|
val mangled = c.mangledName(name)
|
||||||
|
fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return resolveRecord(scope, rec, name, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return resolveRecord(scope, rec, name, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[mangled]?.let { rec ->
|
instanceScope.objects[mangled]?.let { rec ->
|
||||||
if (rec.visibility == Visibility.Private) {
|
if (rec.visibility == Visibility.Private) {
|
||||||
return resolveRecord(scope, rec, name, c)
|
return resolveRecord(scope, rec, name, c)
|
||||||
@@ -67,6 +117,16 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
for (cls in objClass.mro) {
|
for (cls in objClass.mro) {
|
||||||
if (cls.className == "Obj") break
|
if (cls.className == "Obj") break
|
||||||
val mangled = cls.mangledName(name)
|
val mangled = cls.mangledName(name)
|
||||||
|
fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (canAccessMember(rec.visibility, cls, caller, name)) {
|
||||||
|
return resolveRecord(scope, rec, name, cls)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (canAccessMember(rec.visibility, cls, caller, name)) {
|
||||||
|
return resolveRecord(scope, rec, name, cls)
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[mangled]?.let { rec ->
|
instanceScope.objects[mangled]?.let { rec ->
|
||||||
if (canAccessMember(rec.visibility, cls, caller, name)) {
|
if (canAccessMember(rec.visibility, cls, caller, name)) {
|
||||||
return resolveRecord(scope, rec, name, cls)
|
return resolveRecord(scope, rec, name, cls)
|
||||||
@@ -81,6 +141,12 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
return resolveRecord(scope, rec, name, decl)
|
return resolveRecord(scope, rec, name, decl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
methodRecordForKey(name)?.let { rec ->
|
||||||
|
val decl = rec.declaringClass ?: objClass.findDeclaringClassOf(name)
|
||||||
|
if (canAccessMember(rec.visibility, decl, caller, name)) {
|
||||||
|
return resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Fall back to super (handles class members and extensions)
|
// 3. Fall back to super (handles class members and extensions)
|
||||||
return super.readField(scope, name)
|
return super.readField(scope, name)
|
||||||
@@ -109,8 +175,13 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
val d = decl ?: obj.declaringClass
|
val d = decl ?: obj.declaringClass
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
val mangled = d.mangledName(name)
|
val mangled = d.mangledName(name)
|
||||||
instanceScope.objects[mangled]?.let {
|
fieldRecordForKey(mangled)?.let {
|
||||||
targetRec = it
|
targetRec = it
|
||||||
|
}
|
||||||
|
if (targetRec === obj) {
|
||||||
|
instanceScope.objects[mangled]?.let {
|
||||||
|
targetRec = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (targetRec === obj) {
|
if (targetRec === obj) {
|
||||||
@@ -134,10 +205,29 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
// Fast path for public members when outside any class context
|
// Fast path for public members when outside any class context
|
||||||
if (caller == null) {
|
if (caller == null) {
|
||||||
objClass.publicMemberResolution[name]?.let { key ->
|
objClass.publicMemberResolution[name]?.let { key ->
|
||||||
|
fieldRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.effectiveWriteVisibility == Visibility.Public) {
|
||||||
|
// Skip property/delegated overhead if it's a plain mutable field
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && rec.isMutable && !rec.isAbstract) {
|
||||||
|
if (rec.value.assign(scope, newValue) == null)
|
||||||
|
rec.value = newValue
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updateRecord(scope, rec, name, newValue, rec.declaringClass)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.effectiveWriteVisibility == Visibility.Public &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
updateRecord(scope, rec, name, newValue, rec.declaringClass)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[key]?.let { rec ->
|
instanceScope.objects[key]?.let { rec ->
|
||||||
if (rec.effectiveWriteVisibility == Visibility.Public) {
|
if (rec.effectiveWriteVisibility == Visibility.Public) {
|
||||||
// Skip property/delegated overhead if it's a plain mutable field
|
// Skip property/delegated overhead if it's a plain mutable field
|
||||||
if (rec.type == ObjRecord.Type.Field && rec.isMutable && !rec.isAbstract) {
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && rec.isMutable && !rec.isAbstract) {
|
||||||
if (rec.value.assign(scope, newValue) == null)
|
if (rec.value.assign(scope, newValue) == null)
|
||||||
rec.value = newValue
|
rec.value = newValue
|
||||||
return
|
return
|
||||||
@@ -160,6 +250,19 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
}
|
}
|
||||||
// Check for private fields (stored in instanceScope)
|
// Check for private fields (stored in instanceScope)
|
||||||
val mangled = c.mangledName(name)
|
val mangled = c.mangledName(name)
|
||||||
|
fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
updateRecord(scope, rec, name, newValue, c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
updateRecord(scope, rec, name, newValue, c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[mangled]?.let { rec ->
|
instanceScope.objects[mangled]?.let { rec ->
|
||||||
if (rec.visibility == Visibility.Private) {
|
if (rec.visibility == Visibility.Private) {
|
||||||
updateRecord(scope, rec, name, newValue, c)
|
updateRecord(scope, rec, name, newValue, c)
|
||||||
@@ -172,6 +275,19 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
for (cls in objClass.mro) {
|
for (cls in objClass.mro) {
|
||||||
if (cls.className == "Obj") break
|
if (cls.className == "Obj") break
|
||||||
val mangled = cls.mangledName(name)
|
val mangled = cls.mangledName(name)
|
||||||
|
fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, cls, caller, name)) {
|
||||||
|
updateRecord(scope, rec, name, newValue, cls)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, cls, caller, name) &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
updateRecord(scope, rec, name, newValue, cls)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[mangled]?.let { rec ->
|
instanceScope.objects[mangled]?.let { rec ->
|
||||||
if (canAccessMember(rec.effectiveWriteVisibility, cls, caller, name)) {
|
if (canAccessMember(rec.effectiveWriteVisibility, cls, caller, name)) {
|
||||||
updateRecord(scope, rec, name, newValue, cls)
|
updateRecord(scope, rec, name, newValue, cls)
|
||||||
@@ -188,6 +304,14 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
methodRecordForKey(name)?.let { rec ->
|
||||||
|
val decl = rec.declaringClass ?: objClass.findDeclaringClassOf(name)
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, decl, caller, name) &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
updateRecord(scope, rec, name, newValue, decl)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.writeField(scope, name, newValue)
|
super.writeField(scope, name, newValue)
|
||||||
}
|
}
|
||||||
@@ -225,6 +349,16 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
// Fast path for public members when outside any class context
|
// Fast path for public members when outside any class context
|
||||||
if (caller == null) {
|
if (caller == null) {
|
||||||
objClass.publicMemberResolution[name]?.let { key ->
|
objClass.publicMemberResolution[name]?.let { key ->
|
||||||
|
methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Public && !rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (args.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, this, decl)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(instanceScope, this, args, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[key]?.let { rec ->
|
instanceScope.objects[key]?.let { rec ->
|
||||||
if (rec.visibility == Visibility.Public && !rec.isAbstract) {
|
if (rec.visibility == Visibility.Public && !rec.isAbstract) {
|
||||||
val decl = rec.declaringClass
|
val decl = rec.declaringClass
|
||||||
@@ -241,6 +375,15 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
// 0. Prefer private member of current class context
|
// 0. Prefer private member of current class context
|
||||||
caller?.let { c ->
|
caller?.let { c ->
|
||||||
val mangled = c.mangledName(name)
|
val mangled = c.mangledName(name)
|
||||||
|
methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private && !rec.isAbstract) {
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (args.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, this, c)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(instanceScope, this, args, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
instanceScope.objects[mangled]?.let { rec ->
|
instanceScope.objects[mangled]?.let { rec ->
|
||||||
if (rec.visibility == Visibility.Private && !rec.isAbstract) {
|
if (rec.visibility == Visibility.Private && !rec.isAbstract) {
|
||||||
if (rec.type == ObjRecord.Type.Property) {
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
@@ -261,50 +404,58 @@ class ObjInstance(override val objClass: ObjClass) : Obj() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Walk MRO to find member, handling delegation
|
// Fast path for non-delegated instance methods in class context
|
||||||
for (cls in objClass.mro) {
|
methodRecordForKey(name)?.let { rec ->
|
||||||
if (cls.className == "Obj") break
|
if (!rec.isAbstract && rec.type == ObjRecord.Type.Fun) {
|
||||||
val rec = cls.members[name] ?: cls.classScope?.objects?.get(name)
|
val decl = rec.declaringClass ?: objClass.findDeclaringClassOf(name) ?: objClass
|
||||||
if (rec != null && !rec.isAbstract) {
|
|
||||||
if (rec.type == ObjRecord.Type.Delegated) {
|
|
||||||
val storageName = cls.mangledName(name)
|
|
||||||
val del = instanceScope[storageName]?.delegate ?: rec.delegate
|
|
||||||
?: scope.raiseError("Internal error: delegated member $name has no delegate (tried $storageName)")
|
|
||||||
|
|
||||||
// For delegated member, try 'invoke' first if it's a function-like call
|
|
||||||
val allArgs = (listOf(this, ObjString(name)) + args.list).toTypedArray()
|
|
||||||
return del.invokeInstanceMethod(scope, "invoke", Arguments(*allArgs), onNotFoundResult = {
|
|
||||||
// Fallback: property delegation (getValue then call result)
|
|
||||||
val propVal = del.invokeInstanceMethod(scope, "getValue", Arguments(this, ObjString(name)))
|
|
||||||
propVal.invoke(scope, this, args, rec.declaringClass ?: cls)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
val decl = rec.declaringClass ?: cls
|
|
||||||
val effectiveCaller = caller ?: if (scope.thisObj === this) objClass else null
|
val effectiveCaller = caller ?: if (scope.thisObj === this) objClass else null
|
||||||
if (!canAccessMember(rec.visibility, decl, effectiveCaller, name))
|
if (canAccessMember(rec.visibility, decl, effectiveCaller, name)) {
|
||||||
scope.raiseError(
|
return rec.value.invoke(instanceScope, this, args, decl)
|
||||||
ObjIllegalAccessException(
|
|
||||||
scope,
|
|
||||||
"can't invoke method $name (declared in ${decl.className})"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if (rec.type == ObjRecord.Type.Property) {
|
|
||||||
if (args.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, this, decl)
|
|
||||||
} else if (rec.type == ObjRecord.Type.Fun) {
|
|
||||||
return rec.value.invoke(
|
|
||||||
instanceScope,
|
|
||||||
this,
|
|
||||||
args,
|
|
||||||
decl
|
|
||||||
)
|
|
||||||
} else if (rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField || rec.type == ObjRecord.Type.Argument) {
|
|
||||||
val resolved = readField(scope, name)
|
|
||||||
return resolved.value.invoke(scope, this, args, resolved.declaringClass)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1. Resolve instance member via cached MRO lookup, handling delegation
|
||||||
|
objClass.resolveInstanceMember(name)?.let { resolvedMember ->
|
||||||
|
val rec = resolvedMember.record
|
||||||
|
val decl = resolvedMember.declaringClass
|
||||||
|
if (rec.type == ObjRecord.Type.Delegated) {
|
||||||
|
val storageName = decl.mangledName(name)
|
||||||
|
val del = instanceScope[storageName]?.delegate ?: rec.delegate
|
||||||
|
?: scope.raiseError("Internal error: delegated member $name has no delegate (tried $storageName)")
|
||||||
|
|
||||||
|
// For delegated member, try 'invoke' first if it's a function-like call
|
||||||
|
val allArgs = (listOf(this, ObjString(name)) + args.list).toTypedArray()
|
||||||
|
return del.invokeInstanceMethod(scope, "invoke", Arguments(*allArgs), onNotFoundResult = {
|
||||||
|
// Fallback: property delegation (getValue then call result)
|
||||||
|
val propVal = del.invokeInstanceMethod(scope, "getValue", Arguments(this, ObjString(name)))
|
||||||
|
propVal.invoke(scope, this, args, rec.declaringClass ?: decl)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
val effectiveCaller = caller ?: if (scope.thisObj === this) objClass else null
|
||||||
|
if (!canAccessMember(rec.visibility, decl, effectiveCaller, name))
|
||||||
|
scope.raiseError(
|
||||||
|
ObjIllegalAccessException(
|
||||||
|
scope,
|
||||||
|
"can't invoke method $name (declared in ${decl.className})"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (args.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, this, decl)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(
|
||||||
|
instanceScope,
|
||||||
|
this,
|
||||||
|
args,
|
||||||
|
decl
|
||||||
|
)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField || rec.type == ObjRecord.Type.Argument) {
|
||||||
|
val resolved = readField(scope, name)
|
||||||
|
return resolved.value.invoke(scope, this, args, resolved.declaringClass)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 2. Fall back to super (handles extensions and root fallback)
|
// 2. Fall back to super (handles extensions and root fallback)
|
||||||
return super.invokeInstanceMethod(scope, name, args, onNotFoundResult)
|
return super.invokeInstanceMethod(scope, name, args, onNotFoundResult)
|
||||||
}
|
}
|
||||||
@@ -431,6 +582,14 @@ class ObjQualifiedView(val instance: ObjInstance, private val startClass: ObjCla
|
|||||||
override suspend fun readField(scope: Scope, name: String): ObjRecord {
|
override suspend fun readField(scope: Scope, name: String): ObjRecord {
|
||||||
// Qualified field access: prefer mangled storage for the qualified ancestor
|
// Qualified field access: prefer mangled storage for the qualified ancestor
|
||||||
val mangled = "${startClass.className}::$name"
|
val mangled = "${startClass.className}::$name"
|
||||||
|
instance.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
// Visibility: declaring class is the qualified ancestor for mangled storage
|
||||||
|
val decl = rec.declaringClass ?: startClass
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (!canAccessMember(rec.visibility, decl, caller, name))
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "can't access field $name (declared in ${decl.className})"))
|
||||||
|
return instance.resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
instance.instanceScope.objects[mangled]?.let { rec ->
|
instance.instanceScope.objects[mangled]?.let { rec ->
|
||||||
// Visibility: declaring class is the qualified ancestor for mangled storage
|
// Visibility: declaring class is the qualified ancestor for mangled storage
|
||||||
val decl = rec.declaringClass ?: startClass
|
val decl = rec.declaringClass ?: startClass
|
||||||
@@ -467,6 +626,18 @@ class ObjQualifiedView(val instance: ObjInstance, private val startClass: ObjCla
|
|||||||
override suspend fun writeField(scope: Scope, name: String, newValue: Obj) {
|
override suspend fun writeField(scope: Scope, name: String, newValue: Obj) {
|
||||||
// Qualified write: target mangled storage for the ancestor
|
// Qualified write: target mangled storage for the ancestor
|
||||||
val mangled = "${startClass.className}::$name"
|
val mangled = "${startClass.className}::$name"
|
||||||
|
instance.fieldRecordForKey(mangled)?.let { f ->
|
||||||
|
val decl = f.declaringClass ?: startClass
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (!canAccessMember(f.effectiveWriteVisibility, decl, caller, name))
|
||||||
|
ObjIllegalAccessException(
|
||||||
|
scope,
|
||||||
|
"can't assign to field $name (declared in ${decl.className})"
|
||||||
|
).raise()
|
||||||
|
if (!f.isMutable && f.value !== ObjUnset) ObjIllegalAssignmentException(scope, "can't reassign val $name").raise()
|
||||||
|
if (f.value.assign(scope, newValue) == null) f.value = newValue
|
||||||
|
return
|
||||||
|
}
|
||||||
instance.instanceScope.objects[mangled]?.let { f ->
|
instance.instanceScope.objects[mangled]?.let { f ->
|
||||||
val decl = f.declaringClass ?: startClass
|
val decl = f.declaringClass ?: startClass
|
||||||
val caller = scope.currentClassCtx
|
val caller = scope.currentClassCtx
|
||||||
@@ -548,4 +719,4 @@ class ObjQualifiedView(val instance: ObjInstance, private val startClass: ObjCla
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = instance.toString()
|
override fun toString(): String = instance.toString()
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,11 @@ class ObjInt(val value: Long, override val isConst: Boolean = false) : Obj(), Nu
|
|||||||
|
|
||||||
override suspend fun compareTo(scope: Scope, other: Obj): Int {
|
override suspend fun compareTo(scope: Scope, other: Obj): Int {
|
||||||
if (other !is Numeric) return -2
|
if (other !is Numeric) return -2
|
||||||
return value.compareTo(other.doubleValue)
|
return if (other is ObjInt) {
|
||||||
|
value.compareTo(other.value)
|
||||||
|
} else {
|
||||||
|
doubleValue.compareTo(other.doubleValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = value.toString()
|
override fun toString(): String = value.toString()
|
||||||
@@ -159,13 +163,19 @@ class ObjInt(val value: Long, override val isConst: Boolean = false) : Obj(), Nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val cache = Array(256) { ObjInt((it - 128).toLong(), true) }
|
internal const val CACHE_LOW: Long = -1024L
|
||||||
|
internal const val CACHE_HIGH: Long = 1023L
|
||||||
|
private val cache = Array((CACHE_HIGH - CACHE_LOW + 1).toInt()) {
|
||||||
|
ObjInt((it + CACHE_LOW).toLong(), true)
|
||||||
|
}
|
||||||
|
|
||||||
fun of(value: Long): ObjInt {
|
fun of(value: Long): ObjInt {
|
||||||
return if (value in -128L..127L) cache[(value + 128).toInt()]
|
return if (value in CACHE_LOW..CACHE_HIGH) cache[(value - CACHE_LOW).toInt()]
|
||||||
else ObjInt(value)
|
else ObjInt(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun cacheArray(): Array<ObjInt> = cache
|
||||||
|
|
||||||
val Zero = of(0)
|
val Zero = of(0)
|
||||||
val One = of(1)
|
val One = of(1)
|
||||||
val type = object : ObjClass("Int") {
|
val type = object : ObjClass("Int") {
|
||||||
@@ -192,4 +202,4 @@ class ObjInt(val value: Long, override val isConst: Boolean = false) : Obj(), Nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Int.toObj() = ObjInt.of(this.toLong())
|
fun Int.toObj() = ObjInt.of(this.toLong())
|
||||||
fun Long.toObj() = ObjInt.of(this)
|
fun Long.toObj() = ObjInt.of(this)
|
||||||
@@ -96,6 +96,30 @@ class ObjRange(val start: Obj?, val end: Obj?, val isEndInclusive: Boolean) : Ob
|
|||||||
if (other is ObjRange)
|
if (other is ObjRange)
|
||||||
return containsRange(scope, other)
|
return containsRange(scope, other)
|
||||||
|
|
||||||
|
if (net.sergeych.lyng.PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
if (start is ObjInt && end is ObjInt && other is ObjInt) {
|
||||||
|
val s = start.value
|
||||||
|
val e = end.value
|
||||||
|
val v = other.value
|
||||||
|
if (v < s) return false
|
||||||
|
return if (isEndInclusive) v <= e else v < e
|
||||||
|
}
|
||||||
|
if (start is ObjChar && end is ObjChar && other is ObjChar) {
|
||||||
|
val s = start.value
|
||||||
|
val e = end.value
|
||||||
|
val v = other.value
|
||||||
|
if (v < s) return false
|
||||||
|
return if (isEndInclusive) v <= e else v < e
|
||||||
|
}
|
||||||
|
if (start is ObjString && end is ObjString && other is ObjString) {
|
||||||
|
val s = start.value
|
||||||
|
val e = end.value
|
||||||
|
val v = other.value
|
||||||
|
if (v < s) return false
|
||||||
|
return if (isEndInclusive) v <= e else v < e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (start == null && end == null) return true
|
if (start == null && end == null) return true
|
||||||
if (start != null) {
|
if (start != null) {
|
||||||
if (start.compareTo(scope, other) > 0) return false
|
if (start.compareTo(scope, other) > 0) return false
|
||||||
@@ -241,4 +265,3 @@ class ObjRange(val start: Obj?, val end: Obj?, val isEndInclusive: Boolean) : Ob
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class ObjRangeIterator(val self: ObjRange) : Obj() {
|
|||||||
start.value.code.toLong() + nextIndex++
|
start.value.code.toLong() + nextIndex++
|
||||||
else
|
else
|
||||||
scope.raiseError("iterator error: unsupported range start")
|
scope.raiseError("iterator error: unsupported range start")
|
||||||
if( isCharRange ) ObjChar(x.toInt().toChar()) else ObjInt(x)
|
if (isCharRange) ObjChar(x.toInt().toChar()) else ObjInt.of(x)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scope.raiseError(ObjIterationFinishedException(scope))
|
scope.raiseError(ObjIterationFinishedException(scope))
|
||||||
@@ -83,13 +83,18 @@ class ObjRangeIterator(val self: ObjRange) : Obj() {
|
|||||||
class ObjFastIntRangeIterator(private val start: Int, private val endExclusive: Int) : Obj() {
|
class ObjFastIntRangeIterator(private val start: Int, private val endExclusive: Int) : Obj() {
|
||||||
|
|
||||||
private var cur: Int = start
|
private var cur: Int = start
|
||||||
|
private val cacheLow = ObjInt.CACHE_LOW.toInt()
|
||||||
|
private val useCache = start >= cacheLow && endExclusive <= ObjInt.CACHE_HIGH.toInt() + 1
|
||||||
|
private val cache = if (useCache) ObjInt.cacheArray() else null
|
||||||
|
|
||||||
override val objClass: ObjClass get() = type
|
override val objClass: ObjClass get() = type
|
||||||
|
|
||||||
fun hasNext(): Boolean = cur < endExclusive
|
fun hasNext(): Boolean = cur < endExclusive
|
||||||
|
|
||||||
fun next(scope: Scope): Obj =
|
fun next(scope: Scope): Obj =
|
||||||
if (cur < endExclusive) ObjInt(cur++.toLong())
|
if (cur < endExclusive) {
|
||||||
|
if (useCache && cache != null) cache[cur++ - cacheLow] else ObjInt(cur++.toLong())
|
||||||
|
}
|
||||||
else scope.raiseError(ObjIterationFinishedException(scope))
|
else scope.raiseError(ObjIterationFinishedException(scope))
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@@ -98,4 +103,4 @@ class ObjFastIntRangeIterator(private val start: Int, private val endExclusive:
|
|||||||
addFn("next") { thisAs<ObjFastIntRangeIterator>().next(this) }
|
addFn("next") { thisAs<ObjFastIntRangeIterator>().next(this) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ enum class BinOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** R-value reference for unary operations. */
|
/** R-value reference for unary operations. */
|
||||||
class UnaryOpRef(private val op: UnaryOp, private val a: ObjRef) : ObjRef {
|
class UnaryOpRef(internal val op: UnaryOp, internal val a: ObjRef) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord {
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
val v = a.evalValue(scope)
|
val v = a.evalValue(scope)
|
||||||
if (PerfFlags.PRIMITIVE_FASTOPS) {
|
if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
@@ -141,7 +141,7 @@ class UnaryOpRef(private val op: UnaryOp, private val a: ObjRef) : ObjRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** R-value reference for binary operations. */
|
/** R-value reference for binary operations. */
|
||||||
class BinaryOpRef(private val op: BinOp, private val left: ObjRef, private val right: ObjRef) : ObjRef {
|
class BinaryOpRef(internal val op: BinOp, internal val left: ObjRef, internal val right: ObjRef) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord {
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
return evalValue(scope).asReadonly
|
return evalValue(scope).asReadonly
|
||||||
}
|
}
|
||||||
@@ -152,6 +152,80 @@ class BinaryOpRef(private val op: BinOp, private val left: ObjRef, private val r
|
|||||||
|
|
||||||
// Primitive fast paths for common cases (guarded by PerfFlags.PRIMITIVE_FASTOPS)
|
// Primitive fast paths for common cases (guarded by PerfFlags.PRIMITIVE_FASTOPS)
|
||||||
if (PerfFlags.PRIMITIVE_FASTOPS) {
|
if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
// Fast membership for common containers
|
||||||
|
if (op == BinOp.IN || op == BinOp.NOTIN) {
|
||||||
|
val inResult: Boolean? = when (b) {
|
||||||
|
is ObjList -> {
|
||||||
|
if (a is ObjInt) {
|
||||||
|
var i = 0
|
||||||
|
val sz = b.list.size
|
||||||
|
var found = false
|
||||||
|
while (i < sz) {
|
||||||
|
val v = b.list[i]
|
||||||
|
if (v is ObjInt && v.value == a.value) {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
found
|
||||||
|
} else {
|
||||||
|
b.list.contains(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ObjSet -> b.set.contains(a)
|
||||||
|
is ObjMap -> b.map.containsKey(a)
|
||||||
|
is ObjRange -> {
|
||||||
|
when (a) {
|
||||||
|
is ObjInt -> {
|
||||||
|
val s = b.start as? ObjInt
|
||||||
|
val e = b.end as? ObjInt
|
||||||
|
val v = a.value
|
||||||
|
if (s == null && e == null) null
|
||||||
|
else {
|
||||||
|
if (s != null && v < s.value) false
|
||||||
|
else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ObjChar -> {
|
||||||
|
val s = b.start as? ObjChar
|
||||||
|
val e = b.end as? ObjChar
|
||||||
|
val v = a.value
|
||||||
|
if (s == null && e == null) null
|
||||||
|
else {
|
||||||
|
if (s != null && v < s.value) false
|
||||||
|
else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ObjString -> {
|
||||||
|
val s = b.start as? ObjString
|
||||||
|
val e = b.end as? ObjString
|
||||||
|
val v = a.value
|
||||||
|
if (s == null && e == null) null
|
||||||
|
else {
|
||||||
|
if (s != null && v < s.value) false
|
||||||
|
else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
is ObjString -> when (a) {
|
||||||
|
is ObjString -> b.value.contains(a.value)
|
||||||
|
is ObjChar -> b.value.contains(a.value)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (inResult != null) {
|
||||||
|
if (PerfFlags.PIC_DEBUG_COUNTERS) PerfStats.primitiveFastOpsHit++
|
||||||
|
return if (op == BinOp.IN) {
|
||||||
|
if (inResult) ObjTrue else ObjFalse
|
||||||
|
} else {
|
||||||
|
if (inResult) ObjFalse else ObjTrue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// Fast boolean ops when both operands are ObjBool
|
// Fast boolean ops when both operands are ObjBool
|
||||||
if (a is ObjBool && b is ObjBool) {
|
if (a is ObjBool && b is ObjBool) {
|
||||||
val r: Obj? = when (op) {
|
val r: Obj? = when (op) {
|
||||||
@@ -381,7 +455,7 @@ class CastRef(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Qualified `this@Type`: resolves to a view of current `this` starting dispatch from the ancestor Type. */
|
/** Qualified `this@Type`: resolves to a view of current `this` starting dispatch from the ancestor Type. */
|
||||||
class QualifiedThisRef(private val typeName: String, private val atPos: Pos) : ObjRef {
|
class QualifiedThisRef(val typeName: String, private val atPos: Pos) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord {
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
val t = scope[typeName]?.value as? ObjClass
|
val t = scope[typeName]?.value as? ObjClass
|
||||||
?: scope.raiseError("unknown type $typeName")
|
?: scope.raiseError("unknown type $typeName")
|
||||||
@@ -403,6 +477,188 @@ class QualifiedThisRef(private val typeName: String, private val atPos: Pos) : O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun resolveQualifiedThisInstance(scope: Scope, typeName: String): Pair<ObjInstance, ObjClass> {
|
||||||
|
val t = scope[typeName]?.value as? ObjClass
|
||||||
|
?: scope.raiseError("unknown type $typeName")
|
||||||
|
var s: Scope? = scope
|
||||||
|
while (s != null) {
|
||||||
|
val inst = s.thisObj as? ObjInstance
|
||||||
|
if (inst != null && (inst.objClass === t || inst.objClass.allParentsSet.contains(t))) {
|
||||||
|
return inst to t
|
||||||
|
}
|
||||||
|
s = s.parent
|
||||||
|
}
|
||||||
|
scope.raiseClassCastError(
|
||||||
|
"No instance of type ${t.className} found in the scope chain"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast path for direct `this@Type.name` access using slot maps when possible.
|
||||||
|
*/
|
||||||
|
class QualifiedThisFieldSlotRef(
|
||||||
|
private val typeName: String,
|
||||||
|
val name: String,
|
||||||
|
private val isOptional: Boolean
|
||||||
|
) : ObjRef {
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
|
val (inst, startClass) = resolveQualifiedThisInstance(scope, typeName)
|
||||||
|
if (isOptional && inst == ObjNull) return ObjNull.asMutable
|
||||||
|
|
||||||
|
if (startClass !== inst.objClass) {
|
||||||
|
return ObjQualifiedView(inst, startClass).readField(scope, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
inst.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return inst.resolveRecord(scope, rec, name, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inst.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return inst.resolveRecord(scope, rec, name, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = inst.objClass.publicMemberResolution[name] ?: name
|
||||||
|
inst.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
inst.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: inst.objClass.findDeclaringClassOf(name) ?: inst.objClass
|
||||||
|
return inst.resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst.readField(scope, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setAt(pos: Pos, scope: Scope, newValue: Obj) {
|
||||||
|
val (inst, startClass) = resolveQualifiedThisInstance(scope, typeName)
|
||||||
|
if (isOptional && inst == ObjNull) return
|
||||||
|
|
||||||
|
if (startClass !== inst.objClass) {
|
||||||
|
ObjQualifiedView(inst, startClass).writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
inst.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
writeDirectOrFallback(scope, inst, rec, name, newValue, caller)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inst.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
inst.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = inst.objClass.publicMemberResolution[name] ?: name
|
||||||
|
inst.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
val decl = rec.declaringClass ?: inst.objClass.findDeclaringClassOf(name)
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, decl, caller, name)) {
|
||||||
|
writeDirectOrFallback(scope, inst, rec, name, newValue, decl)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
inst.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.effectiveWriteVisibility == Visibility.Public &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
inst.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inst.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun writeDirectOrFallback(
|
||||||
|
scope: Scope,
|
||||||
|
inst: ObjInstance,
|
||||||
|
rec: ObjRecord,
|
||||||
|
name: String,
|
||||||
|
newValue: Obj,
|
||||||
|
decl: ObjClass?
|
||||||
|
) {
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract) {
|
||||||
|
if (!rec.isMutable && rec.value !== ObjUnset) {
|
||||||
|
ObjIllegalAssignmentException(scope, "can't reassign val $name").raise()
|
||||||
|
}
|
||||||
|
if (rec.value.assign(scope, newValue) == null) rec.value = newValue
|
||||||
|
} else {
|
||||||
|
inst.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast path for direct `this@Type.method(...)` calls using slots when the qualifier is the
|
||||||
|
* dynamic class. Otherwise falls back to a qualified view dispatch.
|
||||||
|
*/
|
||||||
|
class QualifiedThisMethodSlotCallRef(
|
||||||
|
private val typeName: String,
|
||||||
|
private val name: String,
|
||||||
|
private val args: List<ParsedArgument>,
|
||||||
|
private val tailBlock: Boolean,
|
||||||
|
private val isOptional: Boolean
|
||||||
|
) : ObjRef {
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord = evalValue(scope).asReadonly
|
||||||
|
|
||||||
|
override suspend fun evalValue(scope: Scope): Obj {
|
||||||
|
val (inst, startClass) = resolveQualifiedThisInstance(scope, typeName)
|
||||||
|
if (isOptional && inst == ObjNull) return ObjNull
|
||||||
|
val callArgs = args.toArguments(scope, tailBlock)
|
||||||
|
|
||||||
|
if (startClass !== inst.objClass) {
|
||||||
|
return ObjQualifiedView(inst, startClass).invokeInstanceMethod(scope, name, callArgs, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
inst.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private && !rec.isAbstract) {
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (callArgs.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, inst, caller)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(inst.instanceScope, inst, callArgs, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = inst.objClass.publicMemberResolution[name] ?: name
|
||||||
|
inst.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: inst.objClass.findDeclaringClassOf(name) ?: inst.objClass
|
||||||
|
val effectiveCaller = caller ?: if (scope.thisObj === inst) inst.objClass else null
|
||||||
|
if (!canAccessMember(rec.visibility, decl, effectiveCaller, name))
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "can't invoke method $name (declared in ${decl.className})"))
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (callArgs.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, inst, decl)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(inst.instanceScope, inst, callArgs, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return inst.invokeInstanceMethod(scope, name, callArgs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Assignment compound op: target op= value */
|
/** Assignment compound op: target op= value */
|
||||||
class AssignOpRef(
|
class AssignOpRef(
|
||||||
private val op: BinOp,
|
private val op: BinOp,
|
||||||
@@ -422,7 +678,37 @@ class AssignOpRef(
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
if (inPlace != null) return inPlace.asReadonly
|
if (inPlace != null) return inPlace.asReadonly
|
||||||
val result: Obj = when (op) {
|
val fast: Obj? = if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
when {
|
||||||
|
x is ObjInt && y is ObjInt -> {
|
||||||
|
val xv = x.value
|
||||||
|
val yv = y.value
|
||||||
|
when (op) {
|
||||||
|
BinOp.PLUS -> ObjInt.of(xv + yv)
|
||||||
|
BinOp.MINUS -> ObjInt.of(xv - yv)
|
||||||
|
BinOp.STAR -> ObjInt.of(xv * yv)
|
||||||
|
BinOp.SLASH -> if (yv != 0L) ObjInt.of(xv / yv) else null
|
||||||
|
BinOp.PERCENT -> if (yv != 0L) ObjInt.of(xv % yv) else null
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(x is ObjInt || x is ObjReal) && (y is ObjInt || y is ObjReal) -> {
|
||||||
|
val xv = if (x is ObjInt) x.doubleValue else (x as ObjReal).value
|
||||||
|
val yv = if (y is ObjInt) y.doubleValue else (y as ObjReal).value
|
||||||
|
when (op) {
|
||||||
|
BinOp.PLUS -> ObjReal.of(xv + yv)
|
||||||
|
BinOp.MINUS -> ObjReal.of(xv - yv)
|
||||||
|
BinOp.STAR -> ObjReal.of(xv * yv)
|
||||||
|
BinOp.SLASH -> ObjReal.of(xv / yv)
|
||||||
|
BinOp.PERCENT -> ObjReal.of(xv % yv)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x is ObjString && op == BinOp.PLUS -> ObjString(x.value + y.toString())
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
} else null
|
||||||
|
val result: Obj = fast ?: when (op) {
|
||||||
BinOp.PLUS -> x.plus(scope, y)
|
BinOp.PLUS -> x.plus(scope, y)
|
||||||
BinOp.MINUS -> x.minus(scope, y)
|
BinOp.MINUS -> x.minus(scope, y)
|
||||||
BinOp.STAR -> x.mul(scope, y)
|
BinOp.STAR -> x.mul(scope, y)
|
||||||
@@ -450,7 +736,15 @@ class IncDecRef(
|
|||||||
// We now treat numbers as immutable and always perform write-back via setAt.
|
// We now treat numbers as immutable and always perform write-back via setAt.
|
||||||
// This avoids issues where literals are shared and mutated in-place.
|
// This avoids issues where literals are shared and mutated in-place.
|
||||||
// For post-inc: return ORIGINAL value; for pre-inc: return NEW value.
|
// For post-inc: return ORIGINAL value; for pre-inc: return NEW value.
|
||||||
val result = if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
val result = if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
when (v) {
|
||||||
|
is ObjInt -> if (isIncrement) ObjInt.of(v.value + 1L) else ObjInt.of(v.value - 1L)
|
||||||
|
is ObjReal -> if (isIncrement) ObjReal.of(v.value + 1.0) else ObjReal.of(v.value - 1.0)
|
||||||
|
else -> if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
||||||
|
}
|
||||||
target.setAt(atPos, scope, result)
|
target.setAt(atPos, scope, result)
|
||||||
return (if (isPost) v else result).asReadonly
|
return (if (isPost) v else result).asReadonly
|
||||||
}
|
}
|
||||||
@@ -691,9 +985,20 @@ class FieldRef(
|
|||||||
if (effectiveKey != null) {
|
if (effectiveKey != null) {
|
||||||
rKey1 = key; rVer1 = ver; rGetter1 = { obj, sc ->
|
rKey1 = key; rVer1 = ver; rGetter1 = { obj, sc ->
|
||||||
if (obj is ObjInstance && obj.objClass === cls) {
|
if (obj is ObjInstance && obj.objClass === cls) {
|
||||||
val rec = obj.instanceScope.objects[effectiveKey]
|
val slot = cls.fieldSlotForKey(effectiveKey)
|
||||||
if (rec != null && rec.type != ObjRecord.Type.Delegated) rec
|
if (slot != null) {
|
||||||
else obj.readField(sc, name)
|
val idx = slot.slot
|
||||||
|
val rec = if (idx >= 0 && idx < obj.fieldSlots.size) obj.fieldSlots[idx] else null
|
||||||
|
if (rec != null &&
|
||||||
|
(rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) &&
|
||||||
|
!rec.isAbstract) {
|
||||||
|
rec
|
||||||
|
} else obj.readField(sc, name)
|
||||||
|
} else {
|
||||||
|
val rec = obj.fieldRecordForKey(effectiveKey) ?: obj.instanceScope.objects[effectiveKey]
|
||||||
|
if (rec != null && rec.type != ObjRecord.Type.Delegated) rec
|
||||||
|
else obj.readField(sc, name)
|
||||||
|
}
|
||||||
} else obj.readField(sc, name)
|
} else obj.readField(sc, name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -809,10 +1114,24 @@ class FieldRef(
|
|||||||
if (effectiveKey != null) {
|
if (effectiveKey != null) {
|
||||||
wKey1 = key; wVer1 = ver; wSetter1 = { obj, sc, nv ->
|
wKey1 = key; wVer1 = ver; wSetter1 = { obj, sc, nv ->
|
||||||
if (obj is ObjInstance && obj.objClass === cls) {
|
if (obj is ObjInstance && obj.objClass === cls) {
|
||||||
val rec = obj.instanceScope.objects[effectiveKey]
|
val slot = cls.fieldSlotForKey(effectiveKey)
|
||||||
if (rec != null && rec.effectiveWriteVisibility == Visibility.Public && rec.isMutable && rec.type == ObjRecord.Type.Field) {
|
if (slot != null) {
|
||||||
if (rec.value.assign(sc, nv) == null) rec.value = nv
|
val idx = slot.slot
|
||||||
} else obj.writeField(sc, name, nv)
|
val rec = if (idx >= 0 && idx < obj.fieldSlots.size) obj.fieldSlots[idx] else null
|
||||||
|
if (rec != null &&
|
||||||
|
rec.effectiveWriteVisibility == Visibility.Public &&
|
||||||
|
rec.isMutable &&
|
||||||
|
(rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) &&
|
||||||
|
!rec.isAbstract) {
|
||||||
|
if (rec.value.assign(sc, nv) == null) rec.value = nv
|
||||||
|
} else obj.writeField(sc, name, nv)
|
||||||
|
} else {
|
||||||
|
val rec = obj.fieldRecordForKey(effectiveKey) ?: obj.instanceScope.objects[effectiveKey]
|
||||||
|
if (rec != null && rec.effectiveWriteVisibility == Visibility.Public && rec.isMutable &&
|
||||||
|
(rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField)) {
|
||||||
|
if (rec.value.assign(sc, nv) == null) rec.value = nv
|
||||||
|
} else obj.writeField(sc, name, nv)
|
||||||
|
}
|
||||||
} else obj.writeField(sc, name, nv)
|
} else obj.writeField(sc, name, nv)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -890,6 +1209,113 @@ class FieldRef(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast path for direct `this.name` access using slot maps.
|
||||||
|
* Falls back to normal member resolution when needed.
|
||||||
|
*/
|
||||||
|
class ThisFieldSlotRef(
|
||||||
|
val name: String,
|
||||||
|
private val isOptional: Boolean
|
||||||
|
) : ObjRef {
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
|
val th = scope.thisObj
|
||||||
|
if (th == ObjNull && isOptional) return ObjNull.asMutable
|
||||||
|
if (th !is ObjInstance) return th.readField(scope, name)
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
th.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return th.resolveRecord(scope, rec, name, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return th.resolveRecord(scope, rec, name, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = th.objClass.publicMemberResolution[name] ?: name
|
||||||
|
th.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: th.objClass.findDeclaringClassOf(name) ?: th.objClass
|
||||||
|
return th.resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return th.readField(scope, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setAt(pos: Pos, scope: Scope, newValue: Obj) {
|
||||||
|
val th = scope.thisObj
|
||||||
|
if (th == ObjNull && isOptional) return
|
||||||
|
if (th !is ObjInstance) {
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
th.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
writeDirectOrFallback(scope, th, rec, name, newValue, caller)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = th.objClass.publicMemberResolution[name] ?: name
|
||||||
|
th.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
val decl = rec.declaringClass ?: th.objClass.findDeclaringClassOf(name)
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, decl, caller, name)) {
|
||||||
|
writeDirectOrFallback(scope, th, rec, name, newValue, decl)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.effectiveWriteVisibility == Visibility.Public &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun writeDirectOrFallback(
|
||||||
|
scope: Scope,
|
||||||
|
inst: ObjInstance,
|
||||||
|
rec: ObjRecord,
|
||||||
|
name: String,
|
||||||
|
newValue: Obj,
|
||||||
|
decl: ObjClass?
|
||||||
|
) {
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract) {
|
||||||
|
if (!rec.isMutable && rec.value !== ObjUnset) {
|
||||||
|
ObjIllegalAssignmentException(scope, "can't reassign val $name").raise()
|
||||||
|
}
|
||||||
|
if (rec.value.assign(scope, newValue) == null) rec.value = newValue
|
||||||
|
} else {
|
||||||
|
inst.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to index access (a[i]) with optional chaining.
|
* Reference to index access (a[i]) with optional chaining.
|
||||||
*/
|
*/
|
||||||
@@ -1133,7 +1559,7 @@ class IndexRef(
|
|||||||
/**
|
/**
|
||||||
* R-value reference that wraps a Statement (used during migration for expressions parsed as Statement).
|
* R-value reference that wraps a Statement (used during migration for expressions parsed as Statement).
|
||||||
*/
|
*/
|
||||||
class StatementRef(private val statement: Statement) : ObjRef {
|
class StatementRef(internal val statement: Statement) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord = statement.execute(scope).asReadonly
|
override suspend fun get(scope: Scope): ObjRecord = statement.execute(scope).asReadonly
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1336,36 +1762,50 @@ class MethodCallRef(
|
|||||||
is ObjInstance -> {
|
is ObjInstance -> {
|
||||||
// Prefer resolved class member to avoid per-call lookup on hit
|
// Prefer resolved class member to avoid per-call lookup on hit
|
||||||
// BUT only if it's NOT a root object member (which can be shadowed by extensions)
|
// BUT only if it's NOT a root object member (which can be shadowed by extensions)
|
||||||
var hierarchyMember: ObjRecord? = null
|
|
||||||
val cls0 = base.objClass
|
val cls0 = base.objClass
|
||||||
val keyInScope = cls0.publicMemberResolution[name]
|
val keyInScope = cls0.publicMemberResolution[name]
|
||||||
if (keyInScope != null) {
|
val methodSlot = if (keyInScope != null) cls0.methodSlotForKey(keyInScope) else null
|
||||||
val rec = base.instanceScope.objects[keyInScope]
|
val fastRec = if (methodSlot != null) {
|
||||||
if (rec != null && rec.type == ObjRecord.Type.Fun) {
|
val idx = methodSlot.slot
|
||||||
hierarchyMember = rec
|
if (idx >= 0 && idx < base.methodSlots.size) base.methodSlots[idx] else null
|
||||||
}
|
} else if (keyInScope != null) {
|
||||||
}
|
base.methodRecordForKey(keyInScope) ?: base.instanceScope.objects[keyInScope]
|
||||||
|
} else null
|
||||||
|
val resolved = if (fastRec != null) null else cls0.resolveInstanceMember(name)
|
||||||
|
|
||||||
if (hierarchyMember == null) {
|
val targetRec = when {
|
||||||
for (cls in base.objClass.mro) {
|
fastRec != null && fastRec.type == ObjRecord.Type.Fun -> fastRec
|
||||||
if (cls.className == "Obj") break
|
resolved != null && resolved.record.type == ObjRecord.Type.Fun && !resolved.record.isAbstract -> resolved.record
|
||||||
val rec = cls.members[name] ?: cls.classScope?.objects?.get(name)
|
else -> null
|
||||||
if (rec != null && !rec.isAbstract && rec.type != ObjRecord.Type.Field) {
|
}
|
||||||
hierarchyMember = rec
|
if (targetRec != null) {
|
||||||
break
|
val visibility = targetRec.visibility
|
||||||
|
val decl = targetRec.declaringClass ?: (resolved?.declaringClass ?: cls0)
|
||||||
|
if (methodSlot != null && targetRec.type == ObjRecord.Type.Fun) {
|
||||||
|
val slotIndex = methodSlot.slot
|
||||||
|
mKey1 = key; mVer1 = ver; mInvoker1 = { obj, sc, a ->
|
||||||
|
val inst = obj as ObjInstance
|
||||||
|
if (inst.objClass === cls0) {
|
||||||
|
val rec = if (slotIndex >= 0 && slotIndex < inst.methodSlots.size) inst.methodSlots[slotIndex] else null
|
||||||
|
if (rec != null && rec.type == ObjRecord.Type.Fun && !rec.isAbstract) {
|
||||||
|
if (!visibility.isPublic && !canAccessMember(visibility, decl, sc.currentClassCtx, name))
|
||||||
|
sc.raiseError(ObjIllegalAccessException(sc, "can't invoke non-public method $name"))
|
||||||
|
rec.value.invoke(inst.instanceScope, inst, a, decl)
|
||||||
|
} else {
|
||||||
|
obj.invokeInstanceMethod(sc, name, a)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
obj.invokeInstanceMethod(sc, name, a)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val callable = targetRec.value
|
||||||
|
mKey1 = key; mVer1 = ver; mInvoker1 = { obj, sc, a ->
|
||||||
|
val inst = obj as ObjInstance
|
||||||
|
if (!visibility.isPublic && !canAccessMember(visibility, decl, sc.currentClassCtx, name))
|
||||||
|
sc.raiseError(ObjIllegalAccessException(sc, "can't invoke non-public method $name"))
|
||||||
|
callable.invoke(inst.instanceScope, inst, a)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hierarchyMember != null) {
|
|
||||||
val visibility = hierarchyMember.visibility
|
|
||||||
val callable = hierarchyMember.value
|
|
||||||
val decl = hierarchyMember.declaringClass ?: base.objClass
|
|
||||||
mKey1 = key; mVer1 = ver; mInvoker1 = { obj, sc, a ->
|
|
||||||
val inst = obj as ObjInstance
|
|
||||||
if (!visibility.isPublic && !canAccessMember(visibility, decl, sc.currentClassCtx, name))
|
|
||||||
sc.raiseError(ObjIllegalAccessException(sc, "can't invoke non-public method $name"))
|
|
||||||
callable.invoke(inst.instanceScope, inst, a)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Fallback to name-based lookup per call (handles extensions and root members)
|
// Fallback to name-based lookup per call (handles extensions and root members)
|
||||||
@@ -1399,6 +1839,57 @@ class MethodCallRef(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast path for direct `this.method(...)` calls using slot maps.
|
||||||
|
* Falls back to normal invoke semantics when needed.
|
||||||
|
*/
|
||||||
|
class ThisMethodSlotCallRef(
|
||||||
|
private val name: String,
|
||||||
|
private val args: List<ParsedArgument>,
|
||||||
|
private val tailBlock: Boolean,
|
||||||
|
private val isOptional: Boolean
|
||||||
|
) : ObjRef {
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord = evalValue(scope).asReadonly
|
||||||
|
|
||||||
|
override suspend fun evalValue(scope: Scope): Obj {
|
||||||
|
val base = scope.thisObj
|
||||||
|
if (base == ObjNull && isOptional) return ObjNull
|
||||||
|
val callArgs = args.toArguments(scope, tailBlock)
|
||||||
|
if (base !is ObjInstance) return base.invokeInstanceMethod(scope, name, callArgs)
|
||||||
|
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
if (caller != null) {
|
||||||
|
val mangled = caller.mangledName(name)
|
||||||
|
base.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private && !rec.isAbstract) {
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (callArgs.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, base, caller)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(base.instanceScope, base, callArgs, caller)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val key = base.objClass.publicMemberResolution[name] ?: name
|
||||||
|
base.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: base.objClass.findDeclaringClassOf(name) ?: base.objClass
|
||||||
|
val effectiveCaller = caller ?: if (scope.thisObj === base) base.objClass else null
|
||||||
|
if (!canAccessMember(rec.visibility, decl, effectiveCaller, name))
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "can't invoke method $name (declared in ${decl.className})"))
|
||||||
|
if (rec.type == ObjRecord.Type.Property) {
|
||||||
|
if (callArgs.isEmpty()) return (rec.value as ObjProperty).callGetter(scope, base, decl)
|
||||||
|
} else if (rec.type == ObjRecord.Type.Fun) {
|
||||||
|
return rec.value.invoke(base.instanceScope, base, callArgs, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base.invokeInstanceMethod(scope, name, callArgs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to a local/visible variable by name (Phase A: scope lookup).
|
* Reference to a local/visible variable by name (Phase A: scope lookup).
|
||||||
*/
|
*/
|
||||||
@@ -1729,6 +2220,274 @@ class FastLocalVarRef(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identifier reference in class context that prefers member slots on `this` after local lookup.
|
||||||
|
* Falls back to normal scope lookup for globals/outer scopes.
|
||||||
|
*/
|
||||||
|
class ImplicitThisMemberRef(
|
||||||
|
val name: String,
|
||||||
|
val atPos: Pos
|
||||||
|
) : ObjRef {
|
||||||
|
private fun resolveInstanceFieldRecord(th: ObjInstance, caller: ObjClass?): ObjRecord? {
|
||||||
|
if (caller == null) return null
|
||||||
|
for (cls in th.objClass.mro) {
|
||||||
|
if (cls.className == "Obj") break
|
||||||
|
val rec = cls.members[name] ?: continue
|
||||||
|
if (rec.isAbstract) continue
|
||||||
|
val decl = rec.declaringClass ?: cls
|
||||||
|
if (!canAccessMember(rec.visibility, decl, caller, name)) continue
|
||||||
|
val key = decl.mangledName(name)
|
||||||
|
th.fieldRecordForKey(key)?.let { return it }
|
||||||
|
th.instanceScope.objects[key]?.let { return it }
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun forEachVariable(block: (String) -> Unit) {
|
||||||
|
block(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun forEachVariableWithPos(block: (String, Pos) -> Unit) {
|
||||||
|
block(name, atPos)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
|
scope.pos = atPos
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
val th = scope.thisObj
|
||||||
|
|
||||||
|
// 1) locals in the same `this` chain
|
||||||
|
var s: Scope? = scope
|
||||||
|
while (s != null && s.thisObj === th) {
|
||||||
|
scope.tryGetLocalRecord(s, name, caller)?.let { return it }
|
||||||
|
s = s.parent
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) member slots on this instance
|
||||||
|
if (th is ObjInstance) {
|
||||||
|
// private member access for current class context
|
||||||
|
caller?.let { c ->
|
||||||
|
val mangled = c.mangledName(name)
|
||||||
|
th.fieldRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return th.resolveRecord(scope, rec, name, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(mangled)?.let { rec ->
|
||||||
|
if (rec.visibility == Visibility.Private) {
|
||||||
|
return th.resolveRecord(scope, rec, name, c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveInstanceFieldRecord(th, caller)?.let { return it }
|
||||||
|
|
||||||
|
val key = th.objClass.publicMemberResolution[name] ?: name
|
||||||
|
th.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract)
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (!rec.isAbstract) {
|
||||||
|
val decl = rec.declaringClass ?: th.objClass.findDeclaringClassOf(name) ?: th.objClass
|
||||||
|
return th.resolveRecord(scope, rec, name, decl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) fallback to normal scope resolution (globals/outer scopes)
|
||||||
|
scope[name]?.let { return it }
|
||||||
|
try {
|
||||||
|
return th.readField(scope, name)
|
||||||
|
} catch (e: ExecutionError) {
|
||||||
|
if ((e.message ?: "").contains("no such field: $name")) scope.raiseSymbolNotFound(name)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun evalValue(scope: Scope): Obj {
|
||||||
|
val rec = get(scope)
|
||||||
|
return scope.resolve(rec, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setAt(pos: Pos, scope: Scope, newValue: Obj) {
|
||||||
|
scope.pos = atPos
|
||||||
|
val caller = scope.currentClassCtx
|
||||||
|
val th = scope.thisObj
|
||||||
|
|
||||||
|
// 1) locals in the same `this` chain
|
||||||
|
var s: Scope? = scope
|
||||||
|
while (s != null && s.thisObj === th) {
|
||||||
|
val rec = scope.tryGetLocalRecord(s, name, caller)
|
||||||
|
if (rec != null) {
|
||||||
|
scope.assign(rec, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s = s.parent
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) member slots on this instance
|
||||||
|
if (th is ObjInstance) {
|
||||||
|
val key = th.objClass.publicMemberResolution[name] ?: name
|
||||||
|
th.fieldRecordForKey(key)?.let { rec ->
|
||||||
|
val decl = rec.declaringClass ?: th.objClass.findDeclaringClassOf(name)
|
||||||
|
if (canAccessMember(rec.effectiveWriteVisibility, decl, caller, name)) {
|
||||||
|
if ((rec.type == ObjRecord.Type.Field || rec.type == ObjRecord.Type.ConstructorField) && !rec.isAbstract) {
|
||||||
|
if (!rec.isMutable && rec.value !== ObjUnset) {
|
||||||
|
ObjIllegalAssignmentException(scope, "can't reassign val $name").raise()
|
||||||
|
}
|
||||||
|
if (rec.value.assign(scope, newValue) == null) rec.value = newValue
|
||||||
|
} else {
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
th.methodRecordForKey(key)?.let { rec ->
|
||||||
|
if (rec.effectiveWriteVisibility == Visibility.Public &&
|
||||||
|
(rec.type == ObjRecord.Type.Property || rec.type == ObjRecord.Type.Delegated)) {
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resolveInstanceFieldRecord(th, caller)?.let { rec ->
|
||||||
|
scope.assign(rec, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) fallback to normal scope resolution
|
||||||
|
scope[name]?.let { stored ->
|
||||||
|
scope.assign(stored, name, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
th.writeField(scope, name, newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast path for implicit member calls in class bodies: `foo(...)` resolves locals first,
|
||||||
|
* then falls back to member lookup on `this`.
|
||||||
|
*/
|
||||||
|
class ImplicitThisMethodCallRef(
|
||||||
|
private val name: String,
|
||||||
|
private val args: List<ParsedArgument>,
|
||||||
|
private val tailBlock: Boolean,
|
||||||
|
private val isOptional: Boolean,
|
||||||
|
private val atPos: Pos
|
||||||
|
) : ObjRef {
|
||||||
|
private val memberRef = ImplicitThisMemberRef(name, atPos)
|
||||||
|
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord = evalValue(scope).asReadonly
|
||||||
|
|
||||||
|
override suspend fun evalValue(scope: Scope): Obj {
|
||||||
|
scope.pos = atPos
|
||||||
|
val callee = memberRef.evalValue(scope)
|
||||||
|
if (callee == ObjNull && isOptional) return ObjNull
|
||||||
|
val callArgs = args.toArguments(scope, tailBlock)
|
||||||
|
val usePool = PerfFlags.SCOPE_POOL
|
||||||
|
return if (usePool) {
|
||||||
|
scope.withChildFrame(callArgs) { child ->
|
||||||
|
callee.callOn(child)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
callee.callOn(scope.createChildScope(scope.pos, callArgs))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Direct local slot reference with known slot index and lexical depth.
|
||||||
|
* Depth=0 means current scope, depth=1 means parent scope, etc.
|
||||||
|
*/
|
||||||
|
class LocalSlotRef(
|
||||||
|
val name: String,
|
||||||
|
internal val slot: Int,
|
||||||
|
internal val depth: Int,
|
||||||
|
private val atPos: Pos,
|
||||||
|
) : ObjRef {
|
||||||
|
override fun forEachVariable(block: (String) -> Unit) {
|
||||||
|
block(name)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val fallbackRef = LocalVarRef(name, atPos)
|
||||||
|
private var cachedFrameId: Long = 0L
|
||||||
|
private var cachedOwner: Scope? = null
|
||||||
|
private var cachedOwnerVerified: Boolean = false
|
||||||
|
|
||||||
|
private fun resolveOwner(scope: Scope): Scope? {
|
||||||
|
if (cachedOwner != null && cachedFrameId == scope.frameId && cachedOwnerVerified) {
|
||||||
|
val cached = cachedOwner!!
|
||||||
|
val candidate = if (depth == 0) scope else {
|
||||||
|
var s: Scope? = scope
|
||||||
|
var remaining = depth
|
||||||
|
while (s != null && remaining > 0) {
|
||||||
|
s = s.parent
|
||||||
|
remaining--
|
||||||
|
}
|
||||||
|
s
|
||||||
|
}
|
||||||
|
if (candidate === cached && candidate?.getSlotIndexOf(name) == slot) return cached
|
||||||
|
}
|
||||||
|
var s: Scope? = scope
|
||||||
|
var remaining = depth
|
||||||
|
while (s != null && remaining > 0) {
|
||||||
|
s = s.parent
|
||||||
|
remaining--
|
||||||
|
}
|
||||||
|
if (s == null || s.getSlotIndexOf(name) != slot) {
|
||||||
|
cachedOwner = null
|
||||||
|
cachedOwnerVerified = false
|
||||||
|
cachedFrameId = scope.frameId
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
cachedOwner = s
|
||||||
|
cachedOwnerVerified = true
|
||||||
|
cachedFrameId = scope.frameId
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
|
scope.pos = atPos
|
||||||
|
val owner = resolveOwner(scope) ?: return fallbackRef.get(scope)
|
||||||
|
if (slot < 0 || slot >= owner.slotCount()) return fallbackRef.get(scope)
|
||||||
|
val rec = owner.getSlotRecord(slot)
|
||||||
|
if (rec.declaringClass != null && !canAccessMember(rec.visibility, rec.declaringClass, scope.currentClassCtx, name)) {
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "private field access"))
|
||||||
|
}
|
||||||
|
return rec
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun evalValue(scope: Scope): Obj {
|
||||||
|
scope.pos = atPos
|
||||||
|
val owner = resolveOwner(scope) ?: return fallbackRef.evalValue(scope)
|
||||||
|
if (slot < 0 || slot >= owner.slotCount()) return fallbackRef.evalValue(scope)
|
||||||
|
val rec = owner.getSlotRecord(slot)
|
||||||
|
if (rec.declaringClass != null && !canAccessMember(rec.visibility, rec.declaringClass, scope.currentClassCtx, name)) {
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "private field access"))
|
||||||
|
}
|
||||||
|
return scope.resolve(rec, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun setAt(pos: Pos, scope: Scope, newValue: Obj) {
|
||||||
|
scope.pos = atPos
|
||||||
|
val owner = resolveOwner(scope) ?: run {
|
||||||
|
fallbackRef.setAt(pos, scope, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (slot < 0 || slot >= owner.slotCount()) {
|
||||||
|
fallbackRef.setAt(pos, scope, newValue)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val rec = owner.getSlotRecord(slot)
|
||||||
|
if (rec.declaringClass != null && !canAccessMember(rec.visibility, rec.declaringClass, scope.currentClassCtx, name)) {
|
||||||
|
scope.raiseError(ObjIllegalAccessException(scope, "private field access"))
|
||||||
|
}
|
||||||
|
scope.assign(rec, name, newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class ListLiteralRef(private val entries: List<ListEntry>) : ObjRef {
|
class ListLiteralRef(private val entries: List<ListEntry>) : ObjRef {
|
||||||
override fun forEachVariable(block: (String) -> Unit) {
|
override fun forEachVariable(block: (String) -> Unit) {
|
||||||
for (e in entries) {
|
for (e in entries) {
|
||||||
@@ -1862,9 +2621,9 @@ class MapLiteralRef(private val entries: List<MapLiteralEntry>) : ObjRef {
|
|||||||
* Range literal: left .. right or left ..< right. Right may be omitted in certain contexts.
|
* Range literal: left .. right or left ..< right. Right may be omitted in certain contexts.
|
||||||
*/
|
*/
|
||||||
class RangeRef(
|
class RangeRef(
|
||||||
private val left: ObjRef?,
|
internal val left: ObjRef?,
|
||||||
private val right: ObjRef?,
|
internal val right: ObjRef?,
|
||||||
private val isEndInclusive: Boolean
|
internal val isEndInclusive: Boolean
|
||||||
) : ObjRef {
|
) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord {
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
return evalValue(scope).asReadonly
|
return evalValue(scope).asReadonly
|
||||||
@@ -1898,8 +2657,8 @@ class AssignIfNullRef(
|
|||||||
|
|
||||||
/** Simple assignment: target = value */
|
/** Simple assignment: target = value */
|
||||||
class AssignRef(
|
class AssignRef(
|
||||||
private val target: ObjRef,
|
internal val target: ObjRef,
|
||||||
private val value: ObjRef,
|
internal val value: ObjRef,
|
||||||
private val atPos: Pos,
|
private val atPos: Pos,
|
||||||
) : ObjRef {
|
) : ObjRef {
|
||||||
override suspend fun get(scope: Scope): ObjRecord {
|
override suspend fun get(scope: Scope): ObjRecord {
|
||||||
@@ -1910,7 +2669,15 @@ class AssignRef(
|
|||||||
val v = value.evalValue(scope)
|
val v = value.evalValue(scope)
|
||||||
// For properties, we should not call get() on target because it invokes the getter.
|
// For properties, we should not call get() on target because it invokes the getter.
|
||||||
// Instead, we call setAt directly.
|
// Instead, we call setAt directly.
|
||||||
if (target is FieldRef || target is IndexRef || target is LocalVarRef || target is FastLocalVarRef || target is BoundLocalVarRef) {
|
if (target is FieldRef ||
|
||||||
|
target is IndexRef ||
|
||||||
|
target is LocalVarRef ||
|
||||||
|
target is FastLocalVarRef ||
|
||||||
|
target is BoundLocalVarRef ||
|
||||||
|
target is LocalSlotRef ||
|
||||||
|
target is ThisFieldSlotRef ||
|
||||||
|
target is QualifiedThisFieldSlotRef ||
|
||||||
|
target is ImplicitThisMemberRef) {
|
||||||
target.setAt(atPos, scope, v)
|
target.setAt(atPos, scope, v)
|
||||||
} else {
|
} else {
|
||||||
val rec = target.get(scope)
|
val rec = target.get(scope)
|
||||||
@@ -1923,4 +2690,4 @@ class AssignRef(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// (duplicate LocalVarRef removed; the canonical implementation is defined earlier in this file)
|
// (duplicate LocalVarRef removed; the canonical implementation is defined earlier in this file)
|
||||||
@@ -20,6 +20,7 @@ package net.sergeych.lyng
|
|||||||
import net.sergeych.lyng.obj.Obj
|
import net.sergeych.lyng.obj.Obj
|
||||||
import net.sergeych.lyng.obj.ObjClass
|
import net.sergeych.lyng.obj.ObjClass
|
||||||
import net.sergeych.lyng.obj.ObjVoid
|
import net.sergeych.lyng.obj.ObjVoid
|
||||||
|
import net.sergeych.lyng.obj.toBool
|
||||||
|
|
||||||
fun String.toSource(name: String = "eval"): Source = Source(name, this)
|
fun String.toSource(name: String = "eval"): Source = Source(name, this)
|
||||||
|
|
||||||
@@ -63,6 +64,37 @@ abstract class Statement(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class IfStatement(
|
||||||
|
val condition: Statement,
|
||||||
|
val ifBody: Statement,
|
||||||
|
val elseBody: Statement?,
|
||||||
|
override val pos: Pos,
|
||||||
|
) : Statement() {
|
||||||
|
override suspend fun execute(scope: Scope): Obj {
|
||||||
|
return if (condition.execute(scope).toBool()) {
|
||||||
|
ifBody.execute(scope)
|
||||||
|
} else {
|
||||||
|
elseBody?.execute(scope) ?: ObjVoid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ToBoolStatement(
|
||||||
|
val expr: Statement,
|
||||||
|
override val pos: Pos,
|
||||||
|
) : Statement() {
|
||||||
|
override suspend fun execute(scope: Scope): Obj {
|
||||||
|
return if (expr.execute(scope).toBool()) net.sergeych.lyng.obj.ObjTrue else net.sergeych.lyng.obj.ObjFalse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExpressionStatement(
|
||||||
|
val ref: net.sergeych.lyng.obj.ObjRef,
|
||||||
|
override val pos: Pos
|
||||||
|
) : Statement() {
|
||||||
|
override suspend fun execute(scope: Scope): Obj = ref.evalValue(scope)
|
||||||
|
}
|
||||||
|
|
||||||
fun Statement.raise(text: String): Nothing {
|
fun Statement.raise(text: String): Nothing {
|
||||||
throw ScriptError(pos, text)
|
throw ScriptError(pos, text)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,301 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import net.sergeych.lyng.ExpressionStatement
|
||||||
|
import net.sergeych.lyng.IfStatement
|
||||||
|
import net.sergeych.lyng.Scope
|
||||||
|
import net.sergeych.lyng.bytecode.BytecodeBuilder
|
||||||
|
import net.sergeych.lyng.bytecode.BytecodeCompiler
|
||||||
|
import net.sergeych.lyng.bytecode.BytecodeConst
|
||||||
|
import net.sergeych.lyng.bytecode.BytecodeVm
|
||||||
|
import net.sergeych.lyng.bytecode.Opcode
|
||||||
|
import net.sergeych.lyng.obj.BinaryOpRef
|
||||||
|
import net.sergeych.lyng.obj.BinOp
|
||||||
|
import net.sergeych.lyng.obj.ConstRef
|
||||||
|
import net.sergeych.lyng.obj.LocalSlotRef
|
||||||
|
import net.sergeych.lyng.obj.ObjFalse
|
||||||
|
import net.sergeych.lyng.obj.ObjInt
|
||||||
|
import net.sergeych.lyng.obj.ObjTrue
|
||||||
|
import net.sergeych.lyng.obj.ObjReal
|
||||||
|
import net.sergeych.lyng.obj.ObjString
|
||||||
|
import net.sergeych.lyng.obj.ObjList
|
||||||
|
import net.sergeych.lyng.obj.AssignRef
|
||||||
|
import net.sergeych.lyng.obj.ValueFnRef
|
||||||
|
import net.sergeych.lyng.obj.ObjVoid
|
||||||
|
import net.sergeych.lyng.obj.toBool
|
||||||
|
import net.sergeych.lyng.obj.toDouble
|
||||||
|
import net.sergeych.lyng.obj.toInt
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class BytecodeVmTest {
|
||||||
|
@Test
|
||||||
|
fun addsIntConstants() = kotlinx.coroutines.test.runTest {
|
||||||
|
val builder = BytecodeBuilder()
|
||||||
|
val k0 = builder.addConst(BytecodeConst.IntVal(2))
|
||||||
|
val k1 = builder.addConst(BytecodeConst.IntVal(3))
|
||||||
|
builder.emit(Opcode.CONST_INT, k0, 0)
|
||||||
|
builder.emit(Opcode.CONST_INT, k1, 1)
|
||||||
|
builder.emit(Opcode.ADD_INT, 0, 1, 2)
|
||||||
|
builder.emit(Opcode.RET, 2)
|
||||||
|
val fn = builder.build("addInts", localCount = 3)
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(5, result.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun ifExpressionReturnsThenValue() = kotlinx.coroutines.test.runTest {
|
||||||
|
val cond = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.LT,
|
||||||
|
ConstRef(ObjInt.of(2).asReadonly),
|
||||||
|
ConstRef(ObjInt.of(3).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val thenStmt = ExpressionStatement(
|
||||||
|
ConstRef(ObjInt.of(10).asReadonly),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val elseStmt = ExpressionStatement(
|
||||||
|
ConstRef(ObjInt.of(20).asReadonly),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val ifStmt = IfStatement(cond, thenStmt, elseStmt, net.sergeych.lyng.Pos.builtIn)
|
||||||
|
val fn = BytecodeCompiler().compileStatement("ifTest", ifStmt) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(10, result.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun ifWithoutElseReturnsVoid() = kotlinx.coroutines.test.runTest {
|
||||||
|
val cond = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.LT,
|
||||||
|
ConstRef(ObjInt.of(2).asReadonly),
|
||||||
|
ConstRef(ObjInt.of(1).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val thenStmt = ExpressionStatement(
|
||||||
|
ConstRef(ObjInt.of(10).asReadonly),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val ifStmt = IfStatement(cond, thenStmt, null, net.sergeych.lyng.Pos.builtIn)
|
||||||
|
val fn = BytecodeCompiler().compileStatement("ifNoElse", ifStmt).also {
|
||||||
|
if (it == null) {
|
||||||
|
error("bytecode compile failed for ifNoElse")
|
||||||
|
}
|
||||||
|
}!!
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(ObjVoid, result)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun andIsShortCircuit() = kotlinx.coroutines.test.runTest {
|
||||||
|
val throwingRef = ValueFnRef { error("should not execute") }
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.AND,
|
||||||
|
ConstRef(ObjFalse.asReadonly),
|
||||||
|
throwingRef
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("andShort", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(false, result.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun orIsShortCircuit() = kotlinx.coroutines.test.runTest {
|
||||||
|
val throwingRef = ValueFnRef { error("should not execute") }
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.OR,
|
||||||
|
ConstRef(ObjTrue.asReadonly),
|
||||||
|
throwingRef
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("orShort", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(true, result.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun realArithmeticUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.PLUS,
|
||||||
|
ConstRef(ObjReal.of(2.5).asReadonly),
|
||||||
|
ConstRef(ObjReal.of(3.25).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("realPlus", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(5.75, result.toDouble())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun mixedIntRealComparisonUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val ltExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.LT,
|
||||||
|
ConstRef(ObjInt.of(2).asReadonly),
|
||||||
|
ConstRef(ObjReal.of(2.5).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val ltFn = BytecodeCompiler().compileExpression("mixedLt", ltExpr) ?: error("bytecode compile failed")
|
||||||
|
val ltResult = BytecodeVm().execute(ltFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, ltResult.toBool())
|
||||||
|
|
||||||
|
val eqExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.EQ,
|
||||||
|
ConstRef(ObjReal.of(4.0).asReadonly),
|
||||||
|
ConstRef(ObjInt.of(4).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val eqFn = BytecodeCompiler().compileExpression("mixedEq", eqExpr) ?: error("bytecode compile failed")
|
||||||
|
val eqResult = BytecodeVm().execute(eqFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, eqResult.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun mixedIntRealArithmeticUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.PLUS,
|
||||||
|
ConstRef(ObjInt.of(2).asReadonly),
|
||||||
|
ConstRef(ObjReal.of(3.5).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("mixedPlus", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(5.5, result.toDouble())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun mixedIntRealNotEqualUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.NEQ,
|
||||||
|
ConstRef(ObjInt.of(3).asReadonly),
|
||||||
|
ConstRef(ObjReal.of(2.5).asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("mixedNeq", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(true, result.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun localSlotTypeTrackingEnablesArithmetic() = kotlinx.coroutines.test.runTest {
|
||||||
|
val slotRef = LocalSlotRef("a", 0, 0, net.sergeych.lyng.Pos.builtIn)
|
||||||
|
val assign = AssignRef(
|
||||||
|
slotRef,
|
||||||
|
ConstRef(ObjInt.of(2).asReadonly),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.PLUS,
|
||||||
|
assign,
|
||||||
|
slotRef
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("localSlotAdd", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(4, result.toInt())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun objectEqualityUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val expr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.EQ,
|
||||||
|
ConstRef(ObjString("abc").asReadonly),
|
||||||
|
ConstRef(ObjString("abc").asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val fn = BytecodeCompiler().compileExpression("objEq", expr) ?: error("bytecode compile failed")
|
||||||
|
val result = BytecodeVm().execute(fn, Scope(), emptyList())
|
||||||
|
assertEquals(true, result.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun objectReferenceEqualityUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val shared = ObjList()
|
||||||
|
val eqExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.REF_EQ,
|
||||||
|
ConstRef(shared.asReadonly),
|
||||||
|
ConstRef(shared.asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val eqFn = BytecodeCompiler().compileExpression("objRefEq", eqExpr) ?: error("bytecode compile failed")
|
||||||
|
val eqResult = BytecodeVm().execute(eqFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, eqResult.toBool())
|
||||||
|
|
||||||
|
val neqExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.REF_NEQ,
|
||||||
|
ConstRef(ObjList().asReadonly),
|
||||||
|
ConstRef(ObjList().asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val neqFn = BytecodeCompiler().compileExpression("objRefNeq", neqExpr) ?: error("bytecode compile failed")
|
||||||
|
val neqResult = BytecodeVm().execute(neqFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, neqResult.toBool())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun objectComparisonUsesBytecodeOps() = kotlinx.coroutines.test.runTest {
|
||||||
|
val ltExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.LT,
|
||||||
|
ConstRef(ObjString("a").asReadonly),
|
||||||
|
ConstRef(ObjString("b").asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val ltFn = BytecodeCompiler().compileExpression("objLt", ltExpr) ?: error("bytecode compile failed")
|
||||||
|
val ltResult = BytecodeVm().execute(ltFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, ltResult.toBool())
|
||||||
|
|
||||||
|
val gteExpr = ExpressionStatement(
|
||||||
|
BinaryOpRef(
|
||||||
|
BinOp.GTE,
|
||||||
|
ConstRef(ObjString("b").asReadonly),
|
||||||
|
ConstRef(ObjString("a").asReadonly),
|
||||||
|
),
|
||||||
|
net.sergeych.lyng.Pos.builtIn
|
||||||
|
)
|
||||||
|
val gteFn = BytecodeCompiler().compileExpression("objGte", gteExpr) ?: error("bytecode compile failed")
|
||||||
|
val gteResult = BytecodeVm().execute(gteFn, Scope(), emptyList())
|
||||||
|
assertEquals(true, gteResult.toBool())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import net.sergeych.lyng.Benchmarks
|
||||||
|
import net.sergeych.lyng.eval
|
||||||
|
import net.sergeych.lyng.obj.ObjInt
|
||||||
|
import kotlin.time.TimeSource
|
||||||
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
|
class NestedRangeBenchmarkTest {
|
||||||
|
@Test
|
||||||
|
fun benchmarkHappyNumbersNestedRanges() = runTest {
|
||||||
|
if (!Benchmarks.enabled) return@runTest
|
||||||
|
val script = """
|
||||||
|
fun naiveCountHappyNumbers() {
|
||||||
|
var count = 0
|
||||||
|
for( n1 in 0..9 )
|
||||||
|
for( n2 in 0..9 )
|
||||||
|
for( n3 in 0..9 )
|
||||||
|
for( n4 in 0..9 )
|
||||||
|
for( n5 in 0..9 )
|
||||||
|
for( n6 in 0..9 )
|
||||||
|
if( n1 + n2 + n3 == n4 + n5 + n6 ) count++
|
||||||
|
count
|
||||||
|
}
|
||||||
|
naiveCountHappyNumbers()
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
val start = TimeSource.Monotonic.markNow()
|
||||||
|
val result = eval(script) as ObjInt
|
||||||
|
val elapsedMs = start.elapsedNow().inWholeMilliseconds
|
||||||
|
println("[DEBUG_LOG] [BENCH] nested-happy elapsed=${elapsedMs} ms")
|
||||||
|
assertEquals(55252L, result.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -911,4 +911,19 @@ class OOTest {
|
|||||||
assertEquals("{\"a\":\"foo\",\"b\":\"bar\"}",T("foo", "bar").toJsonString())
|
assertEquals("{\"a\":\"foo\",\"b\":\"bar\"}",T("foo", "bar").toJsonString())
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAssignToUnqualifiedParams() = runTest {
|
||||||
|
eval("""
|
||||||
|
class T(x) {
|
||||||
|
fun setx(v) { x = v }
|
||||||
|
fun incr(v) { x += v }
|
||||||
|
}
|
||||||
|
val t = T(1)
|
||||||
|
t.setx(2)
|
||||||
|
assertEquals(2, t.x)
|
||||||
|
t.incr(3)
|
||||||
|
assertEquals(5, t.x)
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5035,5 +5035,13 @@ class ScriptTest {
|
|||||||
assertEquals(10.0, 15.5.clamp(0.0..10.0))
|
assertEquals(10.0, 15.5.clamp(0.0..10.0))
|
||||||
""".trimIndent())
|
""".trimIndent())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testEmptySpreadList() = runTest {
|
||||||
|
eval("""
|
||||||
|
fun t(a, tags=[]) { [a, ...tags] }
|
||||||
|
assertEquals( [1], t(1) )
|
||||||
|
""".trimIndent())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import net.sergeych.lyng.eval
|
||||||
|
import kotlin.test.Test
|
||||||
|
|
||||||
|
class ValReassignRegressionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun reassign_ctor_param_field_should_work() = runTest {
|
||||||
|
eval(
|
||||||
|
"""
|
||||||
|
class Wallet(balance = 0) {
|
||||||
|
fun add(amount) {
|
||||||
|
balance += amount
|
||||||
|
}
|
||||||
|
fun transfer(amount) {
|
||||||
|
val balance = 0
|
||||||
|
add(amount)
|
||||||
|
}
|
||||||
|
fun get() { balance }
|
||||||
|
}
|
||||||
|
val w = Wallet()
|
||||||
|
w.transfer(1)
|
||||||
|
assertEquals(1, w.get())
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun reassign_field_should_not_see_caller_locals() = runTest {
|
||||||
|
eval(
|
||||||
|
"""
|
||||||
|
class Wallet(balance = 0) {
|
||||||
|
fun add(amount) { balance += amount }
|
||||||
|
fun get() { balance }
|
||||||
|
}
|
||||||
|
fun doTransfer(w, amount) {
|
||||||
|
val balance = 0
|
||||||
|
w.add(amount)
|
||||||
|
}
|
||||||
|
val w = Wallet()
|
||||||
|
doTransfer(w, 2)
|
||||||
|
assertEquals(2, w.get())
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun reassign_field_should_not_see_caller_param() = runTest {
|
||||||
|
eval(
|
||||||
|
"""
|
||||||
|
class Wallet(balance = 0) {
|
||||||
|
fun add(amount) { balance += amount }
|
||||||
|
fun get() { balance }
|
||||||
|
}
|
||||||
|
fun doTransfer(balance, w, amount) {
|
||||||
|
w.add(amount)
|
||||||
|
}
|
||||||
|
val w = Wallet()
|
||||||
|
doTransfer(0, w, 3)
|
||||||
|
assertEquals(3, w.get())
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun reassign_field_should_not_see_block_local() = runTest {
|
||||||
|
eval(
|
||||||
|
"""
|
||||||
|
class Wallet(balance = 0) {
|
||||||
|
fun add(amount) { balance += amount }
|
||||||
|
fun get() { balance }
|
||||||
|
}
|
||||||
|
val w = Wallet()
|
||||||
|
run {
|
||||||
|
val balance = 0
|
||||||
|
w.add(4)
|
||||||
|
}
|
||||||
|
assertEquals(4, w.get())
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
actual object Benchmarks {
|
||||||
|
actual val enabled: Boolean = false
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
actual object Benchmarks {
|
||||||
|
actual val enabled: Boolean = run {
|
||||||
|
val p = System.getProperty("LYNG_BENCHMARKS")?.lowercase()
|
||||||
|
val e = System.getenv("BENCHMARKS")?.lowercase()
|
||||||
|
fun parse(v: String?): Boolean =
|
||||||
|
v == "true" || v == "1" || v == "yes"
|
||||||
|
parse(p) || parse(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
import kotlinx.cinterop.ExperimentalForeignApi
|
||||||
|
import kotlinx.cinterop.toKString
|
||||||
|
import platform.posix.getenv
|
||||||
|
|
||||||
|
@OptIn(ExperimentalForeignApi::class)
|
||||||
|
actual object Benchmarks {
|
||||||
|
actual val enabled: Boolean = run {
|
||||||
|
fun parse(v: String?): Boolean =
|
||||||
|
v == "true" || v == "1" || v == "yes"
|
||||||
|
val b = getenv("BENCHMARKS")?.toKString()?.lowercase()
|
||||||
|
val l = getenv("LYNG_BENCHMARKS")?.toKString()?.lowercase()
|
||||||
|
parse(b) || parse(l)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2026 Sergey S. Chernov real.sergeych@gmail.com
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package net.sergeych.lyng
|
||||||
|
|
||||||
|
actual object Benchmarks {
|
||||||
|
actual val enabled: Boolean = false
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3317:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3713:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3724:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3783:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3894:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3950:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:358:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:377:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 261.854157 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 143.359303 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 198.727671 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 165.057842 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1212.62923 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1221.344844 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 911.390453 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 864.74467 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1258.596122 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1215.214754 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 813.8911 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 840.201914 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 721.329794 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 664.626564 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=246.670 ms, ON=247.664 ms, speedup=1.00x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 358.568027 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 357.649314 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 210.029012 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 197.480796 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 189.724828 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 171.944462 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 155.800531 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 159.326021 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 493.764263 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 473.911057 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 414.496391 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 379.154141 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 395.901223 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 361.008923 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 614.851677 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 606.423947 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 322.701469 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 332.466691 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 125.613919 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 127.188579 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 271.994907 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 269.043016 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1224.41111 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1159.586817 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 494.4744 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 420.160566 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 632.699991 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 558.980979 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 32s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Arguments.kt:171:13 Check for instance is always 'true'.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3317:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3713:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3724:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3783:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3894:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3950:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 262.456983 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 143.016118 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 204.504575 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 169.943911 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1249.839264 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1222.298584 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 901.399509 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 862.404202 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1288.885586 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1240.515769 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 818.753611 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 846.609202 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 673.750784 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 656.929851 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=277.571 ms, ON=278.333 ms, speedup=1.00x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 352.770834 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 350.420946 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 203.043167 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 191.784157 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 190.975557 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 173.62457 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 162.948512 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 161.115548 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 481.70436 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 457.081838 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 416.136033 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 377.996669 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 415.789128 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 369.789878 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 615.689206 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 604.213533 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 330.268329 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 331.937563 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 130.221941 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 129.656747 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 280.648819 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 276.585595 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1244.04352 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1181.395693 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 455.504952 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 388.443547 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 628.199793 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 574.342775 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 32s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3317:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3713:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3724:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3783:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3894:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3950:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 261.781459 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 145.930937 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 198.865061 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 166.602828 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1247.05106 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1281.54336 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 883.211818 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 865.689378 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1233.018601 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1481.964038 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 888.881526 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 849.302933 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 665.365 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 663.883057 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=247.421 ms, ON=260.564 ms, speedup=0.95x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 353.794891 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 353.008114 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 202.620604 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 188.753098 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 187.350501 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 172.926716 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 159.856375 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 173.291963 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 484.924666 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 470.462696 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 418.550739 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 377.176886 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 398.385204 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 361.726326 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 606.153624 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 602.269093 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 327.139818 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 326.264549 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 127.960191 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 133.286108 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 289.541793 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 272.736055 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1238.097545 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1189.624292 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 447.781066 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 373.556778 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 574.938314 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 537.896984 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 32s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3320:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3716:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3727:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3786:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3897:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3953:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 253.651654 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 146.390764 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 197.226054 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 168.955589 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1256.240598 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1270.063908 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 896.05655 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 908.729676 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1275.701226 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1262.923161 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 904.80078 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 843.661706 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 693.294337 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 655.907501 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=246.831 ms, ON=249.673 ms, speedup=0.99x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 363.565902 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 357.239034 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 205.439227 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 192.811329 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 190.153039 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 171.03625 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 171.823152 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 172.076498 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 470.255577 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 452.226068 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 425.250966 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 372.065608 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 425.557633 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 398.662616 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 670.172011 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 654.491316 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 368.642342 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 371.610689 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 132.834786 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 128.264586 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 271.281035 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 265.903301 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1239.838114 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1170.640179 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 440.47053 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 372.095174 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 611.454512 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 553.868896 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 32s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3096:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3128:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3161:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3372:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3768:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3779:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3838:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3949:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:4005:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 268.708055 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 146.48493 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 200.079276 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 163.315912 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1553.293592 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1473.171537 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 1069.276106 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 938.902009 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1272.837347 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1232.000995 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 821.533602 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 845.562175 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 713.778041 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 658.92245 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=258.841 ms, ON=260.836 ms, speedup=0.99x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 359.929596 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 355.440048 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 201.239366 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 193.027976 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 193.231822 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 169.126707 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 152.807956 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 155.12379 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 487.13174 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 458.34973 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 420.451323 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 380.196618 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 407.040834 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 376.63534 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 651.947325 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 665.276754 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 343.185945 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 333.229274 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 128.027033 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 128.223778 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 272.765371 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 267.282587 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1222.526972 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1156.325094 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 454.25713 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 435.042988 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 646.493027 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 581.51493 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 33s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3317:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3713:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3724:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3783:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3894:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3950:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt:169:37 Redundant call of conversion method.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 261.750618 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 146.453823 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 195.212879 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 162.023578 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1500.893007 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1470.571042 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 1069.296265 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 979.876815 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1282.033869 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1219.102212 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 817.077586 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 836.022994 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 694.858051 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 657.045255 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=257.782 ms, ON=248.041 ms, speedup=1.04x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 352.616677 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 342.878941 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 199.536636 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 184.094618 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 192.697462 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 169.343891 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 172.952628 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 175.110539 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 474.235439 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 447.779765 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 416.685434 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 385.882443 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 404.699708 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 363.070008 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 624.839841 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 615.958067 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 329.06723 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 345.786502 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 127.328515 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 128.997015 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 275.285879 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 272.488545 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1007.052847 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 942.271572 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 501.928282 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 431.511816 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 713.844255 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 670.054138 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 32s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3077:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3142:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3350:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3746:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3757:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3816:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3927:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3983:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt:169:37 Redundant call of conversion method.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 255.650854 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 145.478367 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 194.190057 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 161.917102 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1553.057072 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1240.793002 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 944.216355 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 1009.585989 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1539.226472 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1454.032021 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 977.674848 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 990.058604 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 853.990613 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 786.133583 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=268.317 ms, ON=280.306 ms, speedup=0.96x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 373.337982 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 363.041028 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 203.456039 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 189.400538 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 191.685426 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 172.746472 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 172.601148 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 175.298872 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 480.488372 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 449.23481 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 428.089067 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 392.908699 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 409.659747 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 367.216414 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 608.613603 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 626.039278 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 325.012701 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 321.701777 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 127.06677 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 129.773497 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 279.046361 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 271.50303 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1022.352328 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 964.474767 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 496.707269 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 442.890336 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 695.24589 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 579.05104 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 34s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3077:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3142:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3350:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3746:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3757:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3816:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3927:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3983:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt:169:37 Redundant call of conversion method.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 255.197357 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 145.587919 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 192.491336 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 162.773639 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1527.164983 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1468.249877 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 1067.915333 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 1006.785753 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1525.341699 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1272.182191 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 820.632254 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 840.236564 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 688.095527 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 655.496511 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=257.927 ms, ON=256.999 ms, speedup=1.00x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 354.975875 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 345.167837 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 202.94016 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 189.847027 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 194.183153 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 166.705436 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 158.344393 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 171.7144 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 485.762962 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 451.642059 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 422.33805 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 381.000391 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 421.92221 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 374.912331 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 619.019405 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 607.095909 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 344.680073 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 370.68396 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 123.837196 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 127.987498 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 275.825602 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 272.281156 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1004.34663 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 950.919274 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 467.891003 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 380.721475 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 608.237558 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 611.825714 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 33s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
Reusing configuration cache.
|
||||||
|
> Task :lynglib:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lyngio:jvmProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestProcessResources NO-SOURCE
|
||||||
|
> Task :lynglib:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lyngio:kmpPartiallyResolvedDependenciesChecker
|
||||||
|
> Task :lynglib:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lyngio:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmMainResources SKIPPED
|
||||||
|
> Task :lynglib:processJvmTestResources SKIPPED
|
||||||
|
> Task :lyngio:checkKotlinGradlePluginConfigurationErrors SKIPPED
|
||||||
|
> Task :lynglib:generateLyngStdlib
|
||||||
|
> Task :lynglib:generateBuildKonfig
|
||||||
|
|
||||||
|
> Task :lynglib:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:228:25 'when' is exhaustive so 'else' is redundant here.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3044:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3076:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3109:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3317:46 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3713:42 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3724:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3783:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3894:62 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Compiler.kt:3950:66 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/Scope.kt:727:31 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:507:50 The corresponding parameter in the supertype 'Statement' is named 'scope'. This may cause problems when calling this function with named arguments.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/Obj.kt:820:57 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:33:32 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:158:39 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:177:64 'val monthNumber: Int' is deprecated. Use the 'month' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:179:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:181:64 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjDateTime.kt:266:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:35:31 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:102:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:106:24 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:117:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:119:38 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:123:29 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:125:41 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:139:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:144:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:149:25 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:202:69 'val dayOfMonth: Int' is deprecated. Use the 'day' property instead.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:212:28 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:222:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInstant.kt:234:21 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:432:35 No cast needed.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt:451:35 No cast needed.
|
||||||
|
|
||||||
|
> Task :lynglib:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmMainClasses
|
||||||
|
> Task :lynglib:jvmJar
|
||||||
|
|
||||||
|
> Task :lyngio:compileKotlinJvm
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:192:71 'typealias Instant = Instant' is deprecated. This type is deprecated in favor of `kotlin.time.Instant`.
|
||||||
|
w: file:///home/sergeych/dev/ling_lib/lyngio/src/commonMain/kotlin/net/sergeych/lyng/io/fs/LyngFsModule.kt:315:51 Redundant call of conversion method.
|
||||||
|
|
||||||
|
> Task :lyngio:compileJvmMainJava NO-SOURCE
|
||||||
|
> Task :lyngio:jvmMainClasses
|
||||||
|
> Task :lyngio:jvmJar
|
||||||
|
> Task :lynglib:compileTestKotlinJvm
|
||||||
|
> Task :lynglib:compileJvmTestJava NO-SOURCE
|
||||||
|
> Task :lynglib:jvmTestClasses
|
||||||
|
|
||||||
|
> Task :lynglib:jvmTest
|
||||||
|
|
||||||
|
ArithmeticBenchmarkTest[jvm] > benchmarkIntArithmeticAndComparisons[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=OFF]: 257.626421 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-sum x400000 [PRIMITIVE_FASTOPS=ON]: 145.74696 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=OFF]: 185.585751 ms
|
||||||
|
[DEBUG_LOG] [BENCH] int-cmp x400000 [PRIMITIVE_FASTOPS=ON]: 163.520035 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1505.046393 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1314.629855 ms
|
||||||
|
|
||||||
|
CallBenchmarkTest[jvm] > benchmarkSimpleFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=OFF]: 894.419862 ms
|
||||||
|
[DEBUG_LOG] [BENCH] calls x300000 [ARG_BUILDER=ON]: 872.837744 ms
|
||||||
|
|
||||||
|
CallMixedArityBenchmarkTest[jvm] > benchmarkMixedArityCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=OFF]: 1240.254948 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed-arity x200000 [ARG_BUILDER=ON]: 1212.818849 ms
|
||||||
|
|
||||||
|
CallPoolingBenchmarkTest[jvm] > benchmarkScopePoolingOnFunctionCalls[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=OFF]: 809.588732 ms
|
||||||
|
[DEBUG_LOG] [BENCH] call-pooling x300000 [SCOPE_POOL=ON]: 925.016684 ms
|
||||||
|
|
||||||
|
CallSplatBenchmarkTest[jvm] > benchmarkCallsWithSplatArgs[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=OFF]: 721.186901 ms
|
||||||
|
[DEBUG_LOG] [BENCH] splat-calls x120000 [ARG_BUILDER=ON]: 637.576161 ms
|
||||||
|
|
||||||
|
ConcurrencyCallBenchmarkTest[jvm] > benchmark_multithread_calls_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] ConcurrencyCallBenchmark workers=8 iters=15000 each: OFF=262.726 ms, ON=255.278 ms, speedup=1.03x
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkExpressionChains[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=OFF]: 362.438514 ms
|
||||||
|
[DEBUG_LOG] [BENCH] expr-chain x350000 [RVAL_FASTPATH=ON]: 340.324569 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkListIndexReads[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=OFF]: 195.843032 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-index x350000 [RVAL_FASTPATH=ON]: 186.899727 ms
|
||||||
|
|
||||||
|
ExpressionBenchmarkTest[jvm] > benchmarkFieldReadPureReceiver[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=OFF]: 184.415897 ms
|
||||||
|
[DEBUG_LOG] [BENCH] field-read x300000 [RVAL_FASTPATH=ON]: 167.959195 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkSumInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=OFF]: 162.448057 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-sum x200000 [PRIMITIVE_FASTOPS=ON]: 159.74125 ms
|
||||||
|
|
||||||
|
ListOpsBenchmarkTest[jvm] > benchmarkContainsInts[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=OFF]: 481.042413 ms
|
||||||
|
[DEBUG_LOG] [BENCH] list-contains x1000000 [PRIMITIVE_FASTOPS=ON]: 455.885378 ms
|
||||||
|
|
||||||
|
LocalVarBenchmarkTest[jvm] > benchmarkLocalReadsWrites_off_on[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=OFF, FAST_LOCAL=OFF]: 409.51578 ms
|
||||||
|
[DEBUG_LOG] [BENCH] locals x400000 [PIC=ON, FAST_LOCAL=ON]: 372.056401 ms
|
||||||
|
|
||||||
|
MethodPoolingBenchmarkTest[jvm] > benchmarkInstanceMethodCallsWithPooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=OFF]: 388.436636 ms
|
||||||
|
[DEBUG_LOG] [BENCH] method-loop x300000 [SCOPE_POOL=ON]: 361.562638 ms
|
||||||
|
|
||||||
|
MixedBenchmarkTest[jvm] > benchmarkMixedWorkloadRvalFastpath[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=OFF]: 631.060283 ms
|
||||||
|
[DEBUG_LOG] [BENCH] mixed x250000 [RVAL_FASTPATH=ON]: 596.452285 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkMethodPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=OFF, POOL=OFF: 325.619575 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Method PIC=ON, POOL=ON: 323.664554 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkFieldGetSetPic[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=OFF: 130.20855 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Field PIC=ON: 125.922059 ms
|
||||||
|
|
||||||
|
PicBenchmarkTest[jvm] > benchmarkLoopScopePooling[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=OFF: 265.902703 ms
|
||||||
|
[DEBUG_LOG] [BENCH] Loop Pool=ON: 264.289188 ms
|
||||||
|
|
||||||
|
RangeBenchmarkTest[jvm] > benchmarkIntRangeForIn[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=OFF]: 1218.053408 ms
|
||||||
|
[DEBUG_LOG] [BENCH] range-for-in x5000 (inner 0..999) [PRIMITIVE_FASTOPS=ON]: 1156.935646 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkDynamicPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=OFF]: 433.071618 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-dynamic x300000 [REGEX_CACHE=ON]: 371.30824 ms
|
||||||
|
|
||||||
|
RegexBenchmarkTest[jvm] > benchmarkLiteralPatternMatches[jvm] STANDARD_OUT
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=OFF]: 570.399724 ms
|
||||||
|
[DEBUG_LOG] [BENCH] regex-literal x500000 [REGEX_CACHE=ON]: 533.532049 ms
|
||||||
|
|
||||||
|
BUILD SUCCESSFUL in 33s
|
||||||
|
10 actionable tasks: 10 executed
|
||||||
|
Configuration cache entry reused.
|
||||||
@@ -0,0 +1,246 @@
|
|||||||
|
diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt
|
||||||
|
index 0671102..d4cb6ba 100644
|
||||||
|
--- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt
|
||||||
|
+++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjInt.kt
|
||||||
|
@@ -55,7 +55,11 @@ class ObjInt(val value: Long, override val isConst: Boolean = false) : Obj(), Nu
|
||||||
|
|
||||||
|
override suspend fun compareTo(scope: Scope, other: Obj): Int {
|
||||||
|
if (other !is Numeric) return -2
|
||||||
|
- return value.compareTo(other.doubleValue)
|
||||||
|
+ return if (other is ObjInt) {
|
||||||
|
+ value.compareTo(other.value)
|
||||||
|
+ } else {
|
||||||
|
+ doubleValue.compareTo(other.doubleValue)
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = value.toString()
|
||||||
|
@@ -192,4 +196,4 @@ class ObjInt(val value: Long, override val isConst: Boolean = false) : Obj(), Nu
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Int.toObj() = ObjInt.of(this.toLong())
|
||||||
|
-fun Long.toObj() = ObjInt.of(this)
|
||||||
|
\ No newline at end of file
|
||||||
|
+fun Long.toObj() = ObjInt.of(this)
|
||||||
|
diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRange.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRange.kt
|
||||||
|
index 0c631d0..dc61c66 100644
|
||||||
|
--- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRange.kt
|
||||||
|
+++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRange.kt
|
||||||
|
@@ -96,6 +96,30 @@ class ObjRange(val start: Obj?, val end: Obj?, val isEndInclusive: Boolean) : Ob
|
||||||
|
if (other is ObjRange)
|
||||||
|
return containsRange(scope, other)
|
||||||
|
|
||||||
|
+ if (net.sergeych.lyng.PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
+ if (start is ObjInt && end is ObjInt && other is ObjInt) {
|
||||||
|
+ val s = start.value
|
||||||
|
+ val e = end.value
|
||||||
|
+ val v = other.value
|
||||||
|
+ if (v < s) return false
|
||||||
|
+ return if (isEndInclusive) v <= e else v < e
|
||||||
|
+ }
|
||||||
|
+ if (start is ObjChar && end is ObjChar && other is ObjChar) {
|
||||||
|
+ val s = start.value
|
||||||
|
+ val e = end.value
|
||||||
|
+ val v = other.value
|
||||||
|
+ if (v < s) return false
|
||||||
|
+ return if (isEndInclusive) v <= e else v < e
|
||||||
|
+ }
|
||||||
|
+ if (start is ObjString && end is ObjString && other is ObjString) {
|
||||||
|
+ val s = start.value
|
||||||
|
+ val e = end.value
|
||||||
|
+ val v = other.value
|
||||||
|
+ if (v < s) return false
|
||||||
|
+ return if (isEndInclusive) v <= e else v < e
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (start == null && end == null) return true
|
||||||
|
if (start != null) {
|
||||||
|
if (start.compareTo(scope, other) > 0) return false
|
||||||
|
@@ -241,4 +265,3 @@ class ObjRange(val start: Obj?, val end: Obj?, val isEndInclusive: Boolean) : Ob
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-
|
||||||
|
diff --git a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt
|
||||||
|
index 2dd0ae6..76e56d4 100644
|
||||||
|
--- a/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt
|
||||||
|
+++ b/lynglib/src/commonMain/kotlin/net/sergeych/lyng/obj/ObjRef.kt
|
||||||
|
@@ -152,6 +152,90 @@ class BinaryOpRef(private val op: BinOp, private val left: ObjRef, private val r
|
||||||
|
|
||||||
|
// Primitive fast paths for common cases (guarded by PerfFlags.PRIMITIVE_FASTOPS)
|
||||||
|
if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
+ // Fast range equality: avoid compareTo/equals for ObjRange when possible
|
||||||
|
+ if ((op == BinOp.EQ || op == BinOp.NEQ) && a is ObjRange && b is ObjRange) {
|
||||||
|
+ val eq = (a.start == b.start && a.end == b.end)
|
||||||
|
+ if (PerfFlags.PIC_DEBUG_COUNTERS) PerfStats.primitiveFastOpsHit++
|
||||||
|
+ return if (op == BinOp.EQ) {
|
||||||
|
+ if (eq) ObjTrue else ObjFalse
|
||||||
|
+ } else {
|
||||||
|
+ if (eq) ObjFalse else ObjTrue
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ // Fast membership for common containers
|
||||||
|
+ if (op == BinOp.IN || op == BinOp.NOTIN) {
|
||||||
|
+ val inResult: Boolean? = when (b) {
|
||||||
|
+ is ObjList -> {
|
||||||
|
+ if (a is ObjInt) {
|
||||||
|
+ var i = 0
|
||||||
|
+ val sz = b.list.size
|
||||||
|
+ var found = false
|
||||||
|
+ while (i < sz) {
|
||||||
|
+ val v = b.list[i]
|
||||||
|
+ if (v is ObjInt && v.value == a.value) {
|
||||||
|
+ found = true
|
||||||
|
+ break
|
||||||
|
+ }
|
||||||
|
+ i++
|
||||||
|
+ }
|
||||||
|
+ found
|
||||||
|
+ } else {
|
||||||
|
+ b.list.contains(a)
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ is ObjSet -> b.set.contains(a)
|
||||||
|
+ is ObjMap -> b.map.containsKey(a)
|
||||||
|
+ is ObjRange -> {
|
||||||
|
+ when (a) {
|
||||||
|
+ is ObjInt -> {
|
||||||
|
+ val s = b.start as? ObjInt
|
||||||
|
+ val e = b.end as? ObjInt
|
||||||
|
+ val v = a.value
|
||||||
|
+ if (s == null && e == null) null
|
||||||
|
+ else {
|
||||||
|
+ if (s != null && v < s.value) false
|
||||||
|
+ else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ is ObjChar -> {
|
||||||
|
+ val s = b.start as? ObjChar
|
||||||
|
+ val e = b.end as? ObjChar
|
||||||
|
+ val v = a.value
|
||||||
|
+ if (s == null && e == null) null
|
||||||
|
+ else {
|
||||||
|
+ if (s != null && v < s.value) false
|
||||||
|
+ else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ is ObjString -> {
|
||||||
|
+ val s = b.start as? ObjString
|
||||||
|
+ val e = b.end as? ObjString
|
||||||
|
+ val v = a.value
|
||||||
|
+ if (s == null && e == null) null
|
||||||
|
+ else {
|
||||||
|
+ if (s != null && v < s.value) false
|
||||||
|
+ else if (e != null) if (b.isEndInclusive) v <= e.value else v < e.value else true
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ is ObjString -> when (a) {
|
||||||
|
+ is ObjString -> b.value.contains(a.value)
|
||||||
|
+ is ObjChar -> b.value.contains(a.value)
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ if (inResult != null) {
|
||||||
|
+ if (PerfFlags.PIC_DEBUG_COUNTERS) PerfStats.primitiveFastOpsHit++
|
||||||
|
+ return if (op == BinOp.IN) {
|
||||||
|
+ if (inResult) ObjTrue else ObjFalse
|
||||||
|
+ } else {
|
||||||
|
+ if (inResult) ObjFalse else ObjTrue
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
// Fast boolean ops when both operands are ObjBool
|
||||||
|
if (a is ObjBool && b is ObjBool) {
|
||||||
|
val r: Obj? = when (op) {
|
||||||
|
@@ -604,7 +688,37 @@ class AssignOpRef(
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (inPlace != null) return inPlace.asReadonly
|
||||||
|
- val result: Obj = when (op) {
|
||||||
|
+ val fast: Obj? = if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
+ when {
|
||||||
|
+ x is ObjInt && y is ObjInt -> {
|
||||||
|
+ val xv = x.value
|
||||||
|
+ val yv = y.value
|
||||||
|
+ when (op) {
|
||||||
|
+ BinOp.PLUS -> ObjInt.of(xv + yv)
|
||||||
|
+ BinOp.MINUS -> ObjInt.of(xv - yv)
|
||||||
|
+ BinOp.STAR -> ObjInt.of(xv * yv)
|
||||||
|
+ BinOp.SLASH -> if (yv != 0L) ObjInt.of(xv / yv) else null
|
||||||
|
+ BinOp.PERCENT -> if (yv != 0L) ObjInt.of(xv % yv) else null
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ (x is ObjInt || x is ObjReal) && (y is ObjInt || y is ObjReal) -> {
|
||||||
|
+ val xv = if (x is ObjInt) x.doubleValue else (x as ObjReal).value
|
||||||
|
+ val yv = if (y is ObjInt) y.doubleValue else (y as ObjReal).value
|
||||||
|
+ when (op) {
|
||||||
|
+ BinOp.PLUS -> ObjReal.of(xv + yv)
|
||||||
|
+ BinOp.MINUS -> ObjReal.of(xv - yv)
|
||||||
|
+ BinOp.STAR -> ObjReal.of(xv * yv)
|
||||||
|
+ BinOp.SLASH -> ObjReal.of(xv / yv)
|
||||||
|
+ BinOp.PERCENT -> ObjReal.of(xv % yv)
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ x is ObjString && op == BinOp.PLUS -> ObjString(x.value + y.toString())
|
||||||
|
+ else -> null
|
||||||
|
+ }
|
||||||
|
+ } else null
|
||||||
|
+ val result: Obj = fast ?: when (op) {
|
||||||
|
BinOp.PLUS -> x.plus(scope, y)
|
||||||
|
BinOp.MINUS -> x.minus(scope, y)
|
||||||
|
BinOp.STAR -> x.mul(scope, y)
|
||||||
|
@@ -632,7 +746,15 @@ class IncDecRef(
|
||||||
|
// We now treat numbers as immutable and always perform write-back via setAt.
|
||||||
|
// This avoids issues where literals are shared and mutated in-place.
|
||||||
|
// For post-inc: return ORIGINAL value; for pre-inc: return NEW value.
|
||||||
|
- val result = if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
||||||
|
+ val result = if (PerfFlags.PRIMITIVE_FASTOPS) {
|
||||||
|
+ when (v) {
|
||||||
|
+ is ObjInt -> if (isIncrement) ObjInt.of(v.value + 1L) else ObjInt.of(v.value - 1L)
|
||||||
|
+ is ObjReal -> if (isIncrement) ObjReal.of(v.value + 1.0) else ObjReal.of(v.value - 1.0)
|
||||||
|
+ else -> if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ if (isIncrement) v.plus(scope, one) else v.minus(scope, one)
|
||||||
|
+ }
|
||||||
|
target.setAt(atPos, scope, result)
|
||||||
|
return (if (isPost) v else result).asReadonly
|
||||||
|
}
|
||||||
|
@@ -1246,8 +1368,8 @@ class IndexRef(
|
||||||
|
val i = idx.toInt()
|
||||||
|
return ObjChar(base.value[i]).asMutable
|
||||||
|
}
|
||||||
|
- // Map[String] fast path (common case); return ObjNull if absent
|
||||||
|
- if (base is ObjMap && idx is ObjString) {
|
||||||
|
+ // Map[String/Int/Char] fast path (common cases); return ObjNull if absent
|
||||||
|
+ if (base is ObjMap && (idx is ObjString || idx is ObjInt || idx is ObjChar)) {
|
||||||
|
val v = base.map[idx] ?: ObjNull
|
||||||
|
return v.asMutable
|
||||||
|
}
|
||||||
|
@@ -1321,8 +1443,8 @@ class IndexRef(
|
||||||
|
val i = idx.toInt()
|
||||||
|
return ObjChar(base.value[i])
|
||||||
|
}
|
||||||
|
- // Map[String] fast path
|
||||||
|
- if (base is ObjMap && idx is ObjString) {
|
||||||
|
+ // Map[String/Int/Char] fast path
|
||||||
|
+ if (base is ObjMap && (idx is ObjString || idx is ObjInt || idx is ObjChar)) {
|
||||||
|
return base.map[idx] ?: ObjNull
|
||||||
|
}
|
||||||
|
if (PerfFlags.INDEX_PIC) {
|
||||||
|
@@ -1393,7 +1515,7 @@ class IndexRef(
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// Direct write fast path for ObjMap + ObjString
|
||||||
|
- if (base is ObjMap && idx is ObjString) {
|
||||||
|
+ if (base is ObjMap && (idx is ObjString || idx is ObjInt || idx is ObjChar)) {
|
||||||
|
base.map[idx] = newValue
|
||||||
|
return
|
||||||
|
}
|
||||||
Reference in new issue
Block a user