Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[imcc cage] move IMCC_debug_ins to debug.c, remove unused DEBUG_ defs

also do not fatalize -O2 GH 1039 empty ins->op, just warn
  • Loading branch information...
commit 8272ff13fbbebe09637e4f94d93f50839c0ce717 1 parent 104966b
@rurban rurban authored
View
10 compilers/imcc/debug.c
@@ -243,6 +243,16 @@ IMCC_debug(ARGMOD(imc_info_t * imcc), int level, ARGIN(const char *fmt), ...)
va_end(ap);
}
+void IMCC_debug_ins(imc_info_t *imcc, int level, const Instruction *ins) {
+ PIOHANDLE pstderr;
+ if (!(level & imcc->debug))
+ return;
+ pstderr = Parrot_io_internal_std_os_handle(imcc->interp, PIO_STDERR_FILENO);
+ Parrot_io_pprintf(imcc->interp, pstderr, "0x%x %s ", ins, ins->opname);
+ ins_print(imcc, pstderr, ins);
+ Parrot_io_pprintf(imcc->interp, pstderr, "\n");
+}
+
/*
=item C<void dump_instructions(imc_info_t * imcc, const IMC_Unit *unit)>
View
12 compilers/imcc/debug.h
@@ -7,7 +7,9 @@
#define DEBUG_PARROT 0x0001
+/* unused:
#define DEBUG_LEXER 0x0002
+*/
#define DEBUG_PARSER 0x0004
#define DEBUG_IMC 0x0008
#define DEBUG_CFG 0x0010
@@ -16,8 +18,10 @@
#define DEBUG_SPILL 0x0080
#define DEBUG_AST 0x0100
+/* unused:
#define DEBUG_REG 0x0200
#define DEBUG_REG2 0x0400
+*/
#define DEBUG_PBC 0x1000
#define DEBUG_PBC_CONST 0x2000
@@ -60,6 +64,14 @@ void IMCC_debug(
__attribute__nonnull__(3)
FUNC_MODIFIES(* imcc);
+void IMCC_debug_ins(
+ ARGMOD(imc_info_t * imcc),
+ int level,
+ ARGIN(const Instruction *ins))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(3)
+ FUNC_MODIFIES(* imcc);
+
PARROT_DOES_NOT_RETURN
void IMCC_fatal(
ARGMOD(imc_info_t * imcc),
View
13 compilers/imcc/optimizer.c
@@ -211,19 +211,6 @@ static int used_once(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
-/* TODO: move to debug.c. and possibly integrate into IMCC_debug as seperate %p handle */
-void IMCC_debug_ins(imc_info_t *imcc, int level, Instruction *ins);
-
-void IMCC_debug_ins(imc_info_t *imcc, int level, Instruction *ins) {
- PIOHANDLE pstderr;
- if (!(level & imcc->debug))
- return;
- pstderr = Parrot_io_internal_std_os_handle(imcc->interp, PIO_STDERR_FILENO);
- Parrot_io_pprintf(imcc->interp, pstderr, "0x%x %s ", ins, ins->opname);
- ins_print(imcc, pstderr, ins);
- Parrot_io_pprintf(imcc->interp, pstderr, "\n");
-}
-
/*
=item C<int pre_optimize(imc_info_t *imcc, IMC_Unit *unit)>
View
11 compilers/imcc/pbc.c
@@ -694,7 +694,7 @@ get_code_size(ARGMOD(imc_info_t * imcc), ARGIN(const IMC_Unit *unit),
}
(*src_lines)++;
if (!ins->op) { /* caused by constant propagation */
- if (!(imcc->debug & DEBUG_OPT2))
+ if (!(imcc->optimizer_level & OPT_CFG))
IMCC_fatal(imcc, 1, "get_code_size: "
"no opnum ins#%d 0x%x\n",
ins->index, ins);
@@ -2473,6 +2473,15 @@ e_pbc_emit(ARGMOD(imc_info_t * imcc), SHIM(void *param), ARGIN(const IMC_Unit *u
/* Get the info for that opcode */
op_info = ins->op;
+ if (!op_info) {
+ if (imcc->optimizer_level & OPT_CFG) { /* known issue GH #1039 */
+ IMCC_warning(imcc, "e_emit_pbc: empty op %d ", imcc->npc);
+ IMCC_debug_ins(imcc, 0, ins);
+ return 0;
+ } else {
+ IMCC_fatal(imcc, 1, "e_emit_pbc: empty op %d %x", imcc->npc, ins);
+ }
+ }
IMCC_debug(imcc, DEBUG_PBC, "%d %s", imcc->npc, op_info->full_name);
/* Start generating the bytecode */
View
5 frontend/parrot/main.c
@@ -493,13 +493,16 @@ help_debug(void)
"\n"
"--imcc-debug -d [Flags] ...\n"
" 0001 verbose\n"
- " 0002 lexer\n"
" 0004 parser\n"
" 0008 imc\n"
" 0010 CFG\n"
" 0020 optimization 1\n"
" 0040 optimization 2\n"
+ " 0080 spill\n"
" 0100 AST\n"
+ " 1000 PBC\n"
+ " 2000 PBC_CONST\n"
+ " 4000 PBC_FIXUP\n"
"\n");
}
View
6 frontend/parrot2/main.c
@@ -405,13 +405,17 @@ help_debug(void)
printf(
"\n"
"--imcc-debug -d [Flags] ...\n"
- " 0002 lexer\n"
+ " 0001 verbose\n"
" 0004 parser\n"
" 0008 imc\n"
" 0010 CFG\n"
" 0020 optimization 1\n"
" 0040 optimization 2\n"
+ " 0080 spill\n"
" 0100 AST\n"
+ " 1000 PBC\n"
+ " 2000 PBC_CONST\n"
+ " 4000 PBC_FIXUP\n"
"\n");
}
View
21 include/parrot/interpreter.h
@@ -53,18 +53,15 @@ typedef enum {
/* &end_gen */
typedef enum { /* sync with compilers/imcc/debug.h */
- PARROT_IMCC_DEBUG_NONE = 0x00,
- PARROT_IMCC_VERBOSE = 0x01,
- PARROT_IMCC_DEBUG_LEXER = 0x02,
- PARROT_IMCC_DEBUG_PARSER = 0x04, /* sets yydebug */
- PARROT_IMCC_DEBUG_IMC = 0x08, /* dump symreg, insns */
- PARROT_IMCC_DEBUG_CFG = 0x10,
- PARROT_IMCC_DEBUG_OPT1 = 0x20,
- PARROT_IMCC_DEBUG_OPT2 = 0x40,
- PARROT_IMCC_DEBUG_SPILL = 0x80,
- PARROT_IMCC_DEBUG_AST = 0x100,
- PARROT_IMCC_DEBUG_REG = 0x200,
- PARROT_IMCC_DEBUG_REG2 = 0x400,
+ PARROT_IMCC_DEBUG_NONE = 0x0000,
+ PARROT_IMCC_VERBOSE = 0x0001,
+ PARROT_IMCC_DEBUG_PARSER = 0x0004, /* sets yydebug */
+ PARROT_IMCC_DEBUG_IMC = 0x0008, /* dump symreg, insns */
+ PARROT_IMCC_DEBUG_CFG = 0x0010,
+ PARROT_IMCC_DEBUG_OPT1 = 0x0020,
+ PARROT_IMCC_DEBUG_OPT2 = 0x0040,
+ PARROT_IMCC_DEBUG_SPILL = 0x0080,
+ PARROT_IMCC_DEBUG_AST = 0x0100,
PARROT_IMCC_DEBUG_PBC = 0x1000,
PARROT_IMCC_DEBUG_PBC_CONST = 0x2000,
PARROT_IMCC_DEBUG_PBC_FIXUP = 0x4000,
Please sign in to comment.
Something went wrong with that request. Please try again.