Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ d1474affa8e105bece209cc9d594bb0a989859e1

# Indentation
0e4bad888e605d424b9222ae0ca43f85c1634e5e
61aa46c41648c6d1e9b0daa1a292de551fde78df

# Enable Style/StringLiterals cop for RubyGems/Bundler
d7ffd3fea402239b16833cc434404a7af82d44f3
Expand Down Expand Up @@ -42,6 +43,8 @@ d4e24021d39e1f80f0055b55d91f8d5f22e15084
e90282be7ba1bc8e3119f6e1a2c80356ceb3f80a
26a9e0b4e31f7b5a9cbd755e0a15823a8fa51bae
2f53985da9ee593fe524d408256835667938c7d7
bf01f6ae89a95d8f5572e050facfe311c8c28aaf
7480cd8d37fd71a41ce12b759090051c7e14fb5a

# Win32: EOL code of batch files
23f9a0d655c4d405bb2397a147a1523436205486
Expand Down
73 changes: 73 additions & 0 deletions .github/actions/setup/baseruby/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Setup directories etc.
description: >-
Build baseruby for cross-compiling

inputs:
srcdir:
required: true
default: ${{ github.workspace }}
description: >-
Directory of source codes.

builddir:
required: false
default: ${{ github.workspace }}/baseruby
description: >-
Where baseruby will be built.

installdir:
required: false
default: install
description: >-
The path where the baseruby will be installed to.
This is relative from the workspace.

outputs:
ruby:
value: ${{ steps.build.outputs.installdir }}/bin/ruby
description: >-
The path of the executable baseruby.
dump_ast:
value: ${{ steps.build.outputs.installdir }}/bin/dump_ast
description: >-
The path of the executable dump_ast.

runs:
using: composite

steps:
- name: Build baseruby
shell: bash
id: build
run: |
case "$installdir" in /*) ;; *) installdir="$PWD/$installdir";; esac
mkdir "$builddir"
ln -sr "$srcdir" "$builddir/.src"
pushd "$builddir"
.src/configure "--prefix=${installdir}" --disable-install-doc
CONFIGURE_ARGS=--with-out-ext=-test- make install
install dump_ast "${installdir}/bin"
{
echo "${installdir}/bin/dump_ast"
echo "${installdir}/.installed.list"
echo "${installdir}/"
} >> .installed.list
cp .installed.list "${installdir}/"
make distclean
rm .src
popd
rmdir "$builddir"
{
echo "installdir=${installdir}"
} | tee -a "$GITHUB_OUTPUT"
env:
srcdir: ${{ inputs.srcdir }}
builddir: ${{ inputs.builddir }}
installdir: ${{ inputs.installdir }}

- name: clean
uses: gacts/run-and-post-run@598d7a875d5620e0457490555b5e18e46082aa47 # v1.4.4
with:
working-directory: ${{ inputs.srcdir }}
post: |
ruby tool/rbuninstall.rb "${{ steps.build.outputs.installdir }}/.installed.list" > /dev/null
33 changes: 26 additions & 7 deletions .github/actions/setup/ubuntu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,45 @@ runs:
using: composite

steps:
- id: uname
name: uname
shell: bash
env:
arch: ${{ inputs.arch }}
run: |
setarch="${arch:+setarch $arch --}"
# normalize `uname`
if uname=$(${setarch} uname -m 2> /dev/null); then
# `setarch` works, `$arch` is a valid architecture name.
echo "setarch=${setarch}" >> "$GITHUB_OUTPUT"
else
# if `setarch` failed, take the given `arch` as-is.
uname="${arch}"
setarch=""
fi
echo "uname=$uname" >> "$GITHUB_OUTPUT"
echo "dpkg=${uname/686/386}" >> "$GITHUB_OUTPUT"

- name: set SETARCH
shell: bash
run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV" # zizmor: ignore[github-env]
env:
setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }}
setarch: ${{ steps.uname.outputs.setarch }} # validated

- id: uname
name: uname
- name: dpkg setup
shell: bash
run: |
echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT"
echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT"
run: sudo dpkg --add-architecture "${dpkg}"
# `dpkg` is valid, also `uname`.
if: ${{ inputs.arch }}
env:
dpkg: ${{ steps.uname.outputs.dpkg }}

- name: apt-get
shell: bash
env:
arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
run: |
set -x
${arch:+sudo dpkg --add-architecture ${arch#:}}
sudo apt-get update -qq || :
sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
${arch:+cross}build-essential${arch/:/-} \
Expand Down
34 changes: 13 additions & 21 deletions .github/workflows/crosscompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ jobs:
builddir: build
makeup: true

- name: Install cross-compilation toolchain
- name: Setup cross-compilation toolchain sources
run: |
sudo dpkg --add-architecture ${{ matrix.arch }}
native_arch=$(dpkg --print-architecture)
# Restrict existing sources to native arch
sudo sed -i '/^Architectures:/d' /etc/apt/sources.list.d/ubuntu.sources
Expand All @@ -84,32 +83,25 @@ jobs:
"Components: main universe" \
"Architectures: ${{ matrix.arch }}" \
| sudo tee /etc/apt/sources.list.d/cross-${{ matrix.arch }}.sources
sudo apt-get update -qq
sudo apt-get install --no-install-recommends -qq -y \
crossbuild-essential-${{ matrix.arch }} \
libssl-dev:${{ matrix.arch }} \
libyaml-dev:${{ matrix.arch }} \
zlib1g-dev:${{ matrix.arch }} \
libffi-dev:${{ matrix.arch }} \
libreadline-dev:${{ matrix.arch }} \
libncurses-dev:${{ matrix.arch }} \
autoconf ruby

- name: Build baseruby
run: |
mkdir ../baseruby
cd ../baseruby
../src/configure --prefix=$PWD/install --disable-install-doc
make
make install

- uses: ./.github/actions/setup/ubuntu
with:
arch: ${{ matrix.arch }}

- uses: ./.github/actions/setup/baseruby
id: baseruby
with:
srcdir: src

- name: Run configure
run: >-
../src/configure -C --disable-install-doc
--prefix=/usr
--build=${{ matrix.build }}
--host=${{ matrix.host }}
--with-baseruby=$PWD/../baseruby/install/bin/ruby
--with-baseruby="$baseruby"
env:
baseruby: ${{ steps.baseruby.outputs.ruby }}

- run: make

Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,10 @@ jobs:
run: |
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
- name: Build baseruby
- uses: ./.github/actions/setup/baseruby
id: baseruby
run: |
set -ex
mkdir ../baseruby
pushd ../baseruby
echo "ruby=$PWD/install/bin/ruby" >> $GITHUB_OUTPUT
echo "dump_ast=$PWD/dump_ast" >> $GITHUB_OUTPUT
../src/configure --prefix=$PWD/install
make
make install
with:
srcdir: src

- name: Download config.guess with wasi version
run: |
Expand Down
18 changes: 12 additions & 6 deletions gc/mmtk/mmtk.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,19 +813,25 @@ rb_gc_impl_get_vm_context(void *objspace_ptr)
// Object allocation

static VALUE
rb_mmtk_alloc_fast_path(struct objspace *objspace, struct MMTk_ractor_cache *ractor_cache, size_t size)
rb_mmtk_alloc_fast_path(struct objspace *objspace, struct MMTk_ractor_cache *ractor_cache, size_t size, size_t align)
{
MMTk_BumpPointer *bump_pointer = ractor_cache->bump_pointer;
if (bump_pointer == NULL) return 0;

uintptr_t new_cursor = bump_pointer->cursor + size;
uintptr_t cursor = bump_pointer->cursor;

if (new_cursor > bump_pointer->limit) {
// Ensure cursor is aligned
size_t mask = align - 1;
cursor = (cursor + mask) & ~mask;

cursor += size;

if (cursor > bump_pointer->limit) {
return 0;
}
else {
VALUE obj = (VALUE)bump_pointer->cursor;
bump_pointer->cursor = new_cursor;
VALUE obj = cursor - size;
bump_pointer->cursor = cursor;
return obj;
}
}
Expand Down Expand Up @@ -910,7 +916,7 @@ rb_gc_impl_new_obj(void *objspace_ptr, void *cache_ptr, VALUE klass, VALUE flags
// Layout: [hidden size header (sizeof(VALUE))][payload (alloc_size)][suffix (RVALUE_SUFFIX_SIZE)]
alloc_size += sizeof(VALUE) + RVALUE_SUFFIX_SIZE;

VALUE *alloc_obj = (VALUE *)rb_mmtk_alloc_fast_path(objspace, ractor_cache, alloc_size);
VALUE *alloc_obj = (VALUE *)rb_mmtk_alloc_fast_path(objspace, ractor_cache, alloc_size, MMTk_MIN_OBJ_ALIGN);
if (!alloc_obj) {
alloc_obj = mmtk_alloc(ractor_cache->mutator, alloc_size, MMTk_MIN_OBJ_ALIGN, 0, MMTK_ALLOCATION_SEMANTICS_DEFAULT);
}
Expand Down
34 changes: 17 additions & 17 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -11122,48 +11122,48 @@ rb_str_justify(int argc, VALUE *argv, VALUE str, char jflag)
rlen = n - llen;
cr = ENC_CODERANGE(str);
if (flen > 1) {
llen2 = str_offset(f, f + flen, llen % fclen, enc, singlebyte);
rlen2 = str_offset(f, f + flen, rlen % fclen, enc, singlebyte);
llen2 = str_offset(f, f + flen, llen % fclen, enc, singlebyte);
rlen2 = str_offset(f, f + flen, rlen % fclen, enc, singlebyte);
}
size = RSTRING_LEN(str);
if ((len = llen / fclen + rlen / fclen) >= LONG_MAX / flen ||
(len *= flen) >= LONG_MAX - llen2 - rlen2 ||
(len += llen2 + rlen2) >= LONG_MAX - size) {
rb_raise(rb_eArgError, "argument too big");
(len *= flen) >= LONG_MAX - llen2 - rlen2 ||
(len += llen2 + rlen2) >= LONG_MAX - size) {
rb_raise(rb_eArgError, "argument too big");
}
len += size;
res = str_enc_new(rb_cString, 0, len, enc);
p = RSTRING_PTR(res);
if (flen <= 1) {
memset(p, *f, llen);
p += llen;
memset(p, *f, llen);
p += llen;
}
else {
while (llen >= fclen) {
while (llen >= fclen) {
memcpy(p,f,flen);
p += flen;
llen -= fclen;
}
if (llen > 0) {
memcpy(p, f, llen2);
p += llen2;
if (llen > 0) {
memcpy(p, f, llen2);
p += llen2;
}
}
memcpy(p, RSTRING_PTR(str), size);
p += size;
if (flen <= 1) {
memset(p, *f, rlen);
p += rlen;
memset(p, *f, rlen);
p += rlen;
}
else {
while (rlen >= fclen) {
while (rlen >= fclen) {
memcpy(p,f,flen);
p += flen;
rlen -= fclen;
}
if (rlen > 0) {
memcpy(p, f, rlen2);
p += rlen2;
if (rlen > 0) {
memcpy(p, f, rlen2);
p += rlen2;
}
}
TERM_FILL(p, termlen);
Expand Down