From df42f7f1281e7488cfbcf459a7e8a65225b68afd Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Fri, 29 Dec 2023 15:34:24 +0300 Subject: [PATCH] Update IR IR commit: 730763fb25d096099af22c75190fbf7e748ac5af --- ext/opcache/jit/ir/ir.c | 44 ++++++++++++++++++++++++++++-- ext/opcache/jit/ir/ir.h | 2 +- ext/opcache/jit/ir/ir_aarch64.dasc | 38 -------------------------- ext/opcache/jit/ir/ir_dump.c | 4 +-- ext/opcache/jit/ir/ir_x86.dasc | 39 -------------------------- 5 files changed, 45 insertions(+), 82 deletions(-) diff --git a/ext/opcache/jit/ir/ir.c b/ext/opcache/jit/ir/ir.c index f641bab42fe..8be380dfd09 100644 --- a/ext/opcache/jit/ir/ir.c +++ b/ext/opcache/jit/ir/ir.c @@ -72,16 +72,56 @@ const char *ir_op_name[IR_LAST_OP] = { #endif }; +static void ir_print_escaped_str(const char *s, size_t len, FILE *f) +{ + char ch; + + while (len > 0) { + ch = *s; + switch (ch) { + case '\\': fputs("\\\\", f); break; + case '\'': fputs("'", f); break; + case '\"': fputs("\\\"", f); break; + case '\a': fputs("\\a", f); break; + case '\b': fputs("\\b", f); break; + case '\e': fputs("\\e", f); break; + case '\f': fputs("\\f", f); break; + case '\n': fputs("\\n", f); break; + case '\r': fputs("\\r", f); break; + case '\t': fputs("\\t", f); break; + case '\v': fputs("\\v", f); break; + case '\?': fputs("\\?", f); break; + default: + if (ch < 32) { + fprintf(f, "\\%c%c%c", + '0' + ((ch >> 3) % 8), + '0' + ((ch >> 6) % 8), + '0' + (ch % 8)); + break; + } else { + fputc(ch, f); + } + } + s++; + len--; + } +} + void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted) { if (insn->op == IR_FUNC || insn->op == IR_SYM) { fprintf(f, "%s", ir_get_str(ctx, insn->val.name)); return; } else if (insn->op == IR_STR) { + size_t len; + const char *str = ir_get_strl(ctx, insn->val.str, &len); + if (quoted) { - fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.str)); + fprintf(f, "\""); + ir_print_escaped_str(str, len, f); + fprintf(f, "\""); } else { - fprintf(f, "%s", ir_get_str(ctx, insn->val.str)); + ir_print_escaped_str(str, len, f); } return; } diff --git a/ext/opcache/jit/ir/ir.h b/ext/opcache/jit/ir/ir.h index 518ed32e8cb..dd0a6ca683b 100644 --- a/ext/opcache/jit/ir/ir.h +++ b/ext/opcache/jit/ir/ir.h @@ -827,7 +827,7 @@ void ir_save(const ir_ctx *ctx, FILE *f); /* IR debug dump API (implementation in ir_dump.c) */ void ir_dump(const ir_ctx *ctx, FILE *f); -void ir_dump_dot(const ir_ctx *ctx, FILE *f); +void ir_dump_dot(const ir_ctx *ctx, const char *name, FILE *f); void ir_dump_use_lists(const ir_ctx *ctx, FILE *f); void ir_dump_cfg(ir_ctx *ctx, FILE *f); void ir_dump_cfg_map(const ir_ctx *ctx, FILE *f); diff --git a/ext/opcache/jit/ir/ir_aarch64.dasc b/ext/opcache/jit/ir/ir_aarch64.dasc index e58d25dc385..f5158d32f5e 100644 --- a/ext/opcache/jit/ir/ir_aarch64.dasc +++ b/ext/opcache/jit/ir/ir_aarch64.dasc @@ -5767,44 +5767,6 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr) c = str[i]; if (!c) { break; - } else if (c == '\\') { - if (str[i+1] == '\\') { - i++; - c = '\\'; - } else if (str[i+1] == '\'') { - i++; - c = '\''; - } else if (str[i+1] == '"') { - i++; - c = '"'; - } else if (str[i+1] == 'a') { - i++; - c = '\a'; - } else if (str[i+1] == 'b') { - i++; - c = '\b'; - } else if (str[i+1] == 'e') { - i++; - c = 27; /* '\e'; */ - } else if (str[i+1] == 'f') { - i++; - c = '\f'; - } else if (str[i+1] == 'n') { - i++; - c = '\n'; - } else if (str[i+1] == 'r') { - i++; - c = '\r'; - } else if (str[i+1] == 't') { - i++; - c = '\t'; - } else if (str[i+1] == 'v') { - i++; - c = '\v'; - } else if (str[i+1] == '?') { - i++; - c = 0x3f; - } } w |= c << (8 * j); i++; diff --git a/ext/opcache/jit/ir/ir_dump.c b/ext/opcache/jit/ir/ir_dump.c index 7204e8bce77..dbc18d87e78 100644 --- a/ext/opcache/jit/ir/ir_dump.c +++ b/ext/opcache/jit/ir/ir_dump.c @@ -52,7 +52,7 @@ void ir_dump(const ir_ctx *ctx, FILE *f) } } -void ir_dump_dot(const ir_ctx *ctx, FILE *f) +void ir_dump_dot(const ir_ctx *ctx, const char *name, FILE *f) { int DATA_WEIGHT = 0; int CONTROL_WEIGHT = 5; @@ -61,7 +61,7 @@ void ir_dump_dot(const ir_ctx *ctx, FILE *f) ir_insn *insn; uint32_t flags; - fprintf(f, "digraph ir {\n"); + fprintf(f, "digraph %s {\n", name); fprintf(f, "\trankdir=TB;\n"); for (i = 1 - ctx->consts_count, insn = ctx->ir_base + i; i < IR_UNUSED; i++, insn++) { fprintf(f, "\tc%d [label=\"C%d: CONST %s(", -i, -i, ir_type_name[insn->type]); diff --git a/ext/opcache/jit/ir/ir_x86.dasc b/ext/opcache/jit/ir/ir_x86.dasc index 60b6cca21b6..e3fa95a47ce 100644 --- a/ext/opcache/jit/ir/ir_x86.dasc +++ b/ext/opcache/jit/ir/ir_x86.dasc @@ -9673,45 +9673,6 @@ next_block:; while (str[i]) { char c = str[i]; - if (c == '\\') { - if (str[i+1] == '\\') { - i++; - c = '\\'; - } else if (str[i+1] == '\'') { - i++; - c = '\''; - } else if (str[i+1] == '"') { - i++; - c = '"'; - } else if (str[i+1] == 'a') { - i++; - c = '\a'; - } else if (str[i+1] == 'b') { - i++; - c = '\b'; - } else if (str[i+1] == 'e') { - i++; - c = 27; /* '\e'; */ - } else if (str[i+1] == 'f') { - i++; - c = '\f'; - } else if (str[i+1] == 'n') { - i++; - c = '\n'; - } else if (str[i+1] == 'r') { - i++; - c = '\r'; - } else if (str[i+1] == 't') { - i++; - c = '\t'; - } else if (str[i+1] == 'v') { - i++; - c = '\v'; - } else if (str[i+1] == '?') { - i++; - c = 0x3f; - } - } |.byte c i++; }