{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/294","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/294/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/294/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/294/events","html_url":"https://github.com/svaarala/duktape/issues/294","id":102879486,"number":294,"title":"Improve opcode dispatch further by using a local curr_pc in executor","user":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/svaarala/duktape/labels/performance","name":"performance","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/svaarala/duktape/milestones/9","html_url":"https://github.com/svaarala/duktape/milestones/v1.3.0","labels_url":"https://api.github.com/repos/svaarala/duktape/milestones/9/labels","id":1037290,"number":9,"title":"v1.3.0","description":"Buffer bindings, duk_config.h, bytecode dump/load","creator":{"login":"svaarala","id":6377415,"avatar_url":"https://avatars.githubusercontent.com/u/6377415?v=3","gravatar_id":"","url":"https://api.github.com/users/svaarala","html_url":"https://github.com/svaarala","followers_url":"https://api.github.com/users/svaarala/followers","following_url":"https://api.github.com/users/svaarala/following{/other_user}","gists_url":"https://api.github.com/users/svaarala/gists{/gist_id}","starred_url":"https://api.github.com/users/svaarala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/svaarala/subscriptions","organizations_url":"https://api.github.com/users/svaarala/orgs","repos_url":"https://api.github.com/users/svaarala/repos","events_url":"https://api.github.com/users/svaarala/events{/privacy}","received_events_url":"https://api.github.com/users/svaarala/received_events","type":"User","site_admin":false},"open_issues":15,"closed_issues":53,"state":"open","created_at":"2015-03-24T22:16:58Z","updated_at":"2015-08-26T16:40:18Z","due_on":null,"closed_at":null},"comments":73,"created_at":"2015-08-24T20:02:45Z","updated_at":"2015-08-27T16:33:41Z","closed_at":null,"body":"With #265 bytecode dispatch uses a cached `thr->curr_pc` pointer which is copied back into the topmost activation `act->curr_pc` whenever activation states may change or an up-to-date activation state is needed (e.g. for line numbers in the debugger).\r\n\r\nThis can probably be improved a bit further:\r\n\r\n- Use a local variable in the bytecode executor for `curr_pc`. Make that variable volatile so that it is always stored back into the stack frame after a dispatch.\r\n- Store a pointer to the stack frame location which holds `curr_pc` (i.e. a `duk_instr_t **` with `&curr_pc` as its value) in `thr->ptr_curr_pc`.\r\n- Wherever `thr->curr_pc` was copied back into `act->curr_pc` after #265, copy the value from `*thr->ptr_curr_pc` instead.\r\n\r\nThis is faster because `thr` is sometimes spilled but the stack frame pointer is not.\r\n\r\nPreliminary testing suggests this is roughly 5% faster than #265 (to be verified with more careful testing).\r\n\r\nChanges:\r\n\r\n- [x] Main source changes to implement the change\r\n- [x] Perhaps simplify management of `thr->ptr_curr_pc`: bytecode executor can establish it, and restore it before exiting (it always has a setjmp catchpoint so it can do this reliably)\r\n- [x] Check volatile declarations\r\n- [x] Verify performance difference\r\n- [x] Update doc/execution.rst\r\n- [x] Testcases (apitest, qecmatest, test262)\r\n- [x] Test debugger manually"},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/135486368","html_url":"https://github.com/svaarala/duktape/issues/294#issuecomment-135486368","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/294","id":135486368,"user":{"login":"fatcerberus","id":4097841,"avatar_url":"https://avatars.githubusercontent.com/u/4097841?v=3","gravatar_id":"","url":"https://api.github.com/users/fatcerberus","html_url":"https://github.com/fatcerberus","followers_url":"https://api.github.com/users/fatcerberus/followers","following_url":"https://api.github.com/users/fatcerberus/following{/other_user}","gists_url":"https://api.github.com/users/fatcerberus/gists{/gist_id}","starred_url":"https://api.github.com/users/fatcerberus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fatcerberus/subscriptions","organizations_url":"https://api.github.com/users/fatcerberus/orgs","repos_url":"https://api.github.com/users/fatcerberus/repos","events_url":"https://api.github.com/users/fatcerberus/events{/privacy}","received_events_url":"https://api.github.com/users/fatcerberus/received_events","type":"User","site_admin":false},"created_at":"2015-08-27T16:33:41Z","updated_at":"2015-08-27T16:33:41Z","body":"Oh.  I'm essentially using stock settings, the relevant customizations are:\r\nOptimize for speed (/O2)\r\nStatic multithread CRT (/MT)"}}