turn off slice bounds checking in release mode

This change removes bounds checking for Slices, which represents most
indexable storage in the emulator. Removing these checks makes the
emulator less safe, without a doubt. However, it amounts a roughly 5%
improvement in the games tested. Most of the checks today occur in
fixed-length arrays where the index cannot be out of bounds, so I'm
chosing to make this tradeoff.
This commit is contained in:
Matthew Berry 2022-10-30 13:49:06 -07:00
parent e0ef57d9e6
commit d864b27e35

View file

@ -1,3 +1,19 @@
{% if flag?(:release) %}
# Disables bounds checking in release mode.
struct Slice(T)
@[AlwaysInline]
def []=(index : Int, value : T) : T
@pointer[index] = value
end
@[AlwaysInline]
def [](index : Int) : T
@pointer[index]
end
end
{% end %}
require "colorize"
require "option_parser"