diff --git a/compiler/vm/packed_env.nim b/compiler/vm/packed_env.nim index a513d73d3b4..e831f863928 100644 --- a/compiler/vm/packed_env.nim +++ b/compiler/vm/packed_env.nim @@ -806,7 +806,6 @@ proc loadEnv*(dst: var TCtx, src: PackedEnv) = of cnstSliceListInt: co.intSlices = loadSliceList[BiggestInt](src, id) of cnstSliceListFloat: co.floatSlices = loadSliceList[BiggestFloat](src, id) - of cnstSliceListStr: co.strSlices = loadSliceList[ConstantId](src, id) of cnstNode: unreachable() co @@ -871,7 +870,6 @@ func storeEnv*(enc: var PackedEncoder, dst: var PackedEnv, c: TCtx) = of cnstSliceListInt: dst.storeSliceList(c.intSlices) of cnstSliceListFloat: dst.storeSliceList(c.floatSlices) - of cnstSliceListStr: dst.storeSliceList(c.strSlices) of cnstNode: # node constants are not created in a non-compiletime context unreachable() diff --git a/compiler/vm/vm.nim b/compiler/vm/vm.nim index 20133654c74..85fac57ef3c 100644 --- a/compiler/vm/vm.nim +++ b/compiler/vm/vm.nim @@ -2013,39 +2013,12 @@ proc rawExecute(c: var TCtx, t: var VmThread, pc: var int): YieldReason = for s in list.items: if v in s: return true - func cmp(a: string, b: VmString): int = - let minLen = min(a.len, b.len) - if minLen > 0: - result = cmpMem(unsafeAddr a[0], b.data.rawPointer, minLen) - if result == 0: - result = a.len - b.len - var cond = false case value.kind of cnstInt: cond = regs[ra].intVal == value.intVal - of cnstString: cond = regs[ra].strVal == value.strVal of cnstFloat: cond = regs[ra].floatVal == value.floatVal of cnstSliceListInt: cond = regs[ra].intVal in value.intSlices of cnstSliceListFloat: cond = regs[ra].floatVal in value.floatSlices - of cnstSliceListStr: - # string slice-lists don't store the strings directly, but the ID of - # a constant instead - let str = regs[ra].strVal - for s in value.strSlices.items: - let a = c.constants[s.a].strVal - let r = cmp(a, str) - if s.a == s.b: - # no need to compare the string with both slice elements if - # they're the same - if r == 0: - cond = true - break - else: - let b = c.constants[s.b].strVal - if r <= 0 and cmp(b, str) >= 0: - cond = true - break - else: unreachable(value.kind) @@ -2200,7 +2173,7 @@ proc rawExecute(c: var TCtx, t: var VmThread, pc: var int): YieldReason = # cases where non-NimNode PNodes need to be stored in registers # seems unnecessary however. regs[ra] = TFullReg(kind: rkNimNode, nimNode: cnst.node) - of cnstSliceListInt..cnstSliceListStr: + of cnstSliceListInt..cnstSliceListFloat: # A slice-list must not be used with `LdConst` assert false @@ -2212,7 +2185,7 @@ proc rawExecute(c: var TCtx, t: var VmThread, pc: var int): YieldReason = of cnstString: # load the string literal directly into the destination deref(regs[ra].handle).strVal.newVmString(cnst.strVal, c.allocator) - of cnstInt, cnstFloat, cnstNode, cnstSliceListInt..cnstSliceListStr: + of cnstInt, cnstFloat, cnstNode, cnstSliceListInt..cnstSliceListFloat: raiseVmError(VmEvent(kind: vmEvtErrInternal, msg: "illegal constant")) of opcLdGlobal: let rb = instr.regBx - wordExcess diff --git a/compiler/vm/vmdef.nim b/compiler/vm/vmdef.nim index bf7c4114fc2..24332fbf6ec 100644 --- a/compiler/vm/vmdef.nim +++ b/compiler/vm/vmdef.nim @@ -342,7 +342,6 @@ type # slice-lists are used for implementing `opcBranch` (branch for case stmt) cnstSliceListInt cnstSliceListFloat - cnstSliceListStr ConstantId* = int ## The ID of a `VmConstant`. Currently just an index into ## `TCtx.constants` @@ -368,9 +367,6 @@ type intSlices*: seq[Slice[BiggestInt]] of cnstSliceListFloat: floatSlices*: seq[Slice[BiggestFloat]] - of cnstSliceListStr: - strSlices*: seq[Slice[ConstantId]] ## Stores the ids of string constants - ## as a storage optimization VmArgs* = object ra*, rb*, rc*: Natural diff --git a/compiler/vm/vmgen.nim b/compiler/vm/vmgen.nim index 9166e471b23..ee007ff6509 100644 --- a/compiler/vm/vmgen.nim +++ b/compiler/vm/vmgen.nim @@ -757,11 +757,6 @@ proc genBranchLit(c: var TCtx, n: CgNode, t: PType): int = cnst.floatSlices.fillSliceList(values): it.floatVal - of tyString: - cnst = VmConstant(kind: cnstSliceListStr) - cnst.strSlices.fillSliceList(values): - c.toStringCnst(it.strVal) - else: unreachable(t.kind) @@ -801,16 +796,44 @@ proc genCase(c: var TCtx; n: CgNode) = var endings: seq[TPosition] = @[] withDest(tmp): c.gen(n[0], tmp) - # branch tmp, codeIdx - # fjmp elseLabel # iterate of/else branches for i in 1..