[osr] Increase Code::profiler_ticks to 28 bits.
authorbmeurer <bmeurer@chromium.org>
Mon, 13 Jul 2015 10:57:40 +0000 (03:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 13 Jul 2015 10:57:55 +0000 (10:57 +0000)
Up until now we were unable to have profiler ticks beyong 255, which
basically disabled OSR for moderately large functions.

BUG=chromium:508741
LOG=n
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1224173003

Cr-Commit-Position: refs/heads/master@{#29597}

src/objects-inl.h
src/objects.h
src/runtime-profiler.cc

index 6b1cfb3..95c64fc 100644 (file)
@@ -4602,14 +4602,16 @@ void Code::set_allow_osr_at_loop_nesting_level(int level) {
 
 int Code::profiler_ticks() {
   DCHECK_EQ(FUNCTION, kind());
-  return READ_BYTE_FIELD(this, kProfilerTicksOffset);
+  return ProfilerTicksField::decode(
+      READ_UINT32_FIELD(this, kKindSpecificFlags1Offset));
 }
 
 
 void Code::set_profiler_ticks(int ticks) {
-  DCHECK(ticks < 256);
   if (kind() == FUNCTION) {
-    WRITE_BYTE_FIELD(this, kProfilerTicksOffset, ticks);
+    unsigned previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset);
+    unsigned updated = ProfilerTicksField::update(previous, ticks);
+    WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated);
   }
 }
 
index 1693897..fc25ba2 100644 (file)
@@ -5333,8 +5333,7 @@ class Code: public HeapObject {
   class FullCodeFlagsIsCompiledOptimizable: public BitField<bool, 2, 1> {};
   class FullCodeFlagsHasRelocInfoForSerialization
       : public BitField<bool, 3, 1> {};
-
-  static const int kProfilerTicksOffset = kFullCodeFlags + 1;
+  class ProfilerTicksField : public BitField<int, 4, 28> {};
 
   // Flags layout.  BitField<type, shift, size>.
   class ICStateField : public BitField<InlineCacheState, 0, 4> {};
index 351bca7..1840078 100644 (file)
@@ -181,10 +181,12 @@ void RuntimeProfiler::OptimizeNow() {
       // Attempt OSR if we are still running unoptimized code even though the
       // the function has long been marked or even already been optimized.
       int ticks = shared_code->profiler_ticks();
-      int allowance = kOSRCodeSizeAllowanceBase +
-                      ticks * kOSRCodeSizeAllowancePerTick;
-      if (shared_code->CodeSize() > allowance) {
-        if (ticks < 255) shared_code->set_profiler_ticks(ticks + 1);
+      int64_t allowance =
+          kOSRCodeSizeAllowanceBase +
+          static_cast<int64_t>(ticks) * kOSRCodeSizeAllowancePerTick;
+      if (shared_code->CodeSize() > allowance &&
+          ticks < Code::ProfilerTicksField::kMax) {
+        shared_code->set_profiler_ticks(ticks + 1);
       } else {
         AttemptOnStackReplacement(function);
       }