Skip to content

Commit df42f7f

Browse files
committed
Update IR
IR commit: 730763fb25d096099af22c75190fbf7e748ac5af
1 parent 0a8c97d commit df42f7f

File tree

5 files changed

+45
-82
lines changed

5 files changed

+45
-82
lines changed

ext/opcache/jit/ir/ir.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,56 @@ const char *ir_op_name[IR_LAST_OP] = {
7272
#endif
7373
};
7474

75+
static void ir_print_escaped_str(const char *s, size_t len, FILE *f)
76+
{
77+
char ch;
78+
79+
while (len > 0) {
80+
ch = *s;
81+
switch (ch) {
82+
case '\\': fputs("\\\\", f); break;
83+
case '\'': fputs("'", f); break;
84+
case '\"': fputs("\\\"", f); break;
85+
case '\a': fputs("\\a", f); break;
86+
case '\b': fputs("\\b", f); break;
87+
case '\e': fputs("\\e", f); break;
88+
case '\f': fputs("\\f", f); break;
89+
case '\n': fputs("\\n", f); break;
90+
case '\r': fputs("\\r", f); break;
91+
case '\t': fputs("\\t", f); break;
92+
case '\v': fputs("\\v", f); break;
93+
case '\?': fputs("\\?", f); break;
94+
default:
95+
if (ch < 32) {
96+
fprintf(f, "\\%c%c%c",
97+
'0' + ((ch >> 3) % 8),
98+
'0' + ((ch >> 6) % 8),
99+
'0' + (ch % 8));
100+
break;
101+
} else {
102+
fputc(ch, f);
103+
}
104+
}
105+
s++;
106+
len--;
107+
}
108+
}
109+
75110
void ir_print_const(const ir_ctx *ctx, const ir_insn *insn, FILE *f, bool quoted)
76111
{
77112
if (insn->op == IR_FUNC || insn->op == IR_SYM) {
78113
fprintf(f, "%s", ir_get_str(ctx, insn->val.name));
79114
return;
80115
} else if (insn->op == IR_STR) {
116+
size_t len;
117+
const char *str = ir_get_strl(ctx, insn->val.str, &len);
118+
81119
if (quoted) {
82-
fprintf(f, "\"%s\"", ir_get_str(ctx, insn->val.str));
120+
fprintf(f, "\"");
121+
ir_print_escaped_str(str, len, f);
122+
fprintf(f, "\"");
83123
} else {
84-
fprintf(f, "%s", ir_get_str(ctx, insn->val.str));
124+
ir_print_escaped_str(str, len, f);
85125
}
86126
return;
87127
}

ext/opcache/jit/ir/ir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ void ir_save(const ir_ctx *ctx, FILE *f);
827827

828828
/* IR debug dump API (implementation in ir_dump.c) */
829829
void ir_dump(const ir_ctx *ctx, FILE *f);
830-
void ir_dump_dot(const ir_ctx *ctx, FILE *f);
830+
void ir_dump_dot(const ir_ctx *ctx, const char *name, FILE *f);
831831
void ir_dump_use_lists(const ir_ctx *ctx, FILE *f);
832832
void ir_dump_cfg(ir_ctx *ctx, FILE *f);
833833
void ir_dump_cfg_map(const ir_ctx *ctx, FILE *f);

ext/opcache/jit/ir/ir_aarch64.dasc

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5767,44 +5767,6 @@ void *ir_emit_code(ir_ctx *ctx, size_t *size_ptr)
57675767
c = str[i];
57685768
if (!c) {
57695769
break;
5770-
} else if (c == '\\') {
5771-
if (str[i+1] == '\\') {
5772-
i++;
5773-
c = '\\';
5774-
} else if (str[i+1] == '\'') {
5775-
i++;
5776-
c = '\'';
5777-
} else if (str[i+1] == '"') {
5778-
i++;
5779-
c = '"';
5780-
} else if (str[i+1] == 'a') {
5781-
i++;
5782-
c = '\a';
5783-
} else if (str[i+1] == 'b') {
5784-
i++;
5785-
c = '\b';
5786-
} else if (str[i+1] == 'e') {
5787-
i++;
5788-
c = 27; /* '\e'; */
5789-
} else if (str[i+1] == 'f') {
5790-
i++;
5791-
c = '\f';
5792-
} else if (str[i+1] == 'n') {
5793-
i++;
5794-
c = '\n';
5795-
} else if (str[i+1] == 'r') {
5796-
i++;
5797-
c = '\r';
5798-
} else if (str[i+1] == 't') {
5799-
i++;
5800-
c = '\t';
5801-
} else if (str[i+1] == 'v') {
5802-
i++;
5803-
c = '\v';
5804-
} else if (str[i+1] == '?') {
5805-
i++;
5806-
c = 0x3f;
5807-
}
58085770
}
58095771
w |= c << (8 * j);
58105772
i++;

ext/opcache/jit/ir/ir_dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void ir_dump(const ir_ctx *ctx, FILE *f)
5252
}
5353
}
5454

55-
void ir_dump_dot(const ir_ctx *ctx, FILE *f)
55+
void ir_dump_dot(const ir_ctx *ctx, const char *name, FILE *f)
5656
{
5757
int DATA_WEIGHT = 0;
5858
int CONTROL_WEIGHT = 5;
@@ -61,7 +61,7 @@ void ir_dump_dot(const ir_ctx *ctx, FILE *f)
6161
ir_insn *insn;
6262
uint32_t flags;
6363

64-
fprintf(f, "digraph ir {\n");
64+
fprintf(f, "digraph %s {\n", name);
6565
fprintf(f, "\trankdir=TB;\n");
6666
for (i = 1 - ctx->consts_count, insn = ctx->ir_base + i; i < IR_UNUSED; i++, insn++) {
6767
fprintf(f, "\tc%d [label=\"C%d: CONST %s(", -i, -i, ir_type_name[insn->type]);

ext/opcache/jit/ir/ir_x86.dasc

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9673,45 +9673,6 @@ next_block:;
96739673
while (str[i]) {
96749674
char c = str[i];
96759675

9676-
if (c == '\\') {
9677-
if (str[i+1] == '\\') {
9678-
i++;
9679-
c = '\\';
9680-
} else if (str[i+1] == '\'') {
9681-
i++;
9682-
c = '\'';
9683-
} else if (str[i+1] == '"') {
9684-
i++;
9685-
c = '"';
9686-
} else if (str[i+1] == 'a') {
9687-
i++;
9688-
c = '\a';
9689-
} else if (str[i+1] == 'b') {
9690-
i++;
9691-
c = '\b';
9692-
} else if (str[i+1] == 'e') {
9693-
i++;
9694-
c = 27; /* '\e'; */
9695-
} else if (str[i+1] == 'f') {
9696-
i++;
9697-
c = '\f';
9698-
} else if (str[i+1] == 'n') {
9699-
i++;
9700-
c = '\n';
9701-
} else if (str[i+1] == 'r') {
9702-
i++;
9703-
c = '\r';
9704-
} else if (str[i+1] == 't') {
9705-
i++;
9706-
c = '\t';
9707-
} else if (str[i+1] == 'v') {
9708-
i++;
9709-
c = '\v';
9710-
} else if (str[i+1] == '?') {
9711-
i++;
9712-
c = 0x3f;
9713-
}
9714-
}
97159676
|.byte c
97169677
i++;
97179678
}

0 commit comments

Comments
 (0)