diff options
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/cgen.nim | 4 | ||||
-rwxr-xr-x | compiler/crc.nim | 11 | ||||
-rwxr-xr-x | compiler/nimrod.nim | 6 | ||||
-rwxr-xr-x | compiler/treetab.nim | 47 |
4 files changed, 26 insertions, 42 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index d76793c9a..619caf250 100755 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -677,8 +677,8 @@ proc genProcAux(m: BModule, prc: PSym) = if optStackTrace in prc.options: app(generatedProc, deinitFrame(p)) if (optProfiler in prc.options) and (gCmd != cmdCompileToLLVM): appf(generatedProc, - "profileData[$1].total += elapsed(getticks(), NIM_profilingStart);$n", - [toRope(prc.loc.a)]) + "profileData[$1].total += elapsed(getticks(), NIM_profilingStart);$n", + [toRope(prc.loc.a)]) app(generatedProc, returnStmt) app(generatedProc, '}' & tnl) app(m.s[cfsProcs], generatedProc) diff --git a/compiler/crc.nim b/compiler/crc.nim index be1aee16b..b1801d9dc 100755 --- a/compiler/crc.nim +++ b/compiler/crc.nim @@ -100,19 +100,16 @@ proc crcFromBuf(buf: Pointer, length: int): TCrc32 = proc crcFromFile(filename: string): TCrc32 = const - bufSize = 8 * 1024 + bufSize = 8000 # don't use 8K for the memory allocator! var bin: tfile - buf: Pointer - readBytes: int - p: PByteArray result = InitCrc32 if not open(bin, filename): return # not equal if file does not exist - buf = alloc(BufSize) - p = cast[PByteArray](buf) + var buf = alloc(BufSize) + var p = cast[PByteArray](buf) while true: - readBytes = readBuffer(bin, buf, bufSize) + var readBytes = readBuffer(bin, buf, bufSize) for i in countup(0, readBytes - 1): result = updateCrc32(p[i], result) if readBytes != bufSize: break dealloc(buf) diff --git a/compiler/nimrod.nim b/compiler/nimrod.nim index 05c7a2af1..d9580d955 100755 --- a/compiler/nimrod.nim +++ b/compiler/nimrod.nim @@ -50,7 +50,7 @@ proc ProcessCmdLine(pass: TCmdLinePass, command, filename: var string) = rawMessage(errArgsNeedRunOption, []) proc HandleCmdLine() = - var start = getTime() + var start = epochTime() if paramCount() == 0: writeCommandLineUsage() else: @@ -73,7 +73,8 @@ proc HandleCmdLine() = if gCmd == cmdRun: tccgen.run() if gCmd notin {cmdInterpret, cmdRun}: - rawMessage(hintSuccessX, [$gLinesCompiled, $(getTime() - start)]) + rawMessage(hintSuccessX, [$gLinesCompiled, + formatFloat(epochTime() - start, ffDecimal, 3)]) if optRun in gGlobalOptions: when defined(unix): var prog = "./" & quoteIfContainsWhite(changeFileExt(filename, "")) @@ -81,6 +82,7 @@ proc HandleCmdLine() = var prog = quoteIfContainsWhite(changeFileExt(filename, "")) execExternalProgram(prog & ' ' & arguments) +#GC_disableMarkAndSweep() cmdLineInfo = newLineInfo("command line", -1, -1) condsyms.InitDefines() HandleCmdLine() diff --git a/compiler/treetab.nim b/compiler/treetab.nim index 797ef5029..92a329ecc 100755 --- a/compiler/treetab.nim +++ b/compiler/treetab.nim @@ -1,7 +1,7 @@ # # # The Nimrod Compiler -# (c) Copyright 2008 Andreas Rumpf +# (c) Copyright 2011 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. @@ -12,13 +12,7 @@ import nhashes, ast, astalgo, types -proc NodeTableGet*(t: TNodeTable, key: PNode): int -proc NodeTablePut*(t: var TNodeTable, key: PNode, val: int) -proc NodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int -# implementation - proc hashTree(n: PNode): THash = - result = 0 if n == nil: return result = ord(n.kind) case n.kind @@ -41,7 +35,6 @@ proc hashTree(n: PNode): THash = result = concHash(result, hashTree(n.sons[i])) proc TreesEquivalent(a, b: PNode): bool = - result = false if a == b: result = true elif (a != nil) and (b != nil) and (a.kind == b.kind): @@ -60,36 +53,31 @@ proc TreesEquivalent(a, b: PNode): bool = if result: result = sameTypeOrNil(a.typ, b.typ) proc NodeTableRawGet(t: TNodeTable, k: THash, key: PNode): int = - var h: THash - h = k and high(t.data) + var h: THash = k and high(t.data) while t.data[h].key != nil: if (t.data[h].h == k) and TreesEquivalent(t.data[h].key, key): return h h = nextTry(h, high(t.data)) - result = - 1 + result = -1 -proc NodeTableGet(t: TNodeTable, key: PNode): int = - var index: int - index = NodeTableRawGet(t, hashTree(key), key) +proc NodeTableGet*(t: TNodeTable, key: PNode): int = + var index = NodeTableRawGet(t, hashTree(key), key) if index >= 0: result = t.data[index].val else: result = low(int) -proc NodeTableRawInsert(data: var TNodePairSeq, k: THash, key: PNode, val: int) = - var h: THash - h = k and high(data) +proc NodeTableRawInsert(data: var TNodePairSeq, k: THash, key: PNode, + val: int) = + var h: THash = k and high(data) while data[h].key != nil: h = nextTry(h, high(data)) assert(data[h].key == nil) data[h].h = k data[h].key = key data[h].val = val -proc NodeTablePut(t: var TNodeTable, key: PNode, val: int) = - var - index: int - n: TNodePairSeq - k: THash - k = hashTree(key) - index = NodeTableRawGet(t, k, key) +proc NodeTablePut*(t: var TNodeTable, key: PNode, val: int) = + var n: TNodePairSeq + var k: THash = hashTree(key) + var index = NodeTableRawGet(t, k, key) if index >= 0: assert(t.data[index].key != nil) t.data[index].val = val @@ -103,13 +91,10 @@ proc NodeTablePut(t: var TNodeTable, key: PNode, val: int) = NodeTableRawInsert(t.data, k, key, val) inc(t.counter) -proc NodeTableTestOrSet(t: var TNodeTable, key: PNode, val: int): int = - var - index: int - n: TNodePairSeq - k: THash - k = hashTree(key) - index = NodeTableRawGet(t, k, key) +proc NodeTableTestOrSet*(t: var TNodeTable, key: PNode, val: int): int = + var n: TNodePairSeq + var k: THash = hashTree(key) + var index = NodeTableRawGet(t, k, key) if index >= 0: assert(t.data[index].key != nil) result = t.data[index].val |