Dmitry Volyntsev [Thu, 10 Nov 2022 17:33:36 +0000 (09:33 -0800)]
Change: the default JS stack size is reduced to 64k.
After 86784a68e8c8 (Computed goto) the size of a stack frame
njs_vmcode_interpreter() when -O0 is specified during compilation
increased significantly. This might cause system stack overflow for very
deep recursive calls because system stack is exausted faster than JS
stack.
It is possible now to specify JS stack size for CLI.
Dmitry Volyntsev [Tue, 25 Oct 2022 16:19:32 +0000 (09:19 -0700)]
Refactored working with an object properties.
1) njs_object_prop_t is compacted from 72 to 40 bytes on 64bit
platforms.
2) njs_object_prop_define() is revorked to accomodate fast
property creation using njs_value_create_data_prop()
which corresponds to CreateDataProperty() from the specs.
Previously, a direct pointer to the first element of an array of
rejected promise values was used to convert that element to a string.
This is not correct because that pointer may become invalid if rejected
promise values array is resized between invocation of "toString" and
"valueOf" methods which are called while converting the element to a
string.
The fix is to ensure that the rejected promise value is never changed.
Stream: improved async callback support for s.send().
Previously, the "from_upstream" flag (introduced in b33aae5e8dc6) was
ignored for s.send() calls invoked directly from a body filter.
This makes the s.send() behaviour context dependent.
The fix is to always take "from_upstream" flag into account when it is
provided.
Fixed property set instruction when key modifies base binding.
Previously, when obj[prop] expression was evaluated, and prop was an
object with custom "toString" method, which modifies obj binding as its
side-effect, the binding update was visible to property set instruction
which is not correct.
Fixed String.prototype.trimEnd() with unicode string.
Previously, when the method was invoked with a string consisting of space
characters and at least one of them was a Unicode space separator (code
point above 127) it returned invalid string value with non-zero size
but zero length.
The fix is to update the size of the resulting string appropriately.
Dmitry Volyntsev [Tue, 30 Aug 2022 04:09:12 +0000 (21:09 -0700)]
Fixed njs_value_to_string() with non-writable dst argument.
njs_arg(args, nargs, N) returns a pointer to Nth argument OR a pointer
to undefined constant value njs_value_undefined if N >= nargs.
njs_value_to_string() writes to a dst argument its result.
This means that it is incorrect to use value of njs_arg() directly
as a second argument to njs_value_to_string().
Dmitry Volyntsev [Wed, 24 Aug 2022 02:36:16 +0000 (19:36 -0700)]
Stream: improved s.send() with async callbacks.
Previously, s.send() was a context dependant method because the
direction it was sending data to was determined by a callback (upstream
or downstream) it was called from. This works for synchronous
callbacks it was originally designed, but fails with async functions
(e.g. ngx.fetch()).
The fix is to store the direction data was going to as a separate flag
which can be used by s.send().
Modules: extending allowed context for js directives.
HTTP: js_import, js_path, js_set and js_var are allowed in server and
location contexts. js_content, js_body_filter and js_header_filter
are allowed in 'if' context.
Stream: js_import, js_path, js_set and js_var are allowed in server context.
Throwing SyntaxError for octal escape sequences and \8 and \9.
Error messages are same as messages generated by FireFox, because
they are looks more informative in comparison with messages
generated by chrome, nodejs, quickjs.
HTTP: fixed r.headersOut setter for special headers.
The issue was introduced in 5b7676ec600d (0.7.5) when njs module was
adapted to changes in nginx/1.23 related to header structures.
When special headers (Content-Length, Content-Type, Content-Encoding)
were set, the value of the last outgoing header might be overwritten
with a new set value.
Ensuring that double type is always evaluated at standard precision.
Previously, GCC on x86 uses extended precision for intermediate
calculations by default. This might conflict with njs_diyfp_t because
GCC is not always rounds back the intermediate values to standard
precision.
The fix is to explicitly tell to a compiler to do so.
Dmitry Volyntsev [Wed, 29 Jun 2022 06:04:00 +0000 (23:04 -0700)]
Fixed break instruction in a try-catch block.
Previously, JUMP offset for a break instruction inside a try-catch
block was not set to a correct offset during code generation
when a return instruction was present in inner try-catch block.
The fix is to update the JUMP offset appropriately.