{"action":"created","issue":{"url":"https://api.github.com/repos/svaarala/duktape/issues/380","labels_url":"https://api.github.com/repos/svaarala/duktape/issues/380/labels{/name}","comments_url":"https://api.github.com/repos/svaarala/duktape/issues/380/comments","events_url":"https://api.github.com/repos/svaarala/duktape/issues/380/events","html_url":"https://github.com/svaarala/duktape/pull/380","id":108228834,"number":380,"title":"Improve bytecode emitted for a plain number assignment","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/13","html_url":"https://github.com/svaarala/duktape/milestones/v1.4.0","labels_url":"https://api.github.com/repos/svaarala/duktape/milestones/13/labels","id":1225990,"number":13,"title":"v1.4.0","description":"Call handling, Emscripten performance","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":60,"closed_issues":18,"state":"open","created_at":"2015-07-26T04:06:08Z","updated_at":"2015-09-26T15:44:34Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-09-24T22:51:39Z","updated_at":"2015-09-26T16:56:24Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/svaarala/duktape/pulls/380","html_url":"https://github.com/svaarala/duktape/pull/380","diff_url":"https://github.com/svaarala/duktape/pull/380.diff","patch_url":"https://github.com/svaarala/duktape/pull/380.patch"},"body":"In Duktape 1.3.0 a plain assignment with a number source and a register-bound target produced two bytecode instructions per assignment:\r\n\r\n```js\r\nx = 123.0;  // Duktape 1.3.0 produces: LDCONST + LDREG\r\nx = 123;    // Duktape 1.3.0 produces: LDINT + LDREG\r\n```\r\n\r\nImprove the compiler to produce:\r\n\r\n```js\r\nx = 123.0;  // Produce: LDCONST directly to register of 'x'\r\nx = 123;    // Produce: LDINT directly to register of 'x'\r\n```\r\n\r\nThis reduces bytecode size and also improves performance for constant loading.\r\n\r\nTasks:\r\n\r\n- [ ] Careful review of coercions in compilation\r\n- [ ] Check if similar fix for LDTRUE, LDFALSE, etc would be easy\r\n- [ ] Try to replace the \"target is register bound, operation is none\" code path with a `ivalue_toforcedreg` so that no special handling is needed\r\n- [ ] Share assignment handling code with \"for (var i = ...\" code path\r\n- [ ] Ensure testcases cover all paths in compiler, inspect bytecode\r\n- [ ] Ensure \"toplevel assign\" check is correct\r\n- [ ] Test with asserts (also test262)\r\n- [ ] Releases entry"},"comment":{"url":"https://api.github.com/repos/svaarala/duktape/issues/comments/143469696","html_url":"https://github.com/svaarala/duktape/pull/380#issuecomment-143469696","issue_url":"https://api.github.com/repos/svaarala/duktape/issues/380","id":143469696,"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},"created_at":"2015-09-26T16:56:24Z","updated_at":"2015-09-26T16:56:24Z","body":"If you just load the RHS into the LHS, and use *either* RHS or LHS as the assignment expression value, you'll potentially run into issues like #381.\r\n\r\nThe only easy and safe approach is to load through a temporary, and use that temporary as the value of the assignment expression itself. Avoiding this needs to be done carefully, and only when it's safe."}}