{"action":"created","comment":{"url":"https://api.github.com/repos/php/php-src/pulls/comments/47789776","id":47789776,"diff_hunk":"@@ -599,9 +599,110 @@ static uint32_t zend_get_brk_cont_target(const zend_op_array *op_array, const ze\n \treturn opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont;\n }\n \n+static uint32_t zend_resolve_fcall(zend_op_array *op_array, zend_op **opline, uint32_t offset) {\n+\tuint32_t lr_off = 0, end;\n+\tuint32_t fcall_Ts, max_fcall_Ts = 0;\n+\tzend_op *init = *opline;\n+\tuint32_t num_args = init->extended_value;\n+\tuint32_t *live_ranges;\n+\n+\tif (init->opcode == ZEND_INCLUDE_OR_EVAL) {\n+\t\tinit->op1.var = offset;\n+\t\tinit->op1_type = IS_TMP_VAR;\n+\t\treturn ZEND_CALL_FRAME_SLOT;\n+\t}\n+\n+\tlive_ranges = emalloc(sizeof(uint32_t) * num_args);\n+\n+\tif (init->opcode == ZEND_INIT_FCALL && init->result.num == 0) {\n+\t\tzend_function *fbc = zend_hash_find_ptr(CG(function_table), Z_STR_P(CT_CONSTANT_EX(op_array, init->op2.constant)));\n+\t\tZEND_ASSERT(fbc);\n+\t\tif (ZEND_USER_CODE(fbc->type)) {\n+\t\t\tnum_args = MAX(num_args, fbc->op_array.num_args);\n+\t\t}\n+\t} else {\n+\t\tnum_args += ZEND_RESERVED_RECV_SLOTS;\n+\t}\n+\n+\tif (init->opcode != ZEND_NEW) {\n+\t\t/* only one result var per opcode ... can't set object *and* execute_data as result ... maybe find a better solution? */\n+\t\tinit->result.var = offset + num_args;\n+\t\tinit->result_type = IS_TMP_VAR;\n+\t}\n+\n+\twhile (1) {\n+\t\tswitch ((++*opline)->opcode) {\n+\t\t\tcase ZEND_NEW:\n+\t\t\tcase ZEND_INIT_FCALL_BY_NAME:\n+\t\t\tcase ZEND_INIT_FCALL:\n+\t\t\tcase ZEND_INIT_NS_FCALL_BY_NAME:\n+\t\t\tcase ZEND_INIT_METHOD_CALL:\n+\t\t\tcase ZEND_INIT_STATIC_METHOD_CALL:\n+\t\t\tcase ZEND_INIT_USER_CALL:\n+\t\t\tcase ZEND_INIT_DYNAMIC_CALL:\n+\t\t\tcase ZEND_INCLUDE_OR_EVAL:\n+\t\t\t\tfcall_Ts = zend_resolve_fcall(op_array, opline, offset + num_args + ZEND_CALL_FRAME_SLOT);\n+\t\t\t\tif (fcall_Ts > max_fcall_Ts) {\n+\t\t\t\t\tmax_fcall_Ts = fcall_Ts;\n+\t\t\t\t}\n+\t\t\t\tbreak;\n+\n+\t\t\tcase ZEND_DO_FCALL:\n+\t\t\tcase ZEND_DO_ICALL:\n+\t\t\tcase ZEND_DO_UCALL:\n+\t\t\tcase ZEND_DO_FCALL_BY_NAME:\n+\t\t\tcase ZEND_DO_UNPACK_FCALL:\n+\t\t\t\tend = *opline - op_array->opcodes;\n+\t\t\t\twhile (lr_off--) {\n+\t\t\t\t\tzend_live_range *range = op_array->live_range + live_ranges[lr_off];\n+\t\t\t\t\tif (range->start == end && live_ranges[lr_off] == op_array->last_live_range - 1) {\n+\t\t\t\t\t\top_array->last_live_range--;\n+\t\t\t\t\t} else {\n+\t\t\t\t\t\trange->end = end;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\tzend_end_live_range(op_array, (*opline)->op1.num, *opline - op_array->opcodes, ZEND_LIVE_EXECUTE_DATA, offset + num_args);\n+\t\t\t\t(*opline)->op1_type = IS_TMP_VAR;\n+\t\t\t\t(*opline)->op1.var = offset + num_args;\n+\n+\t\t\t\tefree(live_ranges);\n+\t\t\t\treturn ZEND_CALL_FRAME_SLOT + num_args + max_fcall_Ts;\n+\n+\t\t\tcase ZEND_SEND_VAL:\n+\t\t\tcase ZEND_SEND_VAR_EX:\n+\t\t\tcase ZEND_SEND_REF:\n+\t\t\tcase ZEND_SEND_VAR_NO_REF:\n+\t\t\tcase ZEND_SEND_VAL_EX:\n+\t\t\tcase ZEND_SEND_VAR:\n+\t\t\tcase ZEND_SEND_USER:\n+\t\t\t\tlive_ranges[lr_off] = (*opline)->result.num;\n+\t\t\t\t(*opline)->result.var = num_args - ((*opline)->extended_value & ZEND_ARG_SEND_MASK) + offset;\n+\t\t\t\t(*opline)->result_type = IS_VAR;\n+\t\t\t\top_array->live_range[live_ranges[lr_off]].var = ((*opline)->result.var * sizeof(zval)) | ZEND_LIVE_TMPVAR;\n+\t\t\t\tlr_off++;\n+\t\t\tcase ZEND_SEND_UNPACK:\n+\t\t\tcase ZEND_FETCH_FUNC_ARG:\n+\t\t\t\t(*opline)->op2.var = offset + num_args;\n+\t\t\t\t(*opline)->op2_type = IS_TMP_VAR;\n+\t\t\t\tbreak;\n+\n+\t\t\t/* No operands left, using ZEND_OP_DATA here */\n+\t\t\tcase ZEND_FETCH_STATIC_PROP_FUNC_ARG:\n+\t\t\tcase ZEND_FETCH_DIM_FUNC_ARG:\n+\t\t\tcase ZEND_FETCH_OBJ_FUNC_ARG:\n+\t\t\t\t(*opline)++;\n+\t\t\t\tZEND_ASSERT((*opline)->opcode == ZEND_OP_DATA);\n+\t\t\t\t(*opline)->op2.var = offset + num_args;\n+\t\t\t\t(*opline)->op2_type = IS_TMP_VAR;\n+\t\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+","path":"Zend/zend_opcode.c","position":112,"original_position":112,"commit_id":"ea9ee86e74f3ece3e778d326e03080b1bff65171","original_commit_id":"ea9ee86e74f3ece3e778d326e03080b1bff65171","user":{"login":"dstogov","id":2510034,"avatar_url":"https://avatars.githubusercontent.com/u/2510034?v=3","gravatar_id":"","url":"https://api.github.com/users/dstogov","html_url":"https://github.com/dstogov","followers_url":"https://api.github.com/users/dstogov/followers","following_url":"https://api.github.com/users/dstogov/following{/other_user}","gists_url":"https://api.github.com/users/dstogov/gists{/gist_id}","starred_url":"https://api.github.com/users/dstogov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dstogov/subscriptions","organizations_url":"https://api.github.com/users/dstogov/orgs","repos_url":"https://api.github.com/users/dstogov/repos","events_url":"https://api.github.com/users/dstogov/events{/privacy}","received_events_url":"https://api.github.com/users/dstogov/received_events","type":"User","site_admin":false},"body":"Can we do this in regular compiler (not in pass_two)?","created_at":"2015-12-16T15:31:41Z","updated_at":"2015-12-16T15:31:41Z","html_url":"https://github.com/php/php-src/pull/1679#discussion_r47789776","pull_request_url":"https://api.github.com/repos/php/php-src/pulls/1679","_links":{"self":{"href":"https://api.github.com/repos/php/php-src/pulls/comments/47789776"},"html":{"href":"https://github.com/php/php-src/pull/1679#discussion_r47789776"},"pull_request":{"href":"https://api.github.com/repos/php/php-src/pulls/1679"}}},"pull_request":{"url":"https://api.github.com/repos/php/php-src/pulls/1679","id":53844395,"html_url":"https://github.com/php/php-src/pull/1679","diff_url":"https://github.com/php/php-src/pull/1679.diff","patch_url":"https://github.com/php/php-src/pull/1679.patch","issue_url":"https://api.github.com/repos/php/php-src/issues/1679","number":1679,"state":"open","locked":false,"title":"Restructure argument passing onto stack","user":{"login":"bwoebi","id":3154871,"avatar_url":"https://avatars.githubusercontent.com/u/3154871?v=3","gravatar_id":"","url":"https://api.github.com/users/bwoebi","html_url":"https://github.com/bwoebi","followers_url":"https://api.github.com/users/bwoebi/followers","following_url":"https://api.github.com/users/bwoebi/following{/other_user}","gists_url":"https://api.github.com/users/bwoebi/gists{/gist_id}","starred_url":"https://api.github.com/users/bwoebi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwoebi/subscriptions","organizations_url":"https://api.github.com/users/bwoebi/orgs","repos_url":"https://api.github.com/users/bwoebi/repos","events_url":"https://api.github.com/users/bwoebi/events{/privacy}","received_events_url":"https://api.github.com/users/bwoebi/received_events","type":"User","site_admin":false},"body":"Arguments now are prepended to the execute_data, inside the (last!) temporaries of the previous stack frame. Every stack frame has place for sent arguments plus five optional args (RECV_INIT...) and the execute_data.\r\nThis allows EG(vm_stack_top) and EX(call) to be removed and saves us from expensive comparisons to push a call frame completely in some cases (every ICALL).\r\nThe only downside is that arguments now are in reverse order causing variadics to be in reverse order on the stack; extensions might need some update ...\r\nAlso, freeing of args and execute_data is now completely handled by liveness.\r\nFinally, the patch gives 0.5%-3% improvement on applications.\r\n\r\nThere likely is still some room for optimization (e.g. eliminating ZEND_SEND_VAL with TMPs or speeding up the unpacking, removing INIT_FCALL for UCALLs, ...).","created_at":"2015-12-16T14:01:39Z","updated_at":"2015-12-16T15:31:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a229ebd652cbb98241cd3ef6cb82b7226e5e545f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/php/php-src/pulls/1679/commits","review_comments_url":"https://api.github.com/repos/php/php-src/pulls/1679/comments","review_comment_url":"https://api.github.com/repos/php/php-src/pulls/comments{/number}","comments_url":"https://api.github.com/repos/php/php-src/issues/1679/comments","statuses_url":"https://api.github.com/repos/php/php-src/statuses/ea9ee86e74f3ece3e778d326e03080b1bff65171","head":{"label":"bwoebi:vm_stack_restructuring","ref":"vm_stack_restructuring","sha":"ea9ee86e74f3ece3e778d326e03080b1bff65171","user":{"login":"bwoebi","id":3154871,"avatar_url":"https://avatars.githubusercontent.com/u/3154871?v=3","gravatar_id":"","url":"https://api.github.com/users/bwoebi","html_url":"https://github.com/bwoebi","followers_url":"https://api.github.com/users/bwoebi/followers","following_url":"https://api.github.com/users/bwoebi/following{/other_user}","gists_url":"https://api.github.com/users/bwoebi/gists{/gist_id}","starred_url":"https://api.github.com/users/bwoebi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwoebi/subscriptions","organizations_url":"https://api.github.com/users/bwoebi/orgs","repos_url":"https://api.github.com/users/bwoebi/repos","events_url":"https://api.github.com/users/bwoebi/events{/privacy}","received_events_url":"https://api.github.com/users/bwoebi/received_events","type":"User","site_admin":false},"repo":{"id":8383424,"name":"php-src","full_name":"bwoebi/php-src","owner":{"login":"bwoebi","id":3154871,"avatar_url":"https://avatars.githubusercontent.com/u/3154871?v=3","gravatar_id":"","url":"https://api.github.com/users/bwoebi","html_url":"https://github.com/bwoebi","followers_url":"https://api.github.com/users/bwoebi/followers","following_url":"https://api.github.com/users/bwoebi/following{/other_user}","gists_url":"https://api.github.com/users/bwoebi/gists{/gist_id}","starred_url":"https://api.github.com/users/bwoebi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bwoebi/subscriptions","organizations_url":"https://api.github.com/users/bwoebi/orgs","repos_url":"https://api.github.com/users/bwoebi/repos","events_url":"https://api.github.com/users/bwoebi/events{/privacy}","received_events_url":"https://api.github.com/users/bwoebi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bwoebi/php-src","description":"The PHP Interpreter","fork":true,"url":"https://api.github.com/repos/bwoebi/php-src","forks_url":"https://api.github.com/repos/bwoebi/php-src/forks","keys_url":"https://api.github.com/repos/bwoebi/php-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bwoebi/php-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bwoebi/php-src/teams","hooks_url":"https://api.github.com/repos/bwoebi/php-src/hooks","issue_events_url":"https://api.github.com/repos/bwoebi/php-src/issues/events{/number}","events_url":"https://api.github.com/repos/bwoebi/php-src/events","assignees_url":"https://api.github.com/repos/bwoebi/php-src/assignees{/user}","branches_url":"https://api.github.com/repos/bwoebi/php-src/branches{/branch}","tags_url":"https://api.github.com/repos/bwoebi/php-src/tags","blobs_url":"https://api.github.com/repos/bwoebi/php-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bwoebi/php-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bwoebi/php-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/bwoebi/php-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bwoebi/php-src/statuses/{sha}","languages_url":"https://api.github.com/repos/bwoebi/php-src/languages","stargazers_url":"https://api.github.com/repos/bwoebi/php-src/stargazers","contributors_url":"https://api.github.com/repos/bwoebi/php-src/contributors","subscribers_url":"https://api.github.com/repos/bwoebi/php-src/subscribers","subscription_url":"https://api.github.com/repos/bwoebi/php-src/subscription","commits_url":"https://api.github.com/repos/bwoebi/php-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/bwoebi/php-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/bwoebi/php-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/bwoebi/php-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/bwoebi/php-src/contents/{+path}","compare_url":"https://api.github.com/repos/bwoebi/php-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bwoebi/php-src/merges","archive_url":"https://api.github.com/repos/bwoebi/php-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bwoebi/php-src/downloads","issues_url":"https://api.github.com/repos/bwoebi/php-src/issues{/number}","pulls_url":"https://api.github.com/repos/bwoebi/php-src/pulls{/number}","milestones_url":"https://api.github.com/repos/bwoebi/php-src/milestones{/number}","notifications_url":"https://api.github.com/repos/bwoebi/php-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bwoebi/php-src/labels{/name}","releases_url":"https://api.github.com/repos/bwoebi/php-src/releases{/id}","created_at":"2013-02-23T23:09:56Z","updated_at":"2015-01-24T18:08:15Z","pushed_at":"2015-12-16T13:56:00Z","git_url":"git://github.com/bwoebi/php-src.git","ssh_url":"git@github.com:bwoebi/php-src.git","clone_url":"https://github.com/bwoebi/php-src.git","svn_url":"https://github.com/bwoebi/php-src","homepage":"http://www.php.net","size":252832,"stargazers_count":1,"watchers_count":1,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"php:master","ref":"master","sha":"ef6514d6520a19270c04c904bd82281dbe741a15","user":{"login":"php","id":25158,"avatar_url":"https://avatars.githubusercontent.com/u/25158?v=3","gravatar_id":"","url":"https://api.github.com/users/php","html_url":"https://github.com/php","followers_url":"https://api.github.com/users/php/followers","following_url":"https://api.github.com/users/php/following{/other_user}","gists_url":"https://api.github.com/users/php/gists{/gist_id}","starred_url":"https://api.github.com/users/php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php/subscriptions","organizations_url":"https://api.github.com/users/php/orgs","repos_url":"https://api.github.com/users/php/repos","events_url":"https://api.github.com/users/php/events{/privacy}","received_events_url":"https://api.github.com/users/php/received_events","type":"Organization","site_admin":false},"repo":{"id":1903522,"name":"php-src","full_name":"php/php-src","owner":{"login":"php","id":25158,"avatar_url":"https://avatars.githubusercontent.com/u/25158?v=3","gravatar_id":"","url":"https://api.github.com/users/php","html_url":"https://github.com/php","followers_url":"https://api.github.com/users/php/followers","following_url":"https://api.github.com/users/php/following{/other_user}","gists_url":"https://api.github.com/users/php/gists{/gist_id}","starred_url":"https://api.github.com/users/php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php/subscriptions","organizations_url":"https://api.github.com/users/php/orgs","repos_url":"https://api.github.com/users/php/repos","events_url":"https://api.github.com/users/php/events{/privacy}","received_events_url":"https://api.github.com/users/php/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php/php-src","description":"The PHP Interpreter","fork":false,"url":"https://api.github.com/repos/php/php-src","forks_url":"https://api.github.com/repos/php/php-src/forks","keys_url":"https://api.github.com/repos/php/php-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php/php-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php/php-src/teams","hooks_url":"https://api.github.com/repos/php/php-src/hooks","issue_events_url":"https://api.github.com/repos/php/php-src/issues/events{/number}","events_url":"https://api.github.com/repos/php/php-src/events","assignees_url":"https://api.github.com/repos/php/php-src/assignees{/user}","branches_url":"https://api.github.com/repos/php/php-src/branches{/branch}","tags_url":"https://api.github.com/repos/php/php-src/tags","blobs_url":"https://api.github.com/repos/php/php-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php/php-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php/php-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/php/php-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php/php-src/statuses/{sha}","languages_url":"https://api.github.com/repos/php/php-src/languages","stargazers_url":"https://api.github.com/repos/php/php-src/stargazers","contributors_url":"https://api.github.com/repos/php/php-src/contributors","subscribers_url":"https://api.github.com/repos/php/php-src/subscribers","subscription_url":"https://api.github.com/repos/php/php-src/subscription","commits_url":"https://api.github.com/repos/php/php-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/php/php-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/php/php-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/php/php-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/php/php-src/contents/{+path}","compare_url":"https://api.github.com/repos/php/php-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php/php-src/merges","archive_url":"https://api.github.com/repos/php/php-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php/php-src/downloads","issues_url":"https://api.github.com/repos/php/php-src/issues{/number}","pulls_url":"https://api.github.com/repos/php/php-src/pulls{/number}","milestones_url":"https://api.github.com/repos/php/php-src/milestones{/number}","notifications_url":"https://api.github.com/repos/php/php-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php/php-src/labels{/name}","releases_url":"https://api.github.com/repos/php/php-src/releases{/id}","created_at":"2011-06-16T01:52:25Z","updated_at":"2015-12-16T11:25:00Z","pushed_at":"2015-12-16T15:09:20Z","git_url":"git://github.com/php/php-src.git","ssh_url":"git@github.com:php/php-src.git","clone_url":"https://github.com/php/php-src.git","svn_url":"https://github.com/php/php-src","homepage":"http://www.php.net","size":292475,"stargazers_count":8281,"watchers_count":8281,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2787,"mirror_url":null,"open_issues_count":284,"forks":2787,"open_issues":284,"watchers":8281,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/php/php-src/pulls/1679"},"html":{"href":"https://github.com/php/php-src/pull/1679"},"issue":{"href":"https://api.github.com/repos/php/php-src/issues/1679"},"comments":{"href":"https://api.github.com/repos/php/php-src/issues/1679/comments"},"review_comments":{"href":"https://api.github.com/repos/php/php-src/pulls/1679/comments"},"review_comment":{"href":"https://api.github.com/repos/php/php-src/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/php/php-src/pulls/1679/commits"},"statuses":{"href":"https://api.github.com/repos/php/php-src/statuses/ea9ee86e74f3ece3e778d326e03080b1bff65171"}}}}