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}
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);
}
}
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> {};
// 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);
}