{"action":"created","issue":{"url":"https://api.github.com/repos/zonyitoo/context-rs/issues/17","labels_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/17/comments","events_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/17/events","html_url":"https://github.com/zonyitoo/context-rs/pull/17","id":112674766,"number":17,"title":"Asm experiments. NOT FOR MERGE","user":{"login":"target-san","id":4011726,"avatar_url":"https://avatars.githubusercontent.com/u/4011726?v=3","gravatar_id":"","url":"https://api.github.com/users/target-san","html_url":"https://github.com/target-san","followers_url":"https://api.github.com/users/target-san/followers","following_url":"https://api.github.com/users/target-san/following{/other_user}","gists_url":"https://api.github.com/users/target-san/gists{/gist_id}","starred_url":"https://api.github.com/users/target-san/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/target-san/subscriptions","organizations_url":"https://api.github.com/users/target-san/orgs","repos_url":"https://api.github.com/users/target-san/repos","events_url":"https://api.github.com/users/target-san/events{/privacy}","received_events_url":"https://api.github.com/users/target-san/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-10-21T20:42:11Z","updated_at":"2015-10-23T07:11:17Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/zonyitoo/context-rs/pulls/17","html_url":"https://github.com/zonyitoo/context-rs/pull/17","diff_url":"https://github.com/zonyitoo/context-rs/pull/17.diff","patch_url":"https://github.com/zonyitoo/context-rs/pull/17.patch"},"body":"Note. This PR is incomplete and just shows some raw ideas. Don't accep\r\nPlease pay attention to asm/x86_64-linux.S, src/backend.rs\r\nlib/libx86_64-linux.a is built from mentioned ASM file.\r\n\r\n1. backend links against pre-built lib, so no inline asm, GNU tool etc.\r\n2. Context store is unstructured, and is just a memory buffer; it's size is different for each platform, but is defined via simple constant. So no more multiple Registers definitions\r\n3. Swap function is multi-purpose; controlled via null-arity of each argument\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/zonyitoo/context-rs/issues/comments/150494447","html_url":"https://github.com/zonyitoo/context-rs/pull/17#issuecomment-150494447","issue_url":"https://api.github.com/repos/zonyitoo/context-rs/issues/17","id":150494447,"user":{"login":"zonyitoo","id":1067951,"avatar_url":"https://avatars.githubusercontent.com/u/1067951?v=3","gravatar_id":"","url":"https://api.github.com/users/zonyitoo","html_url":"https://github.com/zonyitoo","followers_url":"https://api.github.com/users/zonyitoo/followers","following_url":"https://api.github.com/users/zonyitoo/following{/other_user}","gists_url":"https://api.github.com/users/zonyitoo/gists{/gist_id}","starred_url":"https://api.github.com/users/zonyitoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zonyitoo/subscriptions","organizations_url":"https://api.github.com/users/zonyitoo/orgs","repos_url":"https://api.github.com/users/zonyitoo/repos","events_url":"https://api.github.com/users/zonyitoo/events{/privacy}","received_events_url":"https://api.github.com/users/zonyitoo/received_events","type":"User","site_admin":false},"created_at":"2015-10-23T07:11:17Z","updated_at":"2015-10-23T07:11:17Z","body":"Agree.\r\n\r\nOne more thing for the #16 issue, I found that Rust will always generate a function like this\r\n\r\n```\r\ntest_function_mangling:\r\n    push %rbp\r\n    mov %rsp, %rbp\r\n    // ... The real function body\r\n    pop %rbp\r\n    ret\r\n```\r\n\r\nSo the problem is the `%rbp` is pushed onto the stack, and poped out after the real function body is exectued. If replace the function body as the context switch function, which will save `%rsp` but don't pop out `%rbp` and the return address on the stack, just switch `%rsp` directly and then let the rest of the generated code to pop out the `%rbp` and `ret`.\r\n\r\nAs what I did in https://github.com/zonyitoo/context-rs/blob/feature-inlineasm/src/detail/x86_64.rs#L125.\r\n\r\nIf you are interested in bring inline asm into this crate, I am happy to discuss in #16 ."}}