{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/68327595","id":68327595,"diff_hunk":"@@ -205,45 +205,62 @@ namespace Js\n         // 7.   Set the value of the [[Prototype]] internal data property of O to V.\n         // 8.   Return true.\n \n-        // Notify old prototypes that they are being removed from a prototype chain. This triggers invalidating protocache, etc.\n-        if (!JavascriptProxy::Is(object))\n+        bool isInvalidationOfInlineCacheNeeded = true;\n+        DynamicObject * obj = DynamicObject::FromVar(object);\n+\n+        // If this object was not prototype object, then no need to invalidate inline caches.\n+        // Simply assign it a new type so if this object used protoInlineCache in past, it will\n+        // be invalidated because of type mismatch and subsequently we will update its protoInlineCache\n+        if (!(obj->GetDynamicType()->GetTypeHandler()->GetFlags() & DynamicTypeHandler::IsPrototypeFlag))\n         {\n-            JavascriptOperators::MapObjectAndPrototypes<true>(object->GetPrototype(), [=](RecyclableObject* obj)\n-            {\n-                obj->RemoveFromPrototype(scriptContext);\n-            });\n+            obj->ChangeType();\n+            Assert(!obj->GetScriptContext()->GetThreadContext()->IsObjectRegisteredInProtoInlineCaches(obj));\n+            Assert(!obj->GetScriptContext()->GetThreadContext()->IsObjectRegisteredInStoreFieldInlineCaches(obj));\n+            isInvalidationOfInlineCacheNeeded = false;\n         }\n \n-        // Examine new prototype chain. If it brings in any non-WritableData property, we need to invalidate related caches.\n-        bool objectAndPrototypeChainHasOnlyWritableDataProperties =\n-            JavascriptOperators::CheckIfObjectAndPrototypeChainHasOnlyWritableDataProperties(newPrototype);\n-\n-        if (!objectAndPrototypeChainHasOnlyWritableDataProperties\n-            || object->GetScriptContext() != newPrototype->GetScriptContext())\n+        if (isInvalidationOfInlineCacheNeeded)\n         {\n-            // The HaveOnlyWritableDataProperties cache is cleared when a property is added or changed,\n-            // but only for types in the same script context. Therefore, if the prototype is in another\n-            // context, the object's cache won't be cleared when a property is added or changed on the prototype.\n-            // Moreover, an object is added to the cache only when its whole prototype chain is in the same\n-            // context.\n-            //\n-            // Since we don't have a way to find out which objects have a certain object as their prototype,\n-            // we clear the cache here instead.\n+            // Notify old prototypes that they are being removed from a prototype chain. This triggers invalidating protocache, etc.\n+            if (!JavascriptProxy::Is(object))","path":"lib/Runtime/Library/JavascriptObject.cpp","position":41,"original_position":41,"commit_id":"a88b1ccfc6b69818209cf77782cde34ca7ca8cd4","original_commit_id":"a88b1ccfc6b69818209cf77782cde34ca7ca8cd4","user":{"login":"kunalspathak","id":12488060,"avatar_url":"https://avatars.githubusercontent.com/u/12488060?v=3","gravatar_id":"","url":"https://api.github.com/users/kunalspathak","html_url":"https://github.com/kunalspathak","followers_url":"https://api.github.com/users/kunalspathak/followers","following_url":"https://api.github.com/users/kunalspathak/following{/other_user}","gists_url":"https://api.github.com/users/kunalspathak/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalspathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalspathak/subscriptions","organizations_url":"https://api.github.com/users/kunalspathak/orgs","repos_url":"https://api.github.com/users/kunalspathak/repos","events_url":"https://api.github.com/users/kunalspathak/events{/privacy}","received_events_url":"https://api.github.com/users/kunalspathak/received_events","type":"User","site_admin":false},"body":"This is the old code and I have just moved it under `if (isInvalidationOfInlineCacheNeeded) {}`. \r\nTo answer your question, if this is proxy object, we call Trap and exit from this function in the [beginning](https://github.com/Microsoft/ChakraCore/pull/1188/files#diff-ea542b055c5ff44ee26e3c8131164bf2R155). I will remove this redundant if check for proxy.","created_at":"2016-06-23T22:33:45Z","updated_at":"2016-06-23T22:33:45Z","html_url":"https://github.com/Microsoft/ChakraCore/pull/1188#discussion_r68327595","pull_request_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments/68327595"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/1188#discussion_r68327595"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188","id":75032417,"html_url":"https://github.com/Microsoft/ChakraCore/pull/1188","diff_url":"https://github.com/Microsoft/ChakraCore/pull/1188.diff","patch_url":"https://github.com/Microsoft/ChakraCore/pull/1188.patch","issue_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1188","number":1188,"state":"open","locked":false,"title":"improve changePrototype scenario","user":{"login":"kunalspathak","id":12488060,"avatar_url":"https://avatars.githubusercontent.com/u/12488060?v=3","gravatar_id":"","url":"https://api.github.com/users/kunalspathak","html_url":"https://github.com/kunalspathak","followers_url":"https://api.github.com/users/kunalspathak/followers","following_url":"https://api.github.com/users/kunalspathak/following{/other_user}","gists_url":"https://api.github.com/users/kunalspathak/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalspathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalspathak/subscriptions","organizations_url":"https://api.github.com/users/kunalspathak/orgs","repos_url":"https://api.github.com/users/kunalspathak/repos","events_url":"https://api.github.com/users/kunalspathak/events{/privacy}","received_events_url":"https://api.github.com/users/kunalspathak/received_events","type":"User","site_admin":false},"body":"Whenever we change prototype of an object, we invalidate all proto inline caches of all the properties present in all of the object's prototype chain. However this can be avoided if the object is not a prototype of any other object since it would have never got registered in proto inline cache as a prototype object. So, skip invalidation if the object is not a prototype of any object.\r\nThe only thing that should be done in that case is to change the type of object so that if it's properties were using proto inline caches, they will be invalidated by type mismatch and we will update their proto inline cache on next property access.\r\n\r\nGives approx. 20% gain in AcmeAir benchmarks of node.\r\n\r\nTest: UnitTest pass, Internal test runs in progress.","created_at":"2016-06-23T21:42:16Z","updated_at":"2016-06-23T22:33:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"072c6b8c3bd9199416caa6cd2b3ff3bdae9b5c63","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188/commits","review_comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188/comments","review_comment_url":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1188/comments","statuses_url":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/a88b1ccfc6b69818209cf77782cde34ca7ca8cd4","head":{"label":"kunalspathak:changeprototype","ref":"changeprototype","sha":"a88b1ccfc6b69818209cf77782cde34ca7ca8cd4","user":{"login":"kunalspathak","id":12488060,"avatar_url":"https://avatars.githubusercontent.com/u/12488060?v=3","gravatar_id":"","url":"https://api.github.com/users/kunalspathak","html_url":"https://github.com/kunalspathak","followers_url":"https://api.github.com/users/kunalspathak/followers","following_url":"https://api.github.com/users/kunalspathak/following{/other_user}","gists_url":"https://api.github.com/users/kunalspathak/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalspathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalspathak/subscriptions","organizations_url":"https://api.github.com/users/kunalspathak/orgs","repos_url":"https://api.github.com/users/kunalspathak/repos","events_url":"https://api.github.com/users/kunalspathak/events{/privacy}","received_events_url":"https://api.github.com/users/kunalspathak/received_events","type":"User","site_admin":false},"repo":{"id":49608132,"name":"ChakraCore","full_name":"kunalspathak/ChakraCore","owner":{"login":"kunalspathak","id":12488060,"avatar_url":"https://avatars.githubusercontent.com/u/12488060?v=3","gravatar_id":"","url":"https://api.github.com/users/kunalspathak","html_url":"https://github.com/kunalspathak","followers_url":"https://api.github.com/users/kunalspathak/followers","following_url":"https://api.github.com/users/kunalspathak/following{/other_user}","gists_url":"https://api.github.com/users/kunalspathak/gists{/gist_id}","starred_url":"https://api.github.com/users/kunalspathak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kunalspathak/subscriptions","organizations_url":"https://api.github.com/users/kunalspathak/orgs","repos_url":"https://api.github.com/users/kunalspathak/repos","events_url":"https://api.github.com/users/kunalspathak/events{/privacy}","received_events_url":"https://api.github.com/users/kunalspathak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kunalspathak/ChakraCore","description":"ChakraCore is the core part of the Chakra Javascript engine that powers Microsoft Edge","fork":true,"url":"https://api.github.com/repos/kunalspathak/ChakraCore","forks_url":"https://api.github.com/repos/kunalspathak/ChakraCore/forks","keys_url":"https://api.github.com/repos/kunalspathak/ChakraCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kunalspathak/ChakraCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kunalspathak/ChakraCore/teams","hooks_url":"https://api.github.com/repos/kunalspathak/ChakraCore/hooks","issue_events_url":"https://api.github.com/repos/kunalspathak/ChakraCore/issues/events{/number}","events_url":"https://api.github.com/repos/kunalspathak/ChakraCore/events","assignees_url":"https://api.github.com/repos/kunalspathak/ChakraCore/assignees{/user}","branches_url":"https://api.github.com/repos/kunalspathak/ChakraCore/branches{/branch}","tags_url":"https://api.github.com/repos/kunalspathak/ChakraCore/tags","blobs_url":"https://api.github.com/repos/kunalspathak/ChakraCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kunalspathak/ChakraCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kunalspathak/ChakraCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/kunalspathak/ChakraCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kunalspathak/ChakraCore/statuses/{sha}","languages_url":"https://api.github.com/repos/kunalspathak/ChakraCore/languages","stargazers_url":"https://api.github.com/repos/kunalspathak/ChakraCore/stargazers","contributors_url":"https://api.github.com/repos/kunalspathak/ChakraCore/contributors","subscribers_url":"https://api.github.com/repos/kunalspathak/ChakraCore/subscribers","subscription_url":"https://api.github.com/repos/kunalspathak/ChakraCore/subscription","commits_url":"https://api.github.com/repos/kunalspathak/ChakraCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/kunalspathak/ChakraCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/kunalspathak/ChakraCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/kunalspathak/ChakraCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/kunalspathak/ChakraCore/contents/{+path}","compare_url":"https://api.github.com/repos/kunalspathak/ChakraCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kunalspathak/ChakraCore/merges","archive_url":"https://api.github.com/repos/kunalspathak/ChakraCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kunalspathak/ChakraCore/downloads","issues_url":"https://api.github.com/repos/kunalspathak/ChakraCore/issues{/number}","pulls_url":"https://api.github.com/repos/kunalspathak/ChakraCore/pulls{/number}","milestones_url":"https://api.github.com/repos/kunalspathak/ChakraCore/milestones{/number}","notifications_url":"https://api.github.com/repos/kunalspathak/ChakraCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kunalspathak/ChakraCore/labels{/name}","releases_url":"https://api.github.com/repos/kunalspathak/ChakraCore/releases{/id}","deployments_url":"https://api.github.com/repos/kunalspathak/ChakraCore/deployments","created_at":"2016-01-13T23:07:10Z","updated_at":"2016-01-13T23:07:25Z","pushed_at":"2016-06-23T21:42:16Z","git_url":"git://github.com/kunalspathak/ChakraCore.git","ssh_url":"git@github.com:kunalspathak/ChakraCore.git","clone_url":"https://github.com/kunalspathak/ChakraCore.git","svn_url":"https://github.com/kunalspathak/ChakraCore","homepage":null,"size":30851,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"5790fb727b61c2e3f9ed4c735779f3a0bbcece84","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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,"name":"ChakraCore","full_name":"Microsoft/ChakraCore","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","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},"private":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":"2016-06-23T20:30:06Z","pushed_at":"2016-06-23T22:30:05Z","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":null,"size":41605,"stargazers_count":5298,"watchers_count":5298,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":594,"mirror_url":null,"open_issues_count":153,"forks":594,"open_issues":153,"watchers":5298,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188"},"html":{"href":"https://github.com/Microsoft/ChakraCore/pull/1188"},"issue":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1188"},"comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/issues/1188/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/pulls/1188/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/ChakraCore/statuses/a88b1ccfc6b69818209cf77782cde34ca7ca8cd4"}}}}
{"actor":{"display_login":"kunalspathak"}}