Commit f063a6ab authored by bmeurer's avatar bmeurer Committed by Commit bot

[osr] Increase Code::profiler_ticks to 28 bits.

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}
parent bb964f63
......@@ -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);
}
}
......
......@@ -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> {};
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment