Tor Andersson
df8559e7bd
Bug 704749: Clear jump list after patching jump addresses.
...
Since we can emit a statement multiple times when compiling try/finally
we have to use a new patch list for each instance.
2021-12-06 11:48:32 +01:00
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
6b522a0b1f
Issue 115: Fix compilation of small floating point numbers.
...
The check for whether a number is an integer or not failed on number
too small because we were using an addition in the test.
2019-11-28 11:31:09 +01:00
Tor Andersson
3d3f473c39
Bug 701887: Create arguments if eval is present.
...
We can't know at compile time that the 'arguments' object will not be used
from the eval statement, so err on the side of caution and always create
the arguments object if eval can be called.
2019-11-19 12:53:28 +01:00
Tor Andersson
1e5479084b
Bug 700947: Add missing ENDTRY opcode in try/catch/finally byte code.
...
In one of the code branches in handling exceptions in the catch block
we forgot to call the ENDTRY opcode to pop the inner hidden try.
This leads to an unbalanced exception stack which can cause a crash
due to us jumping to a stack frame that has already been exited.
2019-04-04 12:41:02 +02:00
Tor Andersson
52c22be9c4
Fix MSVC compile errors.
2019-03-25 21:00:59 +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
9f0153a025
Fix typo in ctypeof.
2019-03-18 14:00:02 +01:00
Tor Andersson
8e57b47c5d
Only emit line ops for actual exit handler statements.
2019-03-08 12:55:21 +01:00
Tor Andersson
ce02a9d729
Handle empty scripts.
2019-03-08 10:57:32 +01:00
Tor Andersson
cb1d50bca4
Improve line number tracking in compiler.
2019-03-07 18:35:51 +01:00
Tor Andersson
914ae72a24
Improve line number tracking in parser.
...
Associate statements with their initial keyword, and expressions
with their operator token.
2019-03-07 16:08:06 +01:00
Tor Andersson
6a592abfc4
Use emitarg instead of emitraw to emit opcode arguments.
2019-03-07 16:08:06 +01:00
Tor Andersson
245a6f97e6
Fix 700090, 700094, 700095: Iterate through lists in AST analysis passes.
2018-11-05 16:00:13 +01:00
Sebastian Rasmussen
7448a82448
Fix gcc compiler warnings about switch fallthroughs.
2018-09-11 12:47:31 +02:00
Tor Andersson
dcb3f03e90
Inherit strictness from invoking function in eval.
2018-09-03 16:10:02 +02:00
Avi Halachmi (:avih)
bd75628fe2
js_compile: Don't shadow formal arguments with function name.
...
When a function's name is the same as one of its formal arguments, the
name should refer to the argument, but it was referring to the function.
Other than the obvious bug of referencing an incorrect value, it also
failed to compile in such case in strict mode (but only for lightweight
functions) with "duplicate formal parameter". On non lightweight (and
strict) it was "just" an incorrect value.
2017-08-08 12:28:20 +02:00
Tor Andersson
0365576bab
Emit line numbers for each entry in compound literals.
2017-05-16 13:17:04 +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
5008105780
Fix 697172: degenerate labeled break/continue statement.
...
A labeled break statement will look for a matching label through
its chain of parent statements. We start looking at the break statement
though, so if the label is attached to the break, we'll return the break
statement itself as a break target.
Start looking for targets one level up instead.
2016-10-26 14:31:53 +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
c1ad1ba1e4
Fix mistake when compiling array literals.
...
The values were being used as keys, and vice versa.
2015-02-02 17:27:07 +01:00
Tor Andersson
d9ed73fd71
strict mode: 'this' is undefined for normal function calls.
...
Global (script) code still uses the global object as 'this'.
Eval still uses the calling context's 'this'.
2015-01-14 13:05:12 +01:00
Tor Andersson
d05415b053
strict mode: No redefining 'eval' or 'arguments'.
2015-01-14 13:05:12 +01: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
63a542aa08
strict mode: No duplicate formal parameters.
2015-01-14 13:05:12 +01:00
Tor Andersson
62c6e3f62c
strict mode: No delete operator with an unqualified name.
...
delete is only allowed on x.y and x[y].
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
e673ae661f
Clean up some error messages.
2015-01-08 15:25:04 +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
5a48671015
Clean up cassign[op] arguments.
2014-12-02 16:01:22 +01:00
Tor Andersson
bc51de87ef
Use of try/catch must disqualify a function from being lightweight.
2014-11-17 12:21:04 +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
89dc0c8cd1
Fix warnings on Windows.
...
Call js_realloc, not realloc.
4 warnings remain due to the constnes of js_func strtab and vartab
entries.
2014-03-26 13:09:53 +01:00
Tor Andersson
d664d08a8e
Fix compilation of -0.
2014-03-13 14:23:30 +01: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
67b33c5a86
Handle malloc failure by throwing exceptions.
2014-02-28 14:24:13 +01:00
Tor Andersson
e7e1e0de9c
Build on MSVC 2005.
2014-02-25 20:43:14 +01:00
Tor Andersson
e4a6860f6e
More signedness fixes.
2014-02-25 00:22:17 +01:00
Tor Andersson
ef891c5c9e
Oops. Forgot to emit "setprop" for assignment operators.
2014-02-24 22:44:59 +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
577585c2d1
Silence scan-build warnings about maybe uninitialized variables.
2014-02-18 15:17:33 +01:00
Tor Andersson
588fdd18d6
Small cleanups.
2014-02-18 14:38:50 +01:00
Tor Andersson
5f3ea4132d
Rename jump to emitjump in compiler.
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
722c02ee1b
Never compile scripts as lightweight functions.
2014-02-11 14:25:33 +01:00