--newruntime: work in progress
This commit is contained in:
parent
79b1eafa59
commit
2ab6b2c657
13 changed files with 566 additions and 233 deletions
|
|
@ -63,46 +63,48 @@ proc chckNilDisp(p: pointer) {.compilerproc.} =
|
|||
if p == nil:
|
||||
sysFatal(NilAccessError, "cannot dispatch; dispatcher is nil")
|
||||
|
||||
proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj
|
||||
if x == subclass: return # optimized fast path
|
||||
while x != subclass:
|
||||
if x == nil:
|
||||
sysFatal(ObjectConversionError, "invalid object conversion")
|
||||
x = x.base
|
||||
when not defined(nimV2):
|
||||
|
||||
proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
|
||||
if a != b:
|
||||
sysFatal(ObjectAssignmentError, "invalid object assignment")
|
||||
proc chckObj(obj, subclass: PNimType) {.compilerproc.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj
|
||||
if x == subclass: return # optimized fast path
|
||||
while x != subclass:
|
||||
if x == nil:
|
||||
sysFatal(ObjectConversionError, "invalid object conversion")
|
||||
x = x.base
|
||||
|
||||
type ObjCheckCache = array[0..1, PNimType]
|
||||
proc chckObjAsgn(a, b: PNimType) {.compilerproc, inline.} =
|
||||
if a != b:
|
||||
sysFatal(ObjectAssignmentError, "invalid object assignment")
|
||||
|
||||
proc isObjSlowPath(obj, subclass: PNimType;
|
||||
cache: var ObjCheckCache): bool {.noinline.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj.base
|
||||
while x != subclass:
|
||||
if x == nil:
|
||||
cache[0] = obj
|
||||
return false
|
||||
x = x.base
|
||||
cache[1] = obj
|
||||
return true
|
||||
type ObjCheckCache = array[0..1, PNimType]
|
||||
|
||||
proc isObjWithCache(obj, subclass: PNimType;
|
||||
cache: var ObjCheckCache): bool {.compilerProc, inline.} =
|
||||
if obj == subclass: return true
|
||||
if obj.base == subclass: return true
|
||||
if cache[0] == obj: return false
|
||||
if cache[1] == obj: return true
|
||||
return isObjSlowPath(obj, subclass, cache)
|
||||
proc isObjSlowPath(obj, subclass: PNimType;
|
||||
cache: var ObjCheckCache): bool {.noinline.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj.base
|
||||
while x != subclass:
|
||||
if x == nil:
|
||||
cache[0] = obj
|
||||
return false
|
||||
x = x.base
|
||||
cache[1] = obj
|
||||
return true
|
||||
|
||||
proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj
|
||||
if x == subclass: return true # optimized fast path
|
||||
while x != subclass:
|
||||
if x == nil: return false
|
||||
x = x.base
|
||||
return true
|
||||
proc isObjWithCache(obj, subclass: PNimType;
|
||||
cache: var ObjCheckCache): bool {.compilerProc, inline.} =
|
||||
if obj == subclass: return true
|
||||
if obj.base == subclass: return true
|
||||
if cache[0] == obj: return false
|
||||
if cache[1] == obj: return true
|
||||
return isObjSlowPath(obj, subclass, cache)
|
||||
|
||||
proc isObj(obj, subclass: PNimType): bool {.compilerproc.} =
|
||||
# checks if obj is of type subclass:
|
||||
var x = obj
|
||||
if x == subclass: return true # optimized fast path
|
||||
while x != subclass:
|
||||
if x == nil: return false
|
||||
x = x.base
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -496,6 +496,8 @@ else:
|
|||
elif defined(gcRegions):
|
||||
# XXX due to bootstrapping reasons, we cannot use compileOption("gc", "stack") here
|
||||
include "system/gc_regions"
|
||||
elif defined(nimV2):
|
||||
include "core/runtime_v2"
|
||||
elif defined(gcMarkAndSweep) or defined(gcDestructors):
|
||||
# XXX use 'compileOption' here
|
||||
include "system/gc_ms"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue