Remove dead code (#155)

This commit is contained in:
Ben Noordhuis 2023-11-29 10:13:13 +01:00 committed by GitHub
parent 699744562e
commit f181b3e54f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6061,7 +6061,6 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
{
fprintf(fp, "QuickJS-ng memory usage -- %s version, %d-bit, malloc limit: %"PRId64"\n\n",
JS_GetVersion(), (int)sizeof(void *) * 8, (int64_t)(ssize_t)s->malloc_limit);
#if 1
if (rt) {
static const struct {
const char *name;
@ -6117,7 +6116,6 @@ void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt)
}
fprintf(fp, "\n");
}
#endif
fprintf(fp, "%-20s %8s %8s\n", "NAME", "COUNT", "SIZE");
if (s->malloc_count) {
@ -21557,33 +21555,7 @@ static __exception int js_parse_array_literal(JSParseState *s)
return -1;
if (js_parse_assign_expr(s))
return -1;
#if 1
emit_op(s, OP_append);
#else
int label_next, label_done;
label_next = new_label(s);
label_done = new_label(s);
/* enumerate object */
emit_op(s, OP_for_of_start);
emit_op(s, OP_rot5l);
emit_op(s, OP_rot5l);
emit_label(s, label_next);
/* on stack: enum_rec array idx */
emit_op(s, OP_for_of_next);
emit_u8(s, 2);
emit_goto(s, OP_if_true, label_done);
/* append element */
/* enum_rec array idx val -> enum_rec array new_idx */
emit_op(s, OP_define_array_el);
emit_op(s, OP_inc);
emit_goto(s, OP_goto, label_next);
emit_label(s, label_done);
/* close enumeration */
emit_op(s, OP_drop); /* drop undef val */
emit_op(s, OP_nip1); /* drop enum_rec */
emit_op(s, OP_nip1);
emit_op(s, OP_nip1);
#endif
} else {
need_length = TRUE;
if (s->token.val != ',') {
@ -22861,34 +22833,8 @@ static __exception int js_parse_postfix_expr(JSParseState *s, int parse_flags)
return -1;
if (js_parse_assign_expr(s))
return -1;
#if 1
/* XXX: could pass is_last indicator? */
emit_op(s, OP_append);
#else
int label_next, label_done;
label_next = new_label(s);
label_done = new_label(s);
/* push enumerate object below array/idx pair */
emit_op(s, OP_for_of_start);
emit_op(s, OP_rot5l);
emit_op(s, OP_rot5l);
emit_label(s, label_next);
/* on stack: enum_rec array idx */
emit_op(s, OP_for_of_next);
emit_u8(s, 2);
emit_goto(s, OP_if_true, label_done);
/* append element */
/* enum_rec array idx val -> enum_rec array new_idx */
emit_op(s, OP_define_array_el);
emit_op(s, OP_inc);
emit_goto(s, OP_goto, label_next);
emit_label(s, label_done);
/* close enumeration, drop enum_rec and idx */
emit_op(s, OP_drop); /* drop undef */
emit_op(s, OP_nip1); /* drop enum_rec */
emit_op(s, OP_nip1);
emit_op(s, OP_nip1);
#endif
} else {
if (js_parse_assign_expr(s))
return -1;
@ -24066,7 +24012,6 @@ static int is_let(JSParseState *s, int decl_mask)
int res = FALSE;
if (token_is_pseudo_keyword(s, JS_ATOM_let)) {
#if 1
JSParsePos pos;
js_parse_get_pos(s, &pos);
for (;;) {
@ -24099,12 +24044,6 @@ static int is_let(JSParseState *s, int decl_mask)
if (js_parse_seek_token(s, &pos)) {
res = -1;
}
#else
int tok = peek_token(s, TRUE);
if (tok == '{' || tok == TOK_IDENT || peek_token(s, FALSE) == '[') {
res = TRUE;
}
#endif
}
return res;
}
@ -29044,29 +28983,6 @@ static __exception int resolve_variables(JSContext *ctx, JSFunctionDef *s)
}
}
goto no_change;
case OP_drop:
if (0) {
/* remove drops before return_undef */
/* do not perform this optimization in pass2 because
it breaks patterns recognised in resolve_labels */
int pos1 = pos_next;
int line1 = line_num;
while (code_match(&cc, pos1, OP_drop, -1)) {
if (cc.line_num >= 0) line1 = cc.line_num;
pos1 = cc.pos;
}
if (code_match(&cc, pos1, OP_return_undef, -1)) {
pos_next = pos1;
if (line1 != -1 && line1 != line_num) {
line_num = line1;
s->line_number_size++;
dbuf_putc(&bc_out, OP_line_num);
dbuf_put_u32(&bc_out, line_num);
}
break;
}
}
goto no_change;
case OP_insert3:
/* Transformation: insert3 put_array_el|put_ref_value drop -> put_array_el|put_ref_value */
if (code_match(&cc, pos_next, M2(OP_put_array_el, OP_put_ref_value), OP_drop, -1)) {