Commit afeb560c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[ic] Remove ICUseVector and some access compiler cleanup

BUG=

Change-Id: I1fd0ae3dcb0e644e9f2a56c242720b4def4bb579
Reviewed-on: https://chromium-review.googlesource.com/454836
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43818}
parent 046ae926
......@@ -204,7 +204,8 @@ static int DecodeIt(Isolate* isolate, std::ostream* os,
Code::Kind kind = code->kind();
if (code->is_inline_cache_stub()) {
out.AddFormatted(" %s", Code::Kind2String(kind));
if (!IC::ICUseVector(kind)) {
if (kind == Code::BINARY_OP_IC || kind == Code::TO_BOOLEAN_IC ||
kind == Code::COMPARE_IC) {
InlineCacheState ic_state = IC::StateFromCode(code);
out.AddFormatted(" %s", Code::ICState2String(ic_state));
}
......
......@@ -8,34 +8,6 @@
namespace v8 {
namespace internal {
Handle<Code> PropertyAccessCompiler::GetCodeWithFlags(Code::Flags flags,
const char* name) {
// Create code object in the heap.
CodeDesc desc;
masm()->GetCode(&desc);
Handle<Code> code = factory()->NewCode(desc, flags, masm()->CodeObject());
if (code->IsCodeStubOrIC()) code->set_stub_key(CodeStub::NoCacheKey());
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs) {
CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
OFStream os(trace_scope.file());
code->Disassemble(name, os);
}
#endif
return code;
}
Handle<Code> PropertyAccessCompiler::GetCodeWithFlags(Code::Flags flags,
Handle<Name> name) {
return (FLAG_print_code_stubs && !name.is_null() && name->IsString())
? GetCodeWithFlags(flags,
Handle<String>::cast(name)->ToCString().get())
: GetCodeWithFlags(flags, NULL);
}
void PropertyAccessCompiler::TailCallBuiltin(MacroAssembler* masm,
Builtins::Name name) {
Handle<Code> code(masm->isolate()->builtins()->builtin(name));
......
......@@ -49,7 +49,6 @@ class PropertyAccessCompiler BASE_EMBEDDED {
CacheHolderFlag cache_holder() const { return cache_holder_; }
MacroAssembler* masm() { return &masm_; }
Isolate* isolate() const { return isolate_; }
Heap* heap() const { return isolate()->heap(); }
Factory* factory() const { return isolate()->factory(); }
Register receiver() const { return registers_[0]; }
......@@ -63,9 +62,6 @@ class PropertyAccessCompiler BASE_EMBEDDED {
static void GenerateTailCall(MacroAssembler* masm, Handle<Code> code);
Handle<Code> GetCodeWithFlags(Code::Flags flags, const char* name);
Handle<Code> GetCodeWithFlags(Code::Flags flags, Handle<Name> name);
private:
static Register* GetCallingConvention(Isolate* isolate, Code::Kind kind);
static void InitializePlatformSpecific(AccessCompilerData* data);
......
......@@ -404,10 +404,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -419,7 +417,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -399,10 +399,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
__ B(&success);
__ Bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ Bind(&success);
......@@ -416,7 +414,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
__ B(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ Bind(&success);
......
......@@ -27,9 +27,26 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name,
Handle<Code> PropertyHandlerCompiler::GetCode(Code::Kind kind,
Handle<Name> name) {
Code::Flags flags = Code::ComputeHandlerFlags(kind, cache_holder());
Handle<Code> code = GetCodeWithFlags(flags, name);
// Create code object in the heap.
CodeDesc desc;
masm()->GetCode(&desc);
Handle<Code> code = factory()->NewCode(desc, flags, masm()->CodeObject());
if (code->IsCodeStubOrIC()) code->set_stub_key(CodeStub::NoCacheKey());
#ifdef ENABLE_DISASSEMBLER
if (FLAG_print_code_stubs) {
char* raw_name = !name.is_null() && name->IsString()
? String::cast(*name)->ToCString().get()
: nullptr;
CodeTracer::Scope trace_scope(isolate()->GetCodeTracer());
OFStream os(trace_scope.file());
code->Disassemble(raw_name, os);
}
#endif
PROFILE(isolate(), CodeCreateEvent(CodeEventListener::HANDLER_TAG,
AbstractCode::cast(*code), *name));
#ifdef DEBUG
code->VerifyEmbeddedObjects();
#endif
......
......@@ -70,7 +70,6 @@ const char* GetTransitionMarkModifier(KeyedAccessStoreMode mode) {
void IC::TraceIC(const char* type, Handle<Object> name) {
if (FLAG_ic_stats) {
if (AddressIsDeoptimizedCode()) return;
DCHECK(UseVector());
State new_state = nexus()->StateFromFeedback();
TraceIC(type, name, state(), new_state);
}
......@@ -228,7 +227,6 @@ IC::IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus)
pc_address_ = StackFrame::ResolveReturnAddressLocation(pc_address);
if (nexus) {
kind_ = nexus->kind();
DCHECK(UseVector());
state_ = nexus->StateFromFeedback();
extra_ic_state_ = kNoExtraICState;
} else {
......@@ -244,7 +242,6 @@ IC::IC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus)
UNREACHABLE();
kind_ = FeedbackSlotKind::kInvalid;
}
DCHECK(!UseVector());
state_ = StateFromCode(target);
extra_ic_state_ = target->extra_ic_state();
}
......@@ -332,7 +329,6 @@ static void LookupForRead(LookupIterator* it) {
bool IC::ShouldRecomputeHandler(Handle<String> name) {
if (!RecomputeHandlerForName(name)) return false;
DCHECK(UseVector());
maybe_handler_ = nexus()->FindHandlerForMap(receiver_map());
// This is a contextual access, always just update the handler and stay
......@@ -361,7 +357,6 @@ bool IC::RecomputeHandlerForName(Handle<Object> name) {
if (is_keyed()) {
// Determine whether the failure is due to a name failure.
if (!name->IsName()) return false;
DCHECK(UseVector());
Name* stub_name = nexus()->FindFirstName();
if (*name != stub_name) return false;
}
......@@ -451,8 +446,9 @@ void IC::OnFeedbackChanged(Isolate* isolate, JSFunction* host_function) {
void IC::PostPatching(Address address, Code* target, Code* old_target) {
// Type vector based ICs update these statistics at a different time because
// they don't always patch on state change.
// TODO(ishell): DCHECK
if (ICUseVector(target->kind())) return;
DCHECK(target->kind() == Code::BINARY_OP_IC ||
target->kind() == Code::COMPARE_IC ||
target->kind() == Code::TO_BOOLEAN_IC);
DCHECK(old_target->is_inline_cache_stub());
DCHECK(target->is_inline_cache_stub());
......@@ -517,7 +513,6 @@ static bool MigrateDeprecated(Handle<Object> object) {
}
void IC::ConfigureVectorState(IC::State new_state, Handle<Object> key) {
DCHECK(UseVector());
if (new_state == PREMONOMORPHIC) {
nexus()->ConfigurePremonomorphic();
} else if (new_state == MEGAMORPHIC) {
......@@ -541,7 +536,6 @@ void IC::ConfigureVectorState(IC::State new_state, Handle<Object> key) {
void IC::ConfigureVectorState(Handle<Name> name, Handle<Map> map,
Handle<Object> handler) {
DCHECK(UseVector());
switch (kind_) {
case FeedbackSlotKind::kLoadProperty: {
LoadICNexus* nexus = casted_nexus<LoadICNexus>();
......@@ -592,7 +586,6 @@ void IC::ConfigureVectorState(Handle<Name> name, Handle<Map> map,
void IC::ConfigureVectorState(Handle<Name> name, MapHandleList* maps,
List<Handle<Object>>* handlers) {
DCHECK(UseVector());
switch (kind_) {
case FeedbackSlotKind::kLoadProperty: {
LoadICNexus* nexus = casted_nexus<LoadICNexus>();
......@@ -640,7 +633,6 @@ void IC::ConfigureVectorState(Handle<Name> name, MapHandleList* maps,
void IC::ConfigureVectorState(MapHandleList* maps,
MapHandleList* transitioned_maps,
List<Handle<Object>>* handlers) {
DCHECK(UseVector());
DCHECK(IsKeyedStoreIC());
KeyedStoreICNexus* nexus = casted_nexus<KeyedStoreICNexus>();
nexus->ConfigurePolymorphic(maps, transitioned_maps, handlers);
......@@ -774,7 +766,6 @@ bool IC::UpdatePolymorphicIC(Handle<Name> name, Handle<Object> handler) {
if (number_of_maps == 0 && state() != MONOMORPHIC && state() != POLYMORPHIC) {
return false;
}
DCHECK(UseVector());
if (!nexus()->FindHandlers(&handlers, maps.length())) return false;
number_of_valid_maps++;
......@@ -853,13 +844,11 @@ void IC::PatchCache(Handle<Name> name, Handle<Object> handler) {
// same key.
CopyICToMegamorphicCache(name);
}
DCHECK(UseVector());
ConfigureVectorState(MEGAMORPHIC, name);
// Fall through.
case MEGAMORPHIC:
UpdateMegamorphicCache(*receiver_map(), *name, *handler);
// Indicate that we've handled this case.
DCHECK(UseVector());
vector_set_ = true;
break;
case GENERIC:
......
......@@ -66,17 +66,6 @@ class IC {
Isolate* isolate,
CacheHolderFlag* flag);
static bool ICUseVector(Code::Kind kind) {
return kind == Code::LOAD_IC || kind == Code::LOAD_GLOBAL_IC ||
kind == Code::KEYED_LOAD_IC || kind == Code::STORE_IC ||
kind == Code::KEYED_STORE_IC;
}
static bool ICUseVector(FeedbackSlotKind kind) {
return IsLoadICKind(kind) || IsLoadGlobalICKind(kind) ||
IsKeyedLoadICKind(kind) || IsStoreICKind(kind) ||
IsStoreOwnICKind(kind) || IsKeyedStoreICKind(kind);
}
// The ICs that don't pass slot and vector through the stack have to
// save/restore them in the dispatcher.
static bool ShouldPushPopSlotAndVector(Code::Kind kind);
......@@ -108,13 +97,6 @@ class IC {
inline void set_target(Code* code);
bool is_vector_set() { return vector_set_; }
bool UseVector() const {
bool use = ICUseVector(kind());
// If we are supposed to use the nexus, verify the nexus is non-null.
DCHECK(!use || nexus_ != nullptr);
return use;
}
// Configure for most states.
void ConfigureVectorState(IC::State new_state, Handle<Object> key);
// Configure the vector for MONOMORPHIC.
......@@ -229,7 +211,6 @@ class IC {
void FindTargetMaps() {
if (target_maps_set_) return;
target_maps_set_ = true;
DCHECK(UseVector());
nexus()->ExtractMaps(&target_maps_);
}
......
......@@ -389,10 +389,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ Branch(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -404,7 +402,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ Branch(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -389,10 +389,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ Branch(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -404,7 +402,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ Branch(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -404,10 +404,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -419,7 +417,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -388,10 +388,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -402,7 +400,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ b(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -396,10 +396,8 @@ void NamedLoadHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ jmp(&success);
__ bind(miss);
if (IC::ICUseVector(kind())) {
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
}
DCHECK(kind() == Code::LOAD_IC);
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......@@ -411,7 +409,7 @@ void NamedStoreHandlerCompiler::FrontendFooter(Handle<Name> name, Label* miss) {
Label success;
__ jmp(&success);
GenerateRestoreName(miss, name);
if (IC::ICUseVector(kind())) PopVectorAndSlot();
PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
__ bind(&success);
}
......
......@@ -14552,7 +14552,8 @@ void Code::Disassemble(const char* name, std::ostream& os) { // NOLINT
os << "major_key = " << (n == NULL ? "null" : n) << "\n";
}
if (is_inline_cache_stub()) {
if (!IC::ICUseVector(kind())) {
if (is_compare_ic_stub() || is_to_boolean_ic_stub() ||
is_binary_op_stub()) {
InlineCacheState ic_state = IC::StateFromCode(this);
os << "ic_state = " << ICState2String(ic_state) << "\n";
PrintExtraICState(os, kind(), extra_ic_state());
......
......@@ -4912,7 +4912,6 @@ void CheckIC(Handle<JSFunction> function, Code::Kind kind, int slot_index,
} else {
Code* ic = FindFirstIC(function->code(), kind);
CHECK(ic->is_inline_cache_stub());
CHECK(!IC::ICUseVector(kind));
CHECK_EQ(state, IC::StateFromCode(ic));
}
}
......
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