Vector ICs: Allow for more IC kinds.

We have plans to create more ICs, and we are out of bits to represent the Kind
in the flags field of the code object. The InlineCacheState can lose a bit
because it no longer needs the DEFAULT state. That state existed as a way to
detect errors where code incorrectly looked at a vector IC stub's
InlineCacheState instead of correctly determining said state from a glance at
the vector. This really isn't a danger anymore.

So, with the horse trading, we could now represent up to 32 code kinds.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#31666}
This commit is contained in:
mvstanton 2015-10-29 13:32:38 -07:00 committed by Commit bot
parent 798ce4e463
commit 25d48ec37f
6 changed files with 15 additions and 41 deletions

View File

@ -975,7 +975,7 @@ class CallICStub: public PlatformCodeStub {
Code::Kind GetCodeKind() const override { return Code::CALL_IC; }
InlineCacheState GetICState() const override { return DEFAULT; }
InlineCacheState GetICState() const override { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
@ -2258,7 +2258,7 @@ class LoadICTrampolineStub : public PlatformCodeStub {
Code::Kind GetCodeKind() const override { return Code::LOAD_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
@ -2294,7 +2294,7 @@ class VectorStoreICTrampolineStub : public PlatformCodeStub {
Code::Kind GetCodeKind() const override { return Code::STORE_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
@ -2332,7 +2332,7 @@ class CallICTrampolineStub : public PlatformCodeStub {
Code::Kind GetCodeKind() const override { return Code::CALL_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
@ -2358,7 +2358,7 @@ class LoadICStub : public PlatformCodeStub {
void GenerateForTrampoline(MacroAssembler* masm);
Code::Kind GetCodeKind() const override { return Code::LOAD_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
}
@ -2381,7 +2381,7 @@ class KeyedLoadICStub : public PlatformCodeStub {
void GenerateForTrampoline(MacroAssembler* masm);
Code::Kind GetCodeKind() const override { return Code::KEYED_LOAD_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
}
@ -2404,7 +2404,7 @@ class VectorStoreICStub : public PlatformCodeStub {
void GenerateForTrampoline(MacroAssembler* masm);
Code::Kind GetCodeKind() const final { return Code::STORE_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
}
@ -2427,7 +2427,7 @@ class VectorKeyedStoreICStub : public PlatformCodeStub {
void GenerateForTrampoline(MacroAssembler* masm);
Code::Kind GetCodeKind() const final { return Code::KEYED_STORE_IC; }
InlineCacheState GetICState() const final { return DEFAULT; }
InlineCacheState GetICState() const final { return GENERIC; }
virtual ExtraICState GetExtraICState() const final {
return static_cast<ExtraICState>(minor_key_);
}

View File

@ -595,11 +595,7 @@ enum InlineCacheState {
// A generic handler is installed and no extra typefeedback is recorded.
GENERIC,
// Special state for debug break or step in prepare stubs.
DEBUG_STUB,
// Type-vector-based ICs have a default state, with the full calculation
// of IC state only determined by a look at the IC and the typevector
// together.
DEFAULT
DEBUG_STUB
};

View File

@ -47,9 +47,6 @@ char IC::TransitionMarkFromState(IC::State state) {
// these cases fall through to the unreachable code below.
case DEBUG_STUB:
break;
// Type-vector-based ICs resolve state to one of the above.
case DEFAULT:
break;
}
UNREACHABLE();
return 0;
@ -388,7 +385,6 @@ static void ComputeTypeInfoCountDelta(IC::State old_state, IC::State new_state,
break;
case PROTOTYPE_FAILURE:
case DEBUG_STUB:
case DEFAULT:
UNREACHABLE();
}
}
@ -918,7 +914,6 @@ void IC::PatchCache(Handle<Name> name, Handle<Code> code) {
break;
case DEBUG_STUB:
break;
case DEFAULT:
case GENERIC:
UNREACHABLE();
break;

View File

@ -13359,8 +13359,6 @@ const char* Code::ICState2String(InlineCacheState state) {
case MEGAMORPHIC: return "MEGAMORPHIC";
case GENERIC: return "GENERIC";
case DEBUG_STUB: return "DEBUG_STUB";
case DEFAULT:
return "DEFAULT";
}
UNREACHABLE();
return NULL;

View File

@ -4855,9 +4855,9 @@ class Code: public HeapObject {
NUMBER_OF_KINDS
};
// No more than 16 kinds. The value is currently encoded in four bits in
// No more than 32 kinds. The value is currently encoded in five bits in
// Flags.
STATIC_ASSERT(NUMBER_OF_KINDS <= 16);
STATIC_ASSERT(NUMBER_OF_KINDS <= 32);
static const char* Kind2String(Kind kind);
@ -5284,10 +5284,10 @@ class Code: public HeapObject {
class ProfilerTicksField : public BitField<int, 4, 28> {};
// Flags layout. BitField<type, shift, size>.
class ICStateField : public BitField<InlineCacheState, 0, 4> {};
class TypeField : public BitField<StubType, 4, 1> {};
class CacheHolderField : public BitField<CacheHolderFlag, 5, 2> {};
class KindField : public BitField<Kind, 7, 4> {};
class ICStateField : public BitField<InlineCacheState, 0, 3> {};
class TypeField : public BitField<StubType, 3, 1> {};
class CacheHolderField : public BitField<CacheHolderFlag, 4, 2> {};
class KindField : public BitField<Kind, 6, 5> {};
class ExtraICStateField: public BitField<ExtraICState, 11,
PlatformSmiTagging::kSmiValueSize - 11 + 1> {}; // NOLINT

View File

@ -3818,16 +3818,12 @@ TEST(IncrementalMarkingPreservesMonomorphicIC) {
Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, MONOMORPHIC);
CHECK(ic_before->ic_state() == DEFAULT);
SimulateIncrementalMarking(CcTest::heap());
CcTest::heap()->CollectAllGarbage();
Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, MONOMORPHIC);
CHECK(ic_after->ic_state() == DEFAULT);
}
@ -3850,18 +3846,14 @@ TEST(IncrementalMarkingClearsMonomorphicIC) {
Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, MONOMORPHIC);
CHECK(ic_before->ic_state() == DEFAULT);
// Fire context dispose notification.
CcTest::isolate()->ContextDisposedNotification();
SimulateIncrementalMarking(CcTest::heap());
CcTest::heap()->CollectAllGarbage();
Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorICCleared(f, 0);
CHECK(ic_after->ic_state() == DEFAULT);
}
@ -3891,17 +3883,13 @@ TEST(IncrementalMarkingPreservesPolymorphicIC) {
Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, POLYMORPHIC);
CHECK(ic_before->ic_state() == DEFAULT);
// Fire context dispose notification.
SimulateIncrementalMarking(CcTest::heap());
CcTest::heap()->CollectAllGarbage();
Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, POLYMORPHIC);
CHECK(ic_after->ic_state() == DEFAULT);
}
@ -3931,9 +3919,7 @@ TEST(IncrementalMarkingClearsPolymorphicIC) {
Handle<JSFunction> f = Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))));
Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
CheckVectorIC(f, 0, POLYMORPHIC);
CHECK(ic_before->ic_state() == DEFAULT);
// Fire context dispose notification.
CcTest::isolate()->ContextDisposedNotification();
@ -3941,7 +3927,6 @@ TEST(IncrementalMarkingClearsPolymorphicIC) {
CcTest::heap()->CollectAllGarbage();
CheckVectorICCleared(f, 0);
CHECK(ic_before->ic_state() == DEFAULT);
}