1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00
Commit graph

1403 commits

Author SHA1 Message Date
Ian Price
024bd93b0d modules should be passed current continuation
* module/language/js-il/runtime.js (primitive-load-path): modules
  should be passed the current continuation.
2017-08-11 14:02:13 +01:00
Ian Price
56439a88ae Add `guild jslink' to bundle JS programs
* module/Makefile.am (SOURCES): Install runtime.js and jslink.scm
* module/language/js-il/compile-javascript.scm (compile-exp):
  Compilation units take a continuation to facilitate linking.
* module/scripts/jslink.scm: New script.
2017-08-09 16:06:50 +01:00
Ian Price
7438a192f8 Unwind prompt frames
* module/language/js-il/runtime.js(unwind): Unwind prompts.
2017-08-03 00:26:02 +01:00
Ian Price
2da7a82d9d struct-set! primitive returns no values
* module/language/js-il/runtime.js (struct-set!): Don't return a value.
2017-08-03 00:23:45 +01:00
Ian Price
70c25b1290 Make child structs applicable.
* module/language/js-il/runtime.js (scheme.Struct): When certain flags
  are set, child structs should be marked as applicable.
2017-08-03 00:22:03 +01:00
Ian Price
46fa3b2fb8 Implement misc built-ins
* module/language/js-il/runtime.js
  (scm->u64): New primitive
  (integer?, char=?, make-fluid, read-hash-extend, make-hook,
  simple-format, scm-error): Implement built-ins.
  (syntax-session-id, macroexpand, %exception-handler,
  print-exception, *features*, %load-hook, current-reader): Stubbed
  variables.
2017-08-03 00:20:50 +01:00
Ian Price
3c62ab8185 Implement module built-ins.
* module/language/js-il/runtime.js
  (variable?): New Primitive.
  (primitive-load-path, module-local-variable, module-variable,
  %get-pre-modules-obarray, set-current-module): Implement built-ins.
2017-08-03 00:06:10 +01:00
Ian Price
3d29f2874f Implement procedure built-ins.
* module/language/js-il/runtime.js
  (procedure?, set-procedure-property!, make-procedure-with-setter): Implement.
2017-08-03 00:03:46 +01:00
Ian Price
bfaf07091a Implement hashtable built-ins
* module/language/js-il/runtime.js
  (scheme.HashTable): New Constructor.
  (make-hash-table, hash-clear!, hashq-remove!, hashq-ref, hashq-set!,
  hash-for-each): Implement built-ins.
2017-08-03 00:02:45 +01:00
Ian Price
30cc1e0751 scm_struct_init skips hidden fields.
* module/language/js-il/runtime.js (scm_struct_init): skip 'h' fields.
2017-08-02 22:55:00 +01:00
Ian Price
30dc57cb04 define! primitive only takes one argument.
* module/language/js-il/runtime.js (define!): Ignore argument.
2017-08-02 22:46:13 +01:00
Ian Price
ebe9d00153 Implement struct built-ins.
* module/language/js-il/runtime.js
  (struct?): New primitive.
  (<applicable-struct-vtable>, record-type-vtable,
  set-struct-vtable-name!, make-struct): Implement built-ins.
2017-08-02 22:44:27 +01:00
Ian Price
2273eb4d06 Implement built-in string procedures.
* module/language/js-il/runtime.js
  (string-append): Extend to more than 2 arguments.
  (string-join): New procedure.
2017-08-02 21:17:22 +01:00
Ian Price
2adebea5d0 Implement built-in symbol procedures.
* module/language/js-il/runtime.js
  (symbol->string, gensym): New procedures.
2017-08-02 21:14:57 +01:00
Ian Price
5d49a5be18 Implement built-in syntax procedures.
* module/language/js-il/runtime.js
  (syntax?, make-syntax, syntax-expression, syntax-wrap,
  syntax-module): New procedures.
2017-08-02 21:12:47 +01:00
Ian Price
2a3c43a5a9 Implement builtin list procedures.
* module/language/js-il/runtime.js
  (make-list, length, list?, reverse, append, memq, member, delete!):
  New procedures
2017-08-02 21:11:02 +01:00
Ian Price
0b9b08a28d Implement immediate version of vector primitives.
* module/language/js-il/runtime.js
  (make-vector/immediate, vector-set!/immediate,
  vector-ref/immediate): New Primitives.
2017-08-02 21:03:11 +01:00
Ian Price
cf1ddd466b Implement structs in runtime.js
* module/language/js-il/runtime.js:
  (scheme.Struct): new type.
  (allocate-struct/immediate, struct-vtable, struct-set!, struct-ref,
  struct-set!/immediate, struct-ref/immediate): Implement primitives.
  (def_guile_val): New helper.
  (string=?, string-append): Implement string functions.
  (standard-vtable-fields, <standard-vtable>, vtable-index-layout,
  vtable-index-printer, vtable-offset-user, make-struct/no-tail,
  make-vtable, struct-vtable?): Implement struct functions.
2017-06-28 17:15:57 +01:00
Ian Price
479294fc05 Implement Winding & Unwinding
* module/language/js-il/runtime.js
  (wind, unwind): Implement.
  (callcc): Wind when invoking continuation.
2017-06-28 15:03:03 +01:00
Ian Price
ff7fff920d Add macro type in runtime.js
* module/language/js-il/runtime.js
  (scheme.Macro): Add type.
  (make-syntax-transformer): Add guile procedure.
2017-06-28 10:38:00 +01:00
Ian Price
b3c0fcdb25 Implement cached-module-box
* module/language/js-il/runtime.js (scheme): Add module_cache field.
  (scheme.primitives) Add cached-module-box primitive.
  (def_guile0) Convenience for adding to (guile) module cache.
2017-06-22 16:59:02 +01:00
Ian Price
2204fb64f6 Add more variables to no-values-primitives
* module/language/js-il/inlining.scm (no-values-primitives):
  Add primitives
2017-06-20 23:12:09 +01:00
Ian Price
536d94feb3 Compile Syntax Objects to Javascript
* module/language/js-il/compile-javascript.scm (compile-const):
  Handle the new syntax object struct.
* module/language/js-il/runtime.js(scheme.Syntax): Add Syntax Object type
2017-06-20 22:50:06 +01:00
Ian Price
c2589b5c48 Rebuild nested scopes for js continuations
* module/language/cps/compile-js.scm (compile-cont, compile-clause):
  Rebuild nested scopes for $kargs, using dominator information.
  (compile-fun, compile-clauses): Pass down dominator information.
2017-06-20 19:05:59 +01:00
Ian Price
936050c657 Add some primitives to runtime.js
* module/language/js-il/runtime.js(add/immediate, sub/immediate,
  load-u64, u64-=-scm, handle-interrupts): Add primitives.
2017-06-16 21:48:27 +01:00
Ian Price
e771241020 JS-IL inliner has different count-calls for different clauses
* module/language/js-il/inlining.scm(inline-single-calls): Factor into
  another function inline-clause, so that count-calls is only called on
  the clause.
2017-06-16 17:42:49 +01:00
Ian Price
723fc850f6 Add #:js-inline? and #:js-flatten? debugging options
* module/language/js-il/compile-javascript.scm (compile-javascript):
  Check for #:js-inline? and #:js-flatten?, and turn off
  inline-single-calls and flatten-blocks respectively.
2017-06-15 22:34:39 +01:00
Ian Price
602bfb559d Update primitives in no-values-primitives
* module/language/js-il/inlining.scm (no-values-primitives): Update.
2017-06-15 20:25:24 +01:00
Ian Price
8777c20e94 Handle multiple conts in a function body
* module/language/cps/compile-js.scm (compile-clause, compile-clauses):
  Extract all conts in the function body, and bind in clauses.
  (extract-and-compile-conts): New Procedure
2017-06-15 20:21:47 +01:00
Ian Price
0e4fb0920f compile-js uses the new cps representation
* module/language/cps/compile-js.scm: Rewrite to use cps
2017-06-14 23:07:40 +01:00
Ian Price
23f829b175 Fix build of (language cps compile-js)
* module/language/cps/compile-js.scm (compile-js): Use lower-cps
  from (language cps compile-bytecode) rather than optimize, which is no
  longer there.
2017-06-14 21:27:05 +01:00
Ian Price
1b36a76ea4 Merge branch 'stable-2.2' into compile-to-js-2017 2017-06-14 21:13:10 +01:00
Andy Wingo
64c5cc58fc Add disjoint syntax object type
* libguile/Makefile.am (libguile_@GUILE_EFFECTIVE_VERSION@_la_SOURCES):
  (DOT_X_FILES, DOT_DOC_FILES, noinst_HEADERS): Add syntax.c and
  syntax.h.
* libguile/evalext.c (scm_self_evaluating_p):
* libguile/goops.c (class_syntax, scm_class_of, scm_goops_early_init):
* libguile/init.c (scm_init_guile):
* libguile/print.c (iprin1):
* libguile/tags.h (scm_tc7_syntax):
* module/oop/goops.scm (<syntax>):
* module/system/base/types.scm (%tc7-syntax, cell->object):
* module/system/vm/disassembler.scm (code-annotation): Wire up the new
  data type.
* libguile/syntax.c:
* libguile/syntax.h: New files.
* module/ice-9/boot-9.scm: Move new definitions to (system syntax
  internal).
* module/system/syntax.scm (print-syntax): New helper.
* module/system/vm/assembler.scm (statically-allocatable?)
  (intern-constant, link-data): Arrange to be able to write syntax
  objects into images.
* module/language/cps/types.scm (&syntax): New type.  Remove
  &hash-table; it was never detected, an internal binding, and we need
  the bit to avoid going into bignum territory.
2017-03-28 19:23:13 +02:00
Andy Wingo
0543ec96b2 Nonlocal prompt returns cause all effects
* module/language/cps/effects-analysis.scm (expression-effects): Prompts
  cause &all-effects.  I tried to limit this change to CSE but it was
  actually LICM that was borked, so better to be conservative
* test-suite/tests/control.test ("escape-only continuations"): Add
  test.
2017-03-13 22:20:16 +01:00
Andy Wingo
c525aa6d95 VM support for string-set!; slimmer read-string
* doc/ref/vm.texi (Inlined Scheme Instructions): Add string-set!.
* libguile/vm-engine.c (string-set!): New opcode.
* module/ice-9/rdelim.scm (read-string): Reimplement in terms of a
  geometrically growing list of strings, to reduce total heap usage when
  reading big files.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  string-set! support.
* module/language/cps/types.scm (string-set!): Update for &u64 index.
* module/language/tree-il/compile-cps.scm (convert): Unbox index to
  string-set!.
* module/system/vm/assembler.scm (system): Export string-set!.
2017-03-09 17:24:06 +01:00
Daniel Llorens
7de77bf7d8 Fix bug in comparison between real and complex
This bug was introduced by 35a9059250.

* module/language/cps/specialize-numbers.scm (specialize-operations):
  Check that both operands are real as a condition for
  specialize-f64-comparison.
* test-suite/tests/numbers.test: Add test.
2017-03-09 15:17:35 +01:00
Andy Wingo
7cdfaaada9 Remove contification restriction in case-lambda
* module/language/cps/compile-bytecode.scm (compile-function): Check for
  fallthrough after $kclause too; possible to need to jump if clause
  tails are contified.
* module/language/cps/contification.scm (compute-contification-candidates):
  Enable inter-clause contification.
2017-03-09 14:47:42 +01:00
Andy Wingo
6d9335ad46 All clauses of function have same nlocals
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/slot-allocation.scm ($allocation)
  (lookup-nlocals, compute-frame-size, allocate-slots): Adapt to
  have one frame size per function, for all clauses.
2017-03-09 14:25:37 +01:00
Mark H Weaver
84a740d86a psyntax: Generate identifiers in a deterministic fashion.
Fixes <http://bugs.gnu.org/20272>.

* module/ice-9/boot-9.scm (module-generate-unique-id!)
(module-gensym): New procedures.
(module): Add 'next-unique-id' field.
(the-root-module): Inherit 'next-unique-id' value from early stub.
(make-module, make-autoload-interface): Adjust calls to
module-constructor.
* module/ice-9/psyntax.scm (gen-label, new-mark): Generate unique
identifiers from the module name and the per-module unique-id.
(build-lexical-var, generate-temporaries): Use
'module-gensym' instead of 'gensym'.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/language/tree-il/fix-letrec.scm (fix-letrec!): Use
'module-gensym' instead of 'gensym'.
* module/system/base/syntax.scm (define-record): Likewise.
(transform-record): Likewise.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2017-03-07 20:48:40 +01:00
Andy Wingo
f261eaf03a Fix guild compile --to=cps / --from=cps
* module/language/cps/spec.scm (read-cps, write-cps): Fix CPS
  serialization and parsing, so that "guild compile" works with --to=cps
  and --from=cps.
2017-02-23 11:37:44 +01:00
Andy Wingo
23278d07de Fix kfun parse-cps bug
* module/language/cps.scm (parse-cps): Fix bug parsing kfun.
2017-02-23 11:37:06 +01:00
Andy Wingo
d0811644f6 Fix flonum/complex type inference.
* module/language/cps/types.scm (define-binary-result!): Arithmetic
  where one argument is a flonum may produce a complex.
* test-suite/tests/compiler.test: Add test.
2017-02-19 12:11:07 +01:00
David Thompson
35a9059250 Add unboxed floating point comparison instructions.
* libguile/vm-engine.c (BR_F64_ARITHMETIC): New preprocessor macro.
(br_if_f64_ee, br_if_f64_lt, br_if_f64_le, br_if_f64_gt, br_if_f64_ge):
New VM instructions.
* doc/ref/vm.texi ("Unboxed Floating-Point Arithmetic"): Document them.
* module/language/cps/compile-bytecode.scm (compile-function): Emit f64
comparison instructions.
* module/language/cps/effects-analysis.scm: Define effects for f64
primcalls.
* module/language/cps/primitives.scm (*branching-primcall-arities*): Add
arities for f64 primcalls.
* module/language/cps/specialize-numbers.scm (specialize-f64-comparison):
New procedure.
(specialize-operations): Specialize f64 comparisons.
* module/system/vm/assembler.scm (emit-br-if-f64-=, emit-br-if-f64-<)
(emit-br-if-f64-<=, emit-br-if-f64->, emit-br-if-f64->=): Export.
* module/system/vm/disassembler.scm (code-annotation): Add annotations
for f64 comparison instructions.
2017-01-12 09:27:43 -05:00
Andy Wingo
0ce8a9a5e0 Improve handle-interrupts placement
* module/language/cps/handle-interrupts.scm (compute-safepoints): New
  function.
  (add-handle-interrupts): Add safepoints at backedge targets, not
  backedges.  Gives better register allocation, loop rotation, and code
  size.
2016-12-18 23:05:15 +01:00
Andy Wingo
2660c0b3c8 Fix bug in compute-significant-bits for phi predecessors
* module/language/cps/specialize-numbers.scm (compute-significant-bits):
  Always revisit predecessors after first visit.  Avoids situation where
  predecessor of an unvisited phi var could default to 0 significant
  bits and never be revisited.  Fixes (format #f "~2f" 9.9).
2016-12-14 17:45:26 +01:00
Andy Wingo
7184c176b4 with-dynamic-state compiler and VM support
* libguile/dynstack.h (SCM_DYNSTACK_TYPE_DYNAMIC_STATE):
* libguile/dynstack.c (DYNAMIC_STATE_WORDS, DYNAMIC_STATE_STATE_BOX):
  (scm_dynstack_push_dynamic_state):
  (scm_dynstack_unwind_dynamic_state): New definitions.
  (scm_dynstack_unwind_1, scm_dynstack_wind_1): Add with-dynamic-state
  cases.
* libguile/memoize.c (push_dynamic_state, pop_dynamic_state)
  (do_push_dynamic_state, do_pop_dynamic_state): New definitions.
  (memoize, scm_init_memoize): Handle push-dynamic-state and
  pop-dynamic-state.
* libguile/vm-engine.c (push-dynamic-state, pop-dynamic-state): New
  opcodes.
* module/ice-9/boot-9.scm (with-dynamic-state): New definition in Scheme
  so that the push-dynamic-state and pop-dynamic-state always run in the
  VM.
* module/language/cps/compile-bytecode.scm (compile-function):
* module/language/cps/effects-analysis.scm:
* module/language/cps/types.scm:
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/peval.scm (peval):
* module/language/tree-il/primitives.scm (*interesting-primitive-names*):
* module/system/vm/assembler.scm: Add support for with-dynamic-state to
  the compiler.
* test-suite/tests/fluids.test ("dynamic states"): Add basic tests.
* doc/ref/vm.texi (Dynamic Environment Instructions): Update.
2016-12-05 22:57:29 +01:00
Andy Wingo
8bd5dae8c3 Compile fluid-set! to VM opcode
* libguile/vm-engine.c (fluid-set!): Fix name of opcode to correspond
  with name of Tree-IL primitive.  Fixes compilation of fluid-set! to
  actually use the fluid-set! opcode.
* doc/ref/vm.texi (Dynamic Environment Instructions): Update.
* module/language/cps/compile-bytecode.scm (compile-function): Add
  fluid-set! case.
* module/system/vm/assembler.scm: Update export name for
  emit-fluid-set!.
2016-11-27 21:55:42 +01:00
Andy Wingo
ca74e3fae5 Add handle-interrupts inst and compiler pass
* libguile/vm-engine.c (vm_engine): Remove initial VM_HANDLE_INTERRUPTS
  call; surely our caller already handled interrupts.  Add
  handle-interrupts opcode.
* am/bootstrap.am (SOURCES):
* module/Makefile.am (SOURCES): Add handle-interrupts.scm.
* module/system/vm/assembler.scm (system):
* module/language/cps/compile-bytecode.scm (compile-function):
  (lower-cps): Add handle-interrupts support.
* module/language/cps/handle-interrupts.scm: New file.
2016-11-16 22:55:45 +01:00
Julian Graham
9807d2dced Fix tree-il code generation for ECMAscript `new' expression.
The compiler was producing `((toplevel foo))' instead of `(toplevel foo)'.
Changed to use `call' form with target type and spliced constructor
arguments.

* module/language/ecmascript/compile-tree-il.scm (comp): Replace `@impl'
  shorthand with `call' + `@implv' for better control over resulting
  tree-il.
* test-suite/tests/ecmascript.test (compiler): Add test for "new Object();"

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2016-10-25 23:39:30 +02:00
Andy Wingo
d74e0fed0d Move thread bindings to (ice-9 threads)
* libguile/init.c (scm_i_init_guile): Don't call scm_init_thread_procs.
* libguile/threads.c (scm_init_ice_9_threads): Rename from
  scm_init_thread_procs, make static.
  (scm_init_threads): Register scm_init_thread_procs extension.
* libguile/threads.h (scm_init_thread_procs): Remove decl.
* module/ice-9/boot-9.scm: Load (ice-9 threads), so that related side
  effects occur early.
* module/ice-9/deprecated.scm (define-deprecated): Fix to allow
  deprecated bindings to appear in operator position.  Export deprecated
  bindings.
  (define-deprecated/threads, define-deprecated/threads*): Trampoline
  thread bindings to (ice-9 threads).
* module/ice-9/futures.scm: Use ice-9 threads.
* module/ice-9/threads.scm: Load scm_init_ice_9_threads extension.
  Reorder definitions and imports so that the module circularity
  with (ice-9 futures) continues to work.
* module/language/cps/intmap.scm:
* module/language/cps/intset.scm:
* module/language/tree-il/primitives.scm: Use (ice-9 threads).
* module/language/cps/reify-primitives.scm: Reify current-thread
  in (ice-9 threads) module.
* module/srfi/srfi-18.scm: Use ice-9 threads with a module prefix, and
  adapt all users.  Use proper keywords in module definition form.
* test-suite/tests/filesys.test (test-suite):
* test-suite/tests/fluids.test (test-suite):
* test-suite/tests/srfi-18.test: Use ice-9 threads.
* NEWS: Add entry.
* doc/ref/api-scheduling.texi (Threads): Update.
* doc/ref/posix.texi (Processes): Move current-processor-count and
  total-processor-count docs to Threads.
2016-10-23 22:29:44 +02:00