Commit Graph

54 Commits

Author SHA1 Message Date
Calvin Rose a9176a77e6 Prevent bytecode optimization from remove mk* instructions.
These instructions read from the stack, and therefor have side effects.
Removing them without clearing the stack results in broken bytecode.
2023-11-22 08:18:23 -06:00
Calvin Rose b5d3c87253 Add new opcode subtract immediate. 2023-07-09 21:51:16 -05:00
primo-ppcg c83f3ec097 floor div, variadic mod 2023-06-28 18:31:20 +07:00
Calvin Rose 77189b6e66 Fix some symbol mapping inside nested functions. 2023-05-31 08:19:24 -05:00
Calvin Rose fcca9bbab3 Add recursion to the pruning optimization. 2023-05-29 18:05:14 -05:00
Calvin Rose 4782a76bca Add inital bytecode optimizations for #1163
This removes unnecessary movn, movf, lds, and a few other instructions.
Any instructions that has not side effects and writes to a slot that
isn't used can be removed. A number of other optimizations can follow
from this:

- Implement the def-aliasing-var optimization better
- This function can be iterated as a fix point until no more
  instructions are removed.
- If we implement slot renaming, then we no longer need to free slots
  and can simplify the initial code generation a lot.
2023-05-29 16:10:48 -05:00
Calvin Rose f4bc89d1c0 Progress. 2023-02-02 21:08:48 -06:00
Jona Ekenberg ce31db09e4 symbolslots should be gc'd, local_symbols always pushed in case *debug* is set in middle of function 2023-02-01 11:45:13 +01:00
Jona Ekenberg 587aa87d28 symbolslots now use janet_v vectors, flat structure 2023-02-01 11:06:33 +01:00
Jona Ekenberg 88813c4f87 initial slotsyms implementation 2023-02-01 09:39:24 +01:00
Calvin Rose a0f40042cb Update copyright year. 2023-01-07 15:03:35 -06:00
Calvin Rose 3715d7a184 Auto update copyright date. 2022-03-21 18:22:59 -05:00
Calvin Rose bbae43f259 Update copyright dates. 2021-05-31 13:46:02 -05:00
Calvin Rose 28439d822a Add cancel function.
This should allow better stack unwinding on a fiber that
no longer needs to complete.
2020-08-22 15:35:37 -05:00
Calvin Rose aefde67aa2 And lots of optimization functionality. 2020-06-28 18:16:57 -05:00
Calvin Rose 9c5e97144d More small changes to help with cross compilation
via makefile. Add option to turn off built in
getline via janetconf.
2020-06-27 12:39:16 -05:00
Calvin Rose b0d8369534 Increase reference accuracy of on-stack close envs.
Using a bitset to indicate which stack values are upvalues, we
can more accurately track when a reference to a stack value
persists after the stack frame exits.
2020-03-18 09:30:10 -05:00
Calvin Rose 28d41039b8 Add mod function to core.
The `mod` function is a pair function with `%`, or te remainder
function and is distinct from it. This is taken from common lisp.
2020-01-23 18:54:30 -06:00
Calvin Rose 51678c1aba Extend power of the each form
This changes the implementation of the `next` function which
is now used to implement each. This let's us iterate over
more types, not just tables and structs.
2020-01-18 17:55:07 -06:00
Calvin Rose a68ee7aac6 Update Copyright 2020. 2020-01-12 10:50:37 -06:00
Calvin Rose 9dd152dc28 Add features.h for feature test macros.
Because we use an amalgated build, feature
test macros should be set in a single file that
is included before any other headers, and is placed
at the top of the amalgamated build.
2019-12-30 19:06:15 -05:00
Calvin Rose 022be217a2 Remove ==, not==, and order[<,<=,>,>=].
This unifies equality and comparison checking. Before, we had
separate functions and vm opcodes for comparing general values vs.
for comparing numbers, where the numberic functions were polymorphic and
had special cases for handling NaNs. By unfiying them, abstract types
can now better integrate with other number types and behave as keys.

For now, the old functions are aliased but will eventually be removed.
2019-12-28 16:04:15 -05:00
Calvin Rose cecc7e6b9d Rename 'get' opcode to 'in', add new 'get' opcode.
This makes the names of the opcodes match their implied functionality.
We also rename the C functions to match the opcodes and source level
functionality.
2019-12-02 21:26:28 -06:00
Calvin Rose d37c43716a Lots of work on improving debugging.
doc macro can take no arguments and print out
all bindings. Fix an issues with the vm skipping
over a breakpoint in some situations.

Add examples/debugger.janet for proof of concept
debugger.
2019-11-24 17:45:53 -06:00
Calvin Rose b8032ec61d Add propagate function and opcode
This allows better stacktraces when manually intercepting
signals to clean up resources. Also allows functionality
from Common Lisp's unwind-protect, such as calling cleanup code
while unwindinding the stack, restarting on certain signals, and
just in general having more control over signal and signal propagation.

Also fix a bug encountered while implementing with-resource in the
compiler. Desturcturing arguments that were not the last argument
would often result in bad code generation, as slots used to destructure
the earlier arguments would invalidate the later parameters. This is
fixed by allocating all named parameters before doing any destructuring.
2019-06-24 12:44:13 -04:00
Calvin Rose f10028d41a Add function versions of macro API bindings.
This should help address #81. Also hide janet_exit
and janet_assert, as they are really meant for internal usage.
I have not verified that this yet actually works with Rust's
bindgen.
2019-04-27 15:47:12 -04:00
Calvin Rose e239980da7 Quasiquoting bracketed tuples. 2019-03-31 14:15:26 -04:00
Calvin Rose d42bdf2443 Add proper optional arguments.
Use &opt in the parameter list to get optional arguments.
2019-03-12 00:23:14 -04:00
Calvin Rose 9d4effc02e Add make format to format code.
A consistent style should help with contributors and
readability. We use astyle as the formatter as can make a pretty
good approximation of the current style and my preferred style.

Astyle can be found at http://astyle.sourceforge.net/astyle.html
2019-02-19 20:51:34 -05:00
Calvin Rose ed72dcf82d Rename the header <janet/janet.h> to <janet.h>
Makes it easier to use and remember, and makes the
variable `module/*headerpath*` make more sense.
2019-02-18 20:13:35 -05:00
Calvin Rose 611543c48b Add source amalgamation
The amalgamated source concatenates all sources
to a file janet.c which can be used for
embedding janet, much in the same way as sqlite
or mongoose.
2019-01-24 00:15:58 -05:00
Calvin Rose 6f3bc3d577 Update copyright date, fix types, remove trailing whitespace. 2019-01-06 03:23:03 -05:00
Calvin Rose 6b95326d7c First commit removing the integer number type. This should
remove some complexity and unexpected behavior around numbers in
general as all numbers are the same number type, IEEE 754 double
precision numbers. Also update examples and tests, some of which were
out of date.

Some more testing may be needed for new changes to numbers.
2018-12-27 13:05:29 -05:00
Calvin Rose e8c0dcd14e Make source mapping use byte offset instead of line and col
for better debugging support in repl. Add debug module for better
debugging support.
2018-12-13 18:46:53 -05:00
Calvin Rose c8ef2a0d88 Rename to janet 2018-09-05 22:18:42 -04:00
Calvin Rose 634ec85b07 Fix funcdef flags when marshaling. 2018-08-21 15:07:37 -04:00
Calvin Rose 1acd2d1de7 Inlining for all built in comparators. 2018-07-09 21:24:22 -04:00
Calvin Rose a018f9f54a Major refactor. Move files around, merge compiler into
core and other changes, work on inlining many c functions.
2018-07-03 23:07:35 -04:00
Calvin Rose bb406133de New sourcemaps v1. 2018-06-28 23:37:04 -04:00
Calvin Rose 2a87dada47 Rename fiber.resume and fiber.yield to
resume and yield.
2018-06-09 13:08:30 -04:00
Calvin Rose fb409201b4 Strip trailing whitespace from many files.
Add native modules to import with module.native-path.
2018-05-19 21:16:00 -04:00
Calvin Rose f295692b50 Update copyright to 2018. Add string methods. 2018-05-17 23:41:20 -04:00
Calvin Rose 51bdc41014 Change fiber signal model to add user signals. This
should allow easier implementations of eventloops,
threadpools, or custom data flows with fibers.
2018-05-16 22:09:36 -04:00
Calvin Rose 0cd6cdc28b Add some more opcodes for comparison with numeric types. 2018-05-07 12:34:04 -04:00
Calvin Rose 0fd55282d8 Add error reporting to repl (initial stack traces) 2018-03-21 20:53:39 -04:00
Calvin Rose 2a0dc5f1ad Switch to assymetric coroutines instead of symmetric. 2018-03-11 15:35:23 -04:00
Calvin Rose 0c3b0673ff Enable debug opcode in vm and debug state for fibers. 2018-03-09 17:14:26 -05:00
Calvin Rose 1551bf6b48 Use flatter representation for function and environments. 2018-02-13 16:14:55 -05:00
Calvin Rose a614816a04 Update func env representation to not store envs in function
objects.
2018-02-12 16:43:59 -05:00
bakpakin ce5708af98 Switch over to Cmake fully. 2018-01-29 15:46:26 -05:00