renamed noStackFrame to asmNoStackFrame
This commit is contained in:
parent
15953dfed9
commit
ab72377ce6
8 changed files with 57 additions and 57 deletions
|
|
@ -23,7 +23,7 @@ const
|
||||||
wMagic, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
|
wMagic, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
|
||||||
wCompilerproc, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
|
wCompilerproc, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
|
||||||
wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC,
|
wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC,
|
||||||
wNoStackFrame, wError, wDiscardable, wNoInit, wDestructor, wCodegenDecl,
|
wAsmNoStackFrame, wError, wDiscardable, wNoInit, wDestructor, wCodegenDecl,
|
||||||
wGensym, wInject, wRaises, wTags, wOperator, wDelegator}
|
wGensym, wInject, wRaises, wTags, wOperator, wDelegator}
|
||||||
converterPragmas* = procPragmas
|
converterPragmas* = procPragmas
|
||||||
methodPragmas* = procPragmas
|
methodPragmas* = procPragmas
|
||||||
|
|
@ -47,7 +47,7 @@ const
|
||||||
wInjectStmt}
|
wInjectStmt}
|
||||||
lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
|
||||||
wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
|
wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
|
||||||
wDeprecated, wExtern, wThread, wImportCpp, wImportObjC, wNoStackFrame,
|
wDeprecated, wExtern, wThread, wImportCpp, wImportObjC, wAsmNoStackFrame,
|
||||||
wRaises, wTags}
|
wRaises, wTags}
|
||||||
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
|
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
|
||||||
wPure, wHeader, wCompilerproc, wFinal, wSize, wExtern, wShallow,
|
wPure, wHeader, wCompilerproc, wFinal, wSize, wExtern, wShallow,
|
||||||
|
|
@ -548,9 +548,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
|
||||||
of wNodecl:
|
of wNodecl:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
incl(sym.loc.flags, lfNoDecl)
|
incl(sym.loc.flags, lfNoDecl)
|
||||||
of wPure, wNoStackFrame:
|
of wPure, wAsmNoStackFrame:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
if sym != nil: incl(sym.flags, sfPure)
|
if sym != nil:
|
||||||
|
if k == wPure and sym.kind in routineKinds: invalidPragma(it)
|
||||||
|
else: incl(sym.flags, sfPure)
|
||||||
of wVolatile:
|
of wVolatile:
|
||||||
noVal(it)
|
noVal(it)
|
||||||
incl(sym.flags, sfVolatile)
|
incl(sym.flags, sfVolatile)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ type
|
||||||
wWatchPoint, wSubsChar,
|
wWatchPoint, wSubsChar,
|
||||||
wAcyclic, wShallow, wUnroll, wLinearScanEnd, wComputedGoto, wInjectStmt,
|
wAcyclic, wShallow, wUnroll, wLinearScanEnd, wComputedGoto, wInjectStmt,
|
||||||
wWrite, wGensym, wInject, wDirty, wInheritable, wThreadVar, wEmit,
|
wWrite, wGensym, wInject, wDirty, wInheritable, wThreadVar, wEmit,
|
||||||
wNoStackFrame,
|
wAsmNoStackFrame,
|
||||||
wImplicitStatic, wGlobal, wCodegenDecl,
|
wImplicitStatic, wGlobal, wCodegenDecl,
|
||||||
|
|
||||||
wAuto, wBool, wCatch, wChar, wClass,
|
wAuto, wBool, wCatch, wChar, wClass,
|
||||||
|
|
@ -145,7 +145,7 @@ const
|
||||||
"subschar", "acyclic", "shallow", "unroll", "linearscanend",
|
"subschar", "acyclic", "shallow", "unroll", "linearscanend",
|
||||||
"computedgoto", "injectstmt",
|
"computedgoto", "injectstmt",
|
||||||
"write", "gensym", "inject", "dirty", "inheritable", "threadvar", "emit",
|
"write", "gensym", "inject", "dirty", "inheritable", "threadvar", "emit",
|
||||||
"nostackframe", "implicitstatic", "global", "codegendecl",
|
"asmnostackframe", "implicitstatic", "global", "codegendecl",
|
||||||
|
|
||||||
"auto", "bool", "catch", "char", "class",
|
"auto", "bool", "catch", "char", "class",
|
||||||
"const_cast", "default", "delete", "double",
|
"const_cast", "default", "delete", "double",
|
||||||
|
|
|
||||||
|
|
@ -4893,16 +4893,16 @@ field which is used for runtime type identification is omitted. This is
|
||||||
necessary for binary compatibility with other compiled languages.
|
necessary for binary compatibility with other compiled languages.
|
||||||
|
|
||||||
|
|
||||||
NoStackFrame pragma
|
AsmNoStackFrame pragma
|
||||||
-------------------
|
----------------------
|
||||||
A proc can be marked with the `noStackFrame`:idx: pragma to tell the compiler
|
A proc can be marked with the `AsmNoStackFrame`:idx: pragma to tell the compiler
|
||||||
it should not generate a stack frame for the proc. There are also no exit
|
it should not generate a stack frame for the proc. There are also no exit
|
||||||
statements like ``return result;`` generated and the generated C function is
|
statements like ``return result;`` generated and the generated C function is
|
||||||
declared as ``__declspec(naked)`` or ``__attribute__((naked))`` (depending on
|
declared as ``__declspec(naked)`` or ``__attribute__((naked))`` (depending on
|
||||||
the used C compiler).
|
the used C compiler).
|
||||||
|
|
||||||
**Note**: This pragma should only be used by procs which consist solely of assembler
|
**Note**: This pragma should only be used by procs which consist solely of
|
||||||
statements.
|
assembler statements.
|
||||||
|
|
||||||
error pragma
|
error pragma
|
||||||
------------
|
------------
|
||||||
|
|
|
||||||
|
|
@ -1514,7 +1514,7 @@ when not defined(NimrodVM):
|
||||||
proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
|
proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
|
||||||
result = cast[pointer](x)
|
result = cast[pointer](x)
|
||||||
else:
|
else:
|
||||||
proc seqToPtr[T](x: seq[T]): pointer {.noStackFrame, nosideeffect.} =
|
proc seqToPtr[T](x: seq[T]): pointer {.asmNoStackFrame, nosideeffect.} =
|
||||||
asm """return `x`"""
|
asm """return `x`"""
|
||||||
|
|
||||||
proc `==` *[T](x, y: seq[T]): bool {.noSideEffect.} =
|
proc `==` *[T](x, y: seq[T]): bool {.noSideEffect.} =
|
||||||
|
|
@ -1797,7 +1797,7 @@ type
|
||||||
len*: int ## length of the inspectable slots
|
len*: int ## length of the inspectable slots
|
||||||
|
|
||||||
when defined(JS):
|
when defined(JS):
|
||||||
proc add*(x: var string, y: cstring) {.noStackFrame.} =
|
proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var len = `x`[0].length-1;
|
var len = `x`[0].length-1;
|
||||||
for (var i = 0; i < `y`.length; ++i) {
|
for (var i = 0; i < `y`.length; ++i) {
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ const
|
||||||
when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
# assembler optimized versions for compilers that
|
# assembler optimized versions for compilers that
|
||||||
# have an intel syntax assembler:
|
# have an intel syntax assembler:
|
||||||
proc addInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
proc addInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
# a in eax, and b in edx
|
# a in eax, and b in edx
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
|
|
@ -121,7 +121,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
proc subInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
sub eax, `b`
|
sub eax, `b`
|
||||||
|
|
@ -130,7 +130,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc negInt(a: int): int {.compilerProc, noStackFrame.} =
|
proc negInt(a: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
neg eax
|
neg eax
|
||||||
|
|
@ -139,7 +139,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
proc divInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
@ -150,7 +150,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
theEnd:
|
theEnd:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
proc modInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
@ -162,7 +162,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt(a, b: int): int {.compilerProc, noStackFrame.} =
|
proc mulInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
mov eax, `a`
|
mov eax, `a`
|
||||||
mov ecx, `b`
|
mov ecx, `b`
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ type
|
||||||
PCallFrame = ptr TCallFrame
|
PCallFrame = ptr TCallFrame
|
||||||
TCallFrame {.importc, nodecl, final.} = object
|
TCallFrame {.importc, nodecl, final.} = object
|
||||||
prev: PCallFrame
|
prev: PCallFrame
|
||||||
procname: CString
|
procname: cstring
|
||||||
line: int # current line number
|
line: int # current line number
|
||||||
filename: CString
|
filename: cstring
|
||||||
|
|
||||||
var
|
var
|
||||||
framePtr {.importc, nodecl, volatile.}: PCallFrame
|
framePtr {.importc, nodecl, volatile.}: PCallFrame
|
||||||
|
|
@ -48,7 +48,7 @@ proc getCurrentExceptionMsg*(): string =
|
||||||
|
|
||||||
proc auxWriteStackTrace(f: PCallFrame): string =
|
proc auxWriteStackTrace(f: PCallFrame): string =
|
||||||
type
|
type
|
||||||
TTempFrame = tuple[procname: CString, line: int]
|
TTempFrame = tuple[procname: cstring, line: int]
|
||||||
var
|
var
|
||||||
it = f
|
it = f
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -84,7 +84,7 @@ proc rawWriteStackTrace(): string =
|
||||||
framePtr = nil
|
framePtr = nil
|
||||||
|
|
||||||
proc raiseException(e: ref E_Base, ename: cstring) {.
|
proc raiseException(e: ref E_Base, ename: cstring) {.
|
||||||
compilerproc, noStackFrame.} =
|
compilerproc, asmNoStackFrame.} =
|
||||||
e.name = ename
|
e.name = ename
|
||||||
if excHandler != nil:
|
if excHandler != nil:
|
||||||
excHandler.exc = e
|
excHandler.exc = e
|
||||||
|
|
@ -104,7 +104,7 @@ proc raiseException(e: ref E_Base, ename: cstring) {.
|
||||||
alert(buf)
|
alert(buf)
|
||||||
asm """throw `e`;"""
|
asm """throw `e`;"""
|
||||||
|
|
||||||
proc reraiseException() {.compilerproc, noStackFrame.} =
|
proc reraiseException() {.compilerproc, asmNoStackFrame.} =
|
||||||
if excHandler == nil:
|
if excHandler == nil:
|
||||||
raise newException(ENoExceptionToReraise, "no exception to reraise")
|
raise newException(ENoExceptionToReraise, "no exception to reraise")
|
||||||
else:
|
else:
|
||||||
|
|
@ -125,7 +125,7 @@ proc raiseIndexError() {.compilerproc, noreturn.} =
|
||||||
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
|
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
|
||||||
raise newException(EInvalidField, f & " is not accessible")
|
raise newException(EInvalidField, f & " is not accessible")
|
||||||
|
|
||||||
proc SetConstr() {.varargs, noStackFrame, compilerproc.} =
|
proc SetConstr() {.varargs, asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var i = 0; i < arguments.length; ++i) {
|
for (var i = 0; i < arguments.length; ++i) {
|
||||||
|
|
@ -141,7 +141,7 @@ proc SetConstr() {.varargs, noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc cstrToNimstr(c: cstring): string {.noStackFrame, compilerproc.} =
|
proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = [];
|
var result = [];
|
||||||
for (var i = 0; i < `c`.length; ++i) {
|
for (var i = 0; i < `c`.length; ++i) {
|
||||||
|
|
@ -151,7 +151,7 @@ proc cstrToNimstr(c: cstring): string {.noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc toJSStr(s: string): cstring {.noStackFrame, compilerproc.} =
|
proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var len = `s`.length-1;
|
var len = `s`.length-1;
|
||||||
var result = new Array(len);
|
var result = new Array(len);
|
||||||
|
|
@ -162,7 +162,7 @@ proc toJSStr(s: string): cstring {.noStackFrame, compilerproc.} =
|
||||||
return result.join("");
|
return result.join("");
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mnewString(len: int): string {.noStackFrame, compilerproc.} =
|
proc mnewString(len: int): string {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = new Array(`len`+1);
|
var result = new Array(`len`+1);
|
||||||
result[0] = 0;
|
result[0] = 0;
|
||||||
|
|
@ -170,7 +170,7 @@ proc mnewString(len: int): string {.noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetCard(a: int): int {.compilerproc, noStackFrame.} =
|
proc SetCard(a: int): int {.compilerproc, asmNoStackFrame.} =
|
||||||
# argument type is a fake
|
# argument type is a fake
|
||||||
asm """
|
asm """
|
||||||
var result = 0;
|
var result = 0;
|
||||||
|
|
@ -178,14 +178,14 @@ proc SetCard(a: int): int {.compilerproc, noStackFrame.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetEq(a, b: int): bool {.compilerproc, noStackFrame.} =
|
proc SetEq(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
||||||
for (var elem in `b`) { if (!`a`[elem]) return false; }
|
for (var elem in `b`) { if (!`a`[elem]) return false; }
|
||||||
return true;
|
return true;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetLe(a, b: int): bool {.compilerproc, noStackFrame.} =
|
proc SetLe(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
for (var elem in `a`) { if (!`b`[elem]) return false; }
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -194,7 +194,7 @@ proc SetLe(a, b: int): bool {.compilerproc, noStackFrame.} =
|
||||||
proc SetLt(a, b: int): bool {.compilerproc.} =
|
proc SetLt(a, b: int): bool {.compilerproc.} =
|
||||||
result = SetLe(a, b) and not SetEq(a, b)
|
result = SetLe(a, b) and not SetEq(a, b)
|
||||||
|
|
||||||
proc SetMul(a, b: int): int {.compilerproc, noStackFrame.} =
|
proc SetMul(a, b: int): int {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) {
|
for (var elem in `a`) {
|
||||||
|
|
@ -203,7 +203,7 @@ proc SetMul(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetPlus(a, b: int): int {.compilerproc, noStackFrame.} =
|
proc SetPlus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) { result[elem] = true; }
|
for (var elem in `a`) { result[elem] = true; }
|
||||||
|
|
@ -211,7 +211,7 @@ proc SetPlus(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc SetMinus(a, b: int): int {.compilerproc, noStackFrame.} =
|
proc SetMinus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var result = {};
|
var result = {};
|
||||||
for (var elem in `a`) {
|
for (var elem in `a`) {
|
||||||
|
|
@ -220,7 +220,7 @@ proc SetMinus(a, b: int): int {.compilerproc, noStackFrame.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc cmpStrings(a, b: string): int {.noStackFrame, compilerProc.} =
|
proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerProc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`a` == `b`) return 0;
|
if (`a` == `b`) return 0;
|
||||||
if (!`a`) return -1;
|
if (!`a`) return -1;
|
||||||
|
|
@ -234,7 +234,7 @@ proc cmpStrings(a, b: string): int {.noStackFrame, compilerProc.} =
|
||||||
|
|
||||||
proc cmp(x, y: string): int = return cmpStrings(x, y)
|
proc cmp(x, y: string): int = return cmpStrings(x, y)
|
||||||
|
|
||||||
proc eqStrings(a, b: string): bool {.noStackFrame, compilerProc.} =
|
proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`a` == `b`) return true;
|
if (`a` == `b`) return true;
|
||||||
if ((!`a`) || (!`b`)) return false;
|
if ((!`a`) || (!`b`)) return false;
|
||||||
|
|
@ -300,7 +300,7 @@ type
|
||||||
setAttributeNode*: proc (attr: ref TNode) {.nimcall.}
|
setAttributeNode*: proc (attr: ref TNode) {.nimcall.}
|
||||||
|
|
||||||
when defined(kwin):
|
when defined(kwin):
|
||||||
proc rawEcho {.compilerproc, nostackframe.} =
|
proc rawEcho {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var buf = "";
|
var buf = "";
|
||||||
for (var i = 0; i < arguments.length; ++i) {
|
for (var i = 0; i < arguments.length; ++i) {
|
||||||
|
|
@ -312,7 +312,7 @@ when defined(kwin):
|
||||||
elif defined(nodejs):
|
elif defined(nodejs):
|
||||||
proc ewriteln(x: cstring) = log(x)
|
proc ewriteln(x: cstring) = log(x)
|
||||||
|
|
||||||
proc rawEcho {.compilerproc, nostackframe.} =
|
proc rawEcho {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
var buf = "";
|
var buf = "";
|
||||||
for (var i = 0; i < arguments.length; ++i) {
|
for (var i = 0; i < arguments.length; ++i) {
|
||||||
|
|
@ -345,42 +345,42 @@ else:
|
||||||
node.appendChild(document.createElement("br"))
|
node.appendChild(document.createElement("br"))
|
||||||
|
|
||||||
# Arithmetic:
|
# Arithmetic:
|
||||||
proc addInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc addInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` + `b`;
|
var result = `a` + `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc subInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` - `b`;
|
var result = `a` - `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc mulInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` * `b`;
|
var result = `a` * `b`;
|
||||||
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc divInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
||||||
return Math.floor(`a` / `b`);
|
return Math.floor(`a` / `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc modInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
|
||||||
return Math.floor(`a` % `b`);
|
return Math.floor(`a` % `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc addInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc addInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` + `b`;
|
var result = `a` + `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -388,7 +388,7 @@ proc addInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc subInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc subInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` - `b`;
|
var result = `a` - `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -396,7 +396,7 @@ proc subInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc mulInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc mulInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
var result = `a` * `b`;
|
var result = `a` * `b`;
|
||||||
if (result > 9223372036854775807
|
if (result > 9223372036854775807
|
||||||
|
|
@ -404,14 +404,14 @@ proc mulInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
||||||
return result;
|
return result;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc divInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc divInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
||||||
return Math.floor(`a` / `b`);
|
return Math.floor(`a` / `b`);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc modInt64(a, b: int): int {.noStackFrame, compilerproc.} =
|
proc modInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
if (`b` == 0) `raiseDivByZero`();
|
if (`b` == 0) `raiseDivByZero`();
|
||||||
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
|
||||||
|
|
@ -472,17 +472,17 @@ proc Ze(a: int): int {.compilerproc.} =
|
||||||
proc Ze64(a: int64): int64 {.compilerproc.} =
|
proc Ze64(a: int64): int64 {.compilerproc.} =
|
||||||
result = a
|
result = a
|
||||||
|
|
||||||
proc ToU8(a: int): int8 {.noStackFrame, compilerproc.} =
|
proc ToU8(a: int): int8 {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc ToU16(a: int): int16 {.noStackFrame, compilerproc.} =
|
proc ToU16(a: int): int16 {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc ToU32(a: int): int32 {.noStackFrame, compilerproc.} =
|
proc ToU32(a: int): int32 {.asmNoStackFrame, compilerproc.} =
|
||||||
asm """
|
asm """
|
||||||
return `a`;
|
return `a`;
|
||||||
"""
|
"""
|
||||||
|
|
@ -586,7 +586,7 @@ proc genericReset(x: Pointer, ti: PNimType): pointer {.compilerproc.} =
|
||||||
result = nil
|
result = nil
|
||||||
|
|
||||||
proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
|
proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
|
||||||
noStackFrame, compilerproc.} =
|
asmNoStackFrame, compilerproc.} =
|
||||||
# types are fake
|
# types are fake
|
||||||
asm """
|
asm """
|
||||||
var result = new Array(`len`);
|
var result = new Array(`len`);
|
||||||
|
|
@ -620,7 +620,7 @@ proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
|
||||||
x = x.base
|
x = x.base
|
||||||
return true
|
return true
|
||||||
|
|
||||||
proc addChar(x: string, c: char) {.compilerproc, noStackFrame.} =
|
proc addChar(x: string, c: char) {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
`x`[`x`.length-1] = `c`; `x`.push(0);
|
`x`[`x`.length-1] = `c`; `x`.push(0);
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
4
todo.txt
4
todo.txt
|
|
@ -19,8 +19,6 @@ Bugs
|
||||||
- docgen: sometimes effects are listed twice
|
- docgen: sometimes effects are listed twice
|
||||||
- 'result' is not properly cleaned for NRVO --> use uninit checking instead
|
- 'result' is not properly cleaned for NRVO --> use uninit checking instead
|
||||||
- blocks can "export" an identifier but the CCG generates {} for them ...
|
- blocks can "export" an identifier but the CCG generates {} for them ...
|
||||||
- osproc execProcesses can deadlock if all processes fail (as experienced
|
|
||||||
in c++ mode)
|
|
||||||
|
|
||||||
|
|
||||||
version 0.9.x
|
version 0.9.x
|
||||||
|
|
@ -144,11 +142,9 @@ Not essential for 1.0.0
|
||||||
semantics instead ...
|
semantics instead ...
|
||||||
- implement "closure tuple consists of a single 'ref'" optimization
|
- implement "closure tuple consists of a single 'ref'" optimization
|
||||||
- optimize method dispatchers
|
- optimize method dispatchers
|
||||||
- ``with proc `+`(x, y: T): T`` for generic code
|
|
||||||
- new feature: ``distinct T with operations``
|
- new feature: ``distinct T with operations``
|
||||||
- arglist as a type (iterator chaining); variable length type lists for generics
|
- arglist as a type (iterator chaining); variable length type lists for generics
|
||||||
- implement marker procs for message passing
|
- implement marker procs for message passing
|
||||||
- activate more thread tests
|
|
||||||
- implement closures that support nesting of *procs* > 1
|
- implement closures that support nesting of *procs* > 1
|
||||||
- object constructors: static check for fields if discriminator is known at
|
- object constructors: static check for fields if discriminator is known at
|
||||||
compile time
|
compile time
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ News
|
||||||
- The ``nil`` statement has been deprecated, use an empty ``discard`` instead.
|
- The ``nil`` statement has been deprecated, use an empty ``discard`` instead.
|
||||||
- ``sockets.select`` now prunes sockets that are **not** ready from the list
|
- ``sockets.select`` now prunes sockets that are **not** ready from the list
|
||||||
of sockets given to it.
|
of sockets given to it.
|
||||||
|
- The ``noStackFrame`` pragma has been renamed to ``asmNoStackFrame`` to
|
||||||
|
ensure you only use it when you know what you're doing.
|
||||||
|
|
||||||
|
|
||||||
Compiler Additions
|
Compiler Additions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue