Bob Nystrom
074c016c89
Num.floor.
2014-01-07 23:03:25 -08:00
Bob Nystrom
e64d8ace9a
Ensure upvalue value is initialized.
...
Avoids a crash if a GC happens before the upvalue is closed.
2014-01-07 23:03:15 -08:00
Bob Nystrom
3be059a137
Fix scoping and break statements.
...
Variables declared in the loop were not properly disposed of
when you broke out of the loop.
2014-01-06 08:01:04 -08:00
Bob Nystrom
90a769b6d1
Correctly terminate debug function name.
2014-01-06 07:54:00 -08:00
Bob Nystrom
46e1e7f069
Make string buffer for converting number to string large enough.
2014-01-06 07:53:41 -08:00
Bob Nystrom
b979272305
Clean up text handling a bit:
...
- Rename IO.write -> IO.print.
- Make IO.write not print a newline.
- Support \u Unicode escapes in strings.
2014-01-05 12:27:12 -08:00
Bob Nystrom
870f3b8b93
Allow more than 256 methods and constants.
...
Class symbol tables now grow on demand, and the relevant
instructions take 16-bit arguments. There's a small perf hit
for this, but only a few percent, which is good.
2014-01-04 11:08:31 -08:00
Bob Nystrom
f82a034b57
Add time to GC tracing.
2014-01-03 13:17:14 -08:00
Bob Nystrom
058c2606b0
Better argument validation for core methods.
2014-01-03 10:47:26 -08:00
Bob Nystrom
a89386b4e8
Better argument validation for some list methods.
2014-01-02 07:32:00 -08:00
Bob Nystrom
a0c32f2e6e
Clean up compiler initialization a bit.
2014-01-02 07:31:31 -08:00
Bob Nystrom
e46b4b30b9
Make Buffer "generic".
...
This lets us make a growable line-number buffer.
2014-01-01 22:23:03 -08:00
Bob Nystrom
a6fd0b2dd2
Move SymbolTable to wren_utils.
2014-01-01 20:57:58 -08:00
Bob Nystrom
b750ece08b
Move object freeing over to wren_value.
...
That's where allocation is, so it makes sense.
2014-01-01 13:31:19 -08:00
Bob Nystrom
48db3a9620
Start adding support for runtime errors:
...
- Primitives can now signal an error.
- An error prints a callstack and ends the current (and right
now only) fiber.
- Arithmetic operators error if the operand is not a number.
- Real error for method not found.
- Associate source file name, and method names with functions.
- Debug line number info for functions.
Unfortunately, this regresses perf on fib about 15%, mostly
because of the better checking in arithmetic ops.
There's still a bunch of clean up to do, but this is a big step
in the right direction.
2014-01-01 13:25:24 -08:00
Bob Nystrom
45456733aa
Fix a few GC bugs.
...
Adding a to a symbol table can trigger a GC, so we need to make
sure we don't do that while sitting on an unpinned object.
2013-12-30 07:30:50 -08:00
Bob Nystrom
c8fe27d6c4
Allow empty blocks.
2013-12-29 10:46:21 -08:00
Bob Nystrom
a9323376ec
"native" -> "foreign".
2013-12-29 10:14:38 -08:00
Bob Nystrom
63d1255566
Start sketching in the FFI.
2013-12-29 10:06:35 -08:00
Bob Nystrom
667d393fbb
Write a bunch of docs.
2013-12-28 09:37:41 -08:00
Bob Nystrom
afdcafcecb
Remove explicit calls to free() and malloc().
2013-12-27 09:07:35 -08:00
Bob Nystrom
a8c725ea3f
Use growable buffers for bytecode and strings.
...
Ensures the compiler can handle long chunks of code and strings.
2013-12-27 07:22:43 -08:00
Bob Nystrom
3506a39e27
Pass in all data when creating function.
2013-12-26 17:28:33 -08:00
Bob Nystrom
24686eb4be
First step towards making FnObjs smarter about size.
...
Currently, they have a hardcoded number of constants and
bytecodes. That wastes memory in most cases and fails
catastrophically when there is too much bytecode.
To fix this, we should use growable buffers for both during
compilation and then only create the FnObj when done compiling.
This moves a bunch of stuff around and gets it to the point
where functions are created at the end of compilation. It
doesn't yet size functions appropriately, but all tests are
passing, so this is a good checkpoint.
2013-12-26 16:58:03 -08:00
Bob Nystrom
350c0194b6
"unsigned char" -> "uint8_t".
2013-12-25 16:31:30 -08:00
Bob Nystrom
e62bccd7f2
Inline the bytecode array in ObjFn.
2013-12-25 16:19:35 -08:00
Bob Nystrom
8c4a58a0a3
Make CallFrame and Method use Obj* for functions.
...
There's no point in packing it in a Value since it will always
be an ObjFn or ObjClosure. Leaving it an Obj* is a bit faster.
Also fixed a bug where it was freeing the closure's flexible
array of upvalues.
2013-12-25 16:12:07 -08:00
Bob Nystrom
ba0f39a5e0
Tweak README.
2013-12-25 15:03:17 -08:00
Bob Nystrom
507e89d3b3
Range operators!
...
Added ".." and "..." infix operators. Num implements them to
return Range objects. Those in turn implement the iterator
protocol, so now numeric for loops are easy:
for (i in 1..10) { ... }
I also cleaned up the Wren benchmarks to use this.
In the process, I discovered the method_call benchmark really
just showed loop peformance, so I unrolled the loops in all of
the languages to stress method calls.
2013-12-25 15:01:45 -08:00
Bob Nystrom
2b65e47747
Use getNumArguments() in method bind.
2013-12-24 22:10:30 -08:00
Bob Nystrom
e6e7b2594c
For loops!
2013-12-24 21:04:11 -08:00
Bob Nystrom
1e0401bfc1
Allow statement bodies for flow control.
...
This means this works now:
if (foo) return bar
2013-12-24 10:27:48 -08:00
Bob Nystrom
8c85232b90
Break statements.
2013-12-24 10:15:50 -08:00
Bob Nystrom
a30a5daa29
Clean out a few TODOs.
2013-12-23 15:38:00 -08:00
Bob Nystrom
5a2fde0c2c
Collapse duplicate constants and check for overflow.
2013-12-23 15:08:47 -08:00
Bob Nystrom
c8cb0be816
Better handling for lexing errors.
2013-12-23 14:51:06 -08:00
Bob Nystrom
1503e74233
Get rid of unused DUP instruction.
2013-12-23 11:37:47 -08:00
Bob Nystrom
9235a7e38f
Fields in closures.
2013-12-23 11:17:40 -08:00
Bob Nystrom
c0169896e6
Get rid of ResolvedName.
2013-12-22 20:53:35 -08:00
Bob Nystrom
ad1fcf66bc
Superclass calls in closures.
2013-12-22 20:46:12 -08:00
Bob Nystrom
3c8b4c009f
Allow variables without initializers.
2013-12-22 18:47:58 -08:00
Bob Nystrom
034fec6eaa
Make fibers real objects.
2013-12-22 14:31:33 -08:00
Bob Nystrom
7625de7536
Make ip an actual pointer.
2013-12-22 13:46:13 -08:00
Bob Nystrom
7868287f89
Make IO.write() call toString on its argument.
2013-12-22 11:50:00 -08:00
Bob Nystrom
2ec01c558f
Clean up the root of the class/metaclass hierarchy.
2013-12-21 20:44:37 -08:00
Bob Nystrom
6c3aa85228
Make IO a static class instead of a singleton.
2013-12-21 19:25:09 -08:00
Bob Nystrom
24a6f4cd8c
Closing over "this".
2013-12-21 15:55:08 -08:00
Bob Nystrom
76ac818eaf
Subscript setters.
2013-12-21 09:37:59 -08:00
Bob Nystrom
6fdcf800a8
Do a bit more documentation.
2013-12-21 09:15:30 -08:00
Bob Nystrom
f2b036420d
Fix a bunch of test TODOs.
...
- Added a bunch of tests.
- Removed some TODOs for stuff that's already done.
- Made list literals handle newlines better.
2013-12-20 12:42:11 -08:00
Bob Nystrom
315ed1c425
Make heap usage configurable.
2013-12-20 07:41:35 -08:00
Bob Nystrom
e83d0bb360
Setters!
2013-12-20 07:05:31 -08:00
Bob Nystrom
61e745d548
Bump default heap size up.
...
This makes the binary_trees benchmark much faster.
2013-12-20 07:05:13 -08:00
Bob Nystrom
b937597ea7
Make benchmarks score based instead of time based.
2013-12-20 07:04:04 -08:00
Bob Nystrom
f9099791a1
Add another test for constructor syntax.
2013-12-19 09:10:45 -08:00
Bob Nystrom
4d67f2270a
Use more conventional syntax for constructors.
...
They are now invoked like "new Foo".
Also, superclass constructors are now much less semantically
and syntactically weird. Since the instance is created before
any constructor is called, there's no point in time where the
instance isn't there.
2013-12-19 07:02:27 -08:00
Bob Nystrom
b880b17db9
Add TODO about resolving ctors.
2013-12-18 07:39:46 -08:00
Bob Nystrom
e7cf8ffe2e
Make method_call benchmark use inheritance.
...
This also fixes a bug where constructors weren't being bound
correctly, and eliminates some unneeded instructions when
compiling ifs.
I also tweaked the other method_call languages to match Wren's.
Since Wren needs to do a super call to get to the parent _count,
the other languages do now too.
This is nice too because it means we're benchmarking super
calls.
2013-12-18 07:37:41 -08:00
Bob Nystrom
caafa96252
More work on docs.
2013-12-17 09:39:26 -08:00
Bob Nystrom
271fcec81b
Start getting superclass constructors working.
...
This also means the metaclass inheritance hierarchy parallels
the regular inheritance chain so that the subclass can find
the superclass constructor.
2013-12-17 09:39:05 -08:00
Bob Nystrom
70e548657e
Don't allow "super" outside of methods.
2013-12-15 22:08:40 -08:00
Bob Nystrom
5fb2d5af71
Use flexible array for upvalues in closure.
2013-12-15 22:02:22 -08:00
Bob Nystrom
9e67cd3220
Use stdbool.h and bool for booleans.
2013-12-14 23:41:23 -08:00
Bob Nystrom
f5e4f95069
Write some more scope edge case tests.
2013-12-14 16:36:19 -08:00
Bob Nystrom
7fe60499db
Get rid of my name from TODOs. Anyone can do them.
2013-12-14 15:28:18 -08:00
Bob Nystrom
5c807c0ec5
Track memory during deallocation correctly.
...
It used to subtract the number of bytes during deallocation, but
that required knowing the size of an object at free time. That
isn't always available. The old code could read a freed object
while doing this. Bad!
Instead, this tracks how much memory is still being used by
marked objects. It's correct, and is also a bit less code and
faster.
2013-12-14 14:17:16 -08:00
Bob Nystrom
3fd7fa56fb
Inline wrenObjectToValue().
...
Seems to give a slight speed bump. Inlining the wrenIs___
functions doesn't seem to help (may make it a bit worse.)
2013-12-14 11:34:49 -08:00
Bob Nystrom
088b1be98c
Clean up config #defines.
2013-12-14 11:06:54 -08:00
Bob Nystrom
165cf29db0
Special "constructor methods" -> "new" instruction.
...
This simplifies the call instruction a bit (and is overall
less code).
2013-12-13 11:32:47 -08:00
Bob Nystrom
d54bca3067
Get basic superclass method calls working.
2013-12-13 08:37:49 -08:00
Bob Nystrom
4957728893
Move OP_CLOSURE and OP_LIST down.
...
Since they're less frequently used, pushing them down speeds
things up a little bit.
2013-12-13 06:47:34 -08:00
Bob Nystrom
5aaaa33552
Revise benchmarks:
...
- Ditch JS since it's in a different league.
- Make binary_trees and fib run faster.
- Compare using best time instead of mean.
2013-12-12 16:59:57 -08:00
Bob Nystrom
8e71660ce6
Reorder the method types.
...
Seems to slightly improve perf.
2013-12-12 07:39:27 -08:00
Bob Nystrom
4ba5c38bbf
Generate default constructors at compile time.
...
Also re-ordered a few of the cases in the interpret loop.
Removing a bit of code from CODE_CLASS and CODE_CALL triggered
some branch alignment issues which had a negative perf impact.
The new ordering seems to cancel that out.
2013-12-12 07:34:16 -08:00
Bob Nystrom
e191424a70
Make "super" a reserved word.
2013-12-11 08:02:17 -08:00
Bob Nystrom
6e16df08f0
Add note about default constructor.
2013-12-11 08:00:25 -08:00
Bob Nystrom
71c26c6d89
Add support for just control which language benchmarks are run.
2013-12-10 23:02:24 -08:00
Bob Nystrom
510e3fc383
Add test for default constructor.
2013-12-10 21:58:02 -08:00
Bob Nystrom
03c7b01b0f
Start writing performance doc.
2013-12-10 21:51:58 -08:00
Bob Nystrom
c1cfe1b9f6
Handle inherited fields correctly.
2013-12-10 16:13:25 -08:00
Bob Nystrom
1e2449893e
Add baseline comparison to benchmark script.
...
This way, I can track performance improvements and regressions.
2013-12-07 22:15:25 -08:00
Bob Nystrom
42b04c6c90
Fix bug in loops.
...
It was still popping the stack for the body even though loop
bodies are statements now.
2013-12-07 18:47:40 -08:00
Bob Nystrom
eb1e5b48d6
Fix up benchmarks and add method call one.
2013-12-07 18:43:39 -08:00
Bob Nystrom
3f24515496
Don't allow method names to overflow.
2013-12-06 20:09:43 -08:00
Bob Nystrom
6a0d550562
Bitwise ~ operator.
2013-12-04 22:09:31 -08:00
Bob Nystrom
7355dd3dc7
Fill in some more basic syntax docs.
2013-12-04 21:51:23 -08:00
Bob Nystrom
c91fcd12cc
Treat ";" like newlines.
2013-12-04 19:12:21 -08:00
Bob Nystrom
8521d5ad79
Bunch more work on docs.
2013-12-04 07:46:41 -08:00
Bob Nystrom
047cfacede
Include "include" directory in source code metrics.
2013-12-04 07:46:23 -08:00
Bob Nystrom
157944aa27
Get closures working!
...
In the process, I had to change the grammar. There is now a strong
separation between statements and expressions. The code was just wrong
before when it popped locals at the end of a block scope because there
could be temporaries on the stack if the block was in expression
position. This fixes that.
Still need to implement closing over `this`.
2013-12-04 07:43:50 -08:00
Bob Nystrom
c14b115c02
Use char* instead of offsets for tokens.
...
Simplifies a bunch of code that works with token strings.
2013-12-01 15:22:24 -08:00
Bob Nystrom
e4043d69b4
Unify code for ending compiler.
...
There's now a single code path for the end of a chunk of bytecode, so
we can eventually put code there for capturing closures.
2013-12-01 14:59:56 -08:00
Bob Nystrom
19811143a0
Always use provided allocator for allocation.
2013-12-01 10:22:32 -08:00
Bob Nystrom
9188c00bc0
Start adding navigation to the docs.
2013-12-01 09:54:51 -08:00
Bob Nystrom
d2e82d8967
Clean up parsing a bit.
2013-12-01 00:04:46 -08:00
Bob Nystrom
60c97b5c2f
Make sure we don't go over the maximum number of locals.
2013-11-30 18:51:27 -08:00
Bob Nystrom
88852960ca
Handle local variable shadowing.
2013-11-30 18:28:01 -08:00
Bob Nystrom
74c414937c
Add JS version of binary tree benchmark.
2013-11-29 20:25:00 -08:00
Bob Nystrom
f6c9848706
Ignore scratch script.
2013-11-29 16:20:44 -08:00
Bob Nystrom
edb9032052
Get binary_trees benchmark working.
...
Wren is actually doing well in it:
wren mean: 1.9441 median: 1.9428 std_dev: 0.0260
lua mean: 3.5992 median: 3.6033 std_dev: 0.0156
python mean: 3.6667 median: 3.7097 std_dev: 0.1340
ruby mean: 1.3941 median: 1.3914 std_dev: 0.0091
2013-11-29 16:19:13 -08:00