njs_function_t *functions, *constructors;
njs_object_prototype_t *prototypes;
- static const njs_object_init_t *prototype_init[] = {
+ static const njs_object_init_t *prototype_init[] = {
&njs_object_prototype_init,
&njs_array_prototype_init,
&njs_boolean_prototype_init,
static const njs_object_prototype_t prototype_values[] = {
/*
- * GCC 4 complains about unitialized .shared field,
+ * GCC 4 complains about uninitialized .shared field,
* if the .type field is initialized as .object.type.
*/
{ .object = { .type = NJS_OBJECT } },
static const njs_function_init_t native_constructors[] = {
/* SunC does not allow empty array initialization. */
- { njs_object_constructor, { 0 } },
- { njs_array_constructor, { 0 } },
- { njs_boolean_constructor, { 0 } },
- { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
- { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
- { njs_function_constructor, { 0 } },
+ { njs_object_constructor, { 0 } },
+ { njs_array_constructor, { 0 } },
+ { njs_boolean_constructor, { 0 } },
+ { njs_number_constructor, { NJS_SKIP_ARG, NJS_NUMBER_ARG } },
+ { njs_string_constructor, { NJS_SKIP_ARG, NJS_STRING_ARG } },
+ { njs_function_constructor, { 0 } },
{ njs_regexp_constructor,
{ NJS_SKIP_ARG, NJS_STRING_ARG, NJS_STRING_ARG } },
- { njs_date_constructor, { 0 } },
+ { njs_date_constructor, { 0 } },
};
static const njs_object_init_t *object_init[] = {
#define NJS_FRAME_SPARE_SIZE 512
+
+typedef struct {
+ njs_function_native_t function;
+ u_char *return_address;
+ njs_index_t retval;
+} njs_continuation_t;
+
+
#define njs_continuation(frame) \
(void *) ((u_char *) frame + NJS_NATIVE_FRAME_SIZE)
}
pattern->flags = size;
- pattern->next = NULL;
p = (u_char *) pattern + sizeof(njs_regexp_pattern_t);
pattern->source = p;
struct njs_regexp_pattern_s {
nxt_regex_t regex[2];
- njs_regexp_pattern_t *next;
/*
* A pattern source is used by RegExp.toString() method and
* RegExp.source property. So it is is stored in form "/pattern/flags"
njs_native_frame_t *previous;
njs_vmcode_generic_t *vmcode;
- start:
+start:
for ( ;; ) {
typedef struct njs_property_next_s njs_property_next_t;
-typedef struct njs_continuation_s njs_continuation_t;
-
-struct njs_continuation_s {
- njs_function_native_t function;
- u_char *return_address;
- njs_index_t retval;
-};
-
-
union njs_value_s {
/*
* The njs_value_t size is 16 bytes and must be aligned to 16 bytes
+ usage.ru_stime.tv_sec * 1000000 + usage.ru_stime.tv_usec;
if (n == 1) {
- us /= 1000;
- printf("%s: %d.%03ds\n", msg, (int) (us / 1000), (int) (us % 1000));
+ printf("%s: %.3fs\n", msg, (double) us / 1000000);
} else {
- printf("%s: %d\n", msg, (int) ((uint64_t) n * 1000000 / us));
+ printf("%s: %.3fµs, %d times/s\n",
+ msg, (double) us / n, (int) ((uint64_t) n * 1000000 / us));
}
return NXT_OK;
* Used to link pages with free chunks in pool chunk slot list
* or to link free pages in clusters.
*/
- nxt_queue_link_t link;
+ nxt_queue_link_t link;
};
typedef struct {
- NXT_RBTREE_NODE (node);
+ NXT_RBTREE_NODE (node);
uint8_t type;
uint32_t size;
typedef struct {
- nxt_queue_t pages;
+ nxt_queue_t pages;
#if (NXT_64BIT)
uint32_t size;
uint32_t chunks;
struct nxt_mem_cache_pool_s {
/* rbtree of nxt_mem_cache_block_t. */
- nxt_rbtree_t blocks;
+ nxt_rbtree_t blocks;
- nxt_queue_t free_pages;
+ nxt_queue_t free_pages;
uint8_t chunk_size_shift;
uint8_t page_size_shift;
uint32_t page_alignment;
uint32_t cluster_size;
- const nxt_mem_proto_t *proto;
+ const nxt_mem_proto_t *proto;
void *mem;
void *trace;
- nxt_mem_cache_slot_t slots[];
+ nxt_mem_cache_slot_t slots[];
};
n = pool->cluster_size >> pool->page_size_shift;
cluster = pool->proto->zalloc(pool->mem, sizeof(nxt_mem_cache_block_t)
- + n * sizeof(nxt_mem_cache_page_t));
+ + n * sizeof(nxt_mem_cache_page_t));
if (nxt_slow_path(cluster == NULL)) {
return NULL;
* instructions are longer.
*/
#define NXT_INT_T_SIZE 4
-typedef int nxt_int_t;
-typedef u_int nxt_uint_t;
+typedef int nxt_int_t;
+typedef u_int nxt_uint_t;
#else
#define NXT_INT_T_SIZE NXT_PTR_SIZE
-typedef intptr_t nxt_int_t;
-typedef uintptr_t nxt_uint_t;
+typedef intptr_t nxt_int_t;
+typedef uintptr_t nxt_uint_t;
#endif
lhq.key_hash = key;
lhq.key.length = sizeof(uintptr_t);
- lhq.key.start = (u_char *) &key;
+ lhq.key.start = (u_char *) &key;
lhq.proto = proto;
if (nxt_lvlhsh_find(lh, &lhq) == NXT_OK) {
const size_t cluster_size = 4096;
pool = nxt_mem_cache_pool_create(&mem_cache_pool_proto, NULL, NULL,
- cluster_size, page_alignment,
- page_size, min_chunk_size);
+ cluster_size, page_alignment,
+ page_size, min_chunk_size);
if (pool == NULL) {
return NXT_ERROR;
}
static nxt_int_t
-utf8_unit_test(void)
+utf8_unit_test(nxt_uint_t start)
{
u_char *p, utf8[4];
size_t len;
/* Test all overlong UTF-8. */
- for (i = NXT_UTF8_START_TEST; i < 256; i++) {
+ for (i = start; i < 256; i++) {
utf8[0] = i;
if (utf8_overlong(utf8, 1) != NXT_OK) {
int
-main(void)
+main(int argc, char **argv)
{
- return utf8_unit_test();
+ nxt_uint_t start;
+
+ if (argc > 1 && argv[1][0] == 'a') {
+ start = NXT_UTF8_START_TEST;
+
+ } else {
+ start = 256;
+ }
+
+ return utf8_unit_test(start);
}