Skip to content

Commit

Permalink
Merge branch 'nim-lang:devel' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
maleyva1 authored Jun 30, 2024
2 parents 887f4cc + c88894b commit bd69bca
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
11 changes: 8 additions & 3 deletions compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) =
of tyString:
if optSeqDestructors in p.config.globalOptions:
genGenericAsgn(p, dest, src, flags)
elif (needToCopy notin flags and src.storage != OnStatic) or canMove(p, src.lode, dest):
elif ({needToCopy, needToCopySinkParam} * flags == {} and src.storage != OnStatic) or canMove(p, src.lode, dest):
genRefAssign(p, dest, src)
else:
if (dest.storage == OnStack and p.config.selectedGC != gcGo) or not usesWriteBarrier(p.config):
Expand Down Expand Up @@ -2345,8 +2345,13 @@ proc genMove(p: BProc; n: PNode; d: var TLoc) =
else:
linefmt(p, cpsStmts, "$1($2);$n", [rdLoc(b), byRefLoc(p, a)])
else:
let flags = if not canMove(p, n[1], d): {needToCopy} else: {}
genAssignment(p, d, a, flags)
if n[1].kind == nkSym and isSinkParam(n[1].sym):
var tmp = getTemp(p, n[1].typ.skipTypes({tySink}))
genAssignment(p, tmp, a, {needToCopySinkParam})
genAssignment(p, d, tmp, {})
resetLoc(p, tmp)
else:
genAssignment(p, d, a, {})
resetLoc(p, a)

proc genDestroy(p: BProc; n: PNode) =
Expand Down
1 change: 1 addition & 0 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ proc rdCharLoc(a: TLoc): Rope =
type
TAssignmentFlag = enum
needToCopy
needToCopySinkParam
needTempForOpenArray
TAssignmentFlags = set[TAssignmentFlag]

Expand Down
1 change: 1 addition & 0 deletions doc/mm.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ where code size matters and you know that your code does not produce cycles, you
use `--mm:arc`. Notice that the default `async`:idx: implementation produces cycles
and leaks memory with `--mm:arc`, in other words, for `async` you need to use `--mm:orc`.

Only ARC/ORC support move semantics, destructors, `sink`, `cursor`, `acyclic`.


Other MM modes
Expand Down
2 changes: 1 addition & 1 deletion koch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

const
# examples of possible values for repos: Head, ea82b54
NimbleStableCommit = "f8bd7b5fa6ea7a583b411b5959b06e6b5eb23667" # master
NimbleStableCommit = "be2f1309b35a6189ff5eb34a007793e6d3f94157" # master
AtlasStableCommit = "5faec3e9a33afe99a7d22377dd1b45a5391f5504"
ChecksumsStableCommit = "025bcca3915a1b9f19878cea12ad68f9884648fc"
SatStableCommit = "faf1617f44d7632ee9601ebc13887644925dcc01"
Expand Down
9 changes: 9 additions & 0 deletions tests/refc/tsinkbug.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ var obj = AnObject(value: 42)
echo "Value is: ", obj.value
mutate(obj)
echo "Value is: ", obj.value

proc p(x: sink string) =
var y = move(x)
doAssert x.len == 0
doAssert y.len == 4

p("1234")
var s = "oooo"
p(s)
12 changes: 6 additions & 6 deletions tests/stdlib/thttpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ proc asyncTest() {.async.} =
doAssert("<title>Example Domain</title>" in body)

resp = await client.request("http://example.com/404")
doAssert(resp.code.is4xx)
doAssert(resp.code == Http404)
doAssert(resp.status == $Http404)
doAssert(resp.code.is4xx or resp.code.is5xx)
doAssert(resp.code == Http404 or resp.code == Http500)
doAssert(resp.status == $Http404 or resp.status == $Http500)

when false: # occasionally does not give success code
resp = await client.request("https://google.com/")
Expand Down Expand Up @@ -115,9 +115,9 @@ proc syncTest() =
doAssert("<title>Example Domain</title>" in resp.body)

resp = client.request("http://example.com/404")
doAssert(resp.code.is4xx)
doAssert(resp.code == Http404)
doAssert(resp.status == $Http404)
doAssert(resp.code.is4xx or resp.code.is5xx)
doAssert(resp.code == Http404 or resp.code == Http500)
doAssert(resp.status == $Http404 or resp.status == $Http500)

when false: # occasionally does not give success code
resp = client.request("https://google.com/")
Expand Down

0 comments on commit bd69bca

Please sign in to comment.