Skip to content

Commit

Permalink
Use atom_ids in the code.
Browse files Browse the repository at this point in the history
-- use njs_atom_atomize_key();
-- remove symbol_generator;
-- remove NJS_SYMBOL_KNOWN_MAX;
-- use atom_ids in njs_object_hash_test();
-- use atom_id as key_hash;
-- remove NJS_*_HASH;
-- remove not used files.
  • Loading branch information
VadimZhestikov committed Nov 5, 2024
1 parent 88807fd commit d77fe57
Show file tree
Hide file tree
Showing 38 changed files with 590 additions and 1,776 deletions.
2 changes: 1 addition & 1 deletion nginx/ngx_js.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ ngx_engine_njs_init(ngx_engine_t *engine, ngx_engine_opts_t *opts)
vm_options.argv = ngx_argv;
vm_options.argc = ngx_argc;

vm = njs_vm_create(&vm_options);
vm = njs_vm_create_parent(&vm_options, opts->conf->preload_vm);
if (vm == NULL) {
return NGX_ERROR;
}
Expand Down
1 change: 0 additions & 1 deletion src/njs.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ enum {
NJS_SYMBOL_TO_PRIMITIVE,
NJS_SYMBOL_TO_STRING_TAG,
NJS_SYMBOL_UNSCOPABLES,
NJS_SYMBOL_KNOWN_MAX,
};


Expand Down
13 changes: 7 additions & 6 deletions src/njs_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ static njs_object_prop_t njs_array_constructor_properties[] =
NJS_DECLARE_PROP_NAME(njs_atom.vs_Array),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create,
0, 0, 0),
0, 0),

NJS_DECLARE_PROP_NATIVE(njs_atom.vs_from, njs_array_from, 1, 0),

Expand Down Expand Up @@ -1620,7 +1620,8 @@ njs_array_prototype_to_string(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_lvlhsh_query_t lhq;

if (njs_is_object(njs_argument(args, 0))) {
njs_object_property_init(&lhq, &njs_atom.vs_join, NJS_JOIN_HASH);
lhq.proto = &njs_object_hash_proto;
lhq.key_hash = njs_atom.vs_join.atom_id;

ret = njs_object_property(vm, njs_object(njs_argument(args, 0)), &lhq,
&value);
Expand Down Expand Up @@ -3189,12 +3190,12 @@ njs_array_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args,

static njs_object_prop_t njs_array_prototype_properties[] =
{
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_array_length, 0, 0,
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_array_length, 0,
NJS_OBJECT_PROP_VALUE_W),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_constructor,
njs_object_prototype_create_constructor,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_object_prototype_create_constructor, 0,
NJS_OBJECT_PROP_VALUE_CW),

NJS_DECLARE_PROP_NATIVE(njs_atom.vs_concat, njs_array_prototype_concat, 1,
0),
Expand Down Expand Up @@ -3296,7 +3297,7 @@ static const njs_object_init_t njs_array_prototype_init = {

njs_object_prop_t njs_array_instance_properties[] =
{
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_array_length, 0, 0,
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_array_length, 0,
NJS_OBJECT_PROP_VALUE_W),
};

Expand Down
6 changes: 3 additions & 3 deletions src/njs_array_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static njs_object_prop_t njs_array_buffer_constructor_properties[] =
NJS_DECLARE_PROP_NAME(njs_atom.vs_ArrayBuffer),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create,
0, 0, 0),
0, 0),

NJS_DECLARE_PROP_GETTER(njs_atom.vw_species,
njs_array_buffer_get_this,
Expand Down Expand Up @@ -265,8 +265,8 @@ njs_array_buffer_detach(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
static njs_object_prop_t njs_array_buffer_prototype_properties[] =
{
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_constructor,
njs_object_prototype_create_constructor,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_object_prototype_create_constructor, 0,
NJS_OBJECT_PROP_VALUE_CW),

NJS_DECLARE_PROP_GETTER(njs_atom.vs_byteLength,
njs_array_buffer_prototype_byte_length, 0),
Expand Down
11 changes: 6 additions & 5 deletions src/njs_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ static njs_object_prop_t njs_async_constructor_properties[] =

NJS_DECLARE_PROP_NAME(njs_atom.vs_AsyncFunction),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create, 0, 0, 0),
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create,
0, 0),
};


Expand All @@ -183,8 +184,8 @@ static njs_object_prop_t njs_async_prototype_properties[] =
NJS_OBJECT_PROP_VALUE_C),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_constructor,
njs_object_prototype_create_constructor,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_object_prototype_create_constructor, 0,
NJS_OBJECT_PROP_VALUE_CW),
};


Expand All @@ -205,9 +206,9 @@ const njs_object_type_init_t njs_async_function_type_init = {
static njs_object_prop_t njs_async_function_instance_properties[] =
{
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_function_instance_length, 0,
0, NJS_OBJECT_PROP_VALUE_C),
NJS_OBJECT_PROP_VALUE_C),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_name, njs_function_instance_name, 0, 0,
NJS_DECLARE_PROP_HANDLER(njs_atom.vs_name, njs_function_instance_name, 0,
NJS_OBJECT_PROP_VALUE_C),
};

Expand Down
10 changes: 5 additions & 5 deletions src/njs_boolean.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static njs_object_prop_t njs_boolean_constructor_properties[] =
NJS_OBJECT_PROP_VALUE_C),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create,
0, 0, 0),
0, 0),
};


Expand Down Expand Up @@ -113,12 +113,12 @@ njs_boolean_prototype_to_string(njs_vm_t *vm, njs_value_t *args,
static njs_object_prop_t njs_boolean_prototype_properties[] =
{
NJS_DECLARE_PROP_HANDLER(njs_atom.vs___proto__,
njs_primitive_prototype_get_proto,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_primitive_prototype_get_proto, 0,
NJS_OBJECT_PROP_VALUE_CW),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_constructor,
njs_object_prototype_create_constructor,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_object_prototype_create_constructor, 0,
NJS_OBJECT_PROP_VALUE_CW),

NJS_DECLARE_PROP_NATIVE(njs_atom.vs_valueOf, njs_boolean_prototype_value_of,
0, 0),
Expand Down
8 changes: 4 additions & 4 deletions src/njs_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2473,11 +2473,11 @@ static njs_object_prop_t njs_buffer_prototype_properties[] =
NJS_OBJECT_PROP_VALUE_C),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_constructor,
njs_object_prototype_create_constructor,
0, 0, NJS_OBJECT_PROP_VALUE_CW),
njs_object_prototype_create_constructor, 0,
NJS_OBJECT_PROP_VALUE_CW),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_length, njs_buffer_prototype_length, 0,
0, 0),
0),

NJS_DECLARE_PROP_NATIVE(njs_atom.vs_readInt8, njs_buffer_prototype_read_int,
1, njs_buffer_magic(1, 1, 1)),
Expand Down Expand Up @@ -2673,7 +2673,7 @@ static njs_object_prop_t njs_buffer_constructor_properties[] =
NJS_DECLARE_PROP_NAME(njs_atom.vs_Buffer),

NJS_DECLARE_PROP_HANDLER(njs_atom.vs_prototype, njs_object_prototype_create,
0, 0, 0),
0, 0),

NJS_DECLARE_PROP_NATIVE(njs_atom.vs_alloc, njs_buffer_alloc_safe, 0, 1),

Expand Down
Loading

0 comments on commit d77fe57

Please sign in to comment.