{"action":"created","comment":{"url":"https://api.github.com/repos/dropbox/pyston/pulls/comments/34495938","id":34495938,"diff_hunk":"@@ -333,50 +372,62 @@ void markPhase() {\n #endif\n \n         assert(isMarked(al));\n+        visitByGCKind(p, visitor);\n+    }\n \n-        // printf(\"Marking + scanning %p\\n\", p);\n-\n-        GCKind kind_id = al->kind_id;\n-        if (kind_id == GCKind::UNTRACKED) {\n-            continue;\n-        } else if (kind_id == GCKind::CONSERVATIVE || kind_id == GCKind::CONSERVATIVE_PYTHON) {\n-            uint32_t bytes = al->kind_data;\n-            if (DEBUG >= 2) {\n-                if (global_heap.small_arena.contains(p)) {\n-                    SmallArena::Block* b = SmallArena::Block::forPointer(p);\n-                    assert(b->size >= bytes + sizeof(GCAllocation));\n-                }\n-            }\n-            visitor.visitPotentialRange((void**)p, (void**)((char*)p + bytes));\n-        } else if (kind_id == GCKind::PRECISE) {\n-            uint32_t bytes = al->kind_data;\n-            if (DEBUG >= 2) {\n-                if (global_heap.small_arena.contains(p)) {\n-                    SmallArena::Block* b = SmallArena::Block::forPointer(p);\n-                    assert(b->size >= bytes + sizeof(GCAllocation));\n-                }\n-            }\n-            visitor.visitRange((void**)p, (void**)((char*)p + bytes));\n-        } else if (kind_id == GCKind::PYTHON) {\n-            Box* b = reinterpret_cast<Box*>(p);\n-            BoxedClass* cls = b->cls;\n-\n-            if (cls) {\n-                // The cls can be NULL since we use 'new' to construct them.\n-                // An arbitrary amount of stuff can happen between the 'new' and\n-                // the call to the constructor (ie the args get evaluated), which\n-                // can trigger a collection.\n-                ASSERT(cls->gc_visit, \"%s\", getTypeName(b));\n-                cls->gc_visit(&visitor, b);\n-            }\n-        } else if (kind_id == GCKind::HIDDEN_CLASS) {\n-            HiddenClass* hcls = reinterpret_cast<HiddenClass*>(p);\n-            hcls->gc_visit(&visitor);\n-        } else {\n-            RELEASE_ASSERT(0, \"Unhandled kind: %d\", (int)kind_id);\n+    long us = _t.end();\n+    sc_us.log(us);\n+}\n+\n+static void markPhase() {\n+    static StatCounter sc_us(\"us_gc_mark_phase\");\n+    Timer _t(\"markPhase\", /*min_usec=*/10000);\n+\n+#ifndef NVALGRIND\n+    // Have valgrind close its eyes while we do the conservative stack and data scanning,\n+    // since we'll be looking at potentially-uninitialized values:\n+    VALGRIND_DISABLE_ERROR_REPORTING;\n+#endif\n+\n+#if TRACE_GC_MARKING\n+#if 1 // separate log file per collection\n+    char tracefn_buf[80];\n+    snprintf(tracefn_buf, sizeof(tracefn_buf), \"gc_trace_%03d.txt\", ncollections);\n+    trace_fp = fopen(tracefn_buf, \"w\");\n+#else // overwrite previous log file with each collection\n+    trace_fp = fopen(\"gc_trace.txt\", \"w\");\n+#endif\n+#endif\n+    GC_TRACE_LOG(\"Starting collection %d\\n\", ncollections);\n+\n+    GC_TRACE_LOG(\"Looking at roots\\n\");\n+    TraceStack stack(roots);\n+    GCVisitor visitor(&stack);\n+\n+    markRoots(visitor);\n+\n+    graphTraversalMarking(stack, visitor);\n+\n+    // Some classes might be unreachable. Unfortunately, we have to keep them around for\n+    // one more collection, because during the sweep phase, instances of unreachable\n+    // classes might still end up looking at the class. So we visit those unreachable\n+    // classes and remove it from the list of class objects so that it can be freed\n+    // in the next collection.\n+    std::vector<BoxedClass*> classes_to_remove;\n+    for (BoxedClass* cls : class_objects) {\n+        GCAllocation* al = GCAllocation::fromUserData(cls);\n+        if (!isMarked(al)) {\n+            classes_to_remove.push_back(cls);\n+            visitor.visit(cls);\n         }\n     }\n \n+    graphTraversalMarking(stack, visitor);\n+\n+    for (BoxedClass* cls : classes_to_remove) {","path":"src/gc/collector.cpp","position":292,"original_position":292,"commit_id":"252f8d6f6734aaf51b5684ce27899fa4023c4050","original_commit_id":"252f8d6f6734aaf51b5684ce27899fa4023c4050","user":{"login":"toshok","id":24245,"avatar_url":"https://avatars.githubusercontent.com/u/24245?v=3","gravatar_id":"","url":"https://api.github.com/users/toshok","html_url":"https://github.com/toshok","followers_url":"https://api.github.com/users/toshok/followers","following_url":"https://api.github.com/users/toshok/following{/other_user}","gists_url":"https://api.github.com/users/toshok/gists{/gist_id}","starred_url":"https://api.github.com/users/toshok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toshok/subscriptions","organizations_url":"https://api.github.com/users/toshok/orgs","repos_url":"https://api.github.com/users/toshok/repos","events_url":"https://api.github.com/users/toshok/events{/privacy}","received_events_url":"https://api.github.com/users/toshok/received_events","type":"User","site_admin":false},"body":"which would let us get rid of this loop and all the copying.","created_at":"2015-07-13T18:37:59Z","updated_at":"2015-07-13T18:37:59Z","html_url":"https://github.com/dropbox/pyston/pull/666#discussion_r34495938","pull_request_url":"https://api.github.com/repos/dropbox/pyston/pulls/666","_links":{"self":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/comments/34495938"},"html":{"href":"https://github.com/dropbox/pyston/pull/666#discussion_r34495938"},"pull_request":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/666"}}},"pull_request":{"url":"https://api.github.com/repos/dropbox/pyston/pulls/666","id":39113769,"html_url":"https://github.com/dropbox/pyston/pull/666","diff_url":"https://github.com/dropbox/pyston/pull/666.diff","patch_url":"https://github.com/dropbox/pyston/pull/666.patch","issue_url":"https://api.github.com/repos/dropbox/pyston/issues/666","number":666,"state":"open","locked":false,"title":"Preparation for finalizer code, refactoring some simple_destructor logic.","user":{"login":"rudi-c","id":2747897,"avatar_url":"https://avatars.githubusercontent.com/u/2747897?v=3","gravatar_id":"","url":"https://api.github.com/users/rudi-c","html_url":"https://github.com/rudi-c","followers_url":"https://api.github.com/users/rudi-c/followers","following_url":"https://api.github.com/users/rudi-c/following{/other_user}","gists_url":"https://api.github.com/users/rudi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/rudi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudi-c/subscriptions","organizations_url":"https://api.github.com/users/rudi-c/orgs","repos_url":"https://api.github.com/users/rudi-c/repos","events_url":"https://api.github.com/users/rudi-c/events{/privacy}","received_events_url":"https://api.github.com/users/rudi-c/received_events","type":"User","site_admin":false},"body":"Mostly moving simple_destructor functions into tp_dealloc instead of their own field. Replace the field with a boolean to indicate whether the tp_dealloc has the safety properties of a simple_destructor. Assign simple_destructor to more builtin types.\r\n\r\nDepends on gcfinalizers2 PR.","created_at":"2015-07-02T18:47:25Z","updated_at":"2015-07-13T18:37:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6bc7ba18991b1e5952c8c17e7760abe1f62f30ff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dropbox/pyston/pulls/666/commits","review_comments_url":"https://api.github.com/repos/dropbox/pyston/pulls/666/comments","review_comment_url":"https://api.github.com/repos/dropbox/pyston/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dropbox/pyston/issues/666/comments","statuses_url":"https://api.github.com/repos/dropbox/pyston/statuses/252f8d6f6734aaf51b5684ce27899fa4023c4050","head":{"label":"rudi-c:gcfinalizers3","ref":"gcfinalizers3","sha":"252f8d6f6734aaf51b5684ce27899fa4023c4050","user":{"login":"rudi-c","id":2747897,"avatar_url":"https://avatars.githubusercontent.com/u/2747897?v=3","gravatar_id":"","url":"https://api.github.com/users/rudi-c","html_url":"https://github.com/rudi-c","followers_url":"https://api.github.com/users/rudi-c/followers","following_url":"https://api.github.com/users/rudi-c/following{/other_user}","gists_url":"https://api.github.com/users/rudi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/rudi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudi-c/subscriptions","organizations_url":"https://api.github.com/users/rudi-c/orgs","repos_url":"https://api.github.com/users/rudi-c/repos","events_url":"https://api.github.com/users/rudi-c/events{/privacy}","received_events_url":"https://api.github.com/users/rudi-c/received_events","type":"User","site_admin":false},"repo":{"id":35190032,"name":"pyston","full_name":"rudi-c/pyston","owner":{"login":"rudi-c","id":2747897,"avatar_url":"https://avatars.githubusercontent.com/u/2747897?v=3","gravatar_id":"","url":"https://api.github.com/users/rudi-c","html_url":"https://github.com/rudi-c","followers_url":"https://api.github.com/users/rudi-c/followers","following_url":"https://api.github.com/users/rudi-c/following{/other_user}","gists_url":"https://api.github.com/users/rudi-c/gists{/gist_id}","starred_url":"https://api.github.com/users/rudi-c/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudi-c/subscriptions","organizations_url":"https://api.github.com/users/rudi-c/orgs","repos_url":"https://api.github.com/users/rudi-c/repos","events_url":"https://api.github.com/users/rudi-c/events{/privacy}","received_events_url":"https://api.github.com/users/rudi-c/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rudi-c/pyston","description":"An open-source Python implementation using JIT techniques. ","fork":true,"url":"https://api.github.com/repos/rudi-c/pyston","forks_url":"https://api.github.com/repos/rudi-c/pyston/forks","keys_url":"https://api.github.com/repos/rudi-c/pyston/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rudi-c/pyston/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rudi-c/pyston/teams","hooks_url":"https://api.github.com/repos/rudi-c/pyston/hooks","issue_events_url":"https://api.github.com/repos/rudi-c/pyston/issues/events{/number}","events_url":"https://api.github.com/repos/rudi-c/pyston/events","assignees_url":"https://api.github.com/repos/rudi-c/pyston/assignees{/user}","branches_url":"https://api.github.com/repos/rudi-c/pyston/branches{/branch}","tags_url":"https://api.github.com/repos/rudi-c/pyston/tags","blobs_url":"https://api.github.com/repos/rudi-c/pyston/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rudi-c/pyston/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rudi-c/pyston/git/refs{/sha}","trees_url":"https://api.github.com/repos/rudi-c/pyston/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rudi-c/pyston/statuses/{sha}","languages_url":"https://api.github.com/repos/rudi-c/pyston/languages","stargazers_url":"https://api.github.com/repos/rudi-c/pyston/stargazers","contributors_url":"https://api.github.com/repos/rudi-c/pyston/contributors","subscribers_url":"https://api.github.com/repos/rudi-c/pyston/subscribers","subscription_url":"https://api.github.com/repos/rudi-c/pyston/subscription","commits_url":"https://api.github.com/repos/rudi-c/pyston/commits{/sha}","git_commits_url":"https://api.github.com/repos/rudi-c/pyston/git/commits{/sha}","comments_url":"https://api.github.com/repos/rudi-c/pyston/comments{/number}","issue_comment_url":"https://api.github.com/repos/rudi-c/pyston/issues/comments{/number}","contents_url":"https://api.github.com/repos/rudi-c/pyston/contents/{+path}","compare_url":"https://api.github.com/repos/rudi-c/pyston/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rudi-c/pyston/merges","archive_url":"https://api.github.com/repos/rudi-c/pyston/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rudi-c/pyston/downloads","issues_url":"https://api.github.com/repos/rudi-c/pyston/issues{/number}","pulls_url":"https://api.github.com/repos/rudi-c/pyston/pulls{/number}","milestones_url":"https://api.github.com/repos/rudi-c/pyston/milestones{/number}","notifications_url":"https://api.github.com/repos/rudi-c/pyston/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rudi-c/pyston/labels{/name}","releases_url":"https://api.github.com/repos/rudi-c/pyston/releases{/id}","created_at":"2015-05-07T00:30:38Z","updated_at":"2015-05-07T00:30:47Z","pushed_at":"2015-07-13T18:14:41Z","git_url":"git://github.com/rudi-c/pyston.git","ssh_url":"git@github.com:rudi-c/pyston.git","clone_url":"https://github.com/rudi-c/pyston.git","svn_url":"https://github.com/rudi-c/pyston","homepage":"https://tech.dropbox.com/2014/04/introducing-pyston-an-upcoming-jit-based-python-implementation/","size":22507,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"dropbox:master","ref":"master","sha":"b9daab7ad19e1953e3e52fb2d0a3e70ee28e9746","user":{"login":"dropbox","id":559357,"avatar_url":"https://avatars.githubusercontent.com/u/559357?v=3","gravatar_id":"","url":"https://api.github.com/users/dropbox","html_url":"https://github.com/dropbox","followers_url":"https://api.github.com/users/dropbox/followers","following_url":"https://api.github.com/users/dropbox/following{/other_user}","gists_url":"https://api.github.com/users/dropbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dropbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropbox/subscriptions","organizations_url":"https://api.github.com/users/dropbox/orgs","repos_url":"https://api.github.com/users/dropbox/repos","events_url":"https://api.github.com/users/dropbox/events{/privacy}","received_events_url":"https://api.github.com/users/dropbox/received_events","type":"Organization","site_admin":false},"repo":{"id":18320947,"name":"pyston","full_name":"dropbox/pyston","owner":{"login":"dropbox","id":559357,"avatar_url":"https://avatars.githubusercontent.com/u/559357?v=3","gravatar_id":"","url":"https://api.github.com/users/dropbox","html_url":"https://github.com/dropbox","followers_url":"https://api.github.com/users/dropbox/followers","following_url":"https://api.github.com/users/dropbox/following{/other_user}","gists_url":"https://api.github.com/users/dropbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dropbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dropbox/subscriptions","organizations_url":"https://api.github.com/users/dropbox/orgs","repos_url":"https://api.github.com/users/dropbox/repos","events_url":"https://api.github.com/users/dropbox/events{/privacy}","received_events_url":"https://api.github.com/users/dropbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dropbox/pyston","description":"An open-source Python implementation using JIT techniques. ","fork":false,"url":"https://api.github.com/repos/dropbox/pyston","forks_url":"https://api.github.com/repos/dropbox/pyston/forks","keys_url":"https://api.github.com/repos/dropbox/pyston/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dropbox/pyston/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dropbox/pyston/teams","hooks_url":"https://api.github.com/repos/dropbox/pyston/hooks","issue_events_url":"https://api.github.com/repos/dropbox/pyston/issues/events{/number}","events_url":"https://api.github.com/repos/dropbox/pyston/events","assignees_url":"https://api.github.com/repos/dropbox/pyston/assignees{/user}","branches_url":"https://api.github.com/repos/dropbox/pyston/branches{/branch}","tags_url":"https://api.github.com/repos/dropbox/pyston/tags","blobs_url":"https://api.github.com/repos/dropbox/pyston/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dropbox/pyston/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dropbox/pyston/git/refs{/sha}","trees_url":"https://api.github.com/repos/dropbox/pyston/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dropbox/pyston/statuses/{sha}","languages_url":"https://api.github.com/repos/dropbox/pyston/languages","stargazers_url":"https://api.github.com/repos/dropbox/pyston/stargazers","contributors_url":"https://api.github.com/repos/dropbox/pyston/contributors","subscribers_url":"https://api.github.com/repos/dropbox/pyston/subscribers","subscription_url":"https://api.github.com/repos/dropbox/pyston/subscription","commits_url":"https://api.github.com/repos/dropbox/pyston/commits{/sha}","git_commits_url":"https://api.github.com/repos/dropbox/pyston/git/commits{/sha}","comments_url":"https://api.github.com/repos/dropbox/pyston/comments{/number}","issue_comment_url":"https://api.github.com/repos/dropbox/pyston/issues/comments{/number}","contents_url":"https://api.github.com/repos/dropbox/pyston/contents/{+path}","compare_url":"https://api.github.com/repos/dropbox/pyston/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dropbox/pyston/merges","archive_url":"https://api.github.com/repos/dropbox/pyston/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dropbox/pyston/downloads","issues_url":"https://api.github.com/repos/dropbox/pyston/issues{/number}","pulls_url":"https://api.github.com/repos/dropbox/pyston/pulls{/number}","milestones_url":"https://api.github.com/repos/dropbox/pyston/milestones{/number}","notifications_url":"https://api.github.com/repos/dropbox/pyston/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dropbox/pyston/labels{/name}","releases_url":"https://api.github.com/repos/dropbox/pyston/releases{/id}","created_at":"2014-04-01T07:17:20Z","updated_at":"2015-07-12T07:58:50Z","pushed_at":"2015-07-13T18:14:42Z","git_url":"git://github.com/dropbox/pyston.git","ssh_url":"git@github.com:dropbox/pyston.git","clone_url":"https://github.com/dropbox/pyston.git","svn_url":"https://github.com/dropbox/pyston","homepage":"https://tech.dropbox.com/2014/04/introducing-pyston-an-upcoming-jit-based-python-implementation/","size":31455,"stargazers_count":3023,"watchers_count":3023,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":214,"mirror_url":null,"open_issues_count":85,"forks":214,"open_issues":85,"watchers":3023,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/666"},"html":{"href":"https://github.com/dropbox/pyston/pull/666"},"issue":{"href":"https://api.github.com/repos/dropbox/pyston/issues/666"},"comments":{"href":"https://api.github.com/repos/dropbox/pyston/issues/666/comments"},"review_comments":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/666/comments"},"review_comment":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dropbox/pyston/pulls/666/commits"},"statuses":{"href":"https://api.github.com/repos/dropbox/pyston/statuses/252f8d6f6734aaf51b5684ce27899fa4023c4050"}}}}