Welcome! Log In Create A New Profile

Advanced

[njs] Renaming nxt_mem_cache_pool_t related structures and fields.

Dmitry Volyntsev
January 28, 2019 01:20PM
details: https://hg.nginx.org/njs/rev/e98be67a10e2
branches:
changeset: 738:e98be67a10e2
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Mon Jan 28 21:18:43 2019 +0300
description:
Renaming nxt_mem_cache_pool_t related structures and fields.

nxt_mem_cache_pool_t -> nxt_mp_t.
nxt_mem_cache_* -> nxt_mp_*.
vm->mem_cache_pool -> vm->mem_pool.

diffstat:

Makefile | 4 +-
njs/njs.c | 72 +-
njs/njs.h | 2 +-
njs/njs_array.c | 18 +-
njs/njs_builtin.c | 27 +-
njs/njs_core.h | 2 +-
njs/njs_crypto.c | 6 +-
njs/njs_date.c | 2 +-
njs/njs_error.c | 4 +-
njs/njs_event.c | 4 +-
njs/njs_extern.c | 19 +-
njs/njs_fs.c | 2 +-
njs/njs_function.c | 26 +-
njs/njs_generator.c | 58 +-
njs/njs_json.c | 50 +-
njs/njs_lexer_keyword.c | 2 +-
njs/njs_object.c | 24 +-
njs/njs_parser.c | 13 +-
njs/njs_parser.h | 5 +-
njs/njs_regexp.c | 20 +-
njs/njs_shell.c | 15 +-
njs/njs_string.c | 40 +-
njs/njs_time.c | 8 +-
njs/njs_variable.c | 22 +-
njs/njs_vm.c | 29 +-
njs/njs_vm.h | 4 +-
njs/test/njs_unit_test.c | 30 +-
nxt/Makefile | 14 +-
nxt/nxt_mem_cache_pool.c | 824 --------------------------------------------
nxt/nxt_mem_cache_pool.h | 40 --
nxt/nxt_mp.c | 818 +++++++++++++++++++++++++++++++++++++++++++
nxt/nxt_mp.h | 37 +
nxt/test/Makefile | 4 +-
nxt/test/lvlhsh_unit_test.c | 35 +-
34 files changed, 1123 insertions(+), 1157 deletions(-)

diffs (truncated from 3916 to 1000 lines):

diff -r 23df46c40a53 -r e98be67a10e2 Makefile
--- a/Makefile Mon Jan 28 16:17:42 2019 +0300
+++ b/Makefile Mon Jan 28 21:18:43 2019 +0300
@@ -50,7 +50,7 @@ NXT_BUILDDIR = build
$(NXT_BUILDDIR)/nxt_pcre.o \
$(NXT_BUILDDIR)/nxt_time.o \
$(NXT_BUILDDIR)/nxt_malloc.o \
- $(NXT_BUILDDIR)/nxt_mem_cache_pool.o \
+ $(NXT_BUILDDIR)/nxt_mp.o \

ar -r -c $(NXT_BUILDDIR)/libnjs.a \
$(NXT_BUILDDIR)/njs_shell.o \
@@ -96,7 +96,7 @@ NXT_BUILDDIR = build
$(NXT_BUILDDIR)/nxt_pcre.o \
$(NXT_BUILDDIR)/nxt_time.o \
$(NXT_BUILDDIR)/nxt_malloc.o \
- $(NXT_BUILDDIR)/nxt_mem_cache_pool.o \
+ $(NXT_BUILDDIR)/nxt_mp.o \

all: test lib_test

diff -r 23df46c40a53 -r e98be67a10e2 njs/njs.c
--- a/njs/njs.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs.c Mon Jan 28 21:18:43 2019 +0300
@@ -49,7 +49,7 @@ njs_free(void *mem, void *p)
}


-const nxt_mem_proto_t njs_vm_mem_cache_pool_proto = {
+const nxt_mem_proto_t njs_vm_mp_proto = {
njs_alloc,
njs_zalloc,
njs_align,
@@ -63,14 +63,14 @@ const nxt_mem_proto_t njs_vm_mem_cache_
static void *
njs_array_mem_alloc(void *mem, size_t size)
{
- return nxt_mem_cache_alloc(mem, size);
+ return nxt_mp_alloc(mem, size);
}


static void
njs_array_mem_free(void *mem, void *p)
{
- nxt_mem_cache_free(mem, p);
+ nxt_mp_free(mem, p);
}


@@ -88,22 +88,22 @@ const nxt_mem_proto_t njs_array_mem_pro
njs_vm_t *
njs_vm_create(njs_vm_opt_t *options)
{
+ nxt_mp_t *mp;
njs_vm_t *vm;
nxt_int_t ret;
nxt_array_t *debug;
- nxt_mem_cache_pool_t *mcp;
njs_regexp_pattern_t *pattern;

- mcp = nxt_mem_cache_pool_create(&njs_vm_mem_cache_pool_proto, NULL,
- NULL, 2 * nxt_pagesize(), 128, 512, 16);
- if (nxt_slow_path(mcp == NULL)) {
+ mp = nxt_mp_create(&njs_vm_mp_proto, NULL, NULL, 2 * nxt_pagesize(),
+ 128, 512, 16);
+ if (nxt_slow_path(mp == NULL)) {
return NULL;
}

- vm = nxt_mem_cache_zalign(mcp, sizeof(njs_value_t), sizeof(njs_vm_t));
+ vm = nxt_mp_zalign(mp, sizeof(njs_value_t), sizeof(njs_vm_t));

if (nxt_fast_path(vm != NULL)) {
- vm->mem_cache_pool = mcp;
+ vm->mem_pool = mp;

ret = njs_regexp_init(vm);
if (nxt_slow_path(ret != NXT_OK)) {
@@ -116,7 +116,7 @@ njs_vm_create(njs_vm_opt_t *options)
vm->shared = options->shared;

} else {
- vm->shared = nxt_mem_cache_zalloc(mcp, sizeof(njs_vm_shared_t));
+ vm->shared = nxt_mp_zalloc(mp, sizeof(njs_vm_shared_t));
if (nxt_slow_path(vm->shared == NULL)) {
return NULL;
}
@@ -125,7 +125,7 @@ njs_vm_create(njs_vm_opt_t *options)

nxt_lvlhsh_init(&vm->shared->keywords_hash);

- ret = njs_lexer_keywords_init(mcp, &vm->shared->keywords_hash);
+ ret = njs_lexer_keywords_init(mp, &vm->shared->keywords_hash);
if (nxt_slow_path(ret != NXT_OK)) {
return NULL;
}
@@ -154,7 +154,7 @@ njs_vm_create(njs_vm_opt_t *options)

vm->external_objects = nxt_array_create(4, sizeof(void *),
&njs_array_mem_proto,
- vm->mem_cache_pool);
+ vm->mem_pool);
if (nxt_slow_path(vm->external_objects == NULL)) {
return NULL;
}
@@ -169,8 +169,7 @@ njs_vm_create(njs_vm_opt_t *options)

if (options->backtrace) {
debug = nxt_array_create(4, sizeof(njs_function_debug_t),
- &njs_array_mem_proto,
- vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(debug == NULL)) {
return NULL;
}
@@ -210,7 +209,7 @@ njs_vm_destroy(njs_vm_t *vm)
}
}

- nxt_mem_cache_pool_destroy(vm->mem_cache_pool);
+ nxt_mp_destroy(vm->mem_pool);
}


@@ -222,7 +221,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
njs_parser_t *parser, *prev;
njs_generator_t *generator;

- parser = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_parser_t));
+ parser = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_parser_t));
if (nxt_slow_path(parser == NULL)) {
return NJS_ERROR;
}
@@ -234,7 +233,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
prev = vm->parser;
vm->parser = parser;

- lexer = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_lexer_t));
+ lexer = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_lexer_t));
if (nxt_slow_path(lexer == NULL)) {
return NJS_ERROR;
}
@@ -269,8 +268,8 @@ njs_vm_compile(njs_vm_t *vm, u_char **st
*/
vm->code = NULL;

- generator = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- sizeof(njs_generator_t));
+ generator = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ sizeof(njs_generator_t));

if (nxt_slow_path(generator == NULL)) {
goto fail;
@@ -310,11 +309,11 @@ fail:
njs_vm_t *
njs_vm_clone(njs_vm_t *vm, njs_external_ptr_t external)
{
- njs_vm_t *nvm;
- uint32_t items;
- nxt_int_t ret;
- nxt_array_t *externals;
- nxt_mem_cache_pool_t *nmcp;
+ nxt_mp_t *nmp;
+ njs_vm_t *nvm;
+ uint32_t items;
+ nxt_int_t ret;
+ nxt_array_t *externals;

nxt_thread_log_debug("CLONE:");

@@ -322,16 +321,16 @@ njs_vm_clone(njs_vm_t *vm, njs_external_
return NULL;
}

- nmcp = nxt_mem_cache_pool_create(&njs_vm_mem_cache_pool_proto, NULL,
- NULL, 2 * nxt_pagesize(), 128, 512, 16);
- if (nxt_slow_path(nmcp == NULL)) {
+ nmp = nxt_mp_create(&njs_vm_mp_proto, NULL, NULL, 2 * nxt_pagesize(),
+ 128, 512, 16);
+ if (nxt_slow_path(nmp == NULL)) {
return NULL;
}

- nvm = nxt_mem_cache_zalign(nmcp, sizeof(njs_value_t), sizeof(njs_vm_t));
+ nvm = nxt_mp_zalign(nmp, sizeof(njs_value_t), sizeof(njs_vm_t));

if (nxt_fast_path(nvm != NULL)) {
- nvm->mem_cache_pool = nmcp;
+ nvm->mem_pool = nmp;

nvm->shared = vm->shared;
nvm->trace = vm->trace;
@@ -345,7 +344,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_

items = vm->external_objects->items;
externals = nxt_array_create(items + 4, sizeof(void *),
- &njs_array_mem_proto, nvm->mem_cache_pool);
+ &njs_array_mem_proto, nvm->mem_pool);

if (nxt_slow_path(externals == NULL)) {
return NULL;
@@ -380,7 +379,7 @@ njs_vm_clone(njs_vm_t *vm, njs_external_

fail:

- nxt_mem_cache_pool_destroy(nmcp);
+ nxt_mp_destroy(nmp);

return NULL;
}
@@ -400,7 +399,7 @@ njs_vm_init(njs_vm_t *vm)
size = NJS_GLOBAL_FRAME_SIZE + scope_size + NJS_FRAME_SPARE_SIZE;
size = nxt_align_size(size, NJS_FRAME_SPARE_SIZE);

- frame = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t), size);
+ frame = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), size);
if (nxt_slow_path(frame == NULL)) {
return NXT_ERROR;
}
@@ -436,7 +435,7 @@ njs_vm_init(njs_vm_t *vm)

if (vm->debug != NULL) {
backtrace = nxt_array_create(4, sizeof(njs_backtrace_entry_t),
- &njs_array_mem_proto, vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(backtrace == NULL)) {
return NXT_ERROR;
}
@@ -486,7 +485,7 @@ njs_vm_add_event(njs_vm_t *vm, njs_funct
{
njs_event_t *event;

- event = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_event_t));
+ event = nxt_mp_alloc(vm->mem_pool, sizeof(njs_event_t));
if (nxt_slow_path(event == NULL)) {
return NULL;
}
@@ -542,8 +541,7 @@ njs_vm_post_event(njs_vm_t *vm, njs_vm_e

if (nargs != 0 && !event->posted) {
event->nargs = nargs;
- event->args = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_value_t) * nargs);
+ event->args = nxt_mp_alloc(vm->mem_pool, sizeof(njs_value_t) * nargs);
if (nxt_slow_path(event->args == NULL)) {
return NJS_ERROR;
}
@@ -709,7 +707,7 @@ njs_vm_object_alloc(njs_vm_t *vm, njs_va
}

lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;
lhq.proto = &njs_object_hash_proto;

njs_string_get(name, &lhq.key);
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs.h
--- a/njs/njs.h Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs.h Mon Jan 28 21:18:43 2019 +0300
@@ -273,6 +273,6 @@ NXT_EXPORT njs_ret_t njs_vm_object_alloc
NXT_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm,
const njs_value_t *value, const nxt_str_t *key);

-extern const nxt_mem_proto_t njs_vm_mem_cache_pool_proto;
+extern const nxt_mem_proto_t njs_vm_mp_proto;

#endif /* _NJS_H_INCLUDED_ */
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_array.c
--- a/njs/njs_array.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_array.c Mon Jan 28 21:18:43 2019 +0300
@@ -130,7 +130,7 @@ njs_array_alloc(njs_vm_t *vm, uint32_t l
uint64_t size;
njs_array_t *array;

- array = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_array_t));
+ array = nxt_mp_alloc(vm->mem_pool, sizeof(njs_array_t));
if (nxt_slow_path(array == NULL)) {
goto memory_error;
}
@@ -141,8 +141,8 @@ njs_array_alloc(njs_vm_t *vm, uint32_t l
goto memory_error;
}

- array->data = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- size * sizeof(njs_value_t));
+ array->data = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ size * sizeof(njs_value_t));
if (nxt_slow_path(array->data == NULL)) {
goto memory_error;
}
@@ -224,8 +224,8 @@ njs_array_expand(njs_vm_t *vm, njs_array
goto memory_error;
}

- start = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- (prepend + size) * sizeof(njs_value_t));
+ start = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ (prepend + size) * sizeof(njs_value_t));
if (nxt_slow_path(start == NULL)) {
goto memory_error;
}
@@ -240,7 +240,7 @@ njs_array_expand(njs_vm_t *vm, njs_array

array->start = start;

- nxt_mem_cache_free(vm->mem_cache_pool, old);
+ nxt_mp_free(vm->mem_pool, old);

return NXT_OK;

@@ -970,8 +970,8 @@ njs_array_prototype_join(njs_vm_t *vm, n
}

if (max != 0) {
- values = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- sizeof(njs_value_t) * max);
+ values = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ sizeof(njs_value_t) * max);
if (nxt_slow_path(values == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -1105,7 +1105,7 @@ njs_array_prototype_join_continuation(nj
njs_release(vm, &values[i]);
}

- nxt_mem_cache_free(vm->mem_cache_pool, values);
+ nxt_mp_free(vm->mem_pool, values);

return NXT_OK;
}
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_builtin.c
--- a/njs/njs_builtin.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_builtin.c Mon Jan 28 21:18:43 2019 +0300
@@ -284,12 +284,12 @@ njs_builtin_objects_create(njs_vm_t *vm)
}

lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

for (p = njs_module_init; *p != NULL; p++) {
obj = *p;

- module = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_module_t));
+ module = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_module_t));
if (nxt_slow_path(module == NULL)) {
return NJS_ERROR;
}
@@ -629,7 +629,7 @@ njs_builtin_completions(njs_vm_t *vm, nx
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + 2;

- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ compl = nxt_mp_zalloc(vm->mem_pool, len);
if (compl == NULL) {
return NULL;
}
@@ -649,7 +649,7 @@ njs_builtin_completions(njs_vm_t *vm, nx
njs_string_get(&prop->name, &string);
len = string.length + 2;

- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ compl = nxt_mp_zalloc(vm->mem_pool, len);
if (compl == NULL) {
return NULL;
}
@@ -679,7 +679,7 @@ njs_builtin_completions(njs_vm_t *vm, nx
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + 2;

- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ compl = nxt_mp_zalloc(vm->mem_pool, len);
if (compl == NULL) {
return NULL;
}
@@ -705,7 +705,7 @@ njs_builtin_completions(njs_vm_t *vm, nx
nxt_lvlhsh_each_init(&lhe_prop, &njs_extern_hash_proto);

len = ev->name.length + 1;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ compl = nxt_mp_zalloc(vm->mem_pool, len);
if (compl == NULL) {
return NULL;
}
@@ -723,7 +723,7 @@ njs_builtin_completions(njs_vm_t *vm, nx
}

len = ev->name.length + ev->name.length + 2;
- compl = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ compl = nxt_mp_zalloc(vm->mem_pool, len);
if (compl == NULL) {
return NULL;
}
@@ -753,8 +753,7 @@ njs_vm_completions(njs_vm_t *vm, nxt_str
size = njs_builtin_completions_size(vm);

completions = nxt_array_create(size, sizeof(nxt_str_t),
- &njs_array_mem_proto,
- vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);

if (nxt_slow_path(completions == NULL)) {
return NULL;
@@ -879,7 +878,7 @@ njs_object_completions(njs_vm_t *vm, njs
} while (o != NULL);

completions = nxt_array_create(size, sizeof(nxt_str_t),
- &njs_array_mem_proto, vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);

if (nxt_slow_path(completions == NULL)) {
return NULL;
@@ -993,7 +992,7 @@ njs_builtin_match_native_function(njs_vm
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + sizeof(".");

- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ buf = nxt_mp_zalloc(vm->mem_pool, len);
if (buf == NULL) {
return NXT_ERROR;
}
@@ -1012,7 +1011,7 @@ njs_builtin_match_native_function(njs_vm
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + sizeof(".prototype.");

- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ buf = nxt_mp_zalloc(vm->mem_pool, len);
if (buf == NULL) {
return NXT_ERROR;
}
@@ -1031,7 +1030,7 @@ njs_builtin_match_native_function(njs_vm
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + sizeof(".");

- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ buf = nxt_mp_zalloc(vm->mem_pool, len);
if (buf == NULL) {
return NXT_ERROR;
}
@@ -1060,7 +1059,7 @@ njs_builtin_match_native_function(njs_vm
njs_string_get(&prop->name, &string);
len = obj->name.length + string.length + sizeof(".");

- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ buf = nxt_mp_zalloc(vm->mem_pool, len);
if (buf == NULL) {
return NXT_ERROR;
}
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_core.h
--- a/njs/njs_core.h Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_core.h Mon Jan 28 21:18:43 2019 +0300
@@ -26,7 +26,7 @@
#include <nxt_random.h>
#include <nxt_time.h>
#include <nxt_malloc.h>
-#include <nxt_mem_cache_pool.h>
+#include <nxt_mp.h>

#include <njs.h>
#include <njs_vm.h>
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_crypto.c
--- a/njs/njs_crypto.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_crypto.c Mon Jan 28 21:18:43 2019 +0300
@@ -132,7 +132,7 @@ njs_crypto_object_value_alloc(njs_vm_t *
{
njs_object_value_t *ov;

- ov = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_object_value_t));
+ ov = nxt_mp_alloc(vm->mem_pool, sizeof(njs_object_value_t));

if (nxt_fast_path(ov != NULL)) {
nxt_lvlhsh_init(&ov->object.hash);
@@ -177,7 +177,7 @@ njs_crypto_create_hash(njs_vm_t *vm, njs
return NJS_ERROR;
}

- dgst = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_digest_t));
+ dgst = nxt_mp_alloc(vm->mem_pool, sizeof(njs_digest_t));
if (nxt_slow_path(dgst == NULL)) {
njs_memory_error(vm);
return NJS_ERROR;
@@ -408,7 +408,7 @@ njs_crypto_create_hmac(njs_vm_t *vm, njs

njs_string_get(&args[2], &key);

- ctx = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_hmac_t));
+ ctx = nxt_mp_alloc(vm->mem_pool, sizeof(njs_hmac_t));
if (nxt_slow_path(ctx == NULL)) {
njs_memory_error(vm);
return NJS_ERROR;
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_date.c
--- a/njs/njs_date.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_date.c Mon Jan 28 21:18:43 2019 +0300
@@ -127,7 +127,7 @@ njs_date_constructor(njs_vm_t *vm, njs_v

done:

- date = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_date_t));
+ date = nxt_mp_alloc(vm->mem_pool, sizeof(njs_date_t));
if (nxt_slow_path(date == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_error.c
--- a/njs/njs_error.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_error.c Mon Jan 28 21:18:43 2019 +0300
@@ -57,7 +57,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_
njs_object_prop_t *prop;
nxt_lvlhsh_query_t lhq;

- error = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_object_t));
+ error = nxt_mp_alloc(vm->mem_pool, sizeof(njs_object_t));
if (nxt_slow_path(error == NULL)) {
njs_memory_error(vm);
return NULL;
@@ -71,7 +71,7 @@ njs_error_alloc(njs_vm_t *vm, njs_value_
error->__proto__ = &vm->prototypes[njs_error_prototype_index(type)].object;

lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

if (name != NULL) {
lhq.key = nxt_string_value("name");
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_event.c
--- a/njs/njs_event.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_event.c Mon Jan 28 21:18:43 2019 +0300
@@ -52,7 +52,7 @@ njs_add_event(njs_vm_t *vm, njs_event_t
lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
lhq.value = event;
lhq.proto = &njs_event_hash_proto;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

ret = nxt_lvlhsh_insert(&vm->events_hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
@@ -86,7 +86,7 @@ njs_del_event(njs_vm_t *vm, njs_event_t
njs_string_get(&ev->id, &lhq.key);
lhq.key_hash = nxt_djb_hash(lhq.key.start, lhq.key.length);
lhq.proto = &njs_event_hash_proto;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

if (ev->posted) {
ev->posted = 0;
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_extern.c
--- a/njs/njs_extern.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_extern.c Mon Jan 28 21:18:43 2019 +0300
@@ -79,7 +79,7 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv
nxt_lvlhsh_query_t lhq;

do {
- ext = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_extern_t));
+ ext = nxt_mp_alloc(vm->mem_pool, sizeof(njs_extern_t));
if (nxt_slow_path(ext == NULL)) {
goto memory_error;
}
@@ -97,14 +97,13 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv
ext->data = external->data;

if (external->method != NULL) {
- function = nxt_mem_cache_zalloc(vm->mem_cache_pool,
- sizeof(njs_function_t));
+ function = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_function_t));
if (nxt_slow_path(function == NULL)) {
goto memory_error;
}

/*
- * nxt_mem_cache_zalloc() does also:
+ * nxt_mp_zalloc() does also:
* nxt_lvlhsh_init(&function->object.hash);
* function->object.__proto__ = NULL;
*/
@@ -139,7 +138,7 @@ njs_vm_external_add(njs_vm_t *vm, nxt_lv
lhq.key = ext->name;
lhq.replace = 0;
lhq.value = ext;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;
lhq.proto = &njs_extern_hash_proto;

ret = nxt_lvlhsh_insert(hash, &lhq);
@@ -182,7 +181,7 @@ njs_vm_external_create(njs_vm_t *vm, njs
}

obj = nxt_array_add(vm->external_objects, &njs_array_mem_proto,
- vm->mem_cache_pool);
+ vm->mem_pool);
if (nxt_slow_path(obj == NULL)) {
return NXT_ERROR;
}
@@ -210,8 +209,8 @@ njs_vm_external_bind(njs_vm_t *vm, const
return NXT_ERROR;
}

- ev = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- sizeof(njs_extern_value_t));
+ ev = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ sizeof(njs_extern_value_t));
if (nxt_slow_path(ev == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -225,7 +224,7 @@ njs_vm_external_bind(njs_vm_t *vm, const
lhq.proto = &njs_extern_value_hash_proto;
lhq.value = ev;
lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

ret = nxt_lvlhsh_insert(&vm->externals_hash, &lhq);
if (nxt_slow_path(ret != NXT_OK)) {
@@ -367,7 +366,7 @@ found:
len += pr->str.length + nxt_length(".");
}

- buf = nxt_mem_cache_zalloc(vm->mem_cache_pool, len);
+ buf = nxt_mp_zalloc(vm->mem_pool, len);
if (buf == NULL) {
return NXT_ERROR;
}
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_fs.c
--- a/njs/njs_fs.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_fs.c Mon Jan 28 21:18:43 2019 +0300
@@ -903,7 +903,7 @@ static njs_ret_t njs_fs_error(njs_vm_t *
}

lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;

if (errn != 0) {
lhq.key = nxt_string_value("errno");
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_function.c
--- a/njs/njs_function.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_function.c Mon Jan 28 21:18:43 2019 +0300
@@ -18,11 +18,11 @@ njs_function_alloc(njs_vm_t *vm)
{
njs_function_t *function;

- function = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_function_t));
+ function = nxt_mp_zalloc(vm->mem_pool, sizeof(njs_function_t));

if (nxt_fast_path(function != NULL)) {
/*
- * nxt_mem_cache_zalloc() does also:
+ * nxt_mp_zalloc() does also:
* nxt_lvlhsh_init(&function->object.hash);
* function->object.__proto__ = NULL;
*/
@@ -33,8 +33,8 @@ njs_function_alloc(njs_vm_t *vm)
function->object.extensible = 1;
function->args_offset = 1;

- function->u.lambda = nxt_mem_cache_zalloc(vm->mem_cache_pool,
- sizeof(njs_function_lambda_t));
+ function->u.lambda = nxt_mp_zalloc(vm->mem_pool,
+ sizeof(njs_function_lambda_t));
if (nxt_slow_path(function->u.lambda == NULL)) {
njs_memory_error(vm);
return NULL;
@@ -66,7 +66,7 @@ njs_function_value_copy(njs_vm_t *vm, nj

size = sizeof(njs_function_t) + nesting * sizeof(njs_closure_t *);

- copy = nxt_mem_cache_alloc(vm->mem_cache_pool, size);
+ copy = nxt_mp_alloc(vm->mem_pool, size);
if (nxt_slow_path(copy == NULL)) {
njs_memory_error(vm);
return NULL;
@@ -134,7 +134,7 @@ njs_function_arguments_object_init(njs_v
njs_string_get(&prop->name, &lhq.key);

lhq.replace = 0;
- lhq.pool = vm->mem_cache_pool;
+ lhq.pool = vm->mem_pool;
lhq.proto = &njs_object_hash_proto;

ret = nxt_lvlhsh_insert(&arguments->hash, &lhq);
@@ -369,8 +369,7 @@ njs_function_frame_alloc(njs_vm_t *vm, s
return NULL;
}

- frame = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- spare_size);
+ frame = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), spare_size);
if (nxt_slow_path(frame == NULL)) {
njs_memory_error(vm);
return NULL;
@@ -454,8 +453,7 @@ njs_function_lambda_call(njs_vm_t *vm, n
size = lambda->closure_size;

if (size != 0) {
- closure = nxt_mem_cache_align(vm->mem_cache_pool,
- sizeof(njs_value_t), size);
+ closure = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t), size);
if (nxt_slow_path(closure == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -706,7 +704,7 @@ njs_function_frame_free(njs_vm_t *vm, nj

if (frame->size != 0) {
vm->stack_size -= frame->size;
- nxt_mem_cache_free(vm->mem_cache_pool, frame);
+ nxt_mp_free(vm->mem_pool, frame);
}

frame = previous;
@@ -994,7 +992,7 @@ njs_function_prototype_bind(njs_vm_t *vm
return NXT_ERROR;
}

- function = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_function_t));
+ function = nxt_mp_alloc(vm->mem_pool, sizeof(njs_function_t));
if (nxt_slow_path(function == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -1017,10 +1015,10 @@ njs_function_prototype_bind(njs_vm_t *vm
function->args_offset = nargs;
size = nargs * sizeof(njs_value_t);

- values = nxt_mem_cache_alloc(vm->mem_cache_pool, size);
+ values = nxt_mp_alloc(vm->mem_pool, size);
if (nxt_slow_path(values == NULL)) {
njs_memory_error(vm);
- nxt_mem_cache_free(vm->mem_cache_pool, function);
+ nxt_mp_free(vm->mem_pool, function);
return NXT_ERROR;
}

diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_generator.c
--- a/njs/njs_generator.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_generator.c Mon Jan 28 21:18:43 2019 +0300
@@ -461,7 +461,7 @@ njs_generate_reserve(njs_vm_t *vm, njs_g
size += size / 2;
}

- p = nxt_mem_cache_alloc(vm->mem_cache_pool, size);
+ p = nxt_mp_alloc(vm->mem_pool, size);
if (nxt_slow_path(p == NULL)) {
njs_memory_error(vm);
return NULL;
@@ -472,7 +472,7 @@ njs_generate_reserve(njs_vm_t *vm, njs_g
size = generator->code_end - generator->code_start;
memcpy(p, generator->code_start, size);

- nxt_mem_cache_free(vm->mem_cache_pool, generator->code_start);
+ nxt_mp_free(vm->mem_pool, generator->code_start);

generator->code_start = p;
generator->code_end = p + size;
@@ -880,8 +880,7 @@ njs_generate_switch_statement(njs_vm_t *
return ret;
}

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));
if (nxt_slow_path(patch == NULL)) {
return NXT_ERROR;
}
@@ -921,7 +920,7 @@ njs_generate_switch_statement(njs_vm_t *

next = patch->next;

- nxt_mem_cache_free(vm->mem_cache_pool, patch);
+ nxt_mp_free(vm->mem_pool, patch);

patch = next;
node = branch->right;
@@ -1259,8 +1258,7 @@ njs_generate_start_block(njs_vm_t *vm, n
{
njs_generator_block_t *block;

- block = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_block_t));
+ block = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_block_t));

if (nxt_fast_path(block != NULL)) {
block->next = generator->block;
@@ -1301,8 +1299,7 @@ njs_generate_make_continuation_patch(njs
{
njs_generator_patch_t *patch;

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));
if (nxt_slow_path(patch == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -1327,7 +1324,7 @@ njs_generate_patch_block(njs_vm_t *vm, n
njs_code_update_offset(generator, patch);
next = patch->next;

- nxt_mem_cache_free(vm->mem_cache_pool, patch);
+ nxt_mp_free(vm->mem_pool, patch);
}
}

@@ -1338,8 +1335,7 @@ njs_generate_make_exit_patch(njs_vm_t *v
{
njs_generator_patch_t *patch;

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));
if (nxt_slow_path(patch == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -1364,7 +1360,7 @@ njs_generate_patch_block_exit(njs_vm_t *

njs_generate_patch_block(vm, generator, block->exit);

- nxt_mem_cache_free(vm->mem_cache_pool, block);
+ nxt_mp_free(vm->mem_pool, block);
}


@@ -1391,8 +1387,7 @@ njs_generate_continue_statement(njs_vm_t

/* TODO: LABEL */

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));

if (nxt_fast_path(patch != NULL)) {
patch->next = block->continuation;
@@ -1441,8 +1436,7 @@ njs_generate_break_statement(njs_vm_t *v

/* TODO: LABEL: loop and switch may have label, block must have label. */

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));

if (nxt_fast_path(patch != NULL)) {
patch->next = block->exit;
@@ -2293,8 +2287,8 @@ njs_generate_function_scope(njs_vm_t *vm
nxt_array_t *closure;
njs_generator_t *generator;

- generator = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- sizeof(njs_generator_t));
+ generator = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ sizeof(njs_generator_t));
if (nxt_slow_path(generator == NULL)) {
return NXT_ERROR;
}
@@ -2326,7 +2320,7 @@ njs_generate_function_scope(njs_vm_t *vm
lambda->start = generator->code_start;
}

- nxt_mem_cache_free(vm->mem_cache_pool, generator);
+ nxt_mp_free(vm->mem_pool, generator);

return ret;
}
@@ -2346,7 +2340,7 @@ njs_generate_scope(njs_vm_t *vm, njs_gen

generator->code_size = 128;

- p = nxt_mem_cache_alloc(vm->mem_cache_pool, generator->code_size);
+ p = nxt_mp_alloc(vm->mem_pool, generator->code_size);
if (nxt_slow_path(p == NULL)) {
return NXT_ERROR;
}
@@ -2371,8 +2365,7 @@ njs_generate_scope(njs_vm_t *vm, njs_gen
scope_size -= NJS_INDEX_GLOBAL_OFFSET;
}

- generator->local_scope = nxt_mem_cache_alloc(vm->mem_cache_pool,
- scope_size);
+ generator->local_scope = nxt_mp_alloc(vm->mem_pool, scope_size);
if (nxt_slow_path(generator->local_scope == NULL)) {
return NXT_ERROR;
}
@@ -2392,13 +2385,13 @@ njs_generate_scope(njs_vm_t *vm, njs_gen

if (vm->code == NULL) {
vm->code = nxt_array_create(4, sizeof(njs_vm_code_t),
- &njs_array_mem_proto, vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(vm->code == NULL)) {
return NXT_ERROR;
}
}

- code = nxt_array_add(vm->code, &njs_array_mem_proto, vm->mem_cache_pool);
+ code = nxt_array_add(vm->code, &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(code == NULL)) {
return NXT_ERROR;
}
@@ -2489,8 +2482,7 @@ njs_generate_return_statement(njs_vm_t *
return NXT_OK;
}

- patch = nxt_mem_cache_alloc(vm->mem_cache_pool,
- sizeof(njs_generator_patch_t));
+ patch = nxt_mp_alloc(vm->mem_pool, sizeof(njs_generator_patch_t));
if (nxt_slow_path(patch == NULL)) {
return NXT_ERROR;
}
@@ -3087,8 +3079,8 @@ njs_generate_temp_index_get(njs_vm_t *vm
* all global variables are allocated in absolute scope
* to simplify global scope handling.
*/
- value = nxt_mem_cache_align(vm->mem_cache_pool, sizeof(njs_value_t),
- sizeof(njs_value_t));
+ value = nxt_mp_align(vm->mem_pool, sizeof(njs_value_t),
+ sizeof(njs_value_t));
if (nxt_slow_path(value == NULL)) {
return NJS_INDEX_ERROR;
}
@@ -3097,7 +3089,7 @@ njs_generate_temp_index_get(njs_vm_t *vm

} else {
value = nxt_array_add(scope->values[0], &njs_array_mem_proto,
- vm->mem_cache_pool);
+ vm->mem_pool);
if (nxt_slow_path(value == NULL)) {
return NJS_INDEX_ERROR;
}
@@ -3153,7 +3145,7 @@ njs_generate_index_release(njs_vm_t *vm,

if (cache == NULL) {
cache = nxt_array_create(4, sizeof(njs_value_t *),
- &njs_array_mem_proto, vm->mem_cache_pool);
+ &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(cache == NULL)) {
return NXT_ERROR;
}
@@ -3161,7 +3153,7 @@ njs_generate_index_release(njs_vm_t *vm,
generator->index_cache = cache;
}

- last = nxt_array_add(cache, &njs_array_mem_proto, vm->mem_cache_pool);
+ last = nxt_array_add(cache, &njs_array_mem_proto, vm->mem_pool);
if (nxt_fast_path(last != NULL)) {
*last = index;
return NXT_OK;
@@ -3177,7 +3169,7 @@ njs_generate_function_debug(njs_vm_t *vm
{
njs_function_debug_t *debug;

- debug = nxt_array_add(vm->debug, &njs_array_mem_proto, vm->mem_cache_pool);
+ debug = nxt_array_add(vm->debug, &njs_array_mem_proto, vm->mem_pool);
if (nxt_slow_path(debug == NULL)) {
return NXT_ERROR;
}
diff -r 23df46c40a53 -r e98be67a10e2 njs/njs_json.c
--- a/njs/njs_json.c Mon Jan 28 16:17:42 2019 +0300
+++ b/njs/njs_json.c Mon Jan 28 21:18:43 2019 +0300
@@ -13,7 +13,7 @@

typedef struct {
njs_vm_t *vm;
- nxt_mem_cache_pool_t *pool;
+ nxt_mp_t *pool;
nxt_uint_t depth;
const u_char *start;
const u_char *end;
@@ -82,7 +82,7 @@ typedef struct {
njs_value_t key;

njs_vm_t *vm;
- nxt_mem_cache_pool_t *pool;
+ nxt_mp_t *pool;
njs_chb_node_t *nodes;
njs_chb_node_t *last;
nxt_array_t stack;
@@ -169,7 +169,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t
njs_string_prop_t string;
njs_json_parse_ctx_t ctx;

- value = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_value_t));
+ value = nxt_mp_alloc(vm->mem_pool, sizeof(njs_value_t));
if (nxt_slow_path(value == NULL)) {
njs_memory_error(vm);
return NXT_ERROR;
@@ -187,7 +187,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t
end = p + string.size;

ctx.vm = vm;
- ctx.pool = vm->mem_cache_pool;
+ ctx.pool = vm->mem_pool;
ctx.depth = 32;
ctx.start = string.start;
ctx.end = end;
@@ -220,7 +220,7 @@ njs_json_parse(njs_vm_t *vm, njs_value_t
parse->function = args[2].data.u.function;

if (nxt_array_init(&parse->stack, NULL, 4, sizeof(njs_json_state_t),
- &njs_array_mem_proto, vm->mem_cache_pool)
+ &njs_array_mem_proto, vm->mem_pool)
== NULL)
{
goto memory_error;
@@ -262,7 +262,7 @@ njs_json_stringify(njs_vm_t *vm, njs_val

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Renaming nxt_mem_cache_pool_t related structures and fields.

Dmitry Volyntsev 297 January 28, 2019 01:20PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready