1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00
Commit graph

21194 commits

Author SHA1 Message Date
Ludovic Courtès
2aed3c117c psyntax: Pass source vectors to tree-il constructors.
Avoiding systematic conversion from source vectors to property alists
saves 20% on the final heap size of a process doing:

  (compile-file FILE #:optimization-level 1)

where FILE is large.

* module/language/tree-il.scm (tree-il-src/ensure-alist): New procedure
with setter.  Export as 'tree-il-src'.
* module/ice-9/psyntax.scm (build-void, build-call)
(build-conditional, build-lexical-reference, build-lexical-assignment)
(build-global-reference, build-global-assignment)
(build-global-definition, build-simple-lambda, build-case-lambda)
(build-lambda-case, build-primcall, build-primref)
(build-data, build-sequence, build-let, build-named-let)
(build-letrec, expand-body): Remove (sourcev->alist src) calls.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): Use
'tree-il-src' instead of accessing the 'src' slot directly.
* module/system/vm/assembler.scm (link-debug): Adjust so PC can be
followed by a vector or an alist.
2022-02-07 12:23:35 +01:00
Ludovic Courtès
032acdeac9 'string->symbol' avoids copying the underlying string.
* libguile/strings.c (scm_i_make_symbol): Reuse NAME's stringbuf unless
it's mutable or NAME starts at a non-zero offset or has a different
length.
2022-02-07 12:23:35 +01:00
Andy Wingo
2f9bc7fe61 Update unicode tables to Unicode 14.0.0; initial charsets immutable
* libguile/srfi-14.i.c: Update from Unicode 14.0.0.
* libguile/unidata_to_charset.pl (compute): Write arrays as static const
data, to avoid polluting the namespace and to avoid adding these to the
GC root set.
* libguile/srfi-14.c (SCM_CODEPOINT_F_IMMUTABLE): New flag.
(scm_charset_is_immutable): New internal predicate.
(SCM_VALIDATE_MUTABLE_CHARSET): New internal validator.
(cs_full_ranges, cs_full_ranges_len): Re-express as separate ranges and
len, because the ranges pointer in scm_t_char_set is mutable.
(scm_char_set_unfold_x, scm_list_to_char_set_x)
(scm_string_to_char_set_x, scm_char_set_filter_x)
(scm_i_ucs_range_to_char_set, scm_char_set_adjoin_x)
(scm_char_set_delete_x, scm_char_set_complement_x)
(scm_char_set_unfold_x, scm_char_set_intersection_x)
(scm_char_set_difference_x, scm_char_set_xor_x): Require mutable
charsets.
(define_charset): Add immutable flag.
(scm_init_srfi_14): Adapt initial charset definitions.
2022-02-06 21:17:24 +01:00
Andy Wingo
7e3470343a NEWS fixup
* NEWS: Remove duplicate word.
2022-02-06 20:18:19 +01:00
Ludovic Courtès
8e2e2ceb17 Deprecate symbol properties.
* libguile/strings.c (scm_i_make_symbol): Remove 'props' argument.  Use
3 words instead of 'scm_double_cell'.
* libguile/strings.h: Adjust accordingly.
* libguile/symbols.c (scm_i_str2symbol, scm_i_str2uninterned_symbol):
Likewise.
(scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x,
scm_symbol_pset_x): Move to...
* libguile/deprecated.c: ... here.  Rewrite in terms of object
properties.
(symbol_function_slot, symbol_property_slot): New variables.
* libguile/symbols.h (SCM_SYMBOL_FUNC, SCM_SET_SYMBOL_FUNC)
(SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS)
(scm_symbol_fref, scm_symbol_pref, scm_symbol_fset_x)
(scm_symbol_pset_x): Move to...
* libguile/deprecated.h: ... here.  Mark declarations as 'SCM_DEPRECATED'.
* module/system/base/types.scm (cell->object): Remove 'props' field for
%TC7-SYMBOL.
* doc/ref/api-data.texi (Symbol Props): Remove.
* NEWS: Update.
2022-02-04 11:12:28 +01:00
Ludovic Courtès
2ebf039707 Remove unused 'scm_i_c_make_symbol'.
* libguile/strings.c (scm_i_c_make_symbol): Remove.
* libguile/strings.h (scm_i_c_make_symbol): Remove declaration.
2022-02-03 23:23:59 +01:00
Andy Wingo
4e92f1d7cc Update NEWS
* NEWS: Update.
2022-02-02 20:53:46 +01:00
Andy Wingo
62fc44e6ee Slight bignum-fixnum multiplication optimization
* libguile/integers.c (scm_integer_mul_zi): Use mpn_mul_1.
2022-02-01 19:57:14 +01:00
Andy Wingo
54bbe0b284 Avoid source properties in psyntax
* module/ice-9/psyntax.scm (source-annotation): Only return source
properties from syntax objects.
(source-wrap): Don't look for source properties.
(expand-macro): Rebuild source properties on macro output via
source-wrap, not source properties.  Only annotate head of a chain of
pairs.
(strip): Here's the only use of set-source-properties!: when stripping
a syntax object to a datum.
(macroexpand): If the input expression is not a syntax object, eagerly
extract its source properties.
(datum->syntax): Fix case in which source is given as an alist.
* module/ice-9/psyntax-pp.scm: Regenerate.
2022-02-01 18:26:41 +01:00
Andy Wingo
e933282f2b Prebuild fewer files
* prebuilt/i686-pc-linux-gnu/Makefile.am:
* prebuilt/mips-unknown-linux-gnu/Makefile.am:
* prebuilt/x86_64-unknown-linux-gnu/Makefile.am: Only prebuild eval.go,
psyntax-pp.go, and boot-9.go.  The builder can handle the rest.
Otherwise the tarball size would explode, given the expansion in
bootstrap.am.
2022-02-01 14:50:44 +01:00
Andy Wingo
9654ab1f21 Fix reproducibility for inlinable-exports
* module/language/tree-il/inlinable-exports.scm (compute-decoder): Map
items in order of their code.
2022-02-01 14:50:44 +01:00
Andy Wingo
9b9149a5bf Rework bootstrap to be reproducible
* configure.ac:
* Makefile.am (SUBDIRS): Replace bootstrap/ with stage0, stage1, and
stage2.
* am/bootstrap.am: Include all files and all rules.
* meta/build-env.in (GUILE_AUTO_COMPILE): Always turn off
auto-compilation.  Take a GUILE_BOOTSTRAP_STAGE argument, which can be
stage0, stage1, stage2, or unset.  Adapt the load-compiled path
accordingly.
* meta/uninstalled-env.in: Include .go files from stage2.
* module/Makefile.am: Rework to use boostrap.am.
* module/system/base/optimize.scm (available-optimizations): Punt the
inlinable-exports machinery to -O2.
* stage0/Makefile.am:
* stage1/Makefile.am:
* stage2/Makefile.am: New files.
2022-02-01 14:50:40 +01:00
Andy Wingo
6ed66f42cb Add -ftlo support
* configure.ac: Check if the compiler supports link-time optimization.
If it does, turn it on.  Saves around 15% off libguile binary size.
Controllable via --enable-lto configure option.
2022-01-29 15:49:43 +01:00
Andy Wingo
373f35b5f7 peval cross-module-inlining gracefully handles missing interface
* module/language/tree-il/peval.scm (peval): The intention was for
resolve-interface to return an interface only if it exists, but actually
it throws if the interface isn't know.  Fix to do what we intended to
do.
2022-01-17 21:25:08 +01:00
Andy Wingo
d01ab7bf5c Fix inlinable-exports bug for pure modules
* module/language/tree-il/inlinable-exports.scm (compute-decoder): Fix
bug in which inlinable exports in a pure module would have a missing
make-struct/no-tail binding.
2022-01-17 21:07:22 +01:00
Andy Wingo
222b320868 Remove dead code in scm_integer_inexact_sqrt_z
* libguile/integers.c (scm_integer_inexact_sqrt_z): Remove some dead
code.
2022-01-13 09:37:17 +01:00
Daniel Llorens
19bc021e34 Have log and log10(real nan) return real nan regardless of sign
* libguile/numbers.c (log_of_shifted_double, scm_log10): Avoid complex
  extension when the argument is a real nan.
* test-suite/tests/numbers.test: Tests for nans of either sign.
2022-01-13 09:37:17 +01:00
Daniel Llorens
4feff820be Don't use HAVE_COPYSIGN in libguile/numbers.c
* libguile/numbers.c (icmplx2str): As stated. copysign() is required by C99 and
  already used without guards elsewhere in this file.
2022-01-13 09:37:17 +01:00
Daniel Llorens
6058d9e05d Simplify scm_abs for the real case
* libguile/numbers.c (scm_abs): As stated. When x is a nan with the sign bit
  set, this changes the behavior of (magnitude x) back to what it was in 3.0.7,
  to clear that bit.
2022-01-13 09:37:17 +01:00
Andy Wingo
9e5aa173c7 Optimize logand against a positive inum
* libguile/integers.c (scm_integer_logand_zi): Optimize.
2022-01-13 09:37:17 +01:00
Andy Wingo
6fe43301aa Optimize integer-expt for fixnums
* libguile/integers.c (scm_integer_expt_ii): Add some optimizations for
cases in which we can avoid allocating an mpz.
2022-01-13 09:37:17 +01:00
Andy Wingo
2cf80ca238 Optimize scm_integer_mul_ii
* libguile/integers.c (make_bignum_2): Always include.
(scm_integer_mul_ii): Avoid making a temporary allocation.
2022-01-13 09:37:17 +01:00
Andy Wingo
210ab8ff76 Optimize bignum subtraction
* libguile/integers.c (scm_integer_sub_iz):
(scm_integer_sub_zi):
(scm_integer_sub_zz): Optimize to avoid temporary allocations.
2022-01-13 09:37:17 +01:00
Andy Wingo
cc52f01aba Optimize bignum add to avoid temporary allocations
* libguile/integers.c (do_add_1, do_add, do_sub_1, do_sub, do_cmp): New
helpers.
(scm_integer_add_zi):
(scm_integer_add_zz): Use new helpers.
2022-01-13 09:37:17 +01:00
Andy Wingo
95350aae8c Avoid bignum clone in scm_integer_sub_zz
* libguile/integers.c (scm_integer_abs_z): Just call
scm_integer_negate_z if negation is needed.
(scm_integer_sub_zz): Use mpz_sub instead of cloning bignum.
2022-01-13 09:37:17 +01:00
Andy Wingo
cae8b30163 Start to optimize scm_integer_sub_iz
* libguile/integers.c (scm_integer_sub_iz): Avoid cloning bignum.
2022-01-13 09:37:17 +01:00
Andy Wingo
2723513712 Less pessimal scm_integer_sub_zi
* libguile/integers.c (scm_integer_sub_zi): Only delegate to
scm_integer_add_ii if y is negative.
2022-01-13 09:37:17 +01:00
Andy Wingo
ad6811a12b Optimize scm_integer_mul_zz.
* libguile/integers.c (scm_integer_mul_zz): Optimize to avoid temporary
allocations.
2022-01-13 09:37:17 +01:00
Andy Wingo
d89f75c535 Optimize scm_integer_mul_zi
* libguile/integers.c (bignum_trim1):
(bignum_negate_if): New helpers.
(scm_integer_mul_zi): Use the mpn API to avoid temporary allocation.
2022-01-13 09:37:17 +01:00
Andy Wingo
5481222670 Re-rewrite integer-expt in C
Calling out to Scheme was a performance regression.

* libguile/integers.h:
* libguile/integers.c (scm_integer_expt_ii, scm_integer_expt_zi): New
internal functions.
* libguile/numbers.c (scm_integer_expt): Go back to C.  But, include
fast cases for inums and doubles.
* module/ice-9/boot-9.scm: Revert addition of integer-expt.
2022-01-13 09:37:17 +01:00
Andy Wingo
eac47c3e45 Fix bug when making mpz from 0
* libguile/integers.c (make_bignum_0): New helper.
(make_bignum_from_uint64):
(ulong_to_bignum):
(long_to_bignum): Call new helper as appropriate.
2022-01-13 09:37:17 +01:00
Andy Wingo
443d239828 take_mpz optimization
* libguile/integers.c (take_mpz): Avoid making a bignum if the value is
fixable.
2022-01-13 09:37:17 +01:00
Andy Wingo
aa5455ea98 Bignums avoid both custom GMP allocator and finalizers
* libguile/deprecated.c (make_bignum): Move here from numbers.c, to
support scm_i_long2big etc.
(scm_i_big2dbl):
(scm_i_long2big):
(scm_i_ulong2big):
(scm_i_clonebig):
(scm_i_normbig): Deprecate.
(scm_install_gmp_memory_functions): Deprecate, happily!  SCM bignums now
have digits allocated inline with the bignum itself, so they are
completely transparent to the GC already.  The price is that if GMP ever
allocates digits via the MPZ API, those digits then have to be copied
back into managed memory.  But we avoid having to install finalizers and
we avoid having to muck with GMP's allocator.
* libguile/numbers.c (scm_from_mpz): Use scm_integer_from_mpz.
(scm_init_numbers): Never muck with GMP's allocators.
* doc/ref/guile-invoke.texi (Environment Variables): Remove note about
GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
* meta/build-env.in: No need to set GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
2022-01-13 09:37:17 +01:00
Andy Wingo
a0765f564a scm_to_ipv6 uses scm_to_mpz
* libguile/socket.c (scm_to_ipv6): Use scm_to_mpz.
2022-01-13 09:37:17 +01:00
Andy Wingo
e78bcdc29a Finish srfi-60 port off old scm mpz API
* libguile/srfi-60.c (scm_srfi60_rotate_bit_field)
(scm_srfi60_reverse_bit_field, scm_srfi60_integer_to_list)
(scm_srfi60_list_to_integer): Update.
2022-01-13 09:37:17 +01:00
Andy Wingo
399d0c8745 Start porting srfi-60 off the bad bignum interfaces
* libguile/integers.h:
* libguile/integers.c (scm_integer_scan1_i):
(scm_integer_scan1_z): New internal functions.
* libguile/srfi-60.c (scm_srfi60_log2_binary_factors): Use scan1
functions.
(scm_srfi60_copy_bit): Use integers lib.
2022-01-13 09:37:17 +01:00
Andy Wingo
bdddef3cfd Avoid scm_i_mkbig outside numbers.c.
* libguile/random.c (scm_c_random_bignum):
* libguile/socket.c (scm_from_ipv6): Avoid scm_i_mkbig.
* libguile/numbers.h:
* libguile/numbers.c (scm_i_mkbig): Remove.
2022-01-13 09:37:17 +01:00
Andy Wingo
0c502a4d3c Use scm_integer_to_double_z in numbers.c instead of big2dbl
* libguile/numbers.c: Use internal function instead of big2dbl which we
will deprecate.
2022-01-13 09:37:17 +01:00
Andy Wingo
7029a9c491 Simplify magnitude, angle
* libguile/numbers.c (scm_i_inum2big): Remove.
(scm_magnitude): Delegate to abs.
(scm_angle): Simplify.
2022-01-13 09:37:17 +01:00
Andy Wingo
3d56a90736 Remove last non-admin SCM_I_BIG_MPZ uses in numbers.c
* libguile/numbers.c (scm_magnitude, scm_angle): Use integers lib.
2022-01-13 09:37:17 +01:00
Andy Wingo
a4524da8c1 Simplify scm_exact_integer_quotient
* libguile/integers.h:
* libguile/integers.c (scm_integer_exact_quotient_iz): New internal
function.
* libguile/numbers.c (scm_i_make_ratio): Simplify and enforce
invariants.
(scm_exact_integer_quotient): Use integer lib.
2022-01-13 09:37:17 +01:00
Andy Wingo
0754dbf3e8 divide2double refactor
* libguile/integers.c (scm_integer_set_mpz_z): New internal function.
(scm_integer_init_set_mpz_z): Rename from scm_integer_to_mpz_z.
* libguile/integers.h:
* libguile/numbers.c (scm_i_divide2double): Avoid SCM_I_BIG_MPZ.
2022-01-13 09:37:17 +01:00
Andy Wingo
c06fc3df54 Remove dead bignum frexp code from numbers.c
* libguile/numbers.c (scm_i_big2dbl_2exp): Remove unused function.
2022-01-13 09:37:17 +01:00
Andy Wingo
f167627bb0 Expose frexp from integers lib
* libguile/integers.h:
* libguile/integers.c (scm_integer_frexp_z): Expose internally.
(scm_integer_to_double_z):
(scm_integer_inexact_sqrt_z): Adapt uses.
* libguile/numbers.c (log_of_exact_integer): Use exposed
scm_integer_frexp_z.
2022-01-13 09:37:17 +01:00
Andy Wingo
124d889227 Refactor scm_sqrt in terms of integers.[ch]
* libguile/integers.h:
* libguile/integers.c (scm_is_integer_perfect_square_i):
(scm_is_integer_perfect_square_z):
(scm_integer_floor_sqrt_i):
(scm_integer_floor_sqrt_z):
(scm_integer_inexact_sqrt_i):
(scm_integer_inexact_sqrt_z): New internal functions.
* libguile/numbers.c (scm_sqrt): Reimplement.
2022-01-13 09:37:17 +01:00
Andy Wingo
63a18a6c1a Reimplement exact-integer-sqrt with integers.[ch]
* libguile/numbers.c (scm_exact_integer_sqrt): Call out.
* libguile/integers.h:
* libguile/integers.c (scm_integer_exact_sqrt_i):
(scm_integer_exact_sqrt_z): New internal functions.
2022-01-13 09:37:17 +01:00
Andy Wingo
9a91c20a55 scm_to_mpz uses integer lib
* libguile/integers.h:
* libguile/integers.c (scm_integer_to_mpz_z): New internal function.
* libguile/numbers.c (scm_to_mpz): Use new function.
2022-01-13 09:37:17 +01:00
Andy Wingo
debcccc215 Remove unused conv-{u,}integer.i.c
* libguile/Makefile.am (noinst_HEADERS):
* libguile/conv-integer.i.c:
* libguile/conv-uinteger.i.c: Remove.
2022-01-13 09:37:17 +01:00
Andy Wingo
106c5de5fc Implement scm_{to,from}_wchar inline
* libguile/numbers.c (scm_to_wchar, scm_from_wchar): Implement inline.
2022-01-13 09:37:17 +01:00
Andy Wingo
1802ed17b3 Reimplement scm_{to,from}_{int64,uint64}
* libguile/numbers.c (scm_to_int64, scm_from_int64, scm_to_uint64):
(scm_from_uint64): Reimplement inline.
2022-01-13 09:37:17 +01:00