summaryrefslogtreecommitdiff
path: root/module/language/assembly
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08Remove assembly language.Andy Wingo4-528/+0
* module/system/repl/command.scm: Remove disassembly cases for stack procedures. * module/system/vm/inspect.scm: Adapt to disassemble RTL programs. * module/language/assembly.scm: * module/language/assembly/compile-bytecode.scm: * module/language/assembly/decompile-bytecode.scm: * module/language/assembly/disassemble.scm: * module/language/assembly/spec.scm: Remove assembly language. * module/Makefile.am: Adapt.
2013-01-31Merge remote-tracking branch 'origin/stable-2.0'Andy Wingo1-1/+2
Conflicts: module/ice-9/psyntax-pp.scm module/ice-9/psyntax.scm module/language/bytecode/spec.scm module/language/tree-il/spec.scm
2013-01-27Add 'for-humans?' flag to <language> specifications.Mark H Weaver1-1/+2
* module/system/base/language.scm (<language>): Add 'for-humans?' field, and export new 'language-for-humans?' predicate. * doc/ref/compiler.texi (Compiler Tower): Document. * module/language/assembly/spec.scm, module/language/bytecode/spec.scm, module/language/glil/spec.scm, module/language/objcode/spec.scm, module/language/tree-il/spec.scm, module/language/value/spec.scm: Mark these languages as 'for-humans?'.
2013-01-23merge stable-2.0Andy Wingo3-4/+27
There are some bugs with command-line handling that will be sorted out with the next commit.
2013-01-14case-lambda* clauses fail to match if too many positionalsAndy Wingo3-4/+27
* doc/ref/api-procedures.texi (Case-lambda): Expand case-lambda* documentation. * module/ice-9/eval.scm (primitive-eval): * libguile/eval.c (prepare_boot_closure_env_for_apply): Dispatch to the next case-lambda clause if there are too many positionals. * doc/ref/vm.texi (Function Prologue Instructions): * libguile/vm-i-system.c (bind-optionals/shuffle-or-br): New instruction, like bind-optionals/shuffle but can dispatch to the next clause if there are too many positionals. * module/language/assembly/disassemble.scm (code-annotation): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add case for bind-optionals/shuffle-or-br. * module/language/glil/compile-assembly.scm (glil->assembly): If there is an alternate, use bind-optionals/shuffle-or-br instead of bind-optionals/shuffle. * test-suite/tests/optargs.test ("case-lambda*"): Add tests.
2012-03-05Merge branch 'bt/elisp'BT Templeton2-1/+5
Conflicts: am/guilec libguile/_scm.h libguile/vm-i-scheme.c module/language/elisp/compile-tree-il.scm module/language/elisp/runtime.scm module/language/elisp/runtime/macros.scm module/language/tree-il/compile-glil.scm module/language/tree-il/primitives.scm
2012-02-03add `nil?' primitiveBT Templeton2-1/+5
* libguile/boolean.c (scm_nil_p): New function. * libguile/vm-i-scheme.c (nilp, not_nilp): * libguile/vm-i-system.c (br_if_nil, br_if_not_nil): New instructions. Renumber other ops. * libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Increment. * module/language/assembly/compile-bytecode.scm (compile-bytecode): Add support for writing `br-if-nil' and `br-if-not-nil' instructions. * module/language/assembly/disassemble.scm (code-annotation): Add `br-if-nil' and `br-if-not-nil' to the list of branch instructions. * module/language/tree-il/compile-glil.scm: Add `nil?' to `*primcall-ops*'. (flatten): Use the new branch instructions for `nil?' conditionals. * module/language/tree-il/primitives.scm: Add `nil?' to `*interesting-primitive-names*', `*effect-free-primitives', and `*effect+exception-free-primitives*'.
2012-01-25better function prologue disassemblyAndy Wingo1-1/+4
* module/language/assembly/disassemble.scm (code-annotation): Add an annotation for assert-nargs-ee/locals and assert-nargs-ge/locals.
2011-09-02more define-syntax-rule usageAndy Wingo1-10/+8
* module/ice-9/boot-9.scm: * module/ice-9/control.scm: * module/ice-9/futures.scm: * module/ice-9/optargs.scm: * module/ice-9/poll.scm: * module/ice-9/receive.scm: * module/ice-9/threads.scm: * module/ice-9/vlist.scm: * module/language/assembly/compile-bytecode.scm: * module/language/ecmascript/compile-tree-il.scm: * module/language/tree-il.scm: * module/oop/goops.scm: * module/oop/goops/simple.scm: * module/oop/goops/stklos.scm: * module/srfi/srfi-1.scm: * module/srfi/srfi-35.scm: * module/srfi/srfi-39.scm: * module/srfi/srfi-45.scm: * module/srfi/srfi-67/compare.scm: * module/sxml/match.scm: * module/system/repl/error-handling.scm: * module/system/repl/repl.scm: * module/system/vm/inspect.scm: * module/texinfo.scm: * module/web/server.scm: Use define-syntax-rule, where it makes sense.
2011-05-31compile-bytecode uses target-endiannessAndy Wingo1-5/+7
* module/language/assembly/compile-bytecode.scm (compile-bytecode): Use target-endianness, from (system base target).
2011-05-05speed up compile-bytecodeAndy Wingo1-102/+135
* module/language/assembly/compile-bytecode.scm (compile-bytecode): Rewrite to fill a bytevector directly, instead of using bytevector ports. `write-bytecode' itself is still present and almost the same as before; it's just that `write-byte' et al now inline the effect of writing a byte to a binary port. * test-suite/tests/asm-to-bytecode.test (comp-test): Refactor to use public interfaces.
2011-02-18core modules use (ice-9 binary-ports) instead of (rnrs io ports)Andy Wingo1-1/+5
* module/language/assembly/compile-bytecode.scm: * module/language/elisp/lexer.scm: * module/web/request.scm: * module/web/response.scm: * module/web/server.scm: * module/web/uri.scm: Use ice-9 binary-ports.
2010-10-01add source:line-for-user, returning a 1-indexed line numberAndy Wingo1-1/+1
* module/system/vm/program.scm (source:line-for-user): New exported procedure, returns a 1-indexed line, suitable for presentation to a user. (write-program): Use source:line-for-user when making fallback names. * module/system/vm/coverage.scm (coverage-data->lcov): * module/language/assembly/disassemble.scm (source->string): * module/system/repl/debug.scm (print-frame): Use source:line-for-user.
2010-06-01rename (rnrs bytevector) to (rnrs bytevectors)Andy Wingo2-2/+2
* module/rnrs/bytevectors.scm: Rename to (rnrs bytevectors), from (rnrs bytevector), to match the name from the R6RS. * benchmark-suite/benchmarks/bytevectors.bm: * doc/ref/api-data.texi: * doc/ref/api-foreign.texi: * libguile/bytevectors.c: * module/6/rnrs.scm: * module/language/assembly.scm: * module/language/assembly/compile-bytecode.scm: * module/language/assembly/decompile-bytecode.scm: * module/language/glil/compile-assembly.scm: * module/language/tree-il/primitives.scm: * module/srfi/srfi-4.scm: * module/srfi/srfi-4/gnu.scm: * module/system/foreign.scm: * test-suite/standalone/test-ffi: * test-suite/tests/asm-to-bytecode.test: * test-suite/tests/bytevectors.test: * test-suite/tests/foreign.test: * test-suite/tests/r6rs-ports.test: Update all referrers.
2010-05-22Fix disassembly of free variable lists.Ludovic Courtès1-4/+6
* module/language/assembly/disassemble.scm (disassemble-free-vars): Handle FREE-VARS as a list, not a vector.
2010-05-02remove `version' field from <language>Andy Wingo1-2/+1
* module/system/base/language.scm (<language>): Remove the `version' field from languages. It just wasn't useful. * module/language/assembly/spec.scm: * module/language/brainfuck/spec.scm: * module/language/bytecode/spec.scm: * module/language/ecmascript/spec.scm: * module/language/elisp/spec.scm: * module/language/glil/spec.scm: * module/language/objcode/spec.scm: * module/language/scheme/spec.scm: * module/language/tree-il/spec.scm: * module/language/value/spec.scm: Remove #:version from all language definitions. Shorten some language names (e.g. "Guile Scheme" -> "Scheme").
2010-03-07Don't export `write-bytecode' from `(language assembly compile-bytecode)'.Ludovic Courtès1-1/+1
* module/language/assembly/compile-bytecode.scm: Don't export `write-bytecode'. * test-suite/tests/asm-to-bytecode.test (write-bytecode): New global variable.
2010-03-07Fix miscompilation of non-ASCII Latin-1 strings.Ludovic Courtès1-8/+6
The bug was introduced dad6817f ("Use the R6RS I/O API in `write-bytecode'."). * module/language/assembly/compile-bytecode.scm (write-bytecode)[write-string]: Rename to... [write-latin1-string]: ... this. Add the `write-loader-len' call. Write each character individually instead of using `string->utf8'. [write-loader]: Remove. * test-suite/tests/asm-to-bytecode.test ("compiler")[load-string "æ"]: New test.
2010-02-19fix prompt disassembly bugAndy Wingo1-1/+1
* module/language/assembly/disassemble.scm (code-annotation): Fix a bug disassembling `prompt'.
2010-02-19prompt handlers are always inlineAndy Wingo2-4/+3
* libguile/control.h (SCM_F_PROMPT_INLINE, SCM_PROMPT_INLINE_P): Remove; prompts always have "inline" handlers now. * libguile/control.c (scm_c_make_prompt): Remove inline_handler_p arg. * libguile/vm-i-system.c (prompt): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/compile-bytecode.scm (write-bytecode): Adapt to prompt changes. * module/language/glil.scm (make-glil-prompt, glil-prompt-inline?): Remove inline? flag. (parse-glil, unparse-glil): * module/language/glil/compile-assembly.scm (glil->assembly): Adapt to <glil-prompt> change. * module/language/tree-il/compile-glil.scm (flatten): Require the handler of a <prompt> to be a lambda-case. * module/language/tree-il/primitives.scm (*primitive-expand-table*): Ensure that the handler of a <prompt> is a lambda-case. * module/language/tree-il/inline.scm (inline!): Simplify a degenerate case: (lambda args (apply (lambda ...) args)) => (lambda ...).
2010-02-10Use the R6RS I/O API in `write-bytecode'.Ludovic Courtès1-36/+13
* module/language/assembly/compile-bytecode.scm (write-bytecode)[u32-bv]: New variable. [write-char, write-uint16-be, write-uint16-le, write-uint32-le]: Remove. [write-string, write-uint32-be, write-uint32, write-wide-string, write-bytevector]: Rewrite using the `(rnrs io ports)' API. [write-uint24-be]: Rename to... [write-int24-be]: ... this. Use `(rnrs io ports)' API. Callers updated. [write-uint16]: Remove.
2010-02-10Change `write-bytecode' to accept a bytevector.Ludovic Courtès1-29/+30
* module/language/assembly/compile-bytecode.scm (write-bytecode): Replace the WRITE-BYTE and GET-ADDR parameters with PORT. New ADDRESS and EMIT-OPCODE? parameters. Callers updated. [write-byte, get-addr]: New procedures. Adjust to write to PORT. (compile-bytecode): Update accordingly. * test-suite/tests/asm-to-bytecode.test (munge-bytecode): Return a bytevector instead of a u8vector. (comp-test): Deal with bytevectors.
2010-01-31GLIL and assembly support for prompt compilationAndy Wingo3-2/+9
* module/language/glil/compile-assembly.scm (glil->assembly): Compile <glil-prompt> appropriately. * module/language/assembly/disassemble.scm (code-annotation): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/compile-bytecode.scm (write-bytecode): Assemble and disassemble `prompt' appropriately.
2010-01-11Remove unused top-level variables.Ludovic Courtès1-16/+0
* module/ice-9/runq.scm (fork-strips): Remove. * module/language/assembly.scm (*block-alignment*): Remove. * module/language/assembly/disassemble.scm (disassemble-objects, simplify): Remove. * module/srfi/srfi-18.scm (mutex-owners): Remove. * module/srfi/srfi-19.scm (leap-year?): Remove. * module/system/base/compile.scm (dsu-sort): Remove. * module/texinfo.scm (ascii->char): Remove. * module/texinfo/html.scm (ignored?): Remove. * module/texinfo/indexing.scm (def-name): Remove. * module/texinfo/plain-text.scm (ignore): Remove.
2010-01-10fix properties disassemblyAndy Wingo1-2/+2
* module/language/assembly/disassemble.scm (disassemble-meta): Properties start with the fourth element, not the third. (The third is the set of arities.)
2009-10-28Fix incorrect display of wide strings in decompilationMichael Gran1-1/+1
A byte ordering error caused incorrect display of wide strings when using the ",c" decompilation from the REPL. * module/language/assembly/decompile-bytecode.scm (decode-bytecode): wide strings are encoded in native endianness
2009-10-25assembly/disassembly support for br-if-nargs-*Andy Wingo3-0/+9
* module/language/assembly/compile-bytecode.scm (write-bytecode): Handle br-if-nargs compilation. * module/language/assembly/decompile-bytecode.scm (decode-load-program): And decompile them nicely as well. * module/language/assembly/disassemble.scm (code-annotation): And, present the disassembly if br-if-nargs-* nicely.
2009-10-23de-nargs struct scm_objcode; procedure-property refactorAndy Wingo3-13/+7
* libguile/objcodes.h (struct scm_objcode): Remove nargs, nrest, and nlocs, as they are no longer needed. Also obviates the need for a padding word. * libguile/procs.c (scm_thunk_p): Use scm_i_program_arity for programs. * libguile/procprop.c (scm_i_procedure_arity): Use scm_i_program_arity for programs. (scm_procedure_properties, scm_set_procedure_properties_x) (scm_procedure_property, scm_set_procedure_property_x): Rework so that non-closure properties are stored directly in a weak hash, instead of needing a weak hash of "stand-in" closures to hold the properties. Fix docstrings also. * libguile/root.h (scm_stand_in_procs): Remove from the scm_sys_protects set. Actually with libGC, we should be able to store the elements of scm_sys_protects directly as global variables. * libguile/gc.c (scm_init_storage): Remove scm_stand_in_procs initialization. * libguile/programs.c (scm_i_program_arity): New private accessor, tries to determine the "minimum arity" of a program. * libguile/vm.c (really_make_boot_program): Adapt to changes in struct scm_objcode. * module/language/assembly.scm (*program-header-len*, byte-length): * module/language/assembly/compile-bytecode.scm (write-bytecode): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/disassemble.scm (disassemble-load-program): Adapt to changes in objcode. * module/system/xref.scm (program-callee-rev-vars): Adapt to changes in assembly. * module/language/glil.scm: Remove nargs, nrest, and nlocs from glil-program. * module/language/glil/compile-assembly.scm (make-meta, glil->assembly): * module/language/glil/decompile-assembly.scm (decompile-toplevel): (decompile-load-program): Adapt to changes in GLIL and assembly. * module/language/tree-il/compile-glil.scm (flatten-lambda): Adapt to changes in GLIL. * test-suite/tests/asm-to-bytecode.test: Adapt to assembly and bytecode changes. * test-suite/tests/tree-il.test: Adapt to GLIL changes.
2009-10-22Fix typos leading to unbound variable references.Ludovic Courtès1-1/+1
* module/ice-9/session.scm (help): Fix unbound reference to `env'. * module/system/vm/program.scm (program-property): Fix typo. * module/system/vm/frame.scm: Add missing `#:use-module (system vm objcode)'. * module/system/repl/command.scm (guile:load): New. (load): Use either `primitive-load' or `load'. * module/srfi/srfi-18.scm (thread-sleep!): Fix typo. * module/srfi/srfi-19.scm: Use `(ice-9 rdelim)'. (date->broken-down-time, priv:year-day, priv:char->int): Fix typo. (time-*->time-*, time-*->time-*!): Fix reference to unbound variable `caller'. * module/oop/goops.scm (bound-check-get): Fix typo. * module/language/glil/compile-assembly.scm (glil->assembly): Fix typo. * module/language/glil.scm (parse-glil): Fix typo. * module/language/ecmascript/base.scm (object->value/string, object->value/number, ->number): Fix typos. * module/language/assembly/disassemble.scm (disassemble-free-vars): Fix typo.
2009-10-22Fix bytecode disassembler.Ludovic Courtès1-1/+1
* module/language/assembly/decompile-bytecode.scm (decode-load-program): Add missing argument to `ensure-label'.
2009-10-16jumps encoded using 24 bits, not 19; blocks no longer alignedAndy Wingo2-16/+17
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/vm-i-system.c (FETCH_OFFSET, BR): Labels are no longer 8-byte aligned; instead, jumps are encoded into 3 bytes instead of 2. (br, br-if, br-if-not, br-if-eq, br-if-not-eq, br-if-null) (br-if-not-null, mv-call): Adapt for new length of br instructions (3 bytes instead of 2). * libguile/vm.c (really_make_boot_program): Adapt hand-coded bytecode for new offset regime. * module/language/assembly.scm (align-block): No alignment necessary. * module/language/assembly/compile-bytecode.scm (write-bytecode): Write out breaks as 24-bit relative jumps. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decompile break instructions.
2009-10-16language-readers receive environment as an argAndy Wingo1-2/+2
* module/language/assembly/spec.scm: * module/language/brainfuck/spec.scm: * module/language/bytecode/spec.scm: * module/language/ecmascript/spec.scm: * module/language/glil/spec.scm: * module/language/scheme/spec.scm: * module/language/tree-il/spec.scm: Language-readers now take two arguments: the port and the environment. This should allow for compile-environment-specific reader behavior. * module/system/base/compile.scm (read-and-compile): * module/system/repl/common.scm (repl-read): Pass the environment to the language-reader. * module/system/repl/repl.scm (meta-reader, prompting-meta-read): * module/system/repl/command.scm (define-meta-command): Use the second argument to repl-reader, so we avoid frobbing current-reader.
2009-09-24Partially revert e5f5113c21f396705d7479a570c96690135c9d36.Ludovic Courtès1-1/+1
The intent is to maintain the readability of `pmatch' invocations. * module/language/assembly/disassemble.scm (disassemble-load-program): Don't use wildcards in `pmatch' invocations, even when the matched elements are unused. * module/language/glil/decompile-assembly.scm (decompile-toplevel, decompile-load-program): Likewise. * module/system/xref.scm (program-callee-rev-vars): Likewise. * module/language/assembly.scm (byte-length): Likewise. * module/language/tree-il/compile-glil.scm (flatten): Likewise.
2009-09-21Remove unused variables in system/language.Ludovic Courtès3-13/+3
* module/language/assembly.scm (byte-length): Don't match unused record slots. * module/language/tree-il.scm (tree-il->scheme, post-order!, pre-order!): Likewise. * module/language/tree-il/analyze.scm (analyze-lexicals): Likewise. * module/language/tree-il/compile-glil.scm (flatten): Likewise. * module/language/assembly/disassemble.scm (disassemble-load-program): Don't match unused list elements. * module/language/glil/decompile-assembly.scm (decompile-toplevel, decompile-load-program): Likewise. * module/system/xref.scm (program-callee-rev-vars): Likewise. * module/language/assembly/compile-bytecode.scm (write-bytecode)[write-sized-loader]: Remove. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Factorize `pad' variables. * module/language/ecmascript/base.scm (object->value/string, object->value/number)[v]: Remove. * module/language/ecmascript/tokenize.scm (read-slash)[c0]: Remove. * module/language/objcode/spec.scm (decompile-value)[nargs]: Remove. * module/system/repl/command.scm (time)[vms-start, vms-end]: Remove. * module/system/repl/repl.scm (prompting-meta-read): Use `prompt'.
2009-08-19Rename string-width to string-bytes-per-charMichael Gran1-1/+1
* libguile/strings.h: rename scm_string_width to scm_string_bytes_per_char * libguile/strings.c (scm_string_width): renamed to scm_string_bytes_per_char (scm_string_bytes_per_char): renamed from scm_string_width * module/language/assembly/compile-bytecode.scm (write-bytecode): string-width -> string-bytes-per-char * module/language/glil/compile-assembly.scm (dump-object): string-width -> string-bytes-per-char
2009-08-13Uncomment run-time objcode alignment check.Ludovic Courtès1-3/+3
This should now work thanks to the changes in 28b119ee3da0f4b14cb87e638794d22843778cda ("make sure all programs are 8-byte aligned"). This commit is a follow-up to ec99fe8ecb412e49e8e981246eb62ca46b32754b ("Add FIXMEs about misaligned objcode-metas."). * libguile/objcodes.c (scm_c_make_objcode_slice): Uncomment assertion that checks for proper alignment of PTR. * module/language/assembly/compile-bytecode.scm (write-bytecode): Update comment about META's alignment.
2009-08-12update docs for recent vm/compiler workAndy Wingo1-0/+2
* doc/ref/compiler.texi: * doc/ref/vm.texi: Update for recent changes. * module/language/assembly/disassemble.scm (disassemble-load-program): Don't print nops, they are distracting.
2009-08-12rework the vm support for wide stringsAndy Wingo2-31/+15
* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump. * libguile/vm-engine.c (vm_error_bad_wide_string_length): New error case. * libguile/vm-i-loader.c (load-unsigned-integer, load-integer) (load-keyword): Remove these instructions. The former two are obsoleted by make-int64/make-uint64, the latter via make-keyword. (load-string): Only handle narrow strings. (load-symbol): Only handle narrow symbols. The wide case is handled via make-symbol. (load-wide-string): New instruction, for wide strings. * libguile/vm-i-system.c (define): Move here from loaders.c, as now it just takes a sym on the stack. (make-keyword, make-symbol): New instructions. * module/language/assembly.scm: Remove removed instructions. No more width byte in load-string etc. * module/language/assembly/compile-bytecode.scm (write-bytecode): Adapt to change in instruction set. * module/language/glil/compile-assembly.scm (glil->assembly): Compile define by pushing the sym then emitting (define). (dump-object): Dump narrow and wide strings differently. Use make-keyword and make-symbol as appropriate. * module/language/tree-il/compile-glil.scm (flatten): When compiling a ref to a primitive (not a call), first see if the primitive is actually bound in the root module. (That's not the case with e.g. bytevector-u8-ref). * module/system/xref.scm (program-callee-rev-vars): Don't parse out "nexts". * test-suite/tests/asm-to-bytecode.test ("compiler"): Adapt to bytecode format change.
2009-08-12Fix disassembly of strings and symbolsMichael Gran1-2/+22
* module/language/assembly/decompile-bytecode.scm (decode-bytecode): fix disassembly of strings, symbols, keywords, and defines
2009-08-08Add Unicode strings and symbolsMichael Gran1-8/+18
This adds full Unicode strings as a datatype, and it adds some minimal functionality. The terminal and port encoding is assumed to be ISO-8859-1. Non-ISO-8859-1 characters are written or input as string character escapes. The string character escapes now have 3 forms: \xXX \uXXXX and \UXXXXXX, for unprintable characters that have 2, 4 or 6 hex digits. The process for writing to strings has been modified. There is now a function scm_i_string_start_writing that does the copy-on-write conversion if necessary. To compile strings that may be wide, the VM storage of strings and string-likes has changed. Most string-using functions have not yet been updated and may break when used with wide strings. * module/language/assembly/compile-bytecode.scm (write-bytecode): use variable width string bytecode format * module/language/assembly.scm (byte-length): use variable width bytecode format * libguile/vm-i-loader.c (load-string, load-symbol): (load-keyword, define): use variable-width bytecode format * libguile/vm-engine.h (FETCH_WIDTH): new macro * libguile/strings.h: new declarations * libguile/strings.c (make_wide_stringbuf): new function (widen_stringbuf): new function (scm_i_make_wide_string): new function (scm_i_is_narrow_string): new function (scm_i_string_wide_chars): new function (scm_i_string_start_writing): new function (scm_i_string_ref): new function (scm_i_string_set_x): new function (scm_i_is_narrow_symbol): new function (scm_i_symbol_wide_chars, scm_i_symbol_ref): new function (scm_string_width): new function (unistring_escapes_to_guile_escapes): new function (scm_to_stringn): new function (scm_i_stringbuf_free): modify for wide strings (scm_i_substring_copy): modify for wide strings (scm_i_string_chars, scm_string_append): modify for wide strings (scm_i_make_symbol, scm_to_locale_stringn): modify for wide strings (scm_string_dump, scm_symbol_dump, scm_to_locale_stringbuf): (scm_string, scm_i_deprecated_string_chars): modify for wide strings (scm_from_locale_string, scm_from_locale_stringn): add null test * libguile/srfi-13.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing (scm_string_for_each): modify for wide strings * libguile/socket.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing * libguile/rw.c: add calls for scm_i_string_start_writing for each call of scm_i_string_stop_writing * libguile/read.c (scm_read_string): allow reading of wide strings * libguile/print.h: add declaration for scm_charprint * libguile/print.c (iprin1): print wide strings and add new string escapes (scm_charprint): new function * libguile/ports.h: new declarations for scm_lfwrite_substr and scm_lfwrite_str * libguile/ports.c (update_port_lf): new function (scm_lfwrite): use update_port_lf (scm_lfwrite_substr): new function (scm_lfwrite_str): new function * test-suite/tests/asm-to-bytecode.test ("compiler"): add string width byte to sting-like asm tests
2009-07-29Add 32-bit charactersMichael Gran1-0/+1
This adds the 32-bit standalone characters. Strings are still 8-bit. Characters larger than 8-bit can only be entered or displayed in octal format at this point. At this point, the terminal's display encoding is expected to be Latin-1. * module/language/assembly/compile-bytecode.scm (write-bytecode): add 32-bit char * module/language/assembly.scm (object->assembly): add 32-bit char (assembly->object): add 32-bit char * libguile/vm-i-system.c (make-char32): new op * libguile/print.c (iprin1): print 32-bit char * libguile/numbers.h: add type scm_t_wchar * libguile/numbers.c: add type scm_t_wchar * libguile/chars.h: new type scm_t_wchar (SCM_CODEPOINT_MAX): new (SCM_IS_UNICODE_CHAR): new (SCM_MAKE_CHAR): operate on 32-bit char * libguile/chars.c: comparison operators now use Unicode codepoints (scm_c_upcase): now receives and returns scm_t_wchar (scm_c_downcase): now receives and returns scm_t_wchar
2009-07-26increase range of relative jumps by aligning blocks to 8-byte boundariesAndy Wingo2-5/+8
* libguile/objcodes.c (OBJCODE_COOKIE): Bump again, as our jump offsets are now multiplied by 8. * libguile/vm-i-system.c (BR): Interpret the 16-bit offset as a relative jump to the nearest 8-byte-aligned block -- increasing relative jump range from +/-32K to +/-240K. (mvra): Do the same for the mvra jump. * libguile/vm.c (really_make_boot_program): Align the mvra. * module/language/assembly.scm (align-block): New export, for aligning blocks. * module/language/assembly/compile-bytecode.scm (write-bytecode): Emit jumps to the nearest 8-byte-aligned block. Effectively our range is 18 bits in either direction. I would like to do this differently -- have long-br and long-br-if, and all the other br instructions go to 8 bits only. But the assembler doesn't have an appropriate representation to allow me to do this yet, so for now this is what we have. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decode the 19-bit jumps.
2009-07-26make sure all programs are 8-byte alignedAndy Wingo2-0/+2
* libguile/objcodes.c (OBJCODE_COOKIE): Bump objcode cookie, as we added to struct scm_objcode. * libguile/objcodes.h (struct scm_objcode): Add a uint32 after metalen and before base, so that if the structure has 8-byte alignment, base will have 8-byte alignment too. (Before, base was 12 bytes from the start of the structure, now it's 16 bytes.) * libguile/vm-engine.h (ASSERT_ALIGNED_PROCEDURE): Add a check that can be turned on with VM_ENABLE_PARANOID_ASSERTIONS. (CACHE_PROGRAM): Call ASSERT_ALIGNED_PROCEDURE. * libguile/vm-i-system.c (long-local-ref): Add a missing semicolon. * libguile/vm.c (really_make_boot_program): Rework to operate directly on a malloc'd buffer, so that the program will be 8-byte aligned. * module/language/assembly.scm (*program-header-len*): Add another 4 for the padding. (object->assembly): Fix case in which we would return (make-int8 0) instead of (make-int8:0). This would throw off compile-assembly.scm's use of addr+. * module/language/assembly/compile-bytecode.scm (write-bytecode): Write out the padding int. * module/language/assembly/decompile-bytecode.scm (decode-load-program): And pop off the padding int too. * module/language/glil/compile-assembly.scm (glil->assembly): Don't pack the assembly, assume that assembly.scm has done it for us. If a program has a meta, pad out the program so that meta will be aligned. * test-suite/tests/asm-to-bytecode.test: Adapt to expect programs to have the extra 4-byte padding int.
2009-07-24check that jumps are within the range of a signed 16-bit intAndy Wingo1-1/+4
* module/language/assembly/compile-bytecode.scm (write-bytecode): Check that the offset is within the range of a signed int16 value.
2009-07-24nlocs is now 16 bits wideAndy Wingo2-3/+8
* libguile/objcodes.h (struct scm_objcode): Remove the "unused" field -- the old "nexts" -- and expand nlocs to 16 bits. * module/language/assembly/compile-bytecode.scm (write-bytecode): Write the nlocs as a uint16. * module/language/assembly/decompile-bytecode.scm (decode-load-program): Decompile 16-bit nlocs. It seems this decompilation is little-endian :-/ * test-suite/tests/asm-to-bytecode.test: Fix up to understand nlocs as a little-endian value. The test does the right thing regarding endianness.
2009-07-23remove all mentions of "external" from the compiler and related codeAndy Wingo3-29/+22
With this, GHIL is effectively bitrotten. I need to port the ECMAScript compiler to tree-il, then I'll remove it. * module/language/assembly.scm (byte-length): * module/language/assembly/compile-bytecode.scm (write-bytecode): * module/language/assembly/decompile-bytecode.scm (decode-load-program): * module/language/assembly/disassemble.scm (disassemble-load-program): (disassemble-free-vars, code-annotation): * module/language/glil.scm (<glil-program>, <glil-local>) (<glil-exteral>, parse-glil, unparse-glil): * module/language/glil/compile-assembly.scm (make-meta): (compile-assembly, glil->assembly): * module/language/glil/decompile-assembly.scm (decompile-toplevel): (decompile-load-program): * module/language/objcode/spec.scm (decompile-value): * module/language/tree-il/compile-glil.scm (flatten-lambda): * module/system/vm/frame.scm (frame-binding-ref): (frame-binding-set!): * module/system/vm/program.scm (binding:boxed?): * module/system/vm/trace.scm (trace-next): * test-suite/tests/asm-to-bytecode.test ("compiler"): * test-suite/tests/tree-il.test: Remove all mentions of "external", and of <glil-local>. Docs updates will come soon.
2009-07-15Add FIXMEs about misaligned objcode-metas.Ludovic Courtès1-0/+3
* libguile/objcodes.c (scm_c_make_objcode_slice): Add comment about misaligned `objcode-meta'. * module/language/assembly/compile-bytecode.scm (write-bytecode): Likewise.
2009-06-19Fix decompilation of the `load-array' instruction.Ludovic Courtès1-4/+15
This allows, e.g., ",c #u8(1 2 3)" at the REPL to actually work instead of failing to decode `load-array'. * module/language/assembly/decompile-bytecode.scm (decode-bytecode): Account for the `load-array' instruction, which is followed by a bytevector instead of a string. We should find a more elegant way to do that.
2009-06-17Change Guile license to LGPLv3+Neil Jerram4-56/+52
(Not quite finished, the following will be done tomorrow. module/srfi/*.scm module/rnrs/*.scm module/scripts/*.scm testsuite/*.scm guile-readline/* )
2009-06-05add ability to compile uniform arraysAndy Wingo1-0/+6
* module/rnrs/bytevector.scm (rnrs): * libguile/bytevectors.h: * libguile/bytevectors.c (scm_uniform_array_to_bytevector): New function. * libguile/unif.h: * libguile/unif.c (scm_from_contiguous_typed_array): New function. * libguile/vm-i-loader.c (load-array): New instruction, for loading byte data into uniform vectors. Currently it copies out the data, though in the future we could avoid that. * module/language/assembly.scm (align-code): New exported function, aligns code on some boundary. (align-program): Use align-code. * module/language/assembly/compile-bytecode.scm (write-bytecode): Support the load-array instruction. * module/language/glil/compile-assembly.scm (dump-object): Dump uniform arrays. Neat :)