diff --git a/gc/mmtk/depend b/gc/mmtk/depend index 1689f9d..79f9200 100644 --- a/gc/mmtk/depend +++ b/gc/mmtk/depend @@ -2,10 +2,22 @@ $(TARGET_SO): $(MMTK_BUILD)/$(LIBMMTK_RUBY) $(OBJS): Makefile +# A raised LLVM inline threshold for the Rust GC code: this is what fuses the +# per-object marking pipeline (work packet loop, closure trampoline, type fast +# paths, mark enqueue) into straight-line code. Without it the fast paths in +# scanning.rs stay behind real calls and the win evaporates. +# +# The flag must reach rustc either via the target-scoped RUSTFLAGS in +# MMTK_CARGO_ENV (LTO builds, see extconf.rb) or via plain RUSTFLAGS. Never +# set both: plain RUSTFLAGS has higher precedence in Cargo and would clobber +# the target-scoped flags. +MMTK_INLINE_THRESHOLD = 5000 +MMTK_THRESHOLD_RUSTFLAGS = -Cllvm-args=-inline-threshold=$(MMTK_INLINE_THRESHOLD) + release/$(LIBMMTK_RUBY) debug/$(LIBMMTK_RUBY): $(RUSTSRCS) $(srcdir)/Cargo.toml $(srcdir)/Cargo.lock Makefile release/$(LIBMMTK_RUBY): - CARGO_TARGET_DIR="." $(MMTK_CARGO_ENV) cargo build --manifest-path=$(srcdir)/Cargo.toml --release $(MMTK_CARGO_FLAGS) + CARGO_TARGET_DIR="." $(if $(MMTK_CARGO_ENV),,RUSTFLAGS="$(RUSTFLAGS) $(MMTK_THRESHOLD_RUSTFLAGS)") $(MMTK_CARGO_ENV) cargo build --manifest-path=$(srcdir)/Cargo.toml --release $(MMTK_CARGO_FLAGS) $(MMTK_CARGO_FIXUP) debug/$(LIBMMTK_RUBY): diff --git a/gc/mmtk/extconf.rb b/gc/mmtk/extconf.rb index 70244ae..3674204 100644 --- a/gc/mmtk/extconf.rb +++ b/gc/mmtk/extconf.rb @@ -134,7 +134,7 @@ def filter_warnflags(cc, flags) CFLAGS += #{cflags} DLDFLAGS += #{ldflags} warnflags = #{warnflags} - MMTK_CARGO_ENV = #{env}="-Clinker-plugin-lto -C target-cpu=native" + MMTK_CARGO_ENV = #{env}="-Clinker-plugin-lto -C target-cpu=native -Cllvm-args=-inline-threshold=$(MMTK_INLINE_THRESHOLD)" MMTK_CARGO_FLAGS = --target #{lto[:host]} MMTK_CARGO_FIXUP = mkdir -p release && cp -f #{lto[:host]}/release/$(LIBMMTK_RUBY) release/$(LIBMMTK_RUBY) endif