Skip to content

Commit e0aa272

Browse files
committed
Emit diagnostic on dasm_link() failure
1 parent 85d4b56 commit e0aa272

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

ext/opcache/jit/zend_jit.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,44 @@ static zend_string *zend_jit_func_name(const zend_op_array *op_array)
240240
}
241241
}
242242

243+
#if ZEND_DEBUG
244+
static void handle_dasm_error(int ret) {
245+
switch (ret & 0xff000000u) {
246+
case DASM_S_NOMEM:
247+
fprintf(stderr, "DASM_S_NOMEM\n");
248+
break;
249+
case DASM_S_PHASE:
250+
fprintf(stderr, "DASM_S_PHASE\n");
251+
break;
252+
case DASM_S_MATCH_SEC:
253+
fprintf(stderr, "DASM_S_MATCH_SEC\n");
254+
break;
255+
case DASM_S_RANGE_I:
256+
fprintf(stderr, "DASM_S_RANGE_I\n");
257+
break;
258+
case DASM_S_RANGE_SEC:
259+
fprintf(stderr, "DASM_S_RANGE_SEC\n");
260+
break;
261+
case DASM_S_RANGE_LG:
262+
fprintf(stderr, "DASM_S_RANGE_LG\n");
263+
break;
264+
case DASM_S_RANGE_PC:
265+
fprintf(stderr, "DASM_S_RANGE_PC %d\n", ret & 0xffffffu);
266+
break;
267+
case DASM_S_RANGE_VREG:
268+
fprintf(stderr, "DASM_S_RANGE_VREG\n");
269+
break;
270+
case DASM_S_UNDEF_L:
271+
fprintf(stderr, "DASM_S_UNDEF_L\n");
272+
break;
273+
case DASM_S_UNDEF_PC:
274+
fprintf(stderr, "DASM_S_UNDEF_PC\n");
275+
break;
276+
}
277+
ZEND_UNREACHABLE();
278+
}
279+
#endif
280+
243281
static void *dasm_link_and_encode(dasm_State **dasm_state,
244282
const zend_op_array *op_array,
245283
zend_ssa *ssa,
@@ -294,8 +332,11 @@ static void *dasm_link_and_encode(dasm_State **dasm_state,
294332
}
295333
}
296334

297-
if (dasm_link(dasm_state, &size) != DASM_S_OK) {
298-
// TODO: dasm_link() failed ???
335+
ret = dasm_link(dasm_state, &size);
336+
if (ret != DASM_S_OK) {
337+
#if ZEND_DEBUG
338+
handle_dasm_error(ret);
339+
#endif
299340
return NULL;
300341
}
301342

@@ -306,11 +347,9 @@ static void *dasm_link_and_encode(dasm_State **dasm_state,
306347
}
307348

308349
ret = dasm_encode(dasm_state, *dasm_ptr);
309-
310350
if (ret != DASM_S_OK) {
311-
// TODO: dasm_encode() failed ???
312351
#if ZEND_DEBUG
313-
ZEND_UNREACHABLE();
352+
handle_dasm_error(ret);
314353
#endif
315354
return NULL;
316355
}

0 commit comments

Comments
 (0)