test i386

This commit is contained in:
ringabout
2026-03-02 19:12:49 +08:00
parent 9ed4077d9a
commit ffdc02c61c
9 changed files with 421 additions and 297 deletions

22
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,22 @@
## Code Standards
### General Guidelines
Don't modify testing files, instead, you should fix the compiler or library code that is causing the test to fail.
<!-- ### Required Before Each Commit
You need to run `./koch boot -d:release` to ensure the compiler can build -->
### Testing a single case
You can run a single test case by using the command `./koch temp c -r testname`, where `testname` is the name of the test case you want to run. Don't use testament.
### Repository Structure
- `compiler`: Contains the Nim compiler source code.
- `lib`: Contains standard libraries and modules.
- `tests`: Contains test cases for the compiler and standard libraries.
- `doc`: Contains documentation related to the Nim programming language.

View File

@@ -1,38 +1,38 @@
# See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901
name: issue comments bisects
on:
issue_comment:
types: created
# # See https://github.com/juancarlospaco/nimrun-action/issues/3#issuecomment-1607344901
# name: issue comments bisects
# on:
# issue_comment:
# types: created
jobs:
bisects:
if: |
github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE'
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
name: ${{ matrix.platform }}-bisects
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v6
# jobs:
# bisects:
# if: |
# github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '!nim ') && github.event.issue.pull_request == null && github.event.comment.author_association != 'NONE'
# strategy:
# fail-fast: false
# matrix:
# platform: [ubuntu-latest, windows-latest, macos-latest]
# name: ${{ matrix.platform }}-bisects
# runs-on: ${{ matrix.platform }}
# steps:
# - uses: actions/checkout@v6
- name: Install OpenSSL (Windows)
if: |
runner.os == 'Windows'
run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init
shell: 'powershell'
# - name: Install OpenSSL (Windows)
# if: |
# runner.os == 'Windows'
# run: choco install openssl.light --version=1.1.1.0 # OpenSSL 3.x removed SSL_library_init
# shell: 'powershell'
# v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug.
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: 'devel'
# # v2 wont work here, because uses "hardcoded" nim versions, action "dynamically" finds version with bug.
# - uses: jiro4989/setup-nim-action@v1
# with:
# nim-version: 'devel'
- uses: juancarlospaco/nimrun-action@nim
if: |
runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) ||
runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') ||
runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) ||
runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# - uses: juancarlospaco/nimrun-action@nim
# if: |
# runner.os == 'Linux' && contains(github.event.comment.body, '-d:linux' ) ||
# runner.os == 'Windows' && contains(github.event.comment.body, '-d:windows') ||
# runner.os == 'macOS' && contains(github.event.comment.body, '-d:osx' ) ||
# runner.os == 'Linux' && !contains(github.event.comment.body, '-d:linux') && !contains(github.event.comment.body, '-d:windows') && !contains(github.event.comment.body, '-d:osx')
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,116 +1,116 @@
name: Nim Docs CI
on:
push:
paths:
- 'compiler/**.nim'
- 'config/nimdoc.cfg'
- 'doc/**.rst'
- 'doc/**.md'
- 'doc/nimdoc.css'
- 'lib/**.nim'
- 'nimdoc/testproject/expected/testproject.html'
- 'tools/dochack/dochack.nim'
- 'tools/kochdocs.nim'
- '.github/workflows/ci_docs.yml'
- 'koch.nim'
# name: Nim Docs CI
# on:
# push:
# paths:
# - 'compiler/**.nim'
# - 'config/nimdoc.cfg'
# - 'doc/**.rst'
# - 'doc/**.md'
# - 'doc/nimdoc.css'
# - 'lib/**.nim'
# - 'nimdoc/testproject/expected/testproject.html'
# - 'tools/dochack/dochack.nim'
# - 'tools/kochdocs.nim'
# - '.github/workflows/ci_docs.yml'
# - 'koch.nim'
pull_request:
# Run only on changes on these files.
paths:
- 'compiler/**.nim'
- 'config/nimdoc.cfg'
- 'doc/**.rst'
- 'doc/**.md'
- 'doc/nimdoc.css'
- 'lib/**.nim'
- 'nimdoc/testproject/expected/testproject.html'
- 'tools/dochack/dochack.nim'
- 'tools/kochdocs.nim'
- '.github/workflows/ci_docs.yml'
- 'koch.nim'
# pull_request:
# # Run only on changes on these files.
# paths:
# - 'compiler/**.nim'
# - 'config/nimdoc.cfg'
# - 'doc/**.rst'
# - 'doc/**.md'
# - 'doc/nimdoc.css'
# - 'lib/**.nim'
# - 'nimdoc/testproject/expected/testproject.html'
# - 'tools/dochack/dochack.nim'
# - 'tools/kochdocs.nim'
# - '.github/workflows/ci_docs.yml'
# - 'koch.nim'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
target: [linux, windows, osx]
include:
- target: linux
os: ubuntu-22.04
- target: windows
os: windows-latest
- target: osx
os: macos-15
# jobs:
# build:
# strategy:
# fail-fast: false
# matrix:
# target: [linux, windows, osx]
# include:
# - target: linux
# os: ubuntu-22.04
# - target: windows
# os: windows-latest
# - target: osx
# os: macos-15
name: ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60 # refs bug #18178
# name: ${{ matrix.target }}
# runs-on: ${{ matrix.os }}
# timeout-minutes: 60 # refs bug #18178
steps:
- name: 'Checkout'
uses: actions/checkout@v6
with:
fetch-depth: 2
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v6
# with:
# fetch-depth: 2
- name: 'Install build dependencies (macOS)'
if: runner.os == 'macOS'
run: brew install make
# - name: 'Install build dependencies (macOS)'
# if: runner.os == 'macOS'
# run: brew install make
- name: 'Install build dependencies (Windows)'
if: runner.os == 'Windows'
shell: bash
run: |
set -e
. ci/funs.sh
nimInternalInstallDepsWindows
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
# - name: 'Install build dependencies (Windows)'
# if: runner.os == 'Windows'
# shell: bash
# run: |
# set -e
# . ci/funs.sh
# nimInternalInstallDepsWindows
# echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
- name: 'Add build binaries to PATH'
shell: bash
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
# - name: 'Add build binaries to PATH'
# shell: bash
# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
- name: 'System information'
shell: bash
run: . ci/funs.sh && nimCiSystemInfo
# - name: 'System information'
# shell: bash
# run: . ci/funs.sh && nimCiSystemInfo
- name: 'Build csourcesAny (posix)'
# this would work on windows and other CI use this on windows,
# but we ensure here that `ci/build_autogen.bat` keeps working on windows.
if: runner.os != 'Windows'
shell: bash
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc
# was previously using caching via `actions/cache@v1` but this wasn't
# used in other CI pipelines and it's unclear the added complexity
# was worth the saving; can be revisited if needed.
# - name: 'Build csourcesAny (posix)'
# # this would work on windows and other CI use this on windows,
# # but we ensure here that `ci/build_autogen.bat` keeps working on windows.
# if: runner.os != 'Windows'
# shell: bash
# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc
# # was previously using caching via `actions/cache@v1` but this wasn't
# # used in other CI pipelines and it's unclear the added complexity
# # was worth the saving; can be revisited if needed.
- name: 'Build csourcesAny (windows)'
if: runner.os == 'Windows'
shell: cmd
run: ci/build_autogen.bat
# - name: 'Build csourcesAny (windows)'
# if: runner.os == 'Windows'
# shell: cmd
# run: ci/build_autogen.bat
- name: 'Build koch'
shell: bash
run: nim c koch
# - name: 'Build koch'
# shell: bash
# run: nim c koch
- name: 'Build the real compiler'
shell: bash
run: ./koch boot -d:release
# - name: 'Build the real compiler'
# shell: bash
# run: ./koch boot -d:release
- name: 'Build documentation'
shell: bash
run: ./koch doc --git.commit:devel
# - name: 'Build documentation'
# shell: bash
# run: ./koch doc --git.commit:devel
- name: 'Publish documentation to Github Pages'
if: |
github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
matrix.target == 'linux'
uses: crazy-max/ghaction-github-pages@v4
with:
build_dir: doc/html
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: 'Publish documentation to Github Pages'
# if: |
# github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
# matrix.target == 'linux'
# uses: crazy-max/ghaction-github-pages@v4
# with:
# build_dir: doc/html
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

99
.github/workflows/ci_i386_linux.yml vendored Normal file
View File

@@ -0,0 +1,99 @@
name: i386 Linux CI
on:
pull_request:
branches:
- '*'
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
max-parallel: 20
matrix:
branch: [devel]
target:
- os: linux
cpu: i386
nim_branch: devel
include:
- target:
os: linux
builder: ubuntu-24.04
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-nim-${{ matrix.target.nim_branch }} (${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
env:
NIM_DIR: nim-${{ matrix.target.nim_branch }}-${{ matrix.target.cpu }}
NIM_BRANCH: ${{ matrix.target.nim_branch }}
NIM_ARCH: ${{ matrix.target.cpu }}
steps:
- name: set `core.autocrlf` to false
run: |
git config --global core.autocrlf false
git config --global init.defaultBranch master
- name: Checkout
uses: actions/checkout@v6
with:
submodules: false
- name: Install dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
working-directory: ${{ github.workspace }}
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -qq
sudo DEBIAN_FRONTEND='noninteractive' apt-get install \
--no-install-recommends -yq gcc-multilib g++-multilib \
libssl-dev:i386
mkdir -p external/bin
cat << EOF > external/bin/gcc
#!/bin/bash
exec $(which gcc) -m32 "\$@"
EOF
cat << EOF > external/bin/g++
#!/bin/bash
exec $(which g++) -m32 "\$@"
EOF
chmod 755 external/bin/gcc external/bin/g++
echo "$PWD/external/bin" >> "${GITHUB_PATH}"
- name: Add repo bin to PATH
run: echo "${GITHUB_WORKSPACE}/bin" >> ${GITHUB_PATH}
- name: Setup Nim
uses: alaviss/setup-nim@0.1.1
with:
path: 'nim'
version: ${{ matrix.target.nim_branch }}
architecture: ${{ matrix.target.cpu }}
# - name: Build koch using existing nim
# run: |
# nim c koch.nim
# - name: Boot the compiler from the checked-out commit
# shell: bash
# run: |
# ./koch boot -d:release
# - name: Show nim version and system info
# run: |
# bin/nim -v || true
# uname -a || true
- name: Run talign test (i386)
shell: bash
run: |
set -euo pipefail
export PATH="${GITHUB_WORKSPACE}/bin:$PATH"
nim c -r --lib:lib --mm:refc -d:useGcAssert -d:useSysAssert tests/align/talign.nim

View File

@@ -1,80 +1,80 @@
name: Packages CI
on:
pull_request:
push:
branches:
- 'devel'
- 'version-2-2'
- 'version-2-0'
- 'version-1-6'
- 'version-1-2'
# name: Packages CI
# on:
# pull_request:
# push:
# branches:
# - 'devel'
# - 'version-2-2'
# - 'version-2-0'
# - 'version-1-6'
# - 'version-1-2'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# concurrency:
# group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-14]
batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num`
include:
- os: ubuntu-latest
cpu: amd64
- os: macos-14
cpu: arm64
name: '${{ matrix.os }} (batch: ${{ matrix.batch }})'
runs-on: ${{ matrix.os }}
timeout-minutes: 60 # refs bug #18178
env:
NIM_TEST_PACKAGES: "1"
NIM_TESTAMENT_BATCH: ${{ matrix.batch }}
steps:
- name: 'Checkout'
uses: actions/checkout@v6
with:
fetch-depth: 2
# jobs:
# build:
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-latest, macos-14]
# batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num`
# include:
# - os: ubuntu-latest
# cpu: amd64
# - os: macos-14
# cpu: arm64
# name: '${{ matrix.os }} (batch: ${{ matrix.batch }})'
# runs-on: ${{ matrix.os }}
# timeout-minutes: 60 # refs bug #18178
# env:
# NIM_TEST_PACKAGES: "1"
# NIM_TESTAMENT_BATCH: ${{ matrix.batch }}
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v6
# with:
# fetch-depth: 2
- name: 'Install node.js'
uses: actions/setup-node@v6
with:
node-version: 24
# - name: 'Install node.js'
# uses: actions/setup-node@v6
# with:
# node-version: 24
- name: 'Install dependencies (Linux amd64)'
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
run: |
sudo apt-get update -qq
DEBIAN_FRONTEND='noninteractive' \
sudo apt-get install --no-install-recommends -yq \
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev
- name: 'Install dependencies (macOS)'
if: runner.os == 'macOS'
run: brew install boehmgc make sfml gtk+3
# XXX can't find boehm and gtk on macos 13
- name: 'Install dependencies (Windows)'
if: runner.os == 'Windows'
shell: bash
run: |
set -e
. ci/funs.sh
nimInternalInstallDepsWindows
echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
# - name: 'Install dependencies (Linux amd64)'
# if: runner.os == 'Linux' && matrix.cpu == 'amd64'
# run: |
# sudo apt-get update -qq
# DEBIAN_FRONTEND='noninteractive' \
# sudo apt-get install --no-install-recommends -yq \
# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
# valgrind libc6-dbg libblas-dev liblapack-dev libpcre3 xorg-dev
# - name: 'Install dependencies (macOS)'
# if: runner.os == 'macOS'
# run: brew install boehmgc make sfml gtk+3
# # XXX can't find boehm and gtk on macos 13
# - name: 'Install dependencies (Windows)'
# if: runner.os == 'Windows'
# shell: bash
# run: |
# set -e
# . ci/funs.sh
# nimInternalInstallDepsWindows
# echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
- name: 'Add build binaries to PATH'
shell: bash
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
# - name: 'Add build binaries to PATH'
# shell: bash
# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
- name: 'System information'
shell: bash
run: . ci/funs.sh && nimCiSystemInfo
# - name: 'System information'
# shell: bash
# run: . ci/funs.sh && nimCiSystemInfo
- name: 'Build csourcesAny'
shell: bash
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
# - name: 'Build csourcesAny'
# shell: bash
# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
- name: 'koch, Run CI'
shell: bash
run: . ci/funs.sh && nimInternalBuildKochAndRunCI
# - name: 'koch, Run CI'
# shell: bash
# run: . ci/funs.sh && nimInternalBuildKochAndRunCI

View File

@@ -1,79 +1,79 @@
name: Tracking orc-booting compiler memory usage
# name: Tracking orc-booting compiler memory usage
on:
pull_request_target:
types: [closed]
# on:
# pull_request_target:
# types: [closed]
jobs:
build:
if: github.event.pull_request.merged == true
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
cpu: [amd64]
name: '${{ matrix.os }}'
runs-on: ${{ matrix.os }}
steps:
- name: 'Checkout'
uses: actions/checkout@v6
with:
fetch-depth: 2
# jobs:
# build:
# if: github.event.pull_request.merged == true
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-22.04]
# cpu: [amd64]
# name: '${{ matrix.os }}'
# runs-on: ${{ matrix.os }}
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v6
# with:
# fetch-depth: 2
- name: 'Install node.js'
uses: actions/setup-node@v6
with:
node-version: 24
# - name: 'Install node.js'
# uses: actions/setup-node@v6
# with:
# node-version: 24
- name: 'Install dependencies (Linux amd64)'
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
run: |
sudo apt-fast update -qq
DEBIAN_FRONTEND='noninteractive' \
sudo apt-fast install --no-install-recommends -yq \
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
valgrind libc6-dbg libblas-dev xorg-dev
# - name: 'Install dependencies (Linux amd64)'
# if: runner.os == 'Linux' && matrix.cpu == 'amd64'
# run: |
# sudo apt-fast update -qq
# DEBIAN_FRONTEND='noninteractive' \
# sudo apt-fast install --no-install-recommends -yq \
# libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
# valgrind libc6-dbg libblas-dev xorg-dev
- name: 'Add build binaries to PATH'
shell: bash
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
# - name: 'Add build binaries to PATH'
# shell: bash
# run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
- name: 'System information'
shell: bash
run: . ci/funs.sh && nimCiSystemInfo
# - name: 'System information'
# shell: bash
# run: . ci/funs.sh && nimCiSystemInfo
- name: 'Build csourcesAny'
shell: bash
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
# - name: 'Build csourcesAny'
# shell: bash
# run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
- name: 'Build koch'
shell: bash
run: nim c koch
# - name: 'Build koch'
# shell: bash
# run: nim c koch
- name: 'Build Nim'
shell: bash
run: ./koch boot -d:release -d:nimStrictMode --lib:lib
# - name: 'Build Nim'
# shell: bash
# run: ./koch boot -d:release -d:nimStrictMode --lib:lib
- name: 'Action'
shell: bash
run: nim c -r -d:release ci/action.nim
# - name: 'Action'
# shell: bash
# run: nim c -r -d:release ci/action.nim
- name: 'Comment'
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
# - name: 'Comment'
# uses: actions/github-script@v8
# with:
# script: |
# const fs = require('fs');
try {
const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: data
})
} catch (err) {
console.error(err);
}
# try {
# const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8');
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: data
# })
# } catch (err) {
# console.error(err);
# }

View File

@@ -1,25 +1,25 @@
# https://github.com/actions/stale#usage
name: Stale pull requests
# # https://github.com/actions/stale#usage
# name: Stale pull requests
on:
schedule:
- cron: '0 0 * * *' # Midnight.
# on:
# schedule:
# - cron: '0 0 * * *' # Midnight.
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v10
with:
days-before-pr-stale: 365
days-before-pr-close: 30
days-before-issue-stale: -1
days-before-issue-close: -1
exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]"
exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority"
stale-pr-message: >
This pull request is stale because it has been open for 1 year with no activity.
Contribute more commits on the pull request and rebase it on the latest devel,
or it will be closed in 30 days. Thank you for your contributions.
close-pr-message: >
This pull request has been marked as stale and closed due to inactivity after 395 days.
# jobs:
# stale:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/stale@v10
# with:
# days-before-pr-stale: 365
# days-before-pr-close: 30
# days-before-issue-stale: -1
# days-before-issue-close: -1
# exempt-pr-labels: "ARC,bounty,Codegen,Crash,Generics,High Priority,Macros,Next release,Showstopper,Static[T]"
# exempt-issue-labels: "Showstopper,Severe,bounty,Compiler Crash,Medium Priority"
# stale-pr-message: >
# This pull request is stale because it has been open for 1 year with no activity.
# Contribute more commits on the pull request and rebase it on the latest devel,
# or it will be closed in 30 days. Thank you for your contributions.
# close-pr-message: >
# This pull request has been marked as stale and closed due to inactivity after 395 days.

View File

@@ -24,6 +24,9 @@ const
elif defined(useMalloc):
when defined(amd64): 16
else: 8
elif defined(gcRefc):
when defined(i386): 8
else: 16
else: 16
BitsPerPage = PageSize div MemAlign

View File

@@ -460,7 +460,7 @@ proc rawNewObj(typ: PNimType, size: int, gch: var GcHeap): pointer =
collectCT(gch)
# Use alignment from typ.base if available, otherwise use MemAlign
let alignment = if typ.kind == tyRef and typ.base != nil and
typ.base.align >= MemAlign: typ.base.align else: 0
typ.base.align > 16: typ.base.align else: 0
var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment))
#gcAssert typ.kind in {tyString, tySequence} or size >= typ.base.size, "size too small"
# Check that the user data (after the Cell header) is properly aligned
@@ -517,7 +517,7 @@ proc newObjRC1(typ: PNimType, size: int): pointer {.compilerRtl, noinline, raise
# Use alignment from typ.base if available, otherwise use MemAlign
let alignment = if typ.kind == tyRef and typ.base != nil and
typ.base.align >= MemAlign: typ.base.align else: 0
typ.base.align > 16: typ.base.align else: 0
var res = cast[PCell](rawAlloc(gch.region, size + sizeof(Cell), alignment))
sysAssert(allocInv(gch.region), "newObjRC1 after rawAlloc")
# Check that the user data (after the Cell header) is properly aligned