mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
the codegen doesn't emit deepCopy for parallel statements
This commit is contained in:
@@ -204,7 +204,7 @@ proc flowVarKind(t: PType): TFlowVarKind =
|
||||
else: fvBlob
|
||||
|
||||
proc addLocalVar(varSection, varInit: PNode; owner: PSym; typ: PType;
|
||||
v: PNode): PSym =
|
||||
v: PNode; useShallowCopy=false): PSym =
|
||||
result = newSym(skTemp, getIdent(genPrefix), owner, varSection.info)
|
||||
result.typ = typ
|
||||
incl(result.flags, sfFromGeneric)
|
||||
@@ -215,11 +215,14 @@ proc addLocalVar(varSection, varInit: PNode; owner: PSym; typ: PType;
|
||||
vpart.sons[2] = if varInit.isNil: v else: ast.emptyNode
|
||||
varSection.add vpart
|
||||
if varInit != nil:
|
||||
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
||||
deepCopyCall.sons[0] = newSymNode(createMagic("deepCopy", mDeepCopy))
|
||||
deepCopyCall.sons[1] = newSymNode(result)
|
||||
deepCopyCall.sons[2] = v
|
||||
varInit.add deepCopyCall
|
||||
if useShallowCopy:
|
||||
varInit.add newFastAsgnStmt(newSymNode(result), v)
|
||||
else:
|
||||
let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
|
||||
deepCopyCall.sons[0] = newSymNode(createMagic("deepCopy", mDeepCopy))
|
||||
deepCopyCall.sons[1] = newSymNode(result)
|
||||
deepCopyCall.sons[2] = v
|
||||
varInit.add deepCopyCall
|
||||
|
||||
discard """
|
||||
We generate roughly this:
|
||||
@@ -420,7 +423,8 @@ proc setupArgsForParallelism(n: PNode; objType: PType; scratchObj: PSym;
|
||||
result.add newFastAsgnStmt(newDotExpr(scratchObj, fieldB), n[3])
|
||||
|
||||
let threadLocal = addLocalVar(varSection,nil, objType.owner, fieldA.typ,
|
||||
indirectAccess(castExpr, fieldA, n.info))
|
||||
indirectAccess(castExpr, fieldA, n.info),
|
||||
useShallowCopy=true)
|
||||
slice.sons[2] = threadLocal.newSymNode
|
||||
else:
|
||||
let a = genAddrOf(n)
|
||||
@@ -434,7 +438,8 @@ proc setupArgsForParallelism(n: PNode; objType: PType; scratchObj: PSym;
|
||||
slice.sons[1] = genDeref(indirectAccess(castExpr, field, n.info))
|
||||
|
||||
let threadLocal = addLocalVar(varSection,nil, objType.owner, fieldB.typ,
|
||||
indirectAccess(castExpr, fieldB, n.info))
|
||||
indirectAccess(castExpr, fieldB, n.info),
|
||||
useShallowCopy=true)
|
||||
slice.sons[3] = threadLocal.newSymNode
|
||||
call.add slice
|
||||
elif (let size = computeSize(argType); size < 0 or size > 16) and
|
||||
@@ -445,7 +450,8 @@ proc setupArgsForParallelism(n: PNode; objType: PType; scratchObj: PSym;
|
||||
objType.addField(field)
|
||||
result.add newFastAsgnStmt(newDotExpr(scratchObj, field), a)
|
||||
let threadLocal = addLocalVar(varSection,nil, objType.owner, field.typ,
|
||||
indirectAccess(castExpr, field, n.info))
|
||||
indirectAccess(castExpr, field, n.info),
|
||||
useShallowCopy=true)
|
||||
call.add(genDeref(threadLocal.newSymNode))
|
||||
else:
|
||||
# boring case
|
||||
@@ -454,7 +460,8 @@ proc setupArgsForParallelism(n: PNode; objType: PType; scratchObj: PSym;
|
||||
result.add newFastAsgnStmt(newDotExpr(scratchObj, field), n)
|
||||
let threadLocal = addLocalVar(varSection, varInit,
|
||||
objType.owner, field.typ,
|
||||
indirectAccess(castExpr, field, n.info))
|
||||
indirectAccess(castExpr, field, n.info),
|
||||
useShallowCopy=true)
|
||||
call.add(threadLocal.newSymNode)
|
||||
|
||||
proc wrapProcForSpawn*(owner: PSym; spawnExpr: PNode; retType: PType;
|
||||
|
||||
@@ -113,7 +113,7 @@ proc parseDirective(L: var TLexer, tok: var TToken) =
|
||||
case whichKeyword(tok.ident)
|
||||
of wIf:
|
||||
setLen(condStack, len(condStack) + 1)
|
||||
var res = evalppIf(L, tok)
|
||||
let res = evalppIf(L, tok)
|
||||
condStack[high(condStack)] = res
|
||||
if not res: jumpToDirective(L, tok, jdElseEndif)
|
||||
of wElif: doElif(L, tok)
|
||||
@@ -224,8 +224,10 @@ proc loadConfigs*(cfg: string) =
|
||||
if libpath == "":
|
||||
# choose default libpath:
|
||||
var prefix = getPrefixDir()
|
||||
if prefix == "/usr": libpath = "/usr/lib/nim"
|
||||
elif prefix == "/usr/local": libpath = "/usr/local/lib/nim"
|
||||
when defined(posix):
|
||||
if prefix == "/usr": libpath = "/usr/lib/nim"
|
||||
elif prefix == "/usr/local": libpath = "/usr/local/lib/nim"
|
||||
else: libpath = joinPath(prefix, "lib")
|
||||
else: libpath = joinPath(prefix, "lib")
|
||||
|
||||
if optSkipConfigFile notin gGlobalOptions:
|
||||
|
||||
@@ -30,9 +30,9 @@ To build from source you will need:
|
||||
If you are on a fairly modern *nix system, the following steps should work:
|
||||
|
||||
```
|
||||
$ git clone git://github.com/Araq/Nimrod.git
|
||||
$ cd Nimrod
|
||||
$ git clone --depth 1 git://github.com/nimrod-code/csources
|
||||
$ git clone git://github.com/Araq/Nim.git
|
||||
$ cd Nim
|
||||
$ git clone --depth 1 git://github.com/nim-code/csources
|
||||
$ cd csources && sh build.sh
|
||||
$ cd ..
|
||||
$ bin/nim c koch
|
||||
|
||||
@@ -5,6 +5,8 @@ true
|
||||
true
|
||||
true
|
||||
true'''
|
||||
|
||||
ccodeCheck: "!'deepcopy('"
|
||||
"""
|
||||
|
||||
# parallel convex hull for Nim bigbreak
|
||||
|
||||
@@ -27,9 +27,9 @@ proc main =
|
||||
var dummy: ref Bar[int]
|
||||
new(dummy)
|
||||
dummy.x = 44
|
||||
parallel:
|
||||
let f = spawn foo(dummy)
|
||||
let b = spawn foo(dummy)
|
||||
echo "done", f, " ", b
|
||||
#parallel:
|
||||
let f = spawn foo(dummy)
|
||||
let b = spawn foo(dummy)
|
||||
echo "done", ^f, " ", ^b
|
||||
|
||||
main()
|
||||
|
||||
5
todo.txt
5
todo.txt
@@ -1,9 +1,8 @@
|
||||
version 0.10
|
||||
============
|
||||
|
||||
- fix missing GC_ref bug for flow variables
|
||||
- fix deepCopy bug in parallel section
|
||||
- implement 'static_call'
|
||||
- find out why global installations end up using the wrong stdlib
|
||||
- implement 'procCall'
|
||||
- make nimble part of the distribution
|
||||
- split idetools into separate tool
|
||||
- split docgen into separate tool
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
Forum
|
||||
=====
|
||||
|
||||
The `Nimrod forum <http://forum.nimrod-code.org/>`_ is the place where most
|
||||
The `Nim forum <http://forum.nim-lang.org/>`_ is the place where most
|
||||
discussions related to the language happen. It not only includes discussions
|
||||
relating to the design of Nimrod but also allows for beginners to ask questions
|
||||
relating to Nimrod.
|
||||
relating to the design of Nim but also allows for beginners to ask questions
|
||||
relating to Nim.
|
||||
|
||||
IRC
|
||||
====
|
||||
|
||||
Many Nimrod developers are a part of the
|
||||
`#nimrod IRC channel <http://webchat.freenode.net/?channels=nimrod>`_ on
|
||||
Freenode. That is the place where the rest of the discussion relating to Nimrod
|
||||
occurs. Be sure to join us there if you wish to discuss Nimrod in real-time.
|
||||
IRC is the perfect place for people just starting to learn Nimrod and we
|
||||
Many Nim developers are a part of the
|
||||
`#nim IRC channel <http://webchat.freenode.net/?channels=nim>`_ on
|
||||
Freenode. That is the place where the rest of the discussion relating to Nim
|
||||
occurs. Be sure to join us there if you wish to discuss Nim in real-time.
|
||||
IRC is the perfect place for people just starting to learn Nim and we
|
||||
welcome any questions that you may have!
|
||||
|
||||
You may also be interested in reading the
|
||||
`IRC logs <http://build.nimrod-code.org/irclogs/>`_ which are an archive of all
|
||||
`IRC logs <http://build.nim-code.org/irclogs/>`_ which are an archive of all
|
||||
of the previous discussions that took place in the IRC channel.
|
||||
|
||||
Github
|
||||
======
|
||||
|
||||
Nimrod's `source code <http://github.com/Araq/Nimrod>`_ is hosted on Github.
|
||||
Together with the `wiki <http://github.com/Araq/Nimrod/wiki>`_ and
|
||||
`issue tracker <http://github.com/Araq/Nimrod/issues>`_.
|
||||
Nim's `source code <http://github.com/Araq/Nim>`_ is hosted on Github.
|
||||
Together with the `wiki <http://github.com/Araq/Nim/wiki>`_ and
|
||||
`issue tracker <http://github.com/Araq/Nim/issues>`_.
|
||||
|
||||
Github also hosts other projects relating to Nimrod. These projects are a part
|
||||
of the `nimrod-code organisation <http://github.com/nimrod-code>`_.
|
||||
This includes the `Babel package manager <http://github.com/nimrod-code/babel>`_
|
||||
and its `package repository <http://github.com/nimrod-code/packages>`_.
|
||||
Github also hosts other projects relating to Nim. These projects are a part
|
||||
of the `nim-code organisation <http://github.com/nim-code>`_.
|
||||
This includes the `Babel package manager <http://github.com/nim-code/babel>`_
|
||||
and its `package repository <http://github.com/nim-code/packages>`_.
|
||||
|
||||
Twitter
|
||||
=======
|
||||
|
||||
Follow us `@nimrodlang <http://twitter.com/nimrodlang>`_ for latest news about
|
||||
Nimrod.
|
||||
Follow us `@nimlang <http://twitter.com/nimlang>`_ for latest news about
|
||||
Nim.
|
||||
|
||||
Reddit
|
||||
======
|
||||
|
||||
Subscribe to `/r/nimrod <http://reddit.com/r/nimrod>`_ for latest news about
|
||||
Nimrod.
|
||||
Subscribe to `/r/nim <http://reddit.com/r/nim>`_ for latest news about
|
||||
Nim.
|
||||
|
||||
StackOverflow
|
||||
=============
|
||||
|
||||
When asking a question relating to Nimrod, be sure to use the
|
||||
`Nimrod <http://stackoverflow.com/questions/tagged/nimrod>`_ tag in your
|
||||
When asking a question relating to Nim, be sure to use the
|
||||
`Nim <http://stackoverflow.com/questions/tagged/nim>`_ tag in your
|
||||
question.
|
||||
|
||||
How to help
|
||||
===========
|
||||
|
||||
There are always many things to be done in the main
|
||||
`Nimrod repository <https://github.com/Araq/Nimrod>`_, check out the
|
||||
`issues <https://github.com/Araq/Nimrod/issues>`_ for
|
||||
`Nim repository <https://github.com/Araq/Nim>`_, check out the
|
||||
`issues <https://github.com/Araq/Nim/issues>`_ for
|
||||
things to do; pull requests are always welcome. You can
|
||||
also contribute to the many other projects hosted by the
|
||||
`nimrod-code <https://github.com/nimrod-code>`_ organisation on github. If you
|
||||
`nim-code <https://github.com/nim-code>`_ organisation on github. If you
|
||||
can't find anything you fancy doing, you can always ask for inspiration on IRC
|
||||
(irc.freenode.net #nimrod) or on the `Nimrod forums <http://forum.nimrod-code.org>`_.
|
||||
(irc.freenode.net #nim) or on the `Nim forums <http://forum.nim-code.org>`_.
|
||||
|
||||
Donations
|
||||
---------
|
||||
|
||||
If you love what we do and are feeling generous then you can always donate.
|
||||
Contributions of any quantity are greatly appreciated and will contribute to
|
||||
making Nimrod even better!
|
||||
making Nim even better!
|
||||
|
||||
Gittip
|
||||
``````
|
||||
|
||||
@@ -92,7 +92,7 @@ Nim plays nice with others
|
||||
the POSIX API, OpenGL, SDL, Cairo, Python, Lua, TCL, X11, libzip, PCRE,
|
||||
libcurl, mySQL and SQLite are included in the standard distribution or
|
||||
can easily be obtained via the
|
||||
`Babel package manager <https://github.com/nimrod-code/babel>`_.
|
||||
`Nimble package manager <https://github.com/nimrod-code/nimble>`_.
|
||||
* A C to Nim conversion utility: New bindings to C libraries are easily
|
||||
generated by ``c2nim``.
|
||||
|
||||
@@ -101,5 +101,5 @@ Roadmap to 1.0
|
||||
==============
|
||||
|
||||
Please have a look at
|
||||
this `wiki page <https://github.com/Araq/Nimrod/wiki/Roadmap>`_ for
|
||||
this `wiki page <https://github.com/Araq/Nim/wiki/Roadmap>`_ for
|
||||
an up-to-date overview.
|
||||
|
||||
@@ -9,6 +9,8 @@ News
|
||||
Changes affecting backwards compatibility
|
||||
-----------------------------------------
|
||||
|
||||
- **The language has been renamed from Nimrod to Nim.** The name of the
|
||||
compiler changed from ``nimrod`` to ``nim`` too.
|
||||
- ``system.fileHandle`` has been renamed to ``system.getFileHandle`` to
|
||||
prevent name conflicts with the new type ``FileHandle``.
|
||||
- Comments are now not part of the AST, as such you cannot use them in place
|
||||
|
||||
Reference in New Issue
Block a user