Dmitry Volyntsev [Tue, 31 Aug 2021 13:16:32 +0000 (13:16 +0000)]
Fixed backtrace output for arrays broken in b0177571ce1d.
After the previous commit the array prototype methods were not found
during njs_object_traverse() invocation. As the result the exceptions in
Array.prototype methods were reported with a backtrace containing "native
(native)" instead of a proper function name.
Miao Wang [Wed, 11 Aug 2021 03:44:12 +0000 (11:44 +0800)]
Stream: fixed CPU hog when js_filter is registered in both directions.
Previously, a single busy chain was used to track filtered data in both
directions. This might lead to a situation when busy chunks are not
freed properly and pile up.
The fix is to separate busy chain for upstream and downstream directions.
Marking different external pointer with unique tag.
An external value has an arbitrary raw pointer associated with it.
External values with different prototypes have different C-level
structures. To ensure that only appropriate structures are fetched
by njs_vm_external() the unique tag has to be provided during
creation of external values.
Dmitry Volyntsev [Fri, 25 Jun 2021 17:00:12 +0000 (17:00 +0000)]
Fixed RegExpBuiltinExec() with UTF-8 only regexps.
The original issue was introduced in f9082cd59ba6 (0.4.2) while adding
RegExpBuiltinExec(), but after de64420d0f2b (0.6.0) it started to affect
RegExp.prototype.test() as it was rewritten according to spec.
Dmitry Volyntsev [Mon, 31 May 2021 06:55:32 +0000 (06:55 +0000)]
Removing the requirement of "aligned" attribute support.
Before 0a2a0b5a74f4, the address of values used in runtime had to be the
multiple of 16, because the address of a variable was used as its VM
index. The first 4 bits of an index signified the scope of a varible.
This is no longer the case, after 0a2a0b5a74f4 the address of a variable
is never used as its VM index.
Dmitry Volyntsev [Mon, 24 May 2021 12:33:36 +0000 (12:33 +0000)]
Suppressed spurious compilation warning with gcc-7 and older.
src/njs_regexp.c:1335:19: error: ‘pos’ may be used uninitialized in this
function [-Werror=maybe-uninitialized]
pos = njs_string_offset(s.start, s.start + s.size, pos) - s.start;
Dmitry Volyntsev [Wed, 24 Feb 2021 14:50:14 +0000 (14:50 +0000)]
Eliminating vm->main_index introduced in ea2ec4c3ed7d.
The vm->main_index was only needed for the disassembler in the
accumulative mode. It was used to prevent from disassembling the code
from the previous iterations in the CLI.
The same result can be achieved without introducing the VM level field.
Dmitry Volyntsev [Wed, 24 Feb 2021 14:48:20 +0000 (14:48 +0000)]
Decoupling parser structure from the main VM structure.
vm->parser is only needed during parsing phase, so it can be eliminated.
This improves dependencies tracking and readability.
As a side effect it fixes #372 issue on Github: previously, Function
constructor left VM context in inconsistent state if compilation failed.
The direct root cause was that a function object was created, but
because Function constructor ended prematurely the object was not fully
initialized. This is not a problem by itself because usually this
partially created object cannot be referenced. In the accumulative mode,
which is only enabled in CLI, vm->parser was used to store the references
to the variables from the previous iteration.
Dmitry Volyntsev [Wed, 10 Feb 2021 14:03:11 +0000 (14:03 +0000)]
Stream: fixed processing buffered data in body filter.
Previously, when data was proxied to upstream, it may be partially
written and is left in upstream connection buffer. Later, when
writing becomes possible again, the body filter is called but it
fails to call the next filter in the chain. This resulted in hanging
connection.
The fix is to take the buffered data in upstream connection into account.
Dmitry Volyntsev [Thu, 21 Jan 2021 18:44:58 +0000 (18:44 +0000)]
Modules: added ngx.fetch().
This is an initial implementation of Fetch API.
The following init options are supported:
body, headers, buffer_size (nginx specific), max_response_body_size
(nginx specific), method.
The following properties and methods of Response object are implemented:
arrayBuffer(), bodyUsed, json(), headers, ok, redirect, status, statusText,
text(), type, url.
The following properties and methods of Header object are implemented:
get(), getAll(), has().
Notable limitations: only http:// scheme is supported, redirects
are not handled.