mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Remove printf calls from jerry core
Related issue: #964 JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
parent
12916c6c55
commit
a004375e1d
@ -51,7 +51,7 @@
|
||||
/**
|
||||
* The implementation-defined Global object's 'print' routine
|
||||
*
|
||||
* The routine converts all of its arguments to strings and outputs them using 'printf'.
|
||||
* The routine converts all of its arguments to strings and outputs them using 'jerry_port_console'.
|
||||
*
|
||||
* Code points, with except of NUL character, that are representable with one utf8-byte
|
||||
* are outputted as is, using "%c" format argument, and other code points are outputted as "\uhhll",
|
||||
@ -68,8 +68,6 @@ ecma_builtin_global_object_print (ecma_value_t this_arg, /**< this argument */
|
||||
JERRY_UNUSED (this_arg);
|
||||
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
|
||||
|
||||
/* TODO: Move the 'print' routine out of engine core. */
|
||||
|
||||
for (ecma_length_t arg_index = 0;
|
||||
ecma_is_value_empty (ret_value) && arg_index < args_number;
|
||||
arg_index++)
|
||||
@ -97,11 +95,11 @@ ecma_builtin_global_object_print (ecma_value_t this_arg, /**< this argument */
|
||||
|
||||
if (code_unit == LIT_CHAR_NULL)
|
||||
{
|
||||
printf ("\\u0000");
|
||||
jerry_port_console ("\\u0000");
|
||||
}
|
||||
else if (code_unit <= LIT_UTF8_1_BYTE_CODE_POINT_MAX)
|
||||
{
|
||||
printf ("%c", (char) code_unit);
|
||||
jerry_port_console ("%c", (char) code_unit);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -115,13 +113,13 @@ ecma_builtin_global_object_print (ecma_value_t this_arg, /**< this argument */
|
||||
0,
|
||||
JERRY_BITSINBYTE);
|
||||
|
||||
printf ("\\u%02x%02x", byte_high, byte_low);
|
||||
jerry_port_console ("\\u%02x%02x", byte_high, byte_low);
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_index < args_number - 1)
|
||||
{
|
||||
printf (" ");
|
||||
jerry_port_console (" ");
|
||||
}
|
||||
|
||||
JMEM_FINALIZE_LOCAL_ARRAY (utf8_str_p);
|
||||
@ -129,7 +127,7 @@ ecma_builtin_global_object_print (ecma_value_t this_arg, /**< this argument */
|
||||
ECMA_FINALIZE (str_value);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
jerry_port_console ("\n");
|
||||
|
||||
if (ecma_is_value_empty (ret_value))
|
||||
{
|
||||
|
||||
@ -609,27 +609,28 @@ jmem_heap_stats_print (void)
|
||||
{
|
||||
jmem_heap_stats_t *heap_stats = &JERRY_CONTEXT (jmem_heap_stats);
|
||||
|
||||
printf ("Heap stats:\n"
|
||||
" Heap size = %zu bytes\n"
|
||||
" Allocated = %zu bytes\n"
|
||||
" Waste = %zu bytes\n"
|
||||
" Peak allocated = %zu bytes\n"
|
||||
" Peak waste = %zu bytes\n"
|
||||
" Skip-ahead ratio = %zu.%04zu\n"
|
||||
" Average alloc iteration = %zu.%04zu\n"
|
||||
" Average free iteration = %zu.%04zu\n"
|
||||
"\n",
|
||||
heap_stats->size,
|
||||
heap_stats->allocated_bytes,
|
||||
heap_stats->waste_bytes,
|
||||
heap_stats->peak_allocated_bytes,
|
||||
heap_stats->peak_waste_bytes,
|
||||
heap_stats->skip_count / heap_stats->nonskip_count,
|
||||
heap_stats->skip_count % heap_stats->nonskip_count * 10000 / heap_stats->nonskip_count,
|
||||
heap_stats->alloc_iter_count / heap_stats->alloc_count,
|
||||
heap_stats->alloc_iter_count % heap_stats->alloc_count * 10000 / heap_stats->alloc_count,
|
||||
heap_stats->free_iter_count / heap_stats->free_count,
|
||||
heap_stats->free_iter_count % heap_stats->free_count * 10000 / heap_stats->free_count);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,
|
||||
"Heap stats:\n"
|
||||
" Heap size = %zu bytes\n"
|
||||
" Allocated = %zu bytes\n"
|
||||
" Waste = %zu bytes\n"
|
||||
" Peak allocated = %zu bytes\n"
|
||||
" Peak waste = %zu bytes\n"
|
||||
" Skip-ahead ratio = %zu.%04zu\n"
|
||||
" Average alloc iteration = %zu.%04zu\n"
|
||||
" Average free iteration = %zu.%04zu\n"
|
||||
"\n",
|
||||
heap_stats->size,
|
||||
heap_stats->allocated_bytes,
|
||||
heap_stats->waste_bytes,
|
||||
heap_stats->peak_allocated_bytes,
|
||||
heap_stats->peak_waste_bytes,
|
||||
heap_stats->skip_count / heap_stats->nonskip_count,
|
||||
heap_stats->skip_count % heap_stats->nonskip_count * 10000 / heap_stats->nonskip_count,
|
||||
heap_stats->alloc_iter_count / heap_stats->alloc_count,
|
||||
heap_stats->alloc_iter_count % heap_stats->alloc_count * 10000 / heap_stats->alloc_count,
|
||||
heap_stats->free_iter_count / heap_stats->free_count,
|
||||
heap_stats->free_iter_count % heap_stats->free_count * 10000 / heap_stats->free_count);
|
||||
} /* jmem_heap_stats_print */
|
||||
|
||||
/**
|
||||
|
||||
@ -204,18 +204,19 @@ jmem_pools_stats_print (void)
|
||||
{
|
||||
jmem_pools_stats_t *pools_stats = &JERRY_CONTEXT (jmem_pools_stats);
|
||||
|
||||
printf ("Pools stats:\n"
|
||||
" Chunk size: %zu\n"
|
||||
" Pool chunks: %zu\n"
|
||||
" Peak pool chunks: %zu\n"
|
||||
" Free chunks: %zu\n"
|
||||
" Pool reuse ratio: %zu.%04zu\n",
|
||||
JMEM_POOL_CHUNK_SIZE,
|
||||
pools_stats->pools_count,
|
||||
pools_stats->peak_pools_count,
|
||||
pools_stats->free_chunks,
|
||||
pools_stats->reused_count / pools_stats->new_alloc_count,
|
||||
pools_stats->reused_count % pools_stats->new_alloc_count * 10000 / pools_stats->new_alloc_count);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,
|
||||
"Pools stats:\n"
|
||||
" Chunk size: %zu\n"
|
||||
" Pool chunks: %zu\n"
|
||||
" Peak pool chunks: %zu\n"
|
||||
" Free chunks: %zu\n"
|
||||
" Pool reuse ratio: %zu.%04zu\n",
|
||||
JMEM_POOL_CHUNK_SIZE,
|
||||
pools_stats->pools_count,
|
||||
pools_stats->peak_pools_count,
|
||||
pools_stats->free_chunks,
|
||||
pools_stats->reused_count / pools_stats->new_alloc_count,
|
||||
pools_stats->reused_count % pools_stats->new_alloc_count * 10000 / pools_stats->new_alloc_count);
|
||||
} /* jmem_pools_stats_print */
|
||||
|
||||
/**
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -33,13 +34,13 @@ void __noreturn
|
||||
jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
printf ("Error: ");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: ");
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ERR_OUT_OF_MEMORY:
|
||||
{
|
||||
printf ("ERR_OUT_OF_MEMORY\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "ERR_OUT_OF_MEMORY\n");
|
||||
break;
|
||||
}
|
||||
case ERR_SYSCALL:
|
||||
@ -49,17 +50,17 @@ jerry_fatal (jerry_fatal_code_t code) /**< status code */
|
||||
}
|
||||
case ERR_REF_COUNT_LIMIT:
|
||||
{
|
||||
printf ("ERR_REF_COUNT_LIMIT\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "ERR_REF_COUNT_LIMIT\n");
|
||||
break;
|
||||
}
|
||||
case ERR_UNIMPLEMENTED_CASE:
|
||||
{
|
||||
printf ("ERR_UNIMPLEMENTED_CASE\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "ERR_UNIMPLEMENTED_CASE\n");
|
||||
break;
|
||||
}
|
||||
case ERR_FAILED_INTERNAL_ASSERTION:
|
||||
{
|
||||
printf ("ERR_FAILED_INTERNAL_ASSERTION\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "ERR_FAILED_INTERNAL_ASSERTION\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -83,8 +84,12 @@ jerry_assert_fail (const char *assertion, /**< assertion condition string */
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
printf ("ICE: Assertion '%s' failed at %s(%s):%lu.\n",
|
||||
assertion, file, function, (unsigned long) line);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR,
|
||||
"ICE: Assertion '%s' failed at %s(%s):%lu.\n",
|
||||
assertion,
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
#else /* JERRY_NDEBUG */
|
||||
(void) assertion;
|
||||
(void) file;
|
||||
@ -106,7 +111,11 @@ jerry_unreachable (const char *comment, /**< comment to unreachable mark if exis
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
printf ("ICE: Unreachable control path at %s(%s):%lu was executed", file, function, (unsigned long) line);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR,
|
||||
"ICE: Unreachable control path at %s(%s):%lu was executed",
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
#else /* JERRY_NDEBUG */
|
||||
(void) file;
|
||||
(void) function;
|
||||
@ -115,9 +124,10 @@ jerry_unreachable (const char *comment, /**< comment to unreachable mark if exis
|
||||
|
||||
if (comment != NULL)
|
||||
{
|
||||
printf ("(%s)", comment);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "(%s)", comment);
|
||||
}
|
||||
printf (".\n");
|
||||
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, ".\n");
|
||||
|
||||
jerry_fatal (ERR_FAILED_INTERNAL_ASSERTION);
|
||||
} /* jerry_unreachable */
|
||||
@ -133,7 +143,11 @@ jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if
|
||||
const uint32_t line) /**< line */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
printf ("SORRY: Unimplemented case at %s(%s):%lu was executed", file, function, (unsigned long) line);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR,
|
||||
"SORRY: Unimplemented case at %s(%s):%lu was executed",
|
||||
file,
|
||||
function,
|
||||
(unsigned long) line);
|
||||
#else /* JERRY_NDEBUG */
|
||||
(void) file;
|
||||
(void) function;
|
||||
@ -142,9 +156,10 @@ jerry_unimplemented (const char *comment, /**< comment to unimplemented mark if
|
||||
|
||||
if (comment != NULL)
|
||||
{
|
||||
printf ("(%s)", comment);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "(%s)", comment);
|
||||
}
|
||||
printf (".\n");
|
||||
|
||||
jerry_port_log (JERRY_LOG_LEVEL_ERROR, ".\n");
|
||||
|
||||
jerry_fatal (ERR_UNIMPLEMENTED_CASE);
|
||||
} /* jerry_unimplemented */
|
||||
|
||||
@ -59,7 +59,7 @@ util_print_chars (const uint8_t *char_p, /**< character pointer */
|
||||
{
|
||||
while (size > 0)
|
||||
{
|
||||
printf ("%c", *char_p++);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "%c", *char_p++);
|
||||
size--;
|
||||
}
|
||||
} /* util_print_chars */
|
||||
@ -73,7 +73,7 @@ util_print_number (ecma_number_t num_p) /**< number to print */
|
||||
lit_utf8_byte_t str_buf[ECMA_MAX_CHARS_IN_STRINGIFIED_NUMBER];
|
||||
lit_utf8_size_t str_size = ecma_number_to_utf8_string (num_p, str_buf, sizeof (str_buf));
|
||||
str_buf[str_size] = 0;
|
||||
printf ("%s", str_buf);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "%s", str_buf);
|
||||
} /* util_print_number */
|
||||
|
||||
/**
|
||||
@ -86,22 +86,22 @@ util_print_literal (lexer_literal_t *literal_p) /**< literal */
|
||||
{
|
||||
if (literal_p->status_flags & LEXER_FLAG_VAR)
|
||||
{
|
||||
printf ("var_ident(");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "var_ident(");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("ident(");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "ident(");
|
||||
}
|
||||
util_print_chars (literal_p->u.char_p, literal_p->prop.length);
|
||||
}
|
||||
else if (literal_p->type == LEXER_FUNCTION_LITERAL)
|
||||
{
|
||||
printf ("function");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "function");
|
||||
return;
|
||||
}
|
||||
else if (literal_p->type == LEXER_STRING_LITERAL)
|
||||
{
|
||||
printf ("string(");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "string(");
|
||||
util_print_chars (literal_p->u.char_p, literal_p->prop.length);
|
||||
}
|
||||
else if (literal_p->type == LEXER_NUMBER_LITERAL)
|
||||
@ -110,21 +110,21 @@ util_print_literal (lexer_literal_t *literal_p) /**< literal */
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_GET_CONTAINER (value_p) == ECMA_STRING_LITERAL_NUMBER);
|
||||
|
||||
printf ("number(");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "number(");
|
||||
util_print_number (ecma_get_number_from_value (value_p->u.lit_number));
|
||||
}
|
||||
else if (literal_p->type == LEXER_REGEXP_LITERAL)
|
||||
{
|
||||
printf ("regexp");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "regexp");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("unknown");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "unknown");
|
||||
return;
|
||||
}
|
||||
|
||||
printf (")");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ")");
|
||||
} /* util_print_literal */
|
||||
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -1609,7 +1609,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
if (context_p->is_show_opcodes
|
||||
&& switch_to_strict_mode)
|
||||
{
|
||||
printf (" Note: switch to strict mode\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Note: switch to strict mode\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
|
||||
@ -170,13 +170,13 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
|
||||
name_p = cbc_ext_names[PARSER_GET_EXT_OPCODE (context_p->last_cbc_opcode)];
|
||||
}
|
||||
|
||||
printf (" [%3d] %s", (int) context_p->stack_depth, name_p);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s", (int) context_p->stack_depth, name_p);
|
||||
|
||||
if (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
|
||||
{
|
||||
uint16_t literal_index = context_p->last_cbc.literal_index;
|
||||
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
|
||||
printf (" idx:%d->", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index);
|
||||
util_print_literal (literal_p);
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
|
||||
{
|
||||
uint16_t literal_index = context_p->last_cbc.value;
|
||||
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
|
||||
printf (" idx:%d->", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index);
|
||||
util_print_literal (literal_p);
|
||||
|
||||
if (!(flags & CBC_HAS_LITERAL_ARG))
|
||||
@ -192,17 +192,17 @@ parser_flush_cbc (parser_context_t *context_p) /**< context */
|
||||
literal_index = context_p->last_cbc.third_literal_index;
|
||||
|
||||
lexer_literal_t *literal_p = PARSER_GET_LITERAL (literal_index);
|
||||
printf (" idx:%d->", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d->", literal_index);
|
||||
util_print_literal (literal_p);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & CBC_HAS_BYTE_ARG)
|
||||
{
|
||||
printf (" byte_arg:%d", (int) context_p->last_cbc.value);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " byte_arg:%d", (int) context_p->last_cbc.value);
|
||||
}
|
||||
|
||||
printf ("\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -327,7 +327,11 @@ parser_emit_cbc_push_number (parser_context_t *context_p, /**< context */
|
||||
real_value = -real_value;
|
||||
}
|
||||
|
||||
printf (" [%3d] %s number:%d\n", (int) context_p->stack_depth, cbc_names[opcode], real_value);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,
|
||||
" [%3d] %s number:%d\n",
|
||||
(int) context_p->stack_depth,
|
||||
cbc_names[opcode],
|
||||
real_value);
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -391,11 +395,11 @@ parser_emit_cbc_forward_branch (parser_context_t *context_p, /**< context */
|
||||
{
|
||||
if (extra_byte_code_increase == 0)
|
||||
{
|
||||
printf (" [%3d] %s\n", (int) context_p->stack_depth, cbc_names[opcode]);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, cbc_names[opcode]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (" [%3d] %s\n", (int) context_p->stack_depth, cbc_ext_names[opcode]);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, cbc_ext_names[opcode]);
|
||||
}
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
@ -506,7 +510,7 @@ parser_emit_cbc_backward_branch (parser_context_t *context_p, /**< context */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
printf (" [%3d] %s\n", (int) context_p->stack_depth, name);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " [%3d] %s\n", (int) context_p->stack_depth, name);
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
|
||||
@ -873,35 +873,35 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
|
||||
|
||||
if (literal_index == const_literal_end)
|
||||
{
|
||||
printf (" idx:%d(self)->function", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d(self)->function", literal_index);
|
||||
break;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (literal_index < argument_end);
|
||||
printf (" idx:%d(arg)->undefined", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d(arg)->undefined", literal_index);
|
||||
break;
|
||||
}
|
||||
|
||||
if (literal_p->prop.index == literal_index
|
||||
&& literal_p->type != LEXER_UNUSED_LITERAL)
|
||||
{
|
||||
printf (" idx:%d", literal_index);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " idx:%d", literal_index);
|
||||
|
||||
if (literal_index < argument_end)
|
||||
{
|
||||
printf ("(arg)->");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(arg)->");
|
||||
}
|
||||
else if (literal_index < register_end)
|
||||
{
|
||||
printf ("(reg)->");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(reg)->");
|
||||
}
|
||||
else if (literal_index < ident_end)
|
||||
{
|
||||
printf ("(ident)->");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(ident)->");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("(lit)->");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "(lit)->");
|
||||
}
|
||||
|
||||
util_print_literal (literal_p);
|
||||
@ -946,14 +946,14 @@ parse_print_define_vars (ecma_compiled_code_t *compiled_code_p, /**< compiled co
|
||||
|
||||
PARSER_READ_IDENTIFIER_INDEX (identifier_end);
|
||||
|
||||
printf (" from: %d to: %d\n", identifier_index, identifier_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " from: %d to: %d\n", identifier_index, identifier_end);
|
||||
|
||||
while (identifier_index <= identifier_end)
|
||||
{
|
||||
printf (" ");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " ");
|
||||
parse_print_literal (compiled_code_p, identifier_index, literal_pool_p);
|
||||
identifier_index++;
|
||||
printf ("\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n");
|
||||
}
|
||||
|
||||
return byte_code_p;
|
||||
@ -977,21 +977,21 @@ parse_print_initialize_vars (ecma_compiled_code_t *compiled_code_p, /**< compile
|
||||
PARSER_READ_IDENTIFIER_INDEX (identifier_index);
|
||||
PARSER_READ_IDENTIFIER_INDEX (identifier_end);
|
||||
|
||||
printf (" from: %d to: %d\n", identifier_index, identifier_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " from: %d to: %d\n", identifier_index, identifier_end);
|
||||
|
||||
while (identifier_index <= identifier_end)
|
||||
{
|
||||
uint16_t literal_index;
|
||||
|
||||
printf (" ");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " ");
|
||||
parse_print_literal (compiled_code_p, identifier_index, literal_pool_p);
|
||||
printf (" =");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " =");
|
||||
|
||||
PARSER_READ_IDENTIFIER_INDEX (literal_index);
|
||||
|
||||
parse_print_literal (compiled_code_p, literal_index, literal_pool_p);
|
||||
identifier_index++;
|
||||
printf ("\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n");
|
||||
}
|
||||
|
||||
return byte_code_p;
|
||||
@ -1039,48 +1039,50 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
literal_end = args->literal_end;
|
||||
}
|
||||
|
||||
printf ("\nFinal byte code dump:\n\n Maximum stack depth: %d\n Flags: [", (int) stack_limit);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,
|
||||
"\nFinal byte code dump:\n\n Maximum stack depth: %d\n Flags: [",
|
||||
(int) stack_limit);
|
||||
|
||||
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FULL_LITERAL_ENCODING))
|
||||
{
|
||||
printf ("small_lit_enc");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "small_lit_enc");
|
||||
encoding_limit = 255;
|
||||
encoding_delta = 0xfe01;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("full_lit_enc");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "full_lit_enc");
|
||||
encoding_limit = 128;
|
||||
encoding_delta = 0x8000;
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
printf (",uint16_arguments");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",uint16_arguments");
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE)
|
||||
{
|
||||
printf (",strict_mode");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",strict_mode");
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_ARGUMENTS_NEEDED)
|
||||
{
|
||||
printf (",arguments_needed");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",arguments_needed");
|
||||
}
|
||||
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED)
|
||||
{
|
||||
printf (",no_lexical_env");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, ",no_lexical_env");
|
||||
}
|
||||
|
||||
printf ("]\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "]\n");
|
||||
|
||||
printf (" Argument range end: %d\n", (int) argument_end);
|
||||
printf (" Register range end: %d\n", (int) register_end);
|
||||
printf (" Identifier range end: %d\n", (int) ident_end);
|
||||
printf (" Const literal range end: %d\n", (int) const_literal_end);
|
||||
printf (" Literal range end: %d\n\n", (int) literal_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Argument range end: %d\n", (int) argument_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Register range end: %d\n", (int) register_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Identifier range end: %d\n", (int) ident_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Const literal range end: %d\n", (int) const_literal_end);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Literal range end: %d\n\n", (int) literal_end);
|
||||
|
||||
byte_code_start_p = (uint8_t *) compiled_code_p;
|
||||
|
||||
@ -1110,7 +1112,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
if (opcode != CBC_EXT_OPCODE)
|
||||
{
|
||||
flags = cbc_flags[opcode];
|
||||
printf (" %3d : %s", (int) cbc_offset, cbc_names[opcode]);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " %3d : %s", (int) cbc_offset, cbc_names[opcode]);
|
||||
byte_code_p++;
|
||||
|
||||
if (opcode == CBC_INITIALIZE_VARS)
|
||||
@ -1136,14 +1138,14 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
if (opcode == CBC_PUSH_NUMBER_POS_BYTE)
|
||||
{
|
||||
int value = *byte_code_p++;
|
||||
printf (" number:%d\n", value + 1);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " number:%d\n", value + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (opcode == CBC_PUSH_NUMBER_NEG_BYTE)
|
||||
{
|
||||
int value = *byte_code_p++;
|
||||
printf (" number:%d\n", -(value + 1));
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " number:%d\n", -(value + 1));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1151,7 +1153,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
{
|
||||
ext_opcode = (cbc_ext_opcode_t) byte_code_p[1];
|
||||
flags = cbc_ext_flags[ext_opcode];
|
||||
printf (" %3d : %s", (int) cbc_offset, cbc_ext_names[ext_opcode]);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " %3d : %s", (int) cbc_offset, cbc_ext_names[ext_opcode]);
|
||||
byte_code_p += 2;
|
||||
}
|
||||
|
||||
@ -1179,7 +1181,7 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
|
||||
if (flags & CBC_HAS_BYTE_ARG)
|
||||
{
|
||||
printf (" byte_arg:%d", *byte_code_p);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " byte_arg:%d", *byte_code_p);
|
||||
byte_code_p++;
|
||||
}
|
||||
|
||||
@ -1201,14 +1203,15 @@ parse_print_final_cbc (ecma_compiled_code_t *compiled_code_p, /**< compiled code
|
||||
|
||||
if (CBC_BRANCH_IS_FORWARD (flags))
|
||||
{
|
||||
printf (" offset:%d(->%d)", (int) offset, (int) (cbc_offset + offset));
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " offset:%d(->%d)", (int) offset, (int) (cbc_offset + offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf (" offset:%d(->%d)", (int) offset, (int) (cbc_offset - offset));
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " offset:%d(->%d)", (int) offset, (int) (cbc_offset - offset));
|
||||
}
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n");
|
||||
}
|
||||
} /* parse_print_final_cbc */
|
||||
|
||||
@ -1685,7 +1688,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
lexer_literal_t *literal_p;
|
||||
|
||||
parse_print_final_cbc (compiled_code_p, &context_p->literal_pool, length);
|
||||
printf ("\nByte code size: %d bytes\n", (int) length);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\nByte code size: %d bytes\n", (int) length);
|
||||
context_p->total_byte_code_size += (uint32_t) length;
|
||||
|
||||
parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
|
||||
@ -1856,7 +1859,7 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
|
||||
if (context.is_show_opcodes)
|
||||
{
|
||||
printf ("\n--- Script parsing start ---\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Script parsing start ---\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -1890,8 +1893,9 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context.is_show_opcodes)
|
||||
{
|
||||
printf ("\nScript parsing successfully completed. Total byte code size: %d bytes\n",
|
||||
(int) context.total_byte_code_size);
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,
|
||||
"\nScript parsing successfully completed. Total byte code size: %d bytes\n",
|
||||
(int) context.total_byte_code_size);
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
}
|
||||
@ -1924,7 +1928,7 @@ parser_parse_source (const uint8_t *source_p, /**< valid UTF-8 source code */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context.is_show_opcodes)
|
||||
{
|
||||
printf ("\n--- Script parsing end ---\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Script parsing end ---\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -1993,7 +1997,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
printf ("\n--- Function parsing start ---\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Function parsing start ---\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -2140,7 +2144,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
if (context_p->is_show_opcodes
|
||||
&& (context_p->status_flags & PARSER_HAS_NON_STRICT_ARG))
|
||||
{
|
||||
printf (" Note: legacy (non-strict) argument definition\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, " Note: legacy (non-strict) argument definition\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
@ -2156,7 +2160,7 @@ parser_parse_function (parser_context_t *context_p, /**< context */
|
||||
#ifdef PARSER_DUMP_BYTE_CODE
|
||||
if (context_p->is_show_opcodes)
|
||||
{
|
||||
printf ("\n--- Function parsing end ---\n\n");
|
||||
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "\n--- Function parsing end ---\n\n");
|
||||
}
|
||||
#endif /* PARSER_DUMP_BYTE_CODE */
|
||||
|
||||
|
||||
46
main-unix.c
46
main-unix.c
@ -93,30 +93,31 @@ assert_handler (const jerry_value_t func_obj_val __attribute__((unused)), /**< f
|
||||
static void
|
||||
print_usage (char *name)
|
||||
{
|
||||
printf ("Usage: %s [OPTION]... [FILE]...\n"
|
||||
"Try '%s --help' for more information.\n",
|
||||
name, name);
|
||||
jerry_port_console ("Usage: %s [OPTION]... [FILE]...\n"
|
||||
"Try '%s --help' for more information.\n",
|
||||
name,
|
||||
name);
|
||||
} /* print_usage */
|
||||
|
||||
static void
|
||||
print_help (char *name)
|
||||
{
|
||||
printf ("Usage: %s [OPTION]... [FILE]...\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -h, --help\n"
|
||||
" -v, --version\n"
|
||||
" --mem-stats\n"
|
||||
" --mem-stats-separate\n"
|
||||
" --parse-only\n"
|
||||
" --show-opcodes\n"
|
||||
" --save-snapshot-for-global FILE\n"
|
||||
" --save-snapshot-for-eval FILE\n"
|
||||
" --exec-snapshot FILE\n"
|
||||
" --log-level [0-3]\n"
|
||||
" --abort-on-fail\n"
|
||||
"\n",
|
||||
name);
|
||||
jerry_port_console ("Usage: %s [OPTION]... [FILE]...\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -h, --help\n"
|
||||
" -v, --version\n"
|
||||
" --mem-stats\n"
|
||||
" --mem-stats-separate\n"
|
||||
" --parse-only\n"
|
||||
" --show-opcodes\n"
|
||||
" --save-snapshot-for-global FILE\n"
|
||||
" --save-snapshot-for-eval FILE\n"
|
||||
" --exec-snapshot FILE\n"
|
||||
" --log-level [0-3]\n"
|
||||
" --abort-on-fail\n"
|
||||
"\n",
|
||||
name);
|
||||
} /* print_help */
|
||||
|
||||
int
|
||||
@ -164,16 +165,18 @@ main (int argc,
|
||||
}
|
||||
else if (!strcmp ("-v", argv[i]) || !strcmp ("--version", argv[i]))
|
||||
{
|
||||
printf ("Version: \t%d.%d\n\n", JERRY_API_MAJOR_VERSION, JERRY_API_MINOR_VERSION);
|
||||
jerry_port_console ("Version: \t%d.%d\n\n", JERRY_API_MAJOR_VERSION, JERRY_API_MINOR_VERSION);
|
||||
return JERRY_STANDALONE_EXIT_CODE_OK;
|
||||
}
|
||||
else if (!strcmp ("--mem-stats", argv[i]))
|
||||
{
|
||||
flags |= JERRY_INIT_MEM_STATS;
|
||||
jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG);
|
||||
}
|
||||
else if (!strcmp ("--mem-stats-separate", argv[i]))
|
||||
{
|
||||
flags |= JERRY_INIT_MEM_STATS_SEPARATE;
|
||||
jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG);
|
||||
}
|
||||
else if (!strcmp ("--parse-only", argv[i]))
|
||||
{
|
||||
@ -182,6 +185,7 @@ main (int argc,
|
||||
else if (!strcmp ("--show-opcodes", argv[i]))
|
||||
{
|
||||
flags |= JERRY_INIT_SHOW_OPCODES;
|
||||
jerry_port_default_set_log_level (JERRY_LOG_LEVEL_DEBUG);
|
||||
}
|
||||
else if (!strcmp ("--save-snapshot-for-global", argv[i])
|
||||
|| !strcmp ("--save-snapshot-for-eval", argv[i]))
|
||||
@ -396,7 +400,7 @@ main (int argc,
|
||||
uint8_t *source_buffer_tail = buffer;
|
||||
size_t len = 0;
|
||||
|
||||
printf ("%s", prompt);
|
||||
jerry_port_console ("%s", prompt);
|
||||
|
||||
/* Read a line */
|
||||
while (true)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user