renamed noStackFrame to asmNoStackFrame

This commit is contained in:
Araq
2014-02-18 09:57:59 +01:00
parent 15953dfed9
commit ab72377ce6
8 changed files with 57 additions and 57 deletions

View File

@@ -23,7 +23,7 @@ const
wMagic, wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
wCompilerproc, wProcVar, wDeprecated, wVarargs, wCompileTime, wMerge,
wBorrow, wExtern, wImportCompilerProc, wThread, wImportCpp, wImportObjC,
wNoStackFrame, wError, wDiscardable, wNoInit, wDestructor, wCodegenDecl,
wAsmNoStackFrame, wError, wDiscardable, wNoInit, wDestructor, wCodegenDecl,
wGensym, wInject, wRaises, wTags, wOperator, wDelegator}
converterPragmas* = procPragmas
methodPragmas* = procPragmas
@@ -47,7 +47,7 @@ const
wInjectStmt}
lambdaPragmas* = {FirstCallConv..LastCallConv, wImportc, wExportc, wNodecl,
wNosideeffect, wSideeffect, wNoreturn, wDynlib, wHeader,
wDeprecated, wExtern, wThread, wImportCpp, wImportObjC, wNoStackFrame,
wDeprecated, wExtern, wThread, wImportCpp, wImportObjC, wAsmNoStackFrame,
wRaises, wTags}
typePragmas* = {wImportc, wExportc, wDeprecated, wMagic, wAcyclic, wNodecl,
wPure, wHeader, wCompilerproc, wFinal, wSize, wExtern, wShallow,
@@ -548,9 +548,11 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: int,
of wNodecl:
noVal(it)
incl(sym.loc.flags, lfNoDecl)
of wPure, wNoStackFrame:
of wPure, wAsmNoStackFrame:
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:
noVal(it)
incl(sym.flags, sfVolatile)

View File

@@ -62,7 +62,7 @@ type
wWatchPoint, wSubsChar,
wAcyclic, wShallow, wUnroll, wLinearScanEnd, wComputedGoto, wInjectStmt,
wWrite, wGensym, wInject, wDirty, wInheritable, wThreadVar, wEmit,
wNoStackFrame,
wAsmNoStackFrame,
wImplicitStatic, wGlobal, wCodegenDecl,
wAuto, wBool, wCatch, wChar, wClass,
@@ -145,7 +145,7 @@ const
"subschar", "acyclic", "shallow", "unroll", "linearscanend",
"computedgoto", "injectstmt",
"write", "gensym", "inject", "dirty", "inheritable", "threadvar", "emit",
"nostackframe", "implicitstatic", "global", "codegendecl",
"asmnostackframe", "implicitstatic", "global", "codegendecl",
"auto", "bool", "catch", "char", "class",
"const_cast", "default", "delete", "double",

View File

@@ -4893,16 +4893,16 @@ field which is used for runtime type identification is omitted. This is
necessary for binary compatibility with other compiled languages.
NoStackFrame pragma
-------------------
A proc can be marked with the `noStackFrame`:idx: pragma to tell the compiler
AsmNoStackFrame pragma
----------------------
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
statements like ``return result;`` generated and the generated C function is
declared as ``__declspec(naked)`` or ``__attribute__((naked))`` (depending on
the used C compiler).
**Note**: This pragma should only be used by procs which consist solely of assembler
statements.
**Note**: This pragma should only be used by procs which consist solely of
assembler statements.
error pragma
------------

View File

@@ -1514,7 +1514,7 @@ when not defined(NimrodVM):
proc seqToPtr[T](x: seq[T]): pointer {.inline, nosideeffect.} =
result = cast[pointer](x)
else:
proc seqToPtr[T](x: seq[T]): pointer {.noStackFrame, nosideeffect.} =
proc seqToPtr[T](x: seq[T]): pointer {.asmNoStackFrame, nosideeffect.} =
asm """return `x`"""
proc `==` *[T](x, y: seq[T]): bool {.noSideEffect.} =
@@ -1797,7 +1797,7 @@ type
len*: int ## length of the inspectable slots
when defined(JS):
proc add*(x: var string, y: cstring) {.noStackFrame.} =
proc add*(x: var string, y: cstring) {.asmNoStackFrame.} =
asm """
var len = `x`[0].length-1;
for (var i = 0; i < `y`.length; ++i) {

View File

@@ -111,7 +111,7 @@ const
when asmVersion and not defined(gcc) and not defined(llvm_gcc):
# assembler optimized versions for compilers that
# 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
asm """
mov eax, `a`
@@ -121,7 +121,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
theEnd:
"""
proc subInt(a, b: int): int {.compilerProc, noStackFrame.} =
proc subInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
asm """
mov eax, `a`
sub eax, `b`
@@ -130,7 +130,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
theEnd:
"""
proc negInt(a: int): int {.compilerProc, noStackFrame.} =
proc negInt(a: int): int {.compilerProc, asmNoStackFrame.} =
asm """
mov eax, `a`
neg eax
@@ -139,7 +139,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
theEnd:
"""
proc divInt(a, b: int): int {.compilerProc, noStackFrame.} =
proc divInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
asm """
mov eax, `a`
mov ecx, `b`
@@ -150,7 +150,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
theEnd:
"""
proc modInt(a, b: int): int {.compilerProc, noStackFrame.} =
proc modInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
asm """
mov eax, `a`
mov ecx, `b`
@@ -162,7 +162,7 @@ when asmVersion and not defined(gcc) and not defined(llvm_gcc):
mov eax, edx
"""
proc mulInt(a, b: int): int {.compilerProc, noStackFrame.} =
proc mulInt(a, b: int): int {.compilerProc, asmNoStackFrame.} =
asm """
mov eax, `a`
mov ecx, `b`

View File

@@ -23,9 +23,9 @@ type
PCallFrame = ptr TCallFrame
TCallFrame {.importc, nodecl, final.} = object
prev: PCallFrame
procname: CString
procname: cstring
line: int # current line number
filename: CString
filename: cstring
var
framePtr {.importc, nodecl, volatile.}: PCallFrame
@@ -48,7 +48,7 @@ proc getCurrentExceptionMsg*(): string =
proc auxWriteStackTrace(f: PCallFrame): string =
type
TTempFrame = tuple[procname: CString, line: int]
TTempFrame = tuple[procname: cstring, line: int]
var
it = f
i = 0
@@ -84,7 +84,7 @@ proc rawWriteStackTrace(): string =
framePtr = nil
proc raiseException(e: ref E_Base, ename: cstring) {.
compilerproc, noStackFrame.} =
compilerproc, asmNoStackFrame.} =
e.name = ename
if excHandler != nil:
excHandler.exc = e
@@ -104,7 +104,7 @@ proc raiseException(e: ref E_Base, ename: cstring) {.
alert(buf)
asm """throw `e`;"""
proc reraiseException() {.compilerproc, noStackFrame.} =
proc reraiseException() {.compilerproc, asmNoStackFrame.} =
if excHandler == nil:
raise newException(ENoExceptionToReraise, "no exception to reraise")
else:
@@ -125,7 +125,7 @@ proc raiseIndexError() {.compilerproc, noreturn.} =
proc raiseFieldError(f: string) {.compilerproc, noreturn.} =
raise newException(EInvalidField, f & " is not accessible")
proc SetConstr() {.varargs, noStackFrame, compilerproc.} =
proc SetConstr() {.varargs, asmNoStackFrame, compilerproc.} =
asm """
var result = {};
for (var i = 0; i < arguments.length; ++i) {
@@ -141,7 +141,7 @@ proc SetConstr() {.varargs, noStackFrame, compilerproc.} =
return result;
"""
proc cstrToNimstr(c: cstring): string {.noStackFrame, compilerproc.} =
proc cstrToNimstr(c: cstring): string {.asmNoStackFrame, compilerproc.} =
asm """
var result = [];
for (var i = 0; i < `c`.length; ++i) {
@@ -151,7 +151,7 @@ proc cstrToNimstr(c: cstring): string {.noStackFrame, compilerproc.} =
return result;
"""
proc toJSStr(s: string): cstring {.noStackFrame, compilerproc.} =
proc toJSStr(s: string): cstring {.asmNoStackFrame, compilerproc.} =
asm """
var len = `s`.length-1;
var result = new Array(len);
@@ -162,7 +162,7 @@ proc toJSStr(s: string): cstring {.noStackFrame, compilerproc.} =
return result.join("");
"""
proc mnewString(len: int): string {.noStackFrame, compilerproc.} =
proc mnewString(len: int): string {.asmNoStackFrame, compilerproc.} =
asm """
var result = new Array(`len`+1);
result[0] = 0;
@@ -170,7 +170,7 @@ proc mnewString(len: int): string {.noStackFrame, compilerproc.} =
return result;
"""
proc SetCard(a: int): int {.compilerproc, noStackFrame.} =
proc SetCard(a: int): int {.compilerproc, asmNoStackFrame.} =
# argument type is a fake
asm """
var result = 0;
@@ -178,14 +178,14 @@ proc SetCard(a: int): int {.compilerproc, noStackFrame.} =
return result;
"""
proc SetEq(a, b: int): bool {.compilerproc, noStackFrame.} =
proc SetEq(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
asm """
for (var elem in `a`) { if (!`b`[elem]) return false; }
for (var elem in `b`) { if (!`a`[elem]) return false; }
return true;
"""
proc SetLe(a, b: int): bool {.compilerproc, noStackFrame.} =
proc SetLe(a, b: int): bool {.compilerproc, asmNoStackFrame.} =
asm """
for (var elem in `a`) { if (!`b`[elem]) return false; }
return true;
@@ -194,7 +194,7 @@ proc SetLe(a, b: int): bool {.compilerproc, noStackFrame.} =
proc SetLt(a, b: int): bool {.compilerproc.} =
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 """
var result = {};
for (var elem in `a`) {
@@ -203,7 +203,7 @@ proc SetMul(a, b: int): int {.compilerproc, noStackFrame.} =
return result;
"""
proc SetPlus(a, b: int): int {.compilerproc, noStackFrame.} =
proc SetPlus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
asm """
var result = {};
for (var elem in `a`) { result[elem] = true; }
@@ -211,7 +211,7 @@ proc SetPlus(a, b: int): int {.compilerproc, noStackFrame.} =
return result;
"""
proc SetMinus(a, b: int): int {.compilerproc, noStackFrame.} =
proc SetMinus(a, b: int): int {.compilerproc, asmNoStackFrame.} =
asm """
var result = {};
for (var elem in `a`) {
@@ -220,7 +220,7 @@ proc SetMinus(a, b: int): int {.compilerproc, noStackFrame.} =
return result;
"""
proc cmpStrings(a, b: string): int {.noStackFrame, compilerProc.} =
proc cmpStrings(a, b: string): int {.asmNoStackFrame, compilerProc.} =
asm """
if (`a` == `b`) return 0;
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 eqStrings(a, b: string): bool {.noStackFrame, compilerProc.} =
proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
asm """
if (`a` == `b`) return true;
if ((!`a`) || (!`b`)) return false;
@@ -300,7 +300,7 @@ type
setAttributeNode*: proc (attr: ref TNode) {.nimcall.}
when defined(kwin):
proc rawEcho {.compilerproc, nostackframe.} =
proc rawEcho {.compilerproc, asmNoStackFrame.} =
asm """
var buf = "";
for (var i = 0; i < arguments.length; ++i) {
@@ -312,7 +312,7 @@ when defined(kwin):
elif defined(nodejs):
proc ewriteln(x: cstring) = log(x)
proc rawEcho {.compilerproc, nostackframe.} =
proc rawEcho {.compilerproc, asmNoStackFrame.} =
asm """
var buf = "";
for (var i = 0; i < arguments.length; ++i) {
@@ -345,42 +345,42 @@ else:
node.appendChild(document.createElement("br"))
# Arithmetic:
proc addInt(a, b: int): int {.noStackFrame, compilerproc.} =
proc addInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` + `b`;
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
return result;
"""
proc subInt(a, b: int): int {.noStackFrame, compilerproc.} =
proc subInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` - `b`;
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
return result;
"""
proc mulInt(a, b: int): int {.noStackFrame, compilerproc.} =
proc mulInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` * `b`;
if (result > 2147483647 || result < -2147483648) `raiseOverflow`();
return result;
"""
proc divInt(a, b: int): int {.noStackFrame, compilerproc.} =
proc divInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
if (`b` == 0) `raiseDivByZero`();
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
return Math.floor(`a` / `b`);
"""
proc modInt(a, b: int): int {.noStackFrame, compilerproc.} =
proc modInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
if (`b` == 0) `raiseDivByZero`();
if (`b` == -1 && `a` == 2147483647) `raiseOverflow`();
return Math.floor(`a` % `b`);
"""
proc addInt64(a, b: int): int {.noStackFrame, compilerproc.} =
proc addInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` + `b`;
if (result > 9223372036854775807
@@ -388,7 +388,7 @@ proc addInt64(a, b: int): int {.noStackFrame, compilerproc.} =
return result;
"""
proc subInt64(a, b: int): int {.noStackFrame, compilerproc.} =
proc subInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` - `b`;
if (result > 9223372036854775807
@@ -396,7 +396,7 @@ proc subInt64(a, b: int): int {.noStackFrame, compilerproc.} =
return result;
"""
proc mulInt64(a, b: int): int {.noStackFrame, compilerproc.} =
proc mulInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
var result = `a` * `b`;
if (result > 9223372036854775807
@@ -404,14 +404,14 @@ proc mulInt64(a, b: int): int {.noStackFrame, compilerproc.} =
return result;
"""
proc divInt64(a, b: int): int {.noStackFrame, compilerproc.} =
proc divInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
if (`b` == 0) `raiseDivByZero`();
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
return Math.floor(`a` / `b`);
"""
proc modInt64(a, b: int): int {.noStackFrame, compilerproc.} =
proc modInt64(a, b: int): int {.asmNoStackFrame, compilerproc.} =
asm """
if (`b` == 0) `raiseDivByZero`();
if (`b` == -1 && `a` == 9223372036854775807) `raiseOverflow`();
@@ -472,17 +472,17 @@ proc Ze(a: int): int {.compilerproc.} =
proc Ze64(a: int64): int64 {.compilerproc.} =
result = a
proc ToU8(a: int): int8 {.noStackFrame, compilerproc.} =
proc ToU8(a: int): int8 {.asmNoStackFrame, compilerproc.} =
asm """
return `a`;
"""
proc ToU16(a: int): int16 {.noStackFrame, compilerproc.} =
proc ToU16(a: int): int16 {.asmNoStackFrame, compilerproc.} =
asm """
return `a`;
"""
proc ToU32(a: int): int32 {.noStackFrame, compilerproc.} =
proc ToU32(a: int): int32 {.asmNoStackFrame, compilerproc.} =
asm """
return `a`;
"""
@@ -586,7 +586,7 @@ proc genericReset(x: Pointer, ti: PNimType): pointer {.compilerproc.} =
result = nil
proc ArrayConstr(len: int, value: pointer, typ: PNimType): pointer {.
noStackFrame, compilerproc.} =
asmNoStackFrame, compilerproc.} =
# types are fake
asm """
var result = new Array(`len`);
@@ -620,7 +620,7 @@ proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
x = x.base
return true
proc addChar(x: string, c: char) {.compilerproc, noStackFrame.} =
proc addChar(x: string, c: char) {.compilerproc, asmNoStackFrame.} =
asm """
`x`[`x`.length-1] = `c`; `x`.push(0);
"""

View File

@@ -19,8 +19,6 @@ Bugs
- docgen: sometimes effects are listed twice
- 'result' is not properly cleaned for NRVO --> use uninit checking instead
- 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
@@ -144,11 +142,9 @@ Not essential for 1.0.0
semantics instead ...
- implement "closure tuple consists of a single 'ref'" optimization
- optimize method dispatchers
- ``with proc `+`(x, y: T): T`` for generic code
- new feature: ``distinct T with operations``
- arglist as a type (iterator chaining); variable length type lists for generics
- implement marker procs for message passing
- activate more thread tests
- implement closures that support nesting of *procs* > 1
- object constructors: static check for fields if discriminator is known at
compile time

View File

@@ -41,6 +41,8 @@ News
- The ``nil`` statement has been deprecated, use an empty ``discard`` instead.
- ``sockets.select`` now prunes sockets that are **not** ready from the list
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