| Index: runtime/vm/pages.cc
|
| ===================================================================
|
| --- runtime/vm/pages.cc (revision 29395)
|
| +++ runtime/vm/pages.cc (working copy)
|
| @@ -384,7 +384,6 @@
|
| }
|
|
|
|
|
| -
|
| class CodeDetacherVisitor : public ObjectVisitor {
|
| public:
|
| explicit CodeDetacherVisitor(Isolate* isolate) : ObjectVisitor(isolate) { }
|
| @@ -392,20 +391,26 @@
|
| 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 (!fn.HasOptimizedCode() &&
|
| - !fn.HasBreakpoint() &&
|
| - fn.HasCode() && // Not already detached.
|
| - (fn.usage_counter() > 0)) {
|
| + if (CodeDetacherVisitor::MayDetachCode(fn)) {
|
| fn.set_usage_counter(fn.usage_counter() / 2);
|
| if (fn.usage_counter() == 0) {
|
| if (FLAG_log_code_drop) {
|
|
|