| Commit message (Collapse) | Author | Age |
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Implemented atom IDs for strings, symbols and small numbers, enabling
equality checks via ID comparison
- Optimized string operations for faster property lookups and comparisons
- Removed short string inlining from njs_value_t structure
Performance improvements (arewefastyet/benchmarks/v8-v7 benchmark):
- Richards: +57% (631 → 989)
- Crypto: +7% (1445 → 1551)
- RayTrace: +37% (562 → 772)
- NavierStokes: +20% (2062 → 2465)
- Overall score: +29% (1014 → 1307)
In collaboration with Dmitry Volyntsev.
|
| |
|
|
|
|
| |
The issue was introduced in 9010aee (not released yet).
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, some promise rejections were not reported.
For example:
async function timeout(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
reject(new Error('timeout'));
}, ms);
});
}
async function handler(r) {
let v = await timeout(1000);
r.return(200);
}
|
|
|
|
|
|
|
|
|
| |
When "%*s" is specified, the first integer is interpreted as width.
Width specifies *minimum* number of characters to output. The next
string is expected to be NULL-terminated.
When "%.*s" is specified, the first integer is interpreted as precision.
Precision specifies *maximum* number of characters to output.
|
|
|
|
|
|
|
|
|
|
| |
Previously, when js_import was declared in http or stream blocks, an extra
copy of the VM instance was created for each server block. This was not
needed and consumed a lot of memory for configurations with many server
blocks.
This issue was introduced in 9b674412 (0.8.6) and was
partially fixed for location blocks only in 685b64f0 (0.8.7).
|
|
|
|
|
|
| |
To ensure optimal use of memory, SSL contexts for ngx.fetch() are now
inherited from previous levels as long as relevant js_fetch_* directives
are not redefined.
|
| |
|
|
|
|
|
| |
Previously, it ignored changes to environment variables introduced
with "env" directive.
|
| |
|
|
|
|
|
|
|
|
|
| |
There are several reasons why a file cannot be opened. Without
extra information, especially in containerized environments, these
problems are difficult to debug. Adding errno status to the
error output helps identify the root cause.
Additionally, error messages are now aligned between njs and QuickJS.
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, a new VM instance was created for every location. This is
not needed and consumes a lot of memory for large configurations.
Instead, if no new js_import is introduced on the location level server
level VM should be used.
The issue was introduced in 9b674412 (0.8.6).
This fixes #795 issue on Github.
|
|
|
|
|
|
| |
Doing JS_IsString() check first before a heavy-weight call to
JS_GetTypedArrayBuffer() which throws an exception when argument is not
a typed array.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
"js_engine" directive is introduced which sets JavaScript engine.
When the module is built with QuickJS library "js_engine qjs;" sets
QuickJS engine for the current block. By default njs engine is used.
For example,
nginx.conf:
location /a {
js_engine qjs;
# will be handled by QuickJS
js_content main.handler;
}
location /b {
# will be handled by njs
js_content main.handler;
}
QuickJS engine implements drop-in replacement for nginx/njs objects
with the following exceptions:
* nginx module API to be added later: ngx.fetch(), ngx.shared.dict.
* Built-in modules to be added later: fs, crypto, WebCrypto, xml.
* NJS specific API: njs.dump(), njs.on(), console.dump().
* js_preload_object directive.
|
|
|
|
| |
No functional changes.
|
| |
|
|
|
|
|
|
|
| |
Even though QuickJS takes length as an argument, when parsing the code,
it expects NUL byte at the end.
This change is similar to 184d2a39cb5 (0.8.5).
|
|
|
|
|
| |
Even though QuickJS takes length as an argument, when parsing the code,
it expects NUL byte at the end.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions are unsafe because they produce byte strings.
Byte strings may not work as expected with the existing JS methods.
The following functions were removed:
- njs_vm_value_string_set() use njs_vm_value_string_create() as a
drop-in replacement.
- njs_vm_value_string_alloc() use njs_chb_t and
njs_vm_value_string_create_chb() instead.
This fixes #710 on Github.
|
|
|
|
| |
Relative importing is again supported.
|
|
|
|
|
|
|
| |
HostLoadImportedModule should be implemented by host
environment according to ECMAScript specs.
The following method was removed: njs_vm_add_path().
|
|
|
|
|
|
|
|
| |
HostPromiseRejectionTracker should be implemented by host
environment according to ECMAScript specs.
The following method was removed: njs_vm_unhandled_rejection().
The following method was introduced: njs_vm_set_rejection_tracker().
|
|
|
|
|
|
|
|
|
|
|
|
| |
Checking for unhandled promise rejections while looping for pending jobs
produces false-positive reports when an rejected promised is handled
by one of the pending jobs later.
The fix is to check for unhandled promise rejections only at top level
calls like ngx_js_name_invoke() and ngx_js_name_call() and only after
all pending jobs are processed.
The issue was introduced in bc80bcb3102c (not released yet).
|
|
|
|
|
| |
Logger is not part of the JS runtime according to ECMAScript and should
be implemented by host environment.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
To align njs with other JS engines, async events are removed from njs
core. The following functions were removed: njs_vm_add_event(),
njs_vm_del_event(), njs_vm_waiting(). Instead the host is expected
to manage async events by itself.
In addition, the posted events are renamed to jobs, to better align with
the ECMA specs. The following methods are removed: njs_vm_run().
Instead, the host is expected to call njs_vm_execute_pending_job() in a
loop to execute pending jobs. The following functions were added:
njs_vm_enqueue_job().
|
| |
|
|
|
|
|
| |
This functions are not part of the ECMAScript and should be
implemented by host environment.
|
|
|
|
|
| |
After previous commit ngx_js_retval() is only used for getting the
exception value and should be renamed to better reflect the purpose.
|
|
|
|
|
| |
The following methods were added: dump(), error(), info(),
log(), time(), timeEnd(), warn().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The directive allows to declare a dictionary that is shared among the
working processes. A dictionary expects strings as keys. It stores
string or number as values. The value type is declared using
type= argument of the directive. The default type is string.
example.conf:
# Declares a shared dictionary of strings of size 1 Mb that
# removes key-value after 60 seconds of inactivity.
js_shared_dict_zone zone=foo:1M timeout=60s;
# Declares a shared dictionary of strings of size 512Kb that
# forcibly remove oldest key-value pairs when memory is not enough.
js_shared_dict_zone zone=bar:512K timeout=30s evict;
# Declares a permanent number shared dictionary of size 32Kb.
js_shared_dict_zone zone=num:32k type=number;
example.js:
function get(r) {
r.return(200, ngx.shared.foo.get(r.args.key));
}
function set(r) {
r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));
}
function delete(r) {
r.return(200, ngx.shared.bar.delete(r.args.key));
}
function increment(r) {
r.return(200, ngx.shared.num.incr(r.args.key, 2));
}
In collaboration with Artem S. Povalyukhin, Jakub Jirutka and
洪志道 (Hong Zhi Dao).
This closes #437 issue on Github.
|
|
|
|
| |
The new API allows to add new constructor/prototype pairs.
|
|
|
|
|
| |
worker_id corresponds to an nginx internal worker id.
The value is between 0 and worker_processes - 1.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The following properties were introduced:
ngx.build - an optional nginx build name, corresponds to
--build=name argument of configure script, by default is "".
ngx.conf_file_path - the file path to current nginx configuration
file.
ngx.error_log_path - the file path to current error log file.
ngx.prefix - the directory that keeps server files.
ngx.version - the nginx version as a string, for example: "1.25.0".
ngx.version_number - the nginx version as a number, for example:
1025000.
|
|
|
|
|
|
|
|
|
| |
The following environment variables are added: NJS_OPENSSL, NJS_LIBXSLT,
NJS_ZLIB. When a variable evaluates to "NO" the part of the module
related to the corresponsing library is disabled.
For example to disable libxslt related code:
NJS_LIBXSLT=NO ./configure .. --add-module=/path/to/njs/module
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, native methods were expected to return
their retval using vm->retval. This caused problem in the part
(1aa137411b09, 293fe42c5e1c) because vm->retval can be overwritten
unexpectedly as a side-effect of operations like ToString(), ToNumber().
The fix is to never used a global retval. Instead methods
are provided with a retval argument to store their retval value.
As a part of the change, retval and exception values are split.
The normal value is returned in the retval argument.
The exception value is thrown by njs_vm_throw() or njs_vm_error().
The exception value can be acquired using njs_vm_exception_get().
|
|
|
|
|
|
|
|
|
|
|
| |
- zlib.deflateRawSync(string|buffer, options?) compresses data using
deflate, and do not append a zlib header, returns Buffer.
- zlib.deflateSync(string|buffer, options?) compresses data using
deflate, returns Buffer.
- zlib.inflateRawSync(string|buffer) decompresses a raw deflate
stream, returns Buffer.
- zlib.inflateSync(string|buffer) decompresses a deflate stream,
return Buffer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- xml.parse(string|buffer) returns an XMLDoc wrapper object around
XML structure.
- xml.c14n(root_node[, excluding_node]]) canonicalizes root_node and
its children according to https://www.w3.org/TR/xml-c14n, optionally
excluding_node allows to omit from the output a part of the
document.
- xml.exclusiveC14n(root_node[, excluding_node[, withComments [,
prefix_list]]]) canonicalizes root_node and its children
according to https://www.w3.org/TR/xml-exc-c14n/. excluding_node
allows to omit from the output a part of the document
corresponding to the node and its children. withComments
is a boolean and is false by default. When withComments is true
canonicalization corresponds to
http://www.w3.org/2001/10/xml-exc-c14n#WithComments. prefix_list is
an optional string with a space separated namespace prefixes for
namespaces that should also be included into the output.
- XMLDoc an XMLDoc wrapper object around XML structure.
doc.xxx returns the first root tag named "xxx" as XMLNode wrapper
object.
- XMLNode an XMLNode wrapper object around XML tag node.
node.$tag$xxx returns the first child tag named "xxx" as XMLNode
wrapper object.
node.xxx a shorthand syntax for node.$tag$xxx.
node.$tags$xxx? returns an array of all children tags named xxx.
node.$attr$xxx returns an attribute value of xxx.
node.$attrs returns an XMLAttr wrapper object.
node.$name returns the tag name of the node.
node.$ns returns the namespace of the node.
node.$parent returns the parent of the node.
node.$text returns the node's content.
- XMLAttrs an XMLAttrs wrapper object around XML node attributes.
attrs.xxx returns a value of the xxx attribute.
- Example:
const xml = require("xml");
let data = `<note><to b="bar" a= "foo" >Tove</to><from>Jani</from></note>`;
let doc = xml.parse(data);
console.log(doc.note.to.$text) /* 'Tove' */
console.log(doc.note.to.$attr$b) /* 'bar' */
console.log(doc.note.$tags[1].$text) /* 'Jani' */
let dec = new TextDecoder();
let c14n = dec.decode(xml.exclusiveC14n(doc.note));
console.log(c14n) /* '<note><to a="foo" b="bar">Tove</to><from>Jani</from></note>' */
c14n = dec.decode(xml.exclusiveC14n(doc.note.to));
console.log(c14n) /* '<to a="foo" b="bar">Tove</to>' */
c14n = dec.decode(xml.exclusiveC14n(doc.note, doc.note.to /* excluding 'to' */));
console.log(c14n) /* '<note><from>Jani</from></note>' */
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, since 446a1cb64a6a (0.7.7), when at least one js_import directive
was declared in both HTTP and Stream, ngx.fetch() returned inapproriate
response in Stream.
The prototype for Response object was created two times for HTTP and STREAM,
but the second initialization of global variable with the index of the
Response() prototype overwrites the first value with a different value. This
caused a problem in Stream code which manifested itself as a `Stream flags`
object returned as a result of ngx.fetch() call instead of a Response instance.
The fix is to ensure that shared prototypes like a Response prototype
have indentical index value in all the modules.
This fixes #596 issue on Github.
|
| |
|
| |
|
| |
|
| |
|