Commit Graph

58 Commits

Author SHA1 Message Date
Tor Andersson
33ffe6efeb Inline doubles and interned string pointers in the byte code.
Avoid linearly searched per function string and number tables.
2021-03-26 14:35:14 +01:00
Tor Andersson
06a6f9fb11 Issue #120: Optimize array construction bytecode.
Use a specialized array initializer that pushes values to the end
of the array instead of using a lot of setprop. This avoids the need
to create a lot of number constants for the array indices.
2021-03-26 12:05:35 +01:00
Tor Andersson
bb65f18fcc Set 'lightweight' and 'arguments' during compile pass.
Avoid doing a separate analysis pass by using the same bytecode for both
lightweight and non-lightweight functions.
2019-03-22 14:00:20 +01:00
Tor Andersson
f5de9d4d2e Remove line opcode in favor of storing the line for each instruction. 2019-03-22 14:00:20 +01:00
Tor Andersson
20d0fa04df Simplify opcodes: numbers and integer constants. 2019-03-22 14:00:20 +01:00
Tor Andersson
dcb3f03e90 Inherit strictness from invoking function in eval. 2018-09-03 16:10:02 +02:00
Tor Andersson
8a26e20943 Compile functions with per-function strictness.
Recognize 'use strict' pragma.
Move strictness checks into compiler from parser.
2017-04-17 23:27:00 +02:00
Tor Andersson
75cab70afd Handle undefined this at the OP_THIS level.
Don't distinguish lax mode code by pushing the global object.
Always push undefined and let the calling code promote an undefined
this to the global object instead.
2017-04-17 14:57:38 +02:00
Tor Andersson
a5c747f1d4 Fix 697171: missed an operand in the bytecode debugger dump. 2016-10-25 14:08:27 +02:00
Tor Andersson
3e3c382a0c Avoid using 'unsigned int'.
Mixing signed and unsigned ints is just a plain headache.
2016-04-27 16:26:00 +02:00
Tor Andersson
44c0e12d62 strict mode: Check duplicate property names.
Also simplify object initialiser opcode set.
2015-01-14 13:05:12 +01:00
Tor Andersson
40dd4a252f Add eval op-code to implement proper 'this' binding for eval code. 2015-01-08 15:55:57 +01:00
Tor Andersson
031513b25b Add stack traces to error objects.
Revert 'add context and flag argument to js_newstate' commit.

The context argument just adds clutter. The flag which was intended
for JS_DEBUG and/or JS_STRICT shouldn't be necessary.

js_newcfunction and js_newcconstructor need an extra argument, the
name of the function to use in stack traces.
2014-12-03 01:18:21 +01:00
Tor Andersson
8a659b2821 Typedef instruction and check addresses and literals for overflow when emitting code. 2014-10-09 15:08:02 +02:00
Tor Andersson
1c52e8b7b4 Fix semantics of x++: return ToNumber(x) rather than x.
Remove unused opcodes.
2014-03-12 15:23:00 +01:00
Tor Andersson
e4a6860f6e More signedness fixes. 2014-02-25 00:22:17 +01:00
Tor Andersson
2d28162c2f typeof X when X in not declared should return undefined rather than throw. 2014-02-24 12:03:59 +01:00
Tor Andersson
588fdd18d6 Small cleanups. 2014-02-18 14:38:50 +01:00
Tor Andersson
7d698ae923 Compile pre/post increment/decrement as special opcodes.
They always do addition, never concatenation as strings, so we can't
treat "++a" the same as "a += 1".
2014-02-11 14:57:56 +01:00
Tor Andersson
be3ed5250c Some cleanups. 2014-02-10 23:51:34 +01:00
Tor Andersson
e45115faee Handle variable shadowing. 2014-02-10 18:54:52 +01:00
Tor Andersson
68862386d8 Implement lightweight functions.
When a function does not use eval, arguments, with and has no inner
functions it does not need a closure. We can call it without creating
a variable object if we store local variables on the stack instead.
2014-02-10 18:00:13 +01:00
Tor Andersson
d5b83c3bf2 Implement Function constructor. 2014-02-07 11:44:39 +01:00
Tor Andersson
b659aa50e1 Compile ES5 getters and setters. 2014-02-06 13:56:50 +01:00
Tor Andersson
8e10640e9e Add RegExp class (with no actual regex implementation hooked up). 2014-01-28 17:19:09 +01:00
Tor Andersson
34b9fda6f8 Create special initializer opcodes for brevity.
Pop the key and value, don't pop the object.
2014-01-25 00:58:14 +01:00
Tor Andersson
d948459f44 Record whether a function is script or function code.
Script code returns the value of the last evaluated expression.
Function code returns the explicit return value or undefined.
2014-01-24 01:48:24 +01:00
Tor Andersson
546ee1e6c2 Fix switch test-chain stack leftovers. Fix iterator on null and undefined. 2014-01-24 01:48:24 +01:00
Tor Andersson
2b209d3f55 Omit needless setjmp guard over catch block in try/catch statement.
Make the catch opcodes only set the scope chain, and add explicit
try/endtry opcodes for the catch block in try/catch/finally statements.
2014-01-23 17:08:59 +01:00
Tor Andersson
40572172a5 Add 'string' operand versions of get/set/del property opcodes. 2014-01-23 17:08:59 +01:00
Tor Andersson
0fd3f364ec Add iterator object class for internal use in for-in loops.
Flatten all enumerable properties in object prototype chain
into a linked list to enumerate.
2014-01-23 10:07:22 +01:00
Tor Andersson
c55b4e18bc Implement instanceof expression. 2014-01-23 00:16:21 +01:00
Tor Andersson
cf9867c833 Implement try/catch/finally exception handling.
TODO: return/break/continue and finally.
2014-01-22 18:04:11 +01:00
Tor Andersson
f1e1171eef Clean up stack and with/endwith balancing on abrupt exits. 2014-01-22 16:24:45 +01:00
Tor Andersson
fdd94dc5dd Break and continue to labelled statements. 2014-01-22 15:18:02 +01:00
Tor Andersson
759acbd4dd Add enum-to-string functions for syntax tree and opcodes. 2014-01-20 16:18:49 +01:00
Tor Andersson
d3d92291f6 Reorder switch cases to match opcode order. 2014-01-18 17:44:20 +01:00
Tor Andersson
24f48308ce Support 'typeof' operator. 2014-01-18 17:38:40 +01:00
Tor Andersson
96ca91ec7c Garbage collector lists. 2014-01-17 23:02:14 +01:00
Tor Andersson
5ce44f9d4a Remember file name and line where a function object came from.
Make "debugger" statement useful: dump current function bytecode,
stack, and environment scope chain.
2014-01-17 16:00:51 +01:00
Tor Andersson
56042de82b Fix the shape of the outer API a bit. Implement eval. 2014-01-16 21:36:54 +01:00
Tor Andersson
7228ec51c4 Handle "this" by always keeping it in stack[0]. 2014-01-16 20:48:43 +01:00
Tor Andersson
3715d6d145 Add JS_NORETURN declaration to longjumping functions. 2014-01-16 14:15:17 +01:00
Tor Andersson
18b192b8aa Minor cleanups. 2014-01-16 02:14:07 +01:00
Tor Andersson
4a3fdcef74 Functions! 2014-01-16 00:23:27 +01:00
Tor Andersson
ede0f888ce Prepare for objects with internal properties, and closures as objects. 2014-01-15 23:41:41 +01:00
Tor Andersson
47e88ac805 Calculate stack index for both positive and negative numbers.
Call all functions with "this" as the first argument.

Negative indexes count from the top, positive indexes count from
the current function call frame (so arguments start at 0).
2014-01-15 01:34:30 +01:00
Tor Andersson
6b1906f3b5 Add for-in iterator. 2014-01-15 00:36:22 +01:00
Tor Andersson
f77a6e7e8e Implement value stack and use it in the interpreter.
We can now run simple programs that don't use function calls.
2014-01-14 18:17:06 +01:00
Tor Andersson
a4cc139e1c Add js_Object with js_Property binary search tree.
Use object to represent a variable record and implement variable
loading and storing in the interpreter.
2014-01-13 21:32:33 +01:00