Skip to content

Commit ec29009

Browse files
committed
rename :nonoverlayed to :native_executable
1 parent c1490b6 commit ec29009

File tree

14 files changed

+66
-51
lines changed

14 files changed

+66
-51
lines changed

base/boot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ macro _foldable_meta()
465465
#=:notaskstate=#false,
466466
#=:inaccessiblememonly=#false,
467467
#=:noub=#true,
468-
#=:nonoverlayed=#false))
468+
#=:native_executable=#false))
469469
end
470470

471471
const NTuple{N,T} = Tuple{Vararg{T,N}}

base/compiler/abstractinterpretation.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,10 @@ function add_call_backedges!(interp::AbstractInterpreter, @nospecialize(rettype)
451451
# don't bother to add backedges when both type and effects information are already
452452
# maximized to the top since a new method couldn't refine or widen them anyway
453453
if rettype === Any
454-
# ignore the `:nonoverlayed` property if `interp` doesn't use overlayed method table
454+
# ignore the `:native_executable` property if `interp` doesn't use overlayed method table
455455
# since it will never be tainted anyway
456456
if !isoverlayed(method_table(interp))
457-
all_effects = Effects(all_effects; nonoverlayed=false)
457+
all_effects = Effects(all_effects; native_executable=false)
458458
end
459459
if (# ignore the `:noinbounds` property if `:consistent`-cy is tainted already
460460
(sv isa InferenceState && sv.ipo_effects.consistent === ALWAYS_FALSE) ||
@@ -854,7 +854,7 @@ function concrete_eval_eligible(interp::AbstractInterpreter,
854854
mi = result.edge
855855
if mi !== nothing && is_foldable(effects)
856856
if f !== nothing && is_all_const_arg(arginfo, #=start=#2)
857-
if is_nonoverlayed(interp) || is_nonoverlayed(effects)
857+
if is_native_executable(interp) || is_native_executable(effects)
858858
return :concrete_eval
859859
end
860860
# disable concrete-evaluation if this function call is tainted by some overlayed

base/compiler/effects.jl

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ following meanings:
4242
Note that undefined behavior may technically cause the method to violate any other effect
4343
assertions (such as `:consistent` or `:effect_free`) as well, but we do not model this,
4444
and they assume the absence of undefined behavior.
45-
- `nonoverlayed::Bool`: indicates that any methods that may be called within this method
46-
are not defined in an [overlayed method table](@ref OverlayMethodTable).
45+
- `native_executable::Bool`: indicates whether this method can be executed using Julia's
46+
native compiler and runtime. Note that in particular this is generally not the case when
47+
any methods defined in an [OverlayMethodTable](OverlayMethodTable) can be called.
4748
- `noinbounds::Bool`: If set, indicates that this method does not read the parent's `:inbounds`
4849
state. In particular, it does not have any reached `:boundscheck` exprs, not propagates inbounds
4950
to any children that do.
@@ -91,7 +92,8 @@ The output represents the state of different effect properties in the following
9192
- `+i` (green): `true`
9293
- `-i` (red): `false`
9394
94-
Additionally, if the `nonoverlayed` property is false, a red prime symbol (′) is displayed after the tuple.
95+
Additionally, if the `native_executable` property is `false`,
96+
a red prime symbol (′) is displayed after the tuple.
9597
"""
9698
struct Effects
9799
consistent::UInt8
@@ -101,7 +103,7 @@ struct Effects
101103
notaskstate::Bool
102104
inaccessiblememonly::UInt8
103105
noub::Bool
104-
nonoverlayed::Bool
106+
native_executable::Bool
105107
noinbounds::Bool
106108
function Effects(
107109
consistent::UInt8,
@@ -111,7 +113,7 @@ struct Effects
111113
notaskstate::Bool,
112114
inaccessiblememonly::UInt8,
113115
noub::Bool,
114-
nonoverlayed::Bool,
116+
native_executable::Bool,
115117
noinbounds::Bool)
116118
return new(
117119
consistent,
@@ -121,7 +123,7 @@ struct Effects
121123
notaskstate,
122124
inaccessiblememonly,
123125
noub,
124-
nonoverlayed,
126+
native_executable,
125127
noinbounds)
126128
end
127129
end
@@ -152,7 +154,7 @@ function Effects(effects::Effects = _EFFECTS_UNKNOWN;
152154
notaskstate::Bool = effects.notaskstate,
153155
inaccessiblememonly::UInt8 = effects.inaccessiblememonly,
154156
noub::Bool = effects.noub,
155-
nonoverlayed::Bool = effects.nonoverlayed,
157+
native_executable::Bool = effects.native_executable,
156158
noinbounds::Bool = effects.noinbounds)
157159
return Effects(
158160
consistent,
@@ -162,7 +164,7 @@ function Effects(effects::Effects = _EFFECTS_UNKNOWN;
162164
notaskstate,
163165
inaccessiblememonly,
164166
noub,
165-
nonoverlayed,
167+
native_executable,
166168
noinbounds)
167169
end
168170

@@ -175,7 +177,7 @@ function merge_effects(old::Effects, new::Effects)
175177
merge_effectbits(old.notaskstate, new.notaskstate),
176178
merge_effectbits(old.inaccessiblememonly, new.inaccessiblememonly),
177179
merge_effectbits(old.noub, new.noub),
178-
merge_effectbits(old.nonoverlayed, new.nonoverlayed),
180+
merge_effectbits(old.native_executable, new.native_executable),
179181
merge_effectbits(old.noinbounds, new.noinbounds))
180182
end
181183

@@ -194,7 +196,7 @@ is_terminates(effects::Effects) = effects.terminates
194196
is_notaskstate(effects::Effects) = effects.notaskstate
195197
is_inaccessiblememonly(effects::Effects) = effects.inaccessiblememonly === ALWAYS_TRUE
196198
is_noub(effects::Effects) = effects.noub
197-
is_nonoverlayed(effects::Effects) = effects.nonoverlayed
199+
is_native_executable(effects::Effects) = effects.native_executable
198200

199201
# implies `is_notaskstate` & `is_inaccessiblememonly`, but not explicitly checked here
200202
is_foldable(effects::Effects) =
@@ -232,7 +234,7 @@ function encode_effects(e::Effects)
232234
((e.notaskstate % UInt32) << 7) |
233235
((e.inaccessiblememonly % UInt32) << 8) |
234236
((e.noub % UInt32) << 10) |
235-
((e.nonoverlayed % UInt32) << 11) |
237+
((e.native_executable % UInt32) << 11) |
236238
((e.noinbounds % UInt32) << 12)
237239
end
238240

@@ -258,7 +260,7 @@ struct EffectsOverride
258260
notaskstate::Bool
259261
inaccessiblememonly::Bool
260262
noub::Bool
261-
nonoverlayed::Bool
263+
native_executable::Bool
262264
end
263265

264266
function encode_effects_override(eo::EffectsOverride)
@@ -271,7 +273,7 @@ function encode_effects_override(eo::EffectsOverride)
271273
eo.notaskstate && (e |= (1 << 5) % UInt32)
272274
eo.inaccessiblememonly && (e |= (1 << 6) % UInt32)
273275
eo.noub && (e |= (1 << 7) % UInt32)
274-
eo.nonoverlayed && (e |= (1 << 8) % UInt32)
276+
eo.native_executable && (e |= (1 << 8) % UInt32)
275277
return e
276278
end
277279

base/compiler/inferencestate.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mutable struct InferenceState
297297
end
298298

299299
if def isa Method
300-
ipo_effects = Effects(ipo_effects; nonoverlayed=is_nonoverlayed(def))
300+
ipo_effects = Effects(ipo_effects; native_executable=is_native_executable(def))
301301
end
302302

303303
restrict_abstract_call_sites = isa(def, Module)
@@ -318,8 +318,9 @@ mutable struct InferenceState
318318
end
319319
end
320320

321-
is_nonoverlayed(m::Method) = !isdefined(m, :external_mt)
322-
is_nonoverlayed(interp::AbstractInterpreter) = !isoverlayed(method_table(interp))
321+
is_native_executable(m::Method) = !isdefined(m, :external_mt)
322+
is_native_executable(interp::AbstractInterpreter) = !isoverlayed(method_table(interp))
323+
323324
isoverlayed(::MethodTableView) = error("unsatisfied MethodTableView interface")
324325
isoverlayed(::InternalMethodTable) = false
325326
isoverlayed(::OverlayMethodTable) = true

base/compiler/ssair/irinterp.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function concrete_eval_invoke(interp::AbstractInterpreter,
1515
argtypes === nothing && return Pair{Any,Bool}(Bottom, false)
1616
effects = decode_effects(code.ipo_purity_bits)
1717
if (is_foldable(effects) && is_all_const_arg(argtypes, #=start=#1) &&
18-
(is_nonoverlayed(interp) || is_nonoverlayed(effects)))
18+
(is_native_executable(interp) || is_native_executable(effects)))
1919
args = collect_const_args(argtypes, #=start=#1)
2020
value = let world = get_world_counter(interp)
2121
try

base/compiler/ssair/show.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ function Base.show(io::IO, e::Effects)
10201020
print(io, ',')
10211021
printstyled(io, effectbits_letter(e, :noinbounds, 'i'); color=effectbits_color(e, :noinbounds))
10221022
print(io, ')')
1023-
e.nonoverlayed || printstyled(io, ''; color=:red)
1023+
e.native_executable || printstyled(io, ''; color=:red)
10241024
end
10251025

10261026
@specialize

base/compiler/typeinfer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,8 +500,8 @@ function adjust_effects(sv::InferenceState)
500500
if is_effect_overridden(override, :noub)
501501
ipo_effects = Effects(ipo_effects; noub=true)
502502
end
503-
if is_effect_overridden(override, :nonoverlayed)
504-
ipo_effects = Effects(ipo_effects; nonoverlayed=true)
503+
if is_effect_overridden(override, :native_executable)
504+
ipo_effects = Effects(ipo_effects; native_executable=true)
505505
end
506506
end
507507

base/essentials.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ macro _total_meta()
210210
#=:notaskstate=#true,
211211
#=:inaccessiblememonly=#true,
212212
#=:noub=#true,
213-
#=:nonoverlayed=#false))
213+
#=:native_executable=#false))
214214
end
215215
# can be used in place of `@assume_effects :foldable` (supposed to be used for bootstrapping)
216216
macro _foldable_meta()
@@ -223,7 +223,7 @@ macro _foldable_meta()
223223
#=:notaskstate=#false,
224224
#=:inaccessiblememonly=#true,
225225
#=:noub=#true,
226-
#=:nonoverlayed=#false))
226+
#=:native_executable=#false))
227227
end
228228
# can be used in place of `@assume_effects :nothrow` (supposed to be used for bootstrapping)
229229
macro _nothrow_meta()
@@ -236,7 +236,7 @@ macro _nothrow_meta()
236236
#=:notaskstate=#false,
237237
#=:inaccessiblememonly=#false,
238238
#=:noub=#false,
239-
#=:nonoverlayed=#false))
239+
#=:native_executable=#false))
240240
end
241241
# can be used in place of `@assume_effects :terminates_locally` (supposed to be used for bootstrapping)
242242
macro _terminates_locally_meta()
@@ -249,7 +249,7 @@ macro _terminates_locally_meta()
249249
#=:notaskstate=#false,
250250
#=:inaccessiblememonly=#false,
251251
#=:noub=#false,
252-
#=:nonoverlayed=#false))
252+
#=:native_executable=#false))
253253
end
254254
# can be used in place of `@assume_effects :effect_free :terminates_locally` (supposed to be used for bootstrapping)
255255
macro _effect_free_terminates_locally_meta()
@@ -262,7 +262,7 @@ macro _effect_free_terminates_locally_meta()
262262
#=:notaskstate=#false,
263263
#=:inaccessiblememonly=#false,
264264
#=:noub=#false,
265-
#=:nonoverlayed=#false))
265+
#=:native_executable=#false))
266266
end
267267

268268
# another version of inlining that propagates an inbounds context

base/expr.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ The following `setting`s are supported.
479479
- `:notaskstate`
480480
- `:inaccessiblememonly`
481481
- `:noub`
482+
- `:native_executable`
482483
- `:foldable`
483484
- `:removable`
484485
- `:total`
@@ -643,6 +644,17 @@ The `:noub` setting asserts that the method will not execute any undefined behav
643644
any other effect assertions (such as `:consistent` or `:effect_free`) as well, but we do
644645
not model this, and they assume the absence of undefined behavior.
645646
647+
---
648+
## `:native_executable`
649+
650+
The `:native_executable` setting asserts that this method can be executed using Julia's
651+
native compiler and runtime. Currently this particularly implies that any methods defined
652+
in an [OverlayMethodTable](@ref Core.Compiler.OverlayMethodTable) (including this method in
653+
question) are never be called during executing the method. However, it is worth noting that
654+
it is safe to annotate [`@overlay`](@ref Base.Experimental.@overlay) method as
655+
`:native_executable` when the overlay-ed method has the same semantics as the original
656+
method and its result can safely be replaced with the result of the original method.
657+
646658
---
647659
## `:foldable`
648660
@@ -717,7 +729,7 @@ macro assume_effects(args...)
717729
idx = length(args)
718730
end
719731
(consistent, effect_free, nothrow, terminates_globally, terminates_locally,
720-
notaskstate, inaccessiblememonly, noub, nonoverlayed) =
732+
notaskstate, inaccessiblememonly, noub, native_executable) =
721733
(false, false, false, false, false, false, false, false, false, false)
722734
for org_setting in args[1:idx]
723735
(setting, val) = compute_assumed_setting(org_setting)
@@ -737,8 +749,8 @@ macro assume_effects(args...)
737749
inaccessiblememonly = val
738750
elseif setting === :noub
739751
noub = val
740-
elseif setting === :nonoverlayed
741-
nonoverlayed = val
752+
elseif setting === :native_executable
753+
native_executable = val
742754
elseif setting === :foldable
743755
consistent = effect_free = terminates_globally = noub = val
744756
elseif setting === :removable
@@ -752,17 +764,17 @@ macro assume_effects(args...)
752764
if is_function_def(inner)
753765
return esc(pushmeta!(ex, :purity,
754766
consistent, effect_free, nothrow, terminates_globally, terminates_locally,
755-
notaskstate, inaccessiblememonly, noub, nonoverlayed))
767+
notaskstate, inaccessiblememonly, noub, native_executable))
756768
elseif isexpr(ex, :macrocall) && ex.args[1] === Symbol("@ccall")
757769
ex.args[1] = GlobalRef(Base, Symbol("@ccall_effects"))
758770
insert!(ex.args, 3, Core.Compiler.encode_effects_override(Core.Compiler.EffectsOverride(
759771
consistent, effect_free, nothrow, terminates_globally, terminates_locally,
760-
notaskstate, inaccessiblememonly, noub, nonoverlayed)))
772+
notaskstate, inaccessiblememonly, noub, native_executable)))
761773
return esc(ex)
762774
else # anonymous function case
763775
return Expr(:meta, Expr(:purity,
764776
consistent, effect_free, nothrow, terminates_globally, terminates_locally,
765-
notaskstate, inaccessiblememonly, noub, nonoverlayed))
777+
notaskstate, inaccessiblememonly, noub, native_executable))
766778
end
767779
end
768780

src/julia.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ typedef union __jl_purity_overrides_t {
269269
uint8_t ipo_notaskstate : 1;
270270
uint8_t ipo_inaccessiblememonly : 1;
271271
uint8_t ipo_noub : 1;
272-
uint8_t ipo_nonoverlayed : 1;
272+
uint8_t ipo_native_executable : 1;
273273
} overrides;
274274
uint32_t bits;
275275
} _jl_purity_overrides_t;
@@ -435,7 +435,7 @@ typedef struct _jl_code_instance_t {
435435
// uint8_t ipo_terminates : 1;
436436
// uint8_t ipo_notaskstate : 2;
437437
// uint8_t ipo_inaccessiblememonly : 2;
438-
// uint8_t ipo_nonoverlayed : 1;
438+
// uint8_t ipo_native_executable : 1;
439439
// uint8_t ipo_noinbounds : 1;
440440
_Atomic(uint32_t) purity_bits;
441441
// purity_flags:
@@ -445,7 +445,7 @@ typedef struct _jl_code_instance_t {
445445
// uint8_t ipo_terminates : 1;
446446
// uint8_t ipo_notaskstate : 2;
447447
// uint8_t ipo_inaccessiblememonly : 2;
448-
// uint8_t ipo_nonoverlayed : 1;
448+
// uint8_t ipo_native_executable : 1;
449449
// uint8_t ipo_noinbounds : 1;
450450
jl_value_t *argescapes; // escape information of call arguments
451451

0 commit comments

Comments
 (0)