Enable pretty-printer only on host and debug
This commit is contained in:
@@ -177,4 +177,11 @@ extern void __noreturn jerry_exit (jerry_status_t code);
|
|||||||
#define JERRY_MIN(v1, v2) ((v1 < v2) ? v1 : v2)
|
#define JERRY_MIN(v1, v2) ((v1 < v2) ? v1 : v2)
|
||||||
#define JERRY_MAX(v1, v2) ((v1 < v2) ? v2 : v1)
|
#define JERRY_MAX(v1, v2) ((v1 < v2) ? v2 : v1)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable --show-opcodes key.
|
||||||
|
*/
|
||||||
|
#if defined (__TARGET_HOST_x64) && !defined (JERRY_NDEBUG)
|
||||||
|
#define JERRY_ENABLE_PP
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* !JERRY_GLOBALS_H */
|
#endif /* !JERRY_GLOBALS_H */
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
#include "pretty-printer.h"
|
#include "pretty-printer.h"
|
||||||
#include "jerry-libc.h"
|
#include "jerry-libc.h"
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
@@ -646,3 +648,4 @@ pp_opcode (opcode_counter_t oc, opcode_t opcode, bool is_rewrite)
|
|||||||
|
|
||||||
__printf ("\n");
|
__printf ("\n");
|
||||||
}
|
}
|
||||||
|
#endif /* JERRY_ENABLE_PP */
|
||||||
|
|||||||
@@ -16,11 +16,14 @@
|
|||||||
#ifndef PRETTY_PRINTER
|
#ifndef PRETTY_PRINTER
|
||||||
#define PRETTY_PRINTER
|
#define PRETTY_PRINTER
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
#include "interpreter.h"
|
#include "interpreter.h"
|
||||||
#include "lp-string.h"
|
#include "lp-string.h"
|
||||||
|
|
||||||
void pp_opcode (opcode_counter_t, opcode_t, bool);
|
void pp_opcode (opcode_counter_t, opcode_t, bool);
|
||||||
void pp_strings (const lp_string *, uint8_t);
|
void pp_strings (const lp_string *, uint8_t);
|
||||||
void pp_nums (const ecma_number_t *, uint8_t, uint8_t);
|
void pp_nums (const ecma_number_t *, uint8_t, uint8_t);
|
||||||
|
#endif // JERRY_ENABLE_PP
|
||||||
|
|
||||||
#endif // PRETTY_PRINTER
|
#endif // PRETTY_PRINTER
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "globals.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "jerry-libc.h"
|
#include "jerry-libc.h"
|
||||||
@@ -39,10 +40,13 @@ void
|
|||||||
serializer_dump_strings_and_nums (const lp_string strings[], uint8_t strs_count,
|
serializer_dump_strings_and_nums (const lp_string strings[], uint8_t strs_count,
|
||||||
const ecma_number_t nums[], uint8_t nums_count)
|
const ecma_number_t nums[], uint8_t nums_count)
|
||||||
{
|
{
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
if (print_opcodes)
|
if (print_opcodes)
|
||||||
{
|
{
|
||||||
pp_strings (strings, strs_count);
|
pp_strings (strings, strs_count);
|
||||||
|
pp_nums (nums, nums_count, strs_count);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bytecode_data.strs_count = strs_count;
|
bytecode_data.strs_count = strs_count;
|
||||||
bytecode_data.nums_count = nums_count;
|
bytecode_data.nums_count = nums_count;
|
||||||
@@ -55,10 +59,12 @@ serializer_dump_opcode (opcode_t opcode)
|
|||||||
{
|
{
|
||||||
JERRY_ASSERT (scopes_tree_opcodes_num (current_scope) < MAX_OPCODES);
|
JERRY_ASSERT (scopes_tree_opcodes_num (current_scope) < MAX_OPCODES);
|
||||||
|
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
if (print_opcodes)
|
if (print_opcodes)
|
||||||
{
|
{
|
||||||
pp_opcode (scopes_tree_opcodes_num (current_scope), opcode, false);
|
pp_opcode (scopes_tree_opcodes_num (current_scope), opcode, false);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
scopes_tree_add_opcode (current_scope, opcode);
|
scopes_tree_add_opcode (current_scope, opcode);
|
||||||
}
|
}
|
||||||
@@ -74,15 +80,18 @@ serializer_rewrite_opcode (const opcode_counter_t loc, opcode_t opcode)
|
|||||||
{
|
{
|
||||||
scopes_tree_set_opcode (current_scope, loc, opcode);
|
scopes_tree_set_opcode (current_scope, loc, opcode);
|
||||||
|
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
if (print_opcodes)
|
if (print_opcodes)
|
||||||
{
|
{
|
||||||
pp_opcode (loc, opcode, true);
|
pp_opcode (loc, opcode, true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
serializer_print_opcodes (void)
|
serializer_print_opcodes (void)
|
||||||
{
|
{
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
opcode_counter_t loc;
|
opcode_counter_t loc;
|
||||||
|
|
||||||
if (!print_opcodes)
|
if (!print_opcodes)
|
||||||
@@ -96,6 +105,7 @@ serializer_print_opcodes (void)
|
|||||||
{
|
{
|
||||||
pp_opcode (loc, bytecode_data.opcodes[loc], false);
|
pp_opcode (loc, bytecode_data.opcodes[loc], false);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make lp_strings also zero-terminated. */
|
/* Make lp_strings also zero-terminated. */
|
||||||
|
|||||||
@@ -172,7 +172,12 @@ main (int argc __unused,
|
|||||||
}
|
}
|
||||||
else if (!__strcmp ("--show-opcodes", argv[i]))
|
else if (!__strcmp ("--show-opcodes", argv[i]))
|
||||||
{
|
{
|
||||||
|
#ifdef JERRY_ENABLE_PP
|
||||||
show_opcodes = true;
|
show_opcodes = true;
|
||||||
|
#else
|
||||||
|
__printf ("Ignoring --show-opcodes since target is not x86_64 or debug is not enabled.\n");
|
||||||
|
show_opcodes = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user