Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions ext/bz2/bz2.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,15 @@ static PHP_MINFO_FUNCTION(bz2)
/* {{{ Reads up to length bytes from a BZip2 stream, or 1024 bytes if length is not specified */
PHP_FUNCTION(bzread)
{
zval *bz;
zend_long len = 1024;
php_stream *stream;
zend_string *data;

if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &bz, &len)) {
RETURN_THROWS();
}

php_stream_from_zval(stream, bz);
ZEND_PARSE_PARAMETERS_START(1, 2)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(len)
ZEND_PARSE_PARAMETERS_END();

if (len < 0) {
zend_argument_value_error(2, "must be greater than or equal to 0");
Expand Down Expand Up @@ -563,17 +562,14 @@ PHP_FUNCTION(bzdecompress)
The central error handling interface, does the work for bzerrno, bzerrstr and bzerror */
static void php_bz2_error(INTERNAL_FUNCTION_PARAMETERS, int opt)
{
zval *bzp; /* BZip2 Resource Pointer */
php_stream *stream;
const char *errstr; /* Error string */
int errnum; /* Error number */
struct php_bz2_stream_data_t *self;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &bzp) == FAILURE) {
RETURN_THROWS();
}

php_stream_from_zval(stream, bzp);
ZEND_PARSE_PARAMETERS_START(1, 1)
PHP_Z_PARAM_STREAM(stream)
ZEND_PARSE_PARAMETERS_END();

if (!php_stream_is(stream, PHP_STREAM_IS_BZIP2)) {
zend_argument_type_error(1, "must be a bz2 stream");
Expand Down
60 changes: 40 additions & 20 deletions ext/ftp/php_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,24 @@ PHP_FUNCTION(ftp_systype)
/* {{{ Retrieves a file from the FTP server and writes it to an open file */
PHP_FUNCTION(ftp_fget)
{
zval *z_ftp, *z_file;
zval *z_ftp;
ftpbuf_t *ftp;
ftptype_t xtype;
php_stream *stream;
char *file;
size_t file_len;
zend_long mode=FTPTYPE_IMAGE, resumepos=0;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_STRING(file, file_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(mode)
Z_PARAM_LONG(resumepos)
ZEND_PARSE_PARAMETERS_END();

GET_FTPBUF(ftp, z_ftp);
php_stream_from_res(stream, Z_RES_P(z_file));
XTYPE(xtype, mode);

/* ignore autoresume if autoseek is switched off */
Expand Down Expand Up @@ -610,19 +615,24 @@ PHP_FUNCTION(ftp_fget)
/* {{{ Retrieves a file from the FTP server asynchronly and writes it to an open file */
PHP_FUNCTION(ftp_nb_fget)
{
zval *z_ftp, *z_file;
zval *z_ftp;
ftpbuf_t *ftp;
ftptype_t xtype;
php_stream *stream;
char *file;
size_t file_len;
zend_long mode=FTPTYPE_IMAGE, resumepos=0, ret;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Ors|ll", &z_ftp, php_ftp_ce, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_STRING(file, file_len)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(mode)
Z_PARAM_LONG(resumepos)
ZEND_PARSE_PARAMETERS_END();

GET_FTPBUF(ftp, z_ftp);
php_stream_from_res(stream, Z_RES_P(z_file));
XTYPE(xtype, mode);

/* ignore autoresume if autoseek is switched off */
Expand Down Expand Up @@ -848,19 +858,24 @@ PHP_FUNCTION(ftp_nb_continue)
/* {{{ Stores a file from an open file to the FTP server */
PHP_FUNCTION(ftp_fput)
{
zval *z_ftp, *z_file;
zval *z_ftp;
ftpbuf_t *ftp;
ftptype_t xtype;
size_t remote_len;
zend_long mode=FTPTYPE_IMAGE, startpos=0;
php_stream *stream;
char *remote;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
Z_PARAM_STRING(remote, remote_len)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(mode)
Z_PARAM_LONG(startpos)
ZEND_PARSE_PARAMETERS_END();

GET_FTPBUF(ftp, z_ftp);
php_stream_from_zval(stream, z_file);
XTYPE(xtype, mode);

/* ignore autoresume if autoseek is switched off */
Expand Down Expand Up @@ -895,7 +910,7 @@ PHP_FUNCTION(ftp_fput)
/* {{{ Stores a file from an open file to the FTP server nbronly */
PHP_FUNCTION(ftp_nb_fput)
{
zval *z_ftp, *z_file;
zval *z_ftp;
ftpbuf_t *ftp;
ftptype_t xtype;
size_t remote_len;
Expand All @@ -904,11 +919,16 @@ PHP_FUNCTION(ftp_nb_fput)
php_stream *stream;
char *remote;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Osr|ll", &z_ftp, php_ftp_ce, &remote, &remote_len, &z_file, &mode, &startpos) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(3, 5)
Z_PARAM_OBJECT_OF_CLASS(z_ftp, php_ftp_ce)
Z_PARAM_STRING(remote, remote_len)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(mode)
Z_PARAM_LONG(startpos)
ZEND_PARSE_PARAMETERS_END();

GET_FTPBUF(ftp, z_ftp);
php_stream_from_res(stream, Z_RES_P(z_file));
XTYPE(xtype, mode);

/* ignore autoresume if autoseek is switched off */
Expand Down
14 changes: 8 additions & 6 deletions ext/hash/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,20 @@ PHP_FUNCTION(hash_update)
/* {{{ Pump data into the hashing algorithm from an open stream */
PHP_FUNCTION(hash_update_stream)
{
zval *zhash, *zstream;
zend_object *hash_obj;
php_hashcontext_object *hash;
php_stream *stream = NULL;
zend_long length = -1, didread = 0;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "Or|l", &zhash, php_hashcontext_ce, &zstream, &length) == FAILURE) {
RETURN_THROWS();
}
ZEND_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_OBJ_OF_CLASS(hash_obj, php_hashcontext_ce)
PHP_Z_PARAM_STREAM(stream)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(length)
ZEND_PARSE_PARAMETERS_END();

hash = php_hashcontext_from_object(Z_OBJ_P(zhash));
hash = php_hashcontext_from_object(hash_obj);
PHP_HASHCONTEXT_VERIFY(hash);
php_stream_from_zval(stream, zstream);

while (length) {
char buf[1024];
Expand Down
36 changes: 16 additions & 20 deletions ext/opcache/jit/ir/ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,69 +1294,65 @@ void ir_build_def_use_lists(ir_ctx *ctx)

void ir_use_list_remove_all(ir_ctx *ctx, ir_ref from, ir_ref ref)
{
ir_ref j, n, *p, *q, use;
ir_ref n, *p, *q, use;
ir_use_list *use_list;
ir_ref skip = 0;

IR_ASSERT(from > 0);
use_list = &ctx->use_lists[from];
n = use_list->count;
for (j = 0, p = q = &ctx->use_edges[use_list->refs]; j < n; j++, p++) {
for (p = q = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
use = *p;
if (use == ref) {
skip++;
} else {
if (use != ref) {
if (p != q) {
*q = use;
}
q++;
}
}
if (skip) {
use_list->count -= skip;
if (p != q) {
use_list->count -= (p - q);
do {
*q = IR_UNUSED;
q++;
} while (--skip);
} while (q != p);
}
}

void ir_use_list_remove_one(ir_ctx *ctx, ir_ref from, ir_ref ref)
{
ir_ref j, n, *p;
ir_ref n, *p;
ir_use_list *use_list;

IR_ASSERT(from > 0);
use_list = &ctx->use_lists[from];
n = use_list->count;
j = 0;
p = &ctx->use_edges[use_list->refs];
while (j < n) {
while (n > 0) {
if (*p == ref) {
use_list->count--;
j++;
while (j < n) {
n--;
while (n > 0) {
*p = *(p+1);
p++;
j++;
n--;
}
*p = IR_UNUSED;
break;
}
p++;
j++;
n--;
}
}

void ir_use_list_replace_one(ir_ctx *ctx, ir_ref ref, ir_ref use, ir_ref new_use)
{
ir_use_list *use_list;
ir_ref i, n, *p;
ir_ref n, *p;

IR_ASSERT(ref > 0);
use_list = &ctx->use_lists[ref];
n = use_list->count;
for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) {
for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
if (*p == use) {
*p = new_use;
break;
Expand All @@ -1367,12 +1363,12 @@ void ir_use_list_replace_one(ir_ctx *ctx, ir_ref ref, ir_ref use, ir_ref new_use
void ir_use_list_replace_all(ir_ctx *ctx, ir_ref ref, ir_ref use, ir_ref new_use)
{
ir_use_list *use_list;
ir_ref i, n, *p;
ir_ref n, *p;

IR_ASSERT(ref > 0);
use_list = &ctx->use_lists[ref];
n = use_list->count;
for (i = 0, p = &ctx->use_edges[use_list->refs]; i < n; i++, p++) {
for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
if (*p == use) {
*p = new_use;
}
Expand Down
22 changes: 18 additions & 4 deletions ext/opcache/jit/ir/ir_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ static void ir_remove_predecessor(ir_ctx *ctx, ir_block *bb, uint32_t from)

static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
{
ir_ref i, j, n, k, *p, use;
ir_ref i, j, n, k, *p, *q, use;
ir_insn *use_insn;
ir_use_list *use_list;
ir_bitset life_inputs;
Expand Down Expand Up @@ -359,7 +359,7 @@ static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
use_list = &ctx->use_lists[merge];
if (use_list->count > 1) {
n++;
for (k = 0, p = &ctx->use_edges[use_list->refs]; k < use_list->count; k++, p++) {
for (k = use_list->count, p = q = &ctx->use_edges[use_list->refs]; k > 0; p++, k--) {
use = *p;
use_insn = &ctx->ir_base[use];
if (use_insn->op == IR_PHI) {
Expand All @@ -379,8 +379,22 @@ static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
for (j = 2; j <= n; j++) {
ir_insn_set_op(use_insn, j, IR_UNUSED);
}
ir_use_list_remove_all(ctx, merge, use);
continue;
}

/*compact use list */
if (p != q){
*q = use;
}
q++;
}

if (p != q) {
use_list->count -= (p - q);
do {
*q = IR_UNUSED; /* clenu-op the removed tail */
q++;
} while (p != q);
}
}
} else {
Expand All @@ -389,7 +403,7 @@ static void ir_remove_merge_input(ir_ctx *ctx, ir_ref merge, ir_ref from)
use_list = &ctx->use_lists[merge];
if (use_list->count > 1) {
n++;
for (k = 0, p = &ctx->use_edges[use_list->refs]; k < use_list->count; k++, p++) {
for (k = use_list->count, p = &ctx->use_edges[use_list->refs]; k > 0; p++, k--) {
use = *p;
use_insn = &ctx->ir_base[use];
if (use_insn->op == IR_PHI) {
Expand Down
12 changes: 6 additions & 6 deletions ext/opcache/jit/ir/ir_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ void ir_consistency_check(void)

static bool ir_check_use_list(const ir_ctx *ctx, ir_ref from, ir_ref to)
{
ir_ref n, j, *p;
ir_ref n, *p;
ir_use_list *use_list = &ctx->use_lists[from];

n = use_list->count;
for (j = 0, p = &ctx->use_edges[use_list->refs]; j < n; j++, p++) {
for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
if (*p == to) {
return 1;
}
Expand Down Expand Up @@ -304,9 +304,9 @@ bool ir_check(const ir_ctx *ctx)

if (ctx->use_lists) {
ir_use_list *use_list = &ctx->use_lists[i];
ir_ref count;
ir_ref count, n = use_list->count;

for (j = 0, p = &ctx->use_edges[use_list->refs]; j < use_list->count; j++, p++) {
for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
use = *p;
if (!ir_check_input_list(ctx, i, use)) {
fprintf(stderr, "ir_base[%d] is in use list of ir_base[%d]\n", use, i);
Expand Down Expand Up @@ -347,8 +347,8 @@ bool ir_check(const ir_ctx *ctx)
break;
default:
/* skip data references */
count = use_list->count;
for (j = 0, p = &ctx->use_edges[use_list->refs]; j < use_list->count; j++, p++) {
count = n = use_list->count;
for (p = &ctx->use_edges[use_list->refs]; n > 0; p++, n--) {
use = *p;
if (!(ir_op_flags[ctx->ir_base[use].op] & IR_OP_FLAG_CONTROL)) {
count--;
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/ir/ir_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static void ir_dump_dessa_moves(const ir_ctx *ctx, int b, ir_block *bb, FILE *f)
use_list = &ctx->use_lists[succ_bb->start];
k = ir_phi_input_number(ctx, succ_bb, b);

for (i = 0, p = &ctx->use_edges[use_list->refs]; i < use_list->count; i++, p++) {
for (i = use_list->count, p = &ctx->use_edges[use_list->refs]; i > 0; p++, i--) {
use_ref = *p;
use_insn = &ctx->ir_base[use_ref];
if (use_insn->op == IR_PHI) {
Expand Down
Loading
Loading