Commit 7aa74c3d authored by olivf@chromium.org's avatar olivf@chromium.org

fix some names in compare nil ic

The compare nil ic introduces a mechanism called lightweight miss. The
idea is to insert a direct call to the miss handler instead of going
through the deopt routine. This can be use for uninitialized stubs, to
directly jump to the runtime.

This cl
1. Cleans up naming
2. localizes the lightweight miss functionality on the only user (compare nil ic)
3. fixes DoCodegen, to actually call the correct method (uninitialized vs initialized)

BUG=
R=verwaest@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14798 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7c2a1346
......@@ -127,8 +127,8 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(CompareNilIC_Miss);
descriptor->miss_handler_ =
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate);
descriptor->SetMissHandler(
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate));
}
......@@ -218,7 +218,7 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
for (int i = 0; i < param_count; ++i) {
__ push(descriptor->register_params_[i]);
}
ExternalReference miss = descriptor->miss_handler_;
ExternalReference miss = descriptor->miss_handler();
__ CallExternalReference(miss, descriptor->register_param_count_);
}
......
......@@ -204,10 +204,10 @@ class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
protected:
virtual HValue* BuildCodeStub() {
if (casted_stub()->IsMiss()) {
return BuildCodeInitializedStub();
} else {
if (casted_stub()->IsUninitialized()) {
return BuildCodeUninitializedStub();
} else {
return BuildCodeInitializedStub();
}
}
......@@ -276,16 +276,17 @@ static Handle<Code> DoGenerateCode(Stub* stub) {
if (descriptor->register_param_count_ < 0) {
stub->InitializeInterfaceDescriptor(isolate, descriptor);
}
// The miss case without stack parameters can use a light-weight stub to enter
// If we are uninitialized we can use a light-weight stub to enter
// the runtime that is significantly faster than using the standard
// stub-failure deopt mechanism.
if (stub->IsMiss() && descriptor->stack_parameter_count_ == NULL) {
if (stub->IsUninitialized() && descriptor->has_miss_handler()) {
ASSERT(descriptor->stack_parameter_count_ == NULL);
return stub->GenerateLightweightMissCode(isolate);
} else {
CodeStubGraphBuilder<Stub> builder(stub);
LChunk* chunk = OptimizeGraph(builder.CreateGraph());
return chunk->Codegen();
}
CodeStubGraphBuilder<Stub> builder(stub);
LChunk* chunk = OptimizeGraph(builder.CreateGraph());
return chunk->Codegen();
}
......@@ -658,7 +659,7 @@ Handle<Code> ArrayNArgumentsConstructorStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeUninitializedStub() {
HValue* CodeStubGraphBuilder<CompareNilICStub>::BuildCodeInitializedStub() {
CompareNilICStub* stub = casted_stub();
HIfContinuation continuation;
Handle<Map> sentinel_map(graph()->isolate()->heap()->meta_map());
......
......@@ -45,7 +45,8 @@ CodeStubInterfaceDescriptor::CodeStubInterfaceDescriptor()
function_mode_(NOT_JS_FUNCTION_STUB_MODE),
register_params_(NULL),
deoptimization_handler_(NULL),
miss_handler_(IC_Utility(IC::kUnreachable), Isolate::Current()) { }
miss_handler_(IC_Utility(IC::kUnreachable), Isolate::Current()),
has_miss_handler_(false) { }
bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) {
......
......@@ -277,7 +277,6 @@ struct CodeStubInterfaceDescriptor {
StubFunctionMode function_mode_;
Register* register_params_;
Address deoptimization_handler_;
ExternalReference miss_handler_;
int environment_length() const {
if (stack_parameter_count_ != NULL) {
......@@ -287,6 +286,24 @@ struct CodeStubInterfaceDescriptor {
}
bool initialized() const { return register_param_count_ >= 0; }
void SetMissHandler(ExternalReference handler) {
miss_handler_ = handler;
has_miss_handler_ = true;
}
ExternalReference miss_handler() {
ASSERT(has_miss_handler_);
return miss_handler_;
}
bool has_miss_handler() {
return has_miss_handler_;
}
private:
ExternalReference miss_handler_;
bool has_miss_handler_;
};
// A helper to make up for the fact that type Register is not fully
......@@ -300,12 +317,12 @@ struct CodeStubInterfaceDescriptor {
class HydrogenCodeStub : public CodeStub {
public:
enum InitializationState {
CODE_STUB_IS_NOT_MISS,
CODE_STUB_IS_MISS
UNINITIALIZED,
INITIALIZED
};
explicit HydrogenCodeStub(InitializationState state) {
is_miss_ = (state == CODE_STUB_IS_MISS);
explicit HydrogenCodeStub(InitializationState state = INITIALIZED) {
is_uninitialized_ = (state == UNINITIALIZED);
}
virtual Code::Kind GetCodeKind() const { return Code::STUB; }
......@@ -314,7 +331,7 @@ class HydrogenCodeStub : public CodeStub {
return isolate->code_stub_interface_descriptor(MajorKey());
}
bool IsMiss() { return is_miss_; }
bool IsUninitialized() { return is_uninitialized_; }
template<class SubClass>
static Handle<Code> GetUninitialized(Isolate* isolate) {
......@@ -339,11 +356,11 @@ class HydrogenCodeStub : public CodeStub {
void GenerateLightweightMiss(MacroAssembler* masm);
virtual int MinorKey() {
return IsMissBits::encode(is_miss_) |
return IsMissBits::encode(is_uninitialized_) |
MinorKeyBits::encode(NotMissMinorKey());
}
bool is_miss_;
bool is_uninitialized_;
};
......@@ -516,8 +533,7 @@ class FastCloneShallowArrayStub : public HydrogenCodeStub {
FastCloneShallowArrayStub(Mode mode,
AllocationSiteMode allocation_site_mode,
int length)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS),
mode_(mode),
: mode_(mode),
allocation_site_mode_(allocation_site_mode),
length_((mode == COPY_ON_WRITE_ELEMENTS) ? 0 : length) {
ASSERT_GE(length_, 0);
......@@ -577,8 +593,7 @@ class FastCloneShallowObjectStub : public HydrogenCodeStub {
static const int kMaximumClonedProperties = 6;
explicit FastCloneShallowObjectStub(int length)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS),
length_(length) {
: length_(length) {
ASSERT_GE(length_, 0);
ASSERT_LE(length_, kMaximumClonedProperties);
}
......@@ -763,7 +778,7 @@ class HICStub: public HydrogenCodeStub {
virtual InlineCacheState GetICState() { return MONOMORPHIC; }
protected:
HICStub() : HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) { }
HICStub() { }
class KindBits: public BitField<Code::Kind, 0, 4> {};
virtual Code::Kind kind() const = 0;
};
......@@ -1076,14 +1091,15 @@ class CompareNilICStub : public HydrogenCodeStub {
// boolean flags we need to store. :-P
STATIC_ASSERT(NUMBER_OF_TYPES <= 6);
CompareNilICStub(EqualityKind kind, NilValue nil, Types types)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS), types_(types) {
CompareNilICStub(EqualityKind kind, NilValue nil, Types types = Types())
: types_(types) {
equality_kind_ = kind;
nil_value_ = nil;
}
explicit CompareNilICStub(Code::ExtraICState ic_state)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
CompareNilICStub(Code::ExtraICState ic_state,
InitializationState init_state = INITIALIZED)
: HydrogenCodeStub(init_state) {
equality_kind_ = EqualityKindField::decode(ic_state);
nil_value_ = NilValueField::decode(ic_state);
types_ = Types(ExtractTypesFromExtraICState(ic_state));
......@@ -1092,7 +1108,7 @@ class CompareNilICStub : public HydrogenCodeStub {
static Handle<Code> GetUninitialized(Isolate* isolate,
EqualityKind kind,
NilValue nil) {
return CompareNilICStub(kind, nil, CODE_STUB_IS_MISS).GetCode(isolate);
return CompareNilICStub(kind, nil, UNINITIALIZED).GetCode(isolate);
}
virtual void InitializeInterfaceDescriptor(
......@@ -1100,8 +1116,7 @@ class CompareNilICStub : public HydrogenCodeStub {
CodeStubInterfaceDescriptor* descriptor);
static void InitializeForIsolate(Isolate* isolate) {
CompareNilICStub compare_stub(kStrictEquality, kNullValue,
CODE_STUB_IS_MISS);
CompareNilICStub compare_stub(kStrictEquality, kNullValue, UNINITIALIZED);
compare_stub.InitializeInterfaceDescriptor(
isolate,
isolate->code_stub_interface_descriptor(CodeStub::CompareNilIC));
......@@ -1148,18 +1163,11 @@ class CompareNilICStub : public HydrogenCodeStub {
CompareNilICStub(EqualityKind kind, NilValue nil,
InitializationState init_state)
: HydrogenCodeStub(init_state), types_(0) {
: HydrogenCodeStub(init_state) {
equality_kind_ = kind;
nil_value_ = nil;
}
CompareNilICStub(Code::ExtraICState ic_state, InitializationState init_state)
: HydrogenCodeStub(init_state) {
equality_kind_ = EqualityKindField::decode(ic_state);
nil_value_ = NilValueField::decode(ic_state);
types_ = Types(ExtractTypesFromExtraICState(ic_state));
}
class EqualityKindField : public BitField<EqualityKind, NUMBER_OF_TYPES, 1> {
};
class NilValueField : public BitField<NilValue, NUMBER_OF_TYPES+1, 1> {};
......@@ -1567,8 +1575,7 @@ class KeyedLoadDictionaryElementStub : public PlatformCodeStub {
class KeyedLoadFastElementStub : public HydrogenCodeStub {
public:
KeyedLoadFastElementStub(bool is_js_array, ElementsKind elements_kind)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
KeyedLoadFastElementStub(bool is_js_array, ElementsKind elements_kind) {
bit_field_ = ElementsKindBits::encode(elements_kind) |
IsJSArrayBits::encode(is_js_array);
}
......@@ -1603,8 +1610,7 @@ class KeyedStoreFastElementStub : public HydrogenCodeStub {
public:
KeyedStoreFastElementStub(bool is_js_array,
ElementsKind elements_kind,
KeyedAccessStoreMode mode)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
KeyedAccessStoreMode mode) {
bit_field_ = ElementsKindBits::encode(elements_kind) |
IsJSArrayBits::encode(is_js_array) |
StoreModeBits::encode(mode);
......@@ -1644,8 +1650,7 @@ class KeyedStoreFastElementStub : public HydrogenCodeStub {
class TransitionElementsKindStub : public HydrogenCodeStub {
public:
TransitionElementsKindStub(ElementsKind from_kind,
ElementsKind to_kind)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
ElementsKind to_kind) {
bit_field_ = FromKindBits::encode(from_kind) |
ToKindBits::encode(to_kind);
}
......@@ -1678,8 +1683,7 @@ class TransitionElementsKindStub : public HydrogenCodeStub {
class ArrayConstructorStubBase : public HydrogenCodeStub {
public:
ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode)
: HydrogenCodeStub(CODE_STUB_IS_NOT_MISS) {
ArrayConstructorStubBase(ElementsKind kind, AllocationSiteMode mode) {
bit_field_ = ElementsKindBits::encode(kind) |
AllocationSiteModeBits::encode(mode == TRACK_ALLOCATION_SITE);
}
......
......@@ -176,8 +176,8 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(CompareNilIC_Miss);
descriptor->miss_handler_ =
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate);
descriptor->SetMissHandler(
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate));
}
......@@ -200,7 +200,7 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
for (int i = 0; i < param_count; ++i) {
__ push(descriptor->register_params_[i]);
}
ExternalReference miss = descriptor->miss_handler_;
ExternalReference miss = descriptor->miss_handler();
__ CallExternalReference(miss, descriptor->register_param_count_);
}
......
......@@ -2892,7 +2892,7 @@ void CompareNilIC::Clear(Address address, Code* target) {
if (target->ic_state() == UNINITIALIZED) return;
Code::ExtraICState state = target->extended_extra_ic_state();
CompareNilICStub stub(state, CompareNilICStub::CODE_STUB_IS_MISS);
CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED);
stub.ClearTypes();
Code* code = NULL;
......
......@@ -811,6 +811,7 @@ void PatchInlinedSmiCode(Address address, InlinedSmiCheck check);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_MissLight);
DECLARE_RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss);
......
......@@ -128,8 +128,8 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(CompareNilIC_Miss);
descriptor->miss_handler_ =
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate);
descriptor->SetMissHandler(
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate));
}
......@@ -218,7 +218,7 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
for (int i = 0; i < param_count; ++i) {
__ push(descriptor->register_params_[i]);
}
ExternalReference miss = descriptor->miss_handler_;
ExternalReference miss = descriptor->miss_handler();
__ CallExternalReference(miss, descriptor->register_param_count_);
}
......
......@@ -919,6 +919,7 @@ Handle<Code> StubCache::ComputeCompareNil(Handle<Map> receiver_map,
}
Handle<Code> ic = stub.GetCode(isolate_);
// For monomorphic maps, use the code as a template, copying and replacing
// the monomorphic map that checks the object's type.
ic = isolate_->factory()->CopyCode(ic);
......
......@@ -170,8 +170,8 @@ void CompareNilICStub::InitializeInterfaceDescriptor(
descriptor->register_params_ = registers;
descriptor->deoptimization_handler_ =
FUNCTION_ADDR(CompareNilIC_Miss);
descriptor->miss_handler_ =
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate);
descriptor->SetMissHandler(
ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate));
}
......@@ -194,7 +194,7 @@ void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) {
for (int i = 0; i < param_count; ++i) {
__ push(descriptor->register_params_[i]);
}
ExternalReference miss = descriptor->miss_handler_;
ExternalReference miss = descriptor->miss_handler();
__ CallExternalReference(miss, descriptor->register_param_count_);
}
......
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