Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Unified Diff: runtime/vm/pages.cc

Issue 70183010: Fixes a couple problems with GC of unoptimized code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/pages.cc
===================================================================
--- runtime/vm/pages.cc (revision 30197)
+++ runtime/vm/pages.cc (working copy)
@@ -384,61 +384,21 @@
}
-class CodeDetacherVisitor : public ObjectVisitor {
- public:
- explicit CodeDetacherVisitor(Isolate* isolate) : ObjectVisitor(isolate) { }
-
- virtual void VisitObject(RawObject* obj);
-
- private:
- static bool MayDetachCode(const Function& fn);
- DISALLOW_COPY_AND_ASSIGN(CodeDetacherVisitor);
-};
-
-
-bool CodeDetacherVisitor::MayDetachCode(const Function& fn) {
- return fn.HasCode() && // Not already detached.
- !fn.HasOptimizedCode() &&
- !fn.HasBreakpoint() &&
- (fn.usage_counter() > 0);
-}
-
-
-void CodeDetacherVisitor::VisitObject(RawObject* raw_obj) {
- Isolate* isolate = Isolate::Current();
- HANDLESCOPE(isolate);
- const Object& obj = Object::Handle(raw_obj);
- if (obj.GetClassId() == kFunctionCid) {
- const Function& fn = Function::Cast(obj);
- if (CodeDetacherVisitor::MayDetachCode(fn)) {
- fn.set_usage_counter(fn.usage_counter() / 2);
- if (fn.usage_counter() == 0) {
- if (FLAG_log_code_drop) {
- const String& name = String::Handle(fn.name());
- OS::Print("Detaching code for function %s\n", name.ToCString());
- }
- fn.DetachCode();
- }
- }
- }
-}
-
-
-void PageSpace::TryDetachingCode() {
+bool PageSpace::ShouldTryCollectingCode() {
// Try to collect code if enough time has passed since the last attempt.
const int64_t start = OS::GetCurrentTimeMicros();
const int64_t last_code_collection_in_us =
page_space_controller_.last_code_collection_in_us();
+
if ((start - last_code_collection_in_us) >
- FLAG_code_collection_interval_in_us) {
+ FLAG_code_collection_interval_in_us) {
if (FLAG_log_code_drop) {
OS::Print("Trying to detach code.\n");
}
- Isolate* isolate = Isolate::Current();
- CodeDetacherVisitor code_detacher(isolate);
- heap_->IterateObjects(&code_detacher);
page_space_controller_.set_last_code_collection_in_us(start);
+ return true;
}
+ return false;
}
@@ -447,9 +407,6 @@
ASSERT(!sweeping_);
sweeping_ = true;
Isolate* isolate = Isolate::Current();
- if (FLAG_collect_code) {
- TryDetachingCode();
- }
NoHandleScope no_handles(isolate);
@@ -469,8 +426,9 @@
const int64_t start = OS::GetCurrentTimeMicros();
// Mark all reachable old-gen objects.
+ bool try_collecting_code = FLAG_collect_code && ShouldTryCollectingCode();
GCMarker marker(heap_);
- marker.MarkObjects(isolate, this, invoke_api_callbacks);
+ marker.MarkObjects(isolate, this, invoke_api_callbacks, try_collecting_code);
int64_t mid1 = OS::GetCurrentTimeMicros();
« runtime/vm/gc_marker.cc ('K') | « runtime/vm/pages.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698