{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/226537209","pull_request_review_id":166383470,"id":226537209,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjUzNzIwOQ==","diff_hunk":"@@ -113,26 +156,182 @@ namespace Js\n         }\n     }\n \n-    bool JavascriptBigInt::MulThenAdd(uint32 digitMul, uint32 digitAdd)\n+    // return low(a+b) and out carry\n+    digit_t JavascriptBigInt::AddDigit(digit_t a, digit_t b, digit_t* carry)\n+    {\n+        digit_t result = a + b;\n+        if (result < a)\n+        {\n+            *carry += 1;\n+        }\n+        return result;\n+    }\n+\n+    // return low(a+b) and out carry\n+    digit_t JavascriptBigInt::SubDigit(digit_t a, digit_t b, digit_t* borrow)\n+    {\n+        digit_t result = a - b;\n+        if (result > a)\n+        {\n+            *borrow += 1;\n+        }\n+        return result;\n+    }\n+\n+    bool JavascriptBigInt::IsZero(JavascriptBigInt * pbi)\n+    {\n+        return (pbi->m_length == 1 && pbi->m_digits[0] == 0);\n+    }\n+\n+    JavascriptBigInt * JavascriptBigInt::AbsoluteIncrement(JavascriptBigInt * pbi)\n+    {\n+        JavascriptBigInt* result = pbi;\n+        digit_t carry = 1;\n+        for (digit_t i = 0; i < result->m_length && carry > 0; i++)\n+        {\n+            digit_t tempCarry = 0;\n+            result->m_digits[i] = JavascriptBigInt::AddDigit(result->m_digits[i], carry, &tempCarry);\n+            carry = tempCarry;\n+        }\n+        if (carry > 0) //increase length\n+        {\n+            if (result->m_length >= result->m_maxLength && !result->Resize(result->m_length + 1))\n+            {\n+                AssertOrFailFastMsg(false, \"AbsoluteIncrement overflow\");\n+            }\n+            result->m_digits[result->m_length++] = carry;\n+        }\n+        return result;\n+    }\n+\n+    JavascriptBigInt * JavascriptBigInt::AbsoluteDecrement(JavascriptBigInt * pbi)\n+    {\n+        JavascriptBigInt* result = pbi;\n+        Assert(!JavascriptBigInt::IsZero(result));\n+        digit_t borrow = 1;\n+        for (digit_t i = 0; i < result->m_length && borrow > 0; i++)\n+        {\n+            digit_t tempBorrow = 0;\n+            result->m_digits[i] = JavascriptBigInt::SubDigit(result->m_digits[i], borrow, &tempBorrow);\n+            borrow = tempBorrow;\n+        }\n+        Assert(borrow == 0);\n+        // remove trailing zero\n+        if (result->m_digits[result->m_length-1] == 0)\n+        {\n+            result->m_length--;\n+        }\n+        return result;\n+    }\n+\n+    JavascriptBigInt * JavascriptBigInt::Increment(JavascriptBigInt * pbi)\n+    {\n+        if (pbi->m_isNegative)\n+        {\n+            // return 0n for -1n\n+            if (pbi->m_length == 1 && pbi->m_digits[0] == 1)\n+            {\n+                JavascriptBigInt* result = pbi;\n+                result->m_digits[0] = 0;\n+                result->m_isNegative = false;\n+                return result;\n+            }\n+            return JavascriptBigInt::AbsoluteDecrement(pbi);\n+        }\n+        return JavascriptBigInt::AbsoluteIncrement(pbi);\n+    }\n+\n+    JavascriptBigInt * JavascriptBigInt::Decrement(JavascriptBigInt * pbi)\n+    {\n+        if (pbi->m_isNegative)\n+        {\n+            return JavascriptBigInt::AbsoluteIncrement(pbi);\n+        }\n+        if (JavascriptBigInt::IsZero(pbi)) // return -1n for 0n\n+        {\n+            JavascriptBigInt* result = pbi;\n+            result->m_digits[0] = 1;\n+            result->m_isNegative = true;\n+            return result;\n+        }\n+        return JavascriptBigInt::AbsoluteDecrement(pbi);\n+    }\n+\n+    Var JavascriptBigInt::Increment(Var aRight)\n+    {\n+        AssertMsg(VarIs<JavascriptBigInt>(aRight), \"BigInt Increment\");\n+\n+        JavascriptBigInt* rightBigInt = VarTo<JavascriptBigInt>(aRight);\n+        return JavascriptBigInt::Increment(rightBigInt);\n+    }\n+\n+    Var JavascriptBigInt::Decrement(Var aRight)\n+    {\n+        AssertMsg(VarIs<JavascriptBigInt>(aRight), \"BigInt Increment\");\n+\n+        JavascriptBigInt* rightBigInt = VarTo<JavascriptBigInt>(aRight);\n+        return JavascriptBigInt::Decrement(rightBigInt);\n+    }\n+\n+    // return low(a*b) and out high\n+    digit_t JavascriptBigInt::MulDigit(digit_t a, digit_t b, digit_t* resultHigh)\n+    {\n+        // Multiply is performed in half chuck favor.","path":"lib/Runtime/Library/JavascriptBigInt.cpp","position":222,"original_position":200,"commit_id":"de0dfd586d01c22b83ba2879986495724d4026d9","original_commit_id":"2a82748d15f04938d1f46857c1215ee170a9710d","user":{"login":"duongnhn","id":5943271,"node_id":"MDQ6VXNlcjU5NDMyNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5943271?v=4","gravatar_id":"","url":"https://api.github.com/users/duongnhn","html_url":"https://github.com/duongnhn","followers_url":"https://api.github.com/users/duongnhn/followers","following_url":"https://api.github.com/users/duongnhn/following{/other_user}","gists_url":"https://api.github.com/users/duongnhn/gists{/gist_id}","starred_url":"https://api.github.com/users/duongnhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duongnhn/subscriptions","organizations_url":"https://api.github.com/users/duongnhn/orgs","repos_url":"https://api.github.com/users/duongnhn/repos","events_url":"https://api.github.com/users/duongnhn/events{/privacy}","received_events_url":"https://api.github.com/users/duongnhn/received_events","type":"User","site_admin":false},"body":"it fail on Linux though so I revert back to first implementation. I think we can improve it later if needed","created_at":"2018-10-19T05:30:42Z","updated_at":"2018-10-19T05:30:42Z","html_url":"https://github.com/Microsoft/ChakraCore/pull/5788#discussion_r226537209","pull_request_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/226537209"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/5788#discussion_r226537209"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788"}},"in_reply_to_id":226479119},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788","id":223786675,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIzNzg2Njc1","html_url":"https://github.com/Microsoft/ChakraCore/pull/5788","diff_url":"https://github.com/Microsoft/ChakraCore/pull/5788.diff","patch_url":"https://github.com/Microsoft/ChakraCore/pull/5788.patch","issue_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5788","number":5788,"state":"open","locked":false,"title":"BigInt: reallocate space, digit_t, increment, decrement","user":{"login":"duongnhn","id":5943271,"node_id":"MDQ6VXNlcjU5NDMyNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5943271?v=4","gravatar_id":"","url":"https://api.github.com/users/duongnhn","html_url":"https://github.com/duongnhn","followers_url":"https://api.github.com/users/duongnhn/followers","following_url":"https://api.github.com/users/duongnhn/following{/other_user}","gists_url":"https://api.github.com/users/duongnhn/gists{/gist_id}","starred_url":"https://api.github.com/users/duongnhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duongnhn/subscriptions","organizations_url":"https://api.github.com/users/duongnhn/orgs","repos_url":"https://api.github.com/users/duongnhn/repos","events_url":"https://api.github.com/users/duongnhn/events{/privacy}","received_events_url":"https://api.github.com/users/duongnhn/received_events","type":"User","site_admin":false},"body":"In this PR, we implement\r\n- reallocate space for BigInt if necessary -> make it arbitrarily-precision.\r\n- make use of configuration with digit_t\r\n- implement increment/decrement operators\r\n- native tests for methods in Javascript BigInt class\r\n\r\nI defer \"assign by value\" to a future PR","created_at":"2018-10-17T23:50:56Z","updated_at":"2018-10-19T05:30:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f393864cb65a61584939ef1a6f93c9b26789adf","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5788/comments","statuses_url":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/de0dfd586d01c22b83ba2879986495724d4026d9","head":{"label":"duongnhn:user/duongn/bigint_size_t","ref":"user/duongn/bigint_size_t","sha":"de0dfd586d01c22b83ba2879986495724d4026d9","user":{"login":"duongnhn","id":5943271,"node_id":"MDQ6VXNlcjU5NDMyNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5943271?v=4","gravatar_id":"","url":"https://api.github.com/users/duongnhn","html_url":"https://github.com/duongnhn","followers_url":"https://api.github.com/users/duongnhn/followers","following_url":"https://api.github.com/users/duongnhn/following{/other_user}","gists_url":"https://api.github.com/users/duongnhn/gists{/gist_id}","starred_url":"https://api.github.com/users/duongnhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duongnhn/subscriptions","organizations_url":"https://api.github.com/users/duongnhn/orgs","repos_url":"https://api.github.com/users/duongnhn/repos","events_url":"https://api.github.com/users/duongnhn/events{/privacy}","received_events_url":"https://api.github.com/users/duongnhn/received_events","type":"User","site_admin":false},"repo":{"id":143789297,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM3ODkyOTc=","name":"ChakraCore","full_name":"duongnhn/ChakraCore","private":false,"owner":{"login":"duongnhn","id":5943271,"node_id":"MDQ6VXNlcjU5NDMyNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5943271?v=4","gravatar_id":"","url":"https://api.github.com/users/duongnhn","html_url":"https://github.com/duongnhn","followers_url":"https://api.github.com/users/duongnhn/followers","following_url":"https://api.github.com/users/duongnhn/following{/other_user}","gists_url":"https://api.github.com/users/duongnhn/gists{/gist_id}","starred_url":"https://api.github.com/users/duongnhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duongnhn/subscriptions","organizations_url":"https://api.github.com/users/duongnhn/orgs","repos_url":"https://api.github.com/users/duongnhn/repos","events_url":"https://api.github.com/users/duongnhn/events{/privacy}","received_events_url":"https://api.github.com/users/duongnhn/received_events","type":"User","site_admin":false},"html_url":"https://github.com/duongnhn/ChakraCore","description":"ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge","fork":true,"url":"https://api.github.com/repos/duongnhn/ChakraCore","forks_url":"https://api.github.com/repos/duongnhn/ChakraCore/forks","keys_url":"https://api.github.com/repos/duongnhn/ChakraCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duongnhn/ChakraCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duongnhn/ChakraCore/teams","hooks_url":"https://api.github.com/repos/duongnhn/ChakraCore/hooks","issue_events_url":"https://api.github.com/repos/duongnhn/ChakraCore/issues/events{/number}","events_url":"https://api.github.com/repos/duongnhn/ChakraCore/events","assignees_url":"https://api.github.com/repos/duongnhn/ChakraCore/assignees{/user}","branches_url":"https://api.github.com/repos/duongnhn/ChakraCore/branches{/branch}","tags_url":"https://api.github.com/repos/duongnhn/ChakraCore/tags","blobs_url":"https://api.github.com/repos/duongnhn/ChakraCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duongnhn/ChakraCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duongnhn/ChakraCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/duongnhn/ChakraCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duongnhn/ChakraCore/statuses/{sha}","languages_url":"https://api.github.com/repos/duongnhn/ChakraCore/languages","stargazers_url":"https://api.github.com/repos/duongnhn/ChakraCore/stargazers","contributors_url":"https://api.github.com/repos/duongnhn/ChakraCore/contributors","subscribers_url":"https://api.github.com/repos/duongnhn/ChakraCore/subscribers","subscription_url":"https://api.github.com/repos/duongnhn/ChakraCore/subscription","commits_url":"https://api.github.com/repos/duongnhn/ChakraCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/duongnhn/ChakraCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/duongnhn/ChakraCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/duongnhn/ChakraCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/duongnhn/ChakraCore/contents/{+path}","compare_url":"https://api.github.com/repos/duongnhn/ChakraCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duongnhn/ChakraCore/merges","archive_url":"https://api.github.com/repos/duongnhn/ChakraCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duongnhn/ChakraCore/downloads","issues_url":"https://api.github.com/repos/duongnhn/ChakraCore/issues{/number}","pulls_url":"https://api.github.com/repos/duongnhn/ChakraCore/pulls{/number}","milestones_url":"https://api.github.com/repos/duongnhn/ChakraCore/milestones{/number}","notifications_url":"https://api.github.com/repos/duongnhn/ChakraCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duongnhn/ChakraCore/labels{/name}","releases_url":"https://api.github.com/repos/duongnhn/ChakraCore/releases{/id}","deployments_url":"https://api.github.com/repos/duongnhn/ChakraCore/deployments","created_at":"2018-08-06T22:19:48Z","updated_at":"2018-08-06T22:20:07Z","pushed_at":"2018-10-19T05:26:31Z","git_url":"git://github.com/duongnhn/ChakraCore.git","ssh_url":"git@github.com:duongnhn/ChakraCore.git","clone_url":"https://github.com/duongnhn/ChakraCore.git","svn_url":"https://github.com/duongnhn/ChakraCore","homepage":"","size":152036,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"21624b8de51fc889f6dd30fbfd0896981c3a08eb","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":49086513,"node_id":"MDEwOlJlcG9zaXRvcnk0OTA4NjUxMw==","name":"ChakraCore","full_name":"Microsoft/ChakraCore","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/ChakraCore","description":"ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge","fork":false,"url":"https://api.github.com/repos/Microsoft/ChakraCore","forks_url":"https://api.github.com/repos/Microsoft/ChakraCore/forks","keys_url":"https://api.github.com/repos/Microsoft/ChakraCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/ChakraCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/ChakraCore/teams","hooks_url":"https://api.github.com/repos/Microsoft/ChakraCore/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/ChakraCore/events","assignees_url":"https://api.github.com/repos/Microsoft/ChakraCore/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/ChakraCore/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/ChakraCore/tags","blobs_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/ChakraCore/languages","stargazers_url":"https://api.github.com/repos/Microsoft/ChakraCore/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/ChakraCore/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/ChakraCore/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/ChakraCore/subscription","commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/ChakraCore/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/ChakraCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/ChakraCore/merges","archive_url":"https://api.github.com/repos/Microsoft/ChakraCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/ChakraCore/downloads","issues_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/ChakraCore/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/ChakraCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/ChakraCore/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/ChakraCore/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/ChakraCore/deployments","created_at":"2016-01-05T19:05:31Z","updated_at":"2018-10-19T02:03:41Z","pushed_at":"2018-10-19T05:26:34Z","git_url":"git://github.com/Microsoft/ChakraCore.git","ssh_url":"git@github.com:Microsoft/ChakraCore.git","clone_url":"https://github.com/Microsoft/ChakraCore.git","svn_url":"https://github.com/Microsoft/ChakraCore","homepage":"","size":158254,"stargazers_count":7464,"watchers_count":7464,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1024,"mirror_url":null,"archived":false,"open_issues_count":350,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":1024,"open_issues":350,"watchers":7464,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/5788"},"issue":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5788"},"comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/5788/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/5788/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/de0dfd586d01c22b83ba2879986495724d4026d9"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"duongnhn"}}