1
0
forked from Mirror/wren
Commit Graph

1672 Commits

Author SHA1 Message Date
44d6d20586 Do not allow inheriting built-in classes Num, Bool and Null (#831)
* Do not allow inheriting `Num`, `Bool` and `Null`. fixes #830
2020-10-26 08:39:36 -07:00
ad4e039187 Fix svg link to travis build (#828) 2020-10-17 15:57:39 -07:00
45c67fae0c Fn call: move arity check into interpret loop, which avoid the expensive if after the call, since runtime errors originating inside the call itself will still be handled, we only have the one emitted from call itself.
This brings the benchmark back up to where it was.
2020-09-18 15:42:37 -07:00
beae242a41 vm; handle errors from fn.call (still investigating) 2020-09-18 13:11:12 -07:00
86463acb90 Fix stack corruption caused by Fn call primitives (#807)
Excerpt from @munificent on the nature of the bug:

In runInterpreter, for performance, the vm caches an IP pointing into some bytecode.

All primitives except for `.call`, do not touch Wren's own callstack. They run a little C code and return, so the array of CallFrames, their IPs, and the IP cached inside run() are not affected at all.

While runInterpreter() is running, the IP in the top CallFrame is not updated, so it gets out of sync. This is deliberate, since storing to a field is slow, but it means the value of that field is stale and doesn't represent where execution actually is at that point in time.

To get that field in sync, we use STORE_FRAME(), which stores the local IP value back into the IP field for the top CallFrame. The interpreter is careful to always call STORE_FRAME() before executing any code that pushes a new CallFrame onto the stack.

In particular, if you look around, you'll see that every place the interpreter calls wrenCallFunction() is preceded by a STORE_FRAME(). That is, except for the call to wrenCallFunction() in the call_fn() primitive. That's the bug.

The .call() method on Fn is special because it does modify the Wren call stack and the C code for that primitive directly calls wrenCallFunction(). When that happens, the correct IP for the current function, which lives only in runInterpreter()'s local variable gets discarded and you're left with a stale IP in the CallFrame.

Giving the function call primitives a different method type and having the case for that method type call STORE_FRAME() before invoking the primitive fixes the bug.
2020-09-18 12:32:43 -07:00
f769599bc6 docs; fix random module docs missing a closing tag (thanks @totallyRonja) 2020-08-29 12:03:46 -07:00
039150efeb docs; fix example formatting 2020-07-30 09:24:23 -07:00
81bfbfce23 fix issue with docs clearing the writeFn from the config. add complete embedding example to docs + repo 2020-07-30 09:09:15 -07:00
dead8df82e GC debug times are easier to reason about when printed in milliseconds, rather than seconds 2020-07-18 20:50:26 -07:00
b279e51fd1 Allow computed goto when using clang on Windows
Clang defines _MSC_VER for compatibility with MSVC, but that can often create problems for code that assumes MSVC only.
2020-07-18 20:41:16 -07:00
286162365a update wip 0.4.0 changelog 2020-07-18 20:26:23 -07:00
5b0f8740f2 Revert "Extended test for Random.sample to cover both branches (#715)"
This reverts commit f81cb5d23c.
2020-07-18 20:10:22 -07:00
f81cb5d23c Extended test for Random.sample to cover both branches (#715)
I've verified that this test fails without the fix in change
186a8c7c13.

See issue #713
2020-07-14 20:15:12 -07:00
54b4c233b9 test: Fix some tests so they fail on expected error, not on syntax error. (#779) 2020-07-14 20:14:08 -07:00
58611240e7 Remove magic values as exit codes in test application (#777) 2020-07-11 13:30:43 -07:00
a3f5b3d98f wren/vm: Allow wrenInterpret to call foreign function (complement 344d343 at fixing #730). (#764) 2020-07-11 13:05:22 -07:00
da091e250c set WREN_MAX_TEMP_ROOTS default to 8 instead of 5
that's 64 bytes, fits nicely in a cache line and isn't _as_ arbitrary.
2020-07-11 11:34:35 -07:00
2ce421eac5 use push root instead of a handle for module GC protection
related to d432b03d62
2020-07-11 11:30:52 -07:00
d432b03d62 fix many module imports causing GC to pull the rug on our module instance 2020-07-10 20:00:17 -07:00
433fbc4019 core; num; add exp & log2
I've had a couple use cases in time that the code is significantly clearer with these, and makes porting less error prone
2020-07-10 19:38:45 -07:00
0e8d56f874 add a note about switched goto for future reference 2020-07-10 19:15:21 -07:00
28ad8aa9e0 compiler; fix incorrect byte length for CODE_IMPORT_VARIABLE
this can lead to some REALLY fun debugging because various code bytes/instructions get skipped, leading to wrong inputs into wrong opcodes and all sorts 💯
2020-07-10 19:14:54 -07:00
b3d496ea36 compiler; rename getNumArguments to be clearer as to the intent 2020-07-10 19:13:44 -07:00
8be40ec14e runFile: Free file source before exiting the function (#774)
This prevents a memleak, noticeable when running `wren_test` under
`valgrind`. For example, the following command would leak

`./bin/wren_test_d any_example.wren`
2020-07-09 11:54:21 -07:00
1623654465 docs; fix embedding tutorial missing a write function so nothing shows up when learning. 2020-06-30 07:40:12 -07:00
e539279121 docs; fix // comments properly this time
...
2020-06-17 09:48:12 -07:00
7651459dfb add // comments to code highlighting, but not with errors in the code 2020-06-17 09:36:34 -07:00
d02903b7d0 add // comments to code highlighting 2020-06-17 09:20:15 -07:00
88043a7cb9 Change wren to wren_cli (#765) 2020-06-17 07:57:03 -07:00
b59c060ccd Small tweaks to error handling. (#762)
* wren/primitive: Remove duplicated declaration introduced in 9f64c05fa.
* wren/primitive: Allow RETURN_ERROR_FMT to have any number of arguments.
* wren/vm: Remove extra validateApiSlot in wrenGetVariable.
(The slot validation is guaranted by setSlot later in the function.)
* wren/primitive: Use RETURN_ERROR_FMT in validateFn.
2020-06-15 11:31:29 -07:00
30b2ebd3f7 fix util/generate_project.py
- fix premake args being incorrect
- remove platform assumptions, making it portable
- start with a best guess based on project layout
- use fallback if not specified or not found
- display errors/help if not found
2020-06-14 19:44:58 -07:00
de6a312868 Functions for operating on Maps from C (#725)
new API functions for maps:
wrenSetSlotNewMap
wrenGetMapCount
wrenGetMapContainsKey
wrenGetMapValue
wrenSetMapValue
wrenRemoveMapValue
2020-06-14 14:45:23 -07:00
344d3432b3 Fix slot array corrupted by wrenInterpret() (#730) 2020-06-13 21:42:06 -07:00
7983082b71 Support positive sign in scientific notation (#706)
* Support positive sign in scientific notation
* Add exponent with positive sign to docs
2020-06-13 21:37:30 -07:00
f3493d0499 Optimize Random.sample(_, _) for performance (#716)
* Optimize Random.sample(_, _) for performance
* Make tests treat random samples as unordered
* Test all sample sizes possible
* Tweak random sampling algorithm for performance
2020-06-13 21:31:23 -07:00
fea0dfafa0 Fix typos in wren_value.h (#749)
* Fix typo: "pointing too" -> "pointing to"
* Fix typo: It *is* heap-allocated
2020-06-13 21:25:55 -07:00
f894273f50 Refactor travis script (#754) 2020-06-13 21:25:18 -07:00
909d1c9471 Add script to regenerate projects using premake (#755) 2020-06-13 21:24:55 -07:00
b5894c6ff5 wren: Remove a magic number in the compiler. (#757) 2020-06-13 21:24:37 -07:00
7c357e1b02 Update gitignore (#759)
Add VSCode project folder and macOS specific stuff.
2020-06-13 21:24:16 -07:00
9fb6d02b5c main branch reference fixes 2020-06-12 10:11:49 -07:00
e45a9d0382 removed localhost (#758) 2020-06-09 17:03:36 -07:00
bef4099101 missed nitpick 2020-06-08 12:31:03 -07:00
9f64c05fa8 Make do blocks in macros consistent with the rest of the code 2020-06-08 12:28:15 -07:00
26d0194117 wren/vm: Uniformize macros to stick to 80 columns. (#756)
uniform macros
2020-06-08 12:23:15 -07:00
2c2f5936eb tests; warn against missing wren_test binary correctly 2020-06-06 10:38:43 -07:00
b694b2231c docs; fix blog template missing links and wrong paths 2020-06-06 10:32:44 -07:00
6cfe6dd6de tests; warn against missing wren_test binary instead of a loud error 2020-06-06 10:29:35 -07:00
8341f61cdb docs; nitpicks 2020-06-05 20:11:32 -07:00
cd01246997 remove pygments setup 0.3.0 2020-06-05 15:21:33 -07:00