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

[ic] Cleanup accessor handling, fix cached property on global, remove cache-on-prototype support

BUG=v8:5561

Change-Id: I425ad7e670b8e9c701ff284ab1be3638a975a6d3
Reviewed-on: https://chromium-review.googlesource.com/455832
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43836}
parent 69da6fcd
...@@ -671,13 +671,6 @@ enum InlineCacheState { ...@@ -671,13 +671,6 @@ enum InlineCacheState {
GENERIC, GENERIC,
}; };
enum CacheHolderFlag {
kCacheOnPrototype,
kCacheOnPrototypeReceiverIsDictionary,
kCacheOnPrototypeReceiverIsPrimitive,
kCacheOnReceiver
};
enum WhereToStart { kStartAtReceiver, kStartAtPrototype }; enum WhereToStart { kStartAtReceiver, kStartAtPrototype };
// The Store Buffer (GC). // The Store Buffer (GC).
......
...@@ -34,11 +34,9 @@ class PropertyAccessCompiler BASE_EMBEDDED { ...@@ -34,11 +34,9 @@ class PropertyAccessCompiler BASE_EMBEDDED {
static void TailCallBuiltin(MacroAssembler* masm, Builtins::Name name); static void TailCallBuiltin(MacroAssembler* masm, Builtins::Name name);
protected: protected:
PropertyAccessCompiler(Isolate* isolate, Code::Kind kind, PropertyAccessCompiler(Isolate* isolate, Code::Kind kind)
CacheHolderFlag cache_holder)
: registers_(GetCallingConvention(isolate, kind)), : registers_(GetCallingConvention(isolate, kind)),
kind_(kind), kind_(kind),
cache_holder_(cache_holder),
isolate_(isolate), isolate_(isolate),
masm_(isolate, NULL, 256, CodeObjectRequired::kYes) { masm_(isolate, NULL, 256, CodeObjectRequired::kYes) {
// TODO(yangguo): remove this once we can serialize IC stubs. // TODO(yangguo): remove this once we can serialize IC stubs.
...@@ -46,7 +44,6 @@ class PropertyAccessCompiler BASE_EMBEDDED { ...@@ -46,7 +44,6 @@ class PropertyAccessCompiler BASE_EMBEDDED {
} }
Code::Kind kind() const { return kind_; } Code::Kind kind() const { return kind_; }
CacheHolderFlag cache_holder() const { return cache_holder_; }
MacroAssembler* masm() { return &masm_; } MacroAssembler* masm() { return &masm_; }
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
Factory* factory() const { return isolate()->factory(); } Factory* factory() const { return isolate()->factory(); }
...@@ -67,8 +64,6 @@ class PropertyAccessCompiler BASE_EMBEDDED { ...@@ -67,8 +64,6 @@ class PropertyAccessCompiler BASE_EMBEDDED {
static void InitializePlatformSpecific(AccessCompilerData* data); static void InitializePlatformSpecific(AccessCompilerData* data);
Code::Kind kind_; Code::Kind kind_;
CacheHolderFlag cache_holder_;
Isolate* isolate_; Isolate* isolate_;
MacroAssembler masm_; MacroAssembler masm_;
// Ensure that MacroAssembler has a reasonable size. // Ensure that MacroAssembler has a reasonable size.
......
...@@ -17,9 +17,8 @@ namespace internal { ...@@ -17,9 +17,8 @@ namespace internal {
Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name, Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name,
Handle<Map> stub_holder, Handle<Map> stub_holder,
Code::Kind kind, Code::Kind kind) {
CacheHolderFlag cache_holder) { Code::Flags flags = Code::ComputeHandlerFlags(kind);
Code::Flags flags = Code::ComputeHandlerFlags(kind, cache_holder);
Code* code = stub_holder->LookupInCodeCache(*name, flags); Code* code = stub_holder->LookupInCodeCache(*name, flags);
if (code == nullptr) return Handle<Code>(); if (code == nullptr) return Handle<Code>();
return handle(code); return handle(code);
...@@ -27,7 +26,7 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name, ...@@ -27,7 +26,7 @@ Handle<Code> PropertyHandlerCompiler::Find(Handle<Name> name,
Handle<Code> PropertyHandlerCompiler::GetCode(Code::Kind kind, Handle<Code> PropertyHandlerCompiler::GetCode(Code::Kind kind,
Handle<Name> name) { Handle<Name> name) {
Code::Flags flags = Code::ComputeHandlerFlags(kind, cache_holder()); Code::Flags flags = Code::ComputeHandlerFlags(kind);
// Create code object in the heap. // Create code object in the heap.
CodeDesc desc; CodeDesc desc;
......
...@@ -15,15 +15,12 @@ class CallOptimization; ...@@ -15,15 +15,12 @@ class CallOptimization;
class PropertyHandlerCompiler : public PropertyAccessCompiler { class PropertyHandlerCompiler : public PropertyAccessCompiler {
public: public:
static Handle<Code> Find(Handle<Name> name, Handle<Map> map, Code::Kind kind, static Handle<Code> Find(Handle<Name> name, Handle<Map> map, Code::Kind kind);
CacheHolderFlag cache_holder);
protected: protected:
PropertyHandlerCompiler(Isolate* isolate, Code::Kind kind, Handle<Map> map, PropertyHandlerCompiler(Isolate* isolate, Code::Kind kind, Handle<Map> map,
Handle<JSObject> holder, CacheHolderFlag cache_holder) Handle<JSObject> holder)
: PropertyAccessCompiler(isolate, kind, cache_holder), : PropertyAccessCompiler(isolate, kind), map_(map), holder_(holder) {}
map_(map),
holder_(holder) {}
virtual ~PropertyHandlerCompiler() {} virtual ~PropertyHandlerCompiler() {}
...@@ -117,10 +114,8 @@ class PropertyHandlerCompiler : public PropertyAccessCompiler { ...@@ -117,10 +114,8 @@ class PropertyHandlerCompiler : public PropertyAccessCompiler {
class NamedLoadHandlerCompiler : public PropertyHandlerCompiler { class NamedLoadHandlerCompiler : public PropertyHandlerCompiler {
public: public:
NamedLoadHandlerCompiler(Isolate* isolate, Handle<Map> map, NamedLoadHandlerCompiler(Isolate* isolate, Handle<Map> map,
Handle<JSObject> holder, Handle<JSObject> holder)
CacheHolderFlag cache_holder) : PropertyHandlerCompiler(isolate, Code::LOAD_IC, map, holder) {}
: PropertyHandlerCompiler(isolate, Code::LOAD_IC, map, holder,
cache_holder) {}
virtual ~NamedLoadHandlerCompiler() {} virtual ~NamedLoadHandlerCompiler() {}
...@@ -159,8 +154,7 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { ...@@ -159,8 +154,7 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler {
explicit NamedStoreHandlerCompiler(Isolate* isolate, Handle<Map> map, explicit NamedStoreHandlerCompiler(Isolate* isolate, Handle<Map> map,
Handle<JSObject> holder) Handle<JSObject> holder)
: PropertyHandlerCompiler(isolate, Code::STORE_IC, map, holder, : PropertyHandlerCompiler(isolate, Code::STORE_IC, map, holder) {
kCacheOnReceiver) {
#ifdef DEBUG #ifdef DEBUG
if (Descriptor::kPassLastArgsOnStack) { if (Descriptor::kPassLastArgsOnStack) {
ZapStackArgumentsRegisterAliases(); ZapStackArgumentsRegisterAliases();
...@@ -208,8 +202,8 @@ class ElementHandlerCompiler : public PropertyHandlerCompiler { ...@@ -208,8 +202,8 @@ class ElementHandlerCompiler : public PropertyHandlerCompiler {
public: public:
explicit ElementHandlerCompiler(Isolate* isolate) explicit ElementHandlerCompiler(Isolate* isolate)
: PropertyHandlerCompiler(isolate, Code::KEYED_LOAD_IC, : PropertyHandlerCompiler(isolate, Code::KEYED_LOAD_IC,
Handle<Map>::null(), Handle<JSObject>::null(), Handle<Map>::null(), Handle<JSObject>::null()) {
kCacheOnReceiver) {} }
virtual ~ElementHandlerCompiler() {} virtual ~ElementHandlerCompiler() {}
......
...@@ -90,40 +90,6 @@ bool IC::IsHandler(Object* object) { ...@@ -90,40 +90,6 @@ bool IC::IsHandler(Object* object) {
(object->IsCode() && Code::cast(object)->is_handler()); (object->IsCode() && Code::cast(object)->is_handler());
} }
Handle<Map> IC::GetHandlerCacheHolder(Handle<Map> receiver_map,
bool receiver_is_holder, Isolate* isolate,
CacheHolderFlag* flag) {
if (receiver_is_holder) {
*flag = kCacheOnReceiver;
return receiver_map;
}
Handle<JSFunction> builtin_ctor;
if (Map::GetConstructorFunction(receiver_map, isolate->native_context())
.ToHandle(&builtin_ctor)) {
*flag = kCacheOnPrototypeReceiverIsPrimitive;
return handle(HeapObject::cast(builtin_ctor->instance_prototype())->map());
}
*flag = receiver_map->is_dictionary_map()
? kCacheOnPrototypeReceiverIsDictionary
: kCacheOnPrototype;
// Callers must ensure that the prototype is non-null.
return handle(JSObject::cast(receiver_map->prototype())->map());
}
Handle<Map> IC::GetICCacheHolder(Handle<Map> map, Isolate* isolate,
CacheHolderFlag* flag) {
Handle<JSFunction> builtin_ctor;
if (Map::GetConstructorFunction(map, isolate->native_context())
.ToHandle(&builtin_ctor)) {
*flag = kCacheOnPrototype;
return handle(builtin_ctor->initial_map());
}
*flag = kCacheOnReceiver;
return map;
}
bool IC::AddressIsDeoptimizedCode() const { bool IC::AddressIsDeoptimizedCode() const {
return AddressIsDeoptimizedCode(isolate(), address()); return AddressIsDeoptimizedCode(isolate(), address());
} }
......
This diff is collapsed.
...@@ -58,14 +58,6 @@ class IC { ...@@ -58,14 +58,6 @@ class IC {
return IsStoreIC() || IsStoreOwnIC() || IsKeyedStoreIC(); return IsStoreIC() || IsStoreOwnIC() || IsKeyedStoreIC();
} }
static inline Handle<Map> GetHandlerCacheHolder(Handle<Map> receiver_map,
bool receiver_is_holder,
Isolate* isolate,
CacheHolderFlag* flag);
static inline Handle<Map> GetICCacheHolder(Handle<Map> receiver_map,
Isolate* isolate,
CacheHolderFlag* flag);
// The ICs that don't pass slot and vector through the stack have to // The ICs that don't pass slot and vector through the stack have to
// save/restore them in the dispatcher. // save/restore them in the dispatcher.
static bool ShouldPushPopSlotAndVector(Code::Kind kind); static bool ShouldPushPopSlotAndVector(Code::Kind kind);
...@@ -137,8 +129,7 @@ class IC { ...@@ -137,8 +129,7 @@ class IC {
return Handle<Code>::null(); return Handle<Code>::null();
} }
virtual Handle<Object> CompileHandler(LookupIterator* lookup, virtual Handle<Object> CompileHandler(LookupIterator* lookup,
Handle<Object> value, Handle<Object> value) {
CacheHolderFlag cache_holder) {
UNREACHABLE(); UNREACHABLE();
return Handle<Object>::null(); return Handle<Object>::null();
} }
...@@ -287,8 +278,8 @@ class LoadIC : public IC { ...@@ -287,8 +278,8 @@ class LoadIC : public IC {
Handle<Object> GetMapIndependentHandler(LookupIterator* lookup) override; Handle<Object> GetMapIndependentHandler(LookupIterator* lookup) override;
Handle<Object> CompileHandler(LookupIterator* lookup, Handle<Object> unused, Handle<Object> CompileHandler(LookupIterator* lookup,
CacheHolderFlag cache_holder) override; Handle<Object> unused) override;
private: private:
// Creates a data handler that represents a load of a field by given index. // Creates a data handler that represents a load of a field by given index.
...@@ -374,8 +365,8 @@ class StoreIC : public IC { ...@@ -374,8 +365,8 @@ class StoreIC : public IC {
void UpdateCaches(LookupIterator* lookup, Handle<Object> value, void UpdateCaches(LookupIterator* lookup, Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode); JSReceiver::StoreFromKeyed store_mode);
Handle<Object> GetMapIndependentHandler(LookupIterator* lookup) override; Handle<Object> GetMapIndependentHandler(LookupIterator* lookup) override;
Handle<Object> CompileHandler(LookupIterator* lookup, Handle<Object> value, Handle<Object> CompileHandler(LookupIterator* lookup,
CacheHolderFlag cache_holder) override; Handle<Object> value) override;
private: private:
Handle<Object> StoreTransition(Handle<Map> receiver_map, Handle<Object> StoreTransition(Handle<Map> receiver_map,
......
...@@ -42,9 +42,9 @@ bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map, ...@@ -42,9 +42,9 @@ bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map,
DCHECK(IC::IsHandler(handler)); DCHECK(IC::IsHandler(handler));
if (handler->IsCode()) { if (handler->IsCode()) {
Code* code = Code::cast(handler); Code* code = Code::cast(handler);
Code::Flags expected_flags = Code::RemoveHolderFromFlags( Code::Flags expected_flags =
Code::ComputeHandlerFlags(stub_cache->ic_kind())); Code::ComputeHandlerFlags(stub_cache->ic_kind());
Code::Flags flags = Code::RemoveHolderFromFlags(code->flags()); Code::Flags flags = code->flags();
DCHECK_EQ(expected_flags, flags); DCHECK_EQ(expected_flags, flags);
DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(code->flags())); DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(code->flags()));
} }
......
...@@ -5182,18 +5182,15 @@ Address Code::constant_pool() { ...@@ -5182,18 +5182,15 @@ Address Code::constant_pool() {
return constant_pool; return constant_pool;
} }
Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state, Code::Flags Code::ComputeFlags(Kind kind, ExtraICState extra_ic_state) {
CacheHolderFlag holder) {
// Compute the bit mask. // Compute the bit mask.
unsigned int bits = KindField::encode(kind) | unsigned int bits =
ExtraICStateField::encode(extra_ic_state) | KindField::encode(kind) | ExtraICStateField::encode(extra_ic_state);
CacheHolderField::encode(holder);
return static_cast<Flags>(bits); return static_cast<Flags>(bits);
} }
Code::Flags Code::ComputeHandlerFlags(Kind handler_kind, Code::Flags Code::ComputeHandlerFlags(Kind handler_kind) {
CacheHolderFlag holder) { return ComputeFlags(Code::HANDLER, handler_kind);
return ComputeFlags(Code::HANDLER, handler_kind, holder);
} }
...@@ -5207,16 +5204,6 @@ ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) { ...@@ -5207,16 +5204,6 @@ ExtraICState Code::ExtractExtraICStateFromFlags(Flags flags) {
} }
CacheHolderFlag Code::ExtractCacheHolderFromFlags(Flags flags) {
return CacheHolderField::decode(flags);
}
Code::Flags Code::RemoveHolderFromFlags(Flags flags) {
int bits = flags & ~CacheHolderField::kMask;
return static_cast<Flags>(bits);
}
Code* Code::GetCodeFromTargetAddress(Address address) { Code* Code::GetCodeFromTargetAddress(Address address) {
HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize); HeapObject* code = HeapObject::FromAddress(address - Code::kHeaderSize);
// GetCodeFromTargetAddress might be called when marking objects during mark // GetCodeFromTargetAddress might be called when marking objects during mark
......
...@@ -5116,18 +5116,13 @@ class Code: public HeapObject { ...@@ -5116,18 +5116,13 @@ class Code: public HeapObject {
// Flags operations. // Flags operations.
static inline Flags ComputeFlags( static inline Flags ComputeFlags(
Kind kind, ExtraICState extra_ic_state = kNoExtraICState, Kind kind, ExtraICState extra_ic_state = kNoExtraICState);
CacheHolderFlag holder = kCacheOnReceiver);
static inline Flags ComputeHandlerFlags( static inline Flags ComputeHandlerFlags(Kind handler_kind);
Kind handler_kind, CacheHolderFlag holder = kCacheOnReceiver);
static inline CacheHolderFlag ExtractCacheHolderFromFlags(Flags flags);
static inline Kind ExtractKindFromFlags(Flags flags); static inline Kind ExtractKindFromFlags(Flags flags);
static inline ExtraICState ExtractExtraICStateFromFlags(Flags flags); static inline ExtraICState ExtractExtraICStateFromFlags(Flags flags);
static inline Flags RemoveHolderFromFlags(Flags flags);
// Convert a target address into a code object. // Convert a target address into a code object.
static inline Code* GetCodeFromTargetAddress(Address address); static inline Code* GetCodeFromTargetAddress(Address address);
...@@ -5338,9 +5333,7 @@ class Code: public HeapObject { ...@@ -5338,9 +5333,7 @@ class Code: public HeapObject {
// Flags layout. BitField<type, shift, size>. // Flags layout. BitField<type, shift, size>.
class HasUnwindingInfoField : public BitField<bool, 0, 1> {}; class HasUnwindingInfoField : public BitField<bool, 0, 1> {};
class CacheHolderField class KindField : public BitField<Kind, HasUnwindingInfoField::kNext, 5> {};
: public BitField<CacheHolderFlag, HasUnwindingInfoField::kNext, 2> {};
class KindField : public BitField<Kind, CacheHolderField::kNext, 5> {};
STATIC_ASSERT(NUMBER_OF_KINDS <= KindField::kMax); STATIC_ASSERT(NUMBER_OF_KINDS <= KindField::kMax);
class ExtraICStateField class ExtraICStateField
: public BitField<ExtraICState, KindField::kNext, : public BitField<ExtraICState, KindField::kNext,
...@@ -5403,9 +5396,6 @@ class Code: public HeapObject { ...@@ -5403,9 +5396,6 @@ class Code: public HeapObject {
static const int kArgumentsBits = 16; static const int kArgumentsBits = 16;
static const int kMaxArguments = (1 << kArgumentsBits) - 1; static const int kMaxArguments = (1 << kArgumentsBits) - 1;
// This constant should be encodable in an ARM instruction.
static const int kFlagsNotUsedInLookup = CacheHolderField::kMask;
private: private:
friend class RelocIterator; friend class RelocIterator;
friend class Deoptimizer; // For FindCodeAgeSequence. friend class Deoptimizer; // For FindCodeAgeSequence.
......
...@@ -204,8 +204,7 @@ TEST(TryProbeStubCache) { ...@@ -204,8 +204,7 @@ TEST(TryProbeStubCache) {
// Generate some number of handlers. // Generate some number of handlers.
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
Code::Flags flags = Code::Flags flags = Code::ComputeHandlerFlags(ic_kind);
Code::RemoveHolderFromFlags(Code::ComputeHandlerFlags(ic_kind));
handlers.push_back(CreateCodeWithFlags(flags)); handlers.push_back(CreateCodeWithFlags(flags));
} }
......
...@@ -31,8 +31,7 @@ static Handle<Code> GetDummyCode(Isolate* isolate) { ...@@ -31,8 +31,7 @@ static Handle<Code> GetDummyCode(Isolate* isolate) {
nullptr, // unwinding_info nullptr, // unwinding_info
0, // unwinding_info_size 0, // unwinding_info_size
nullptr}; // origin nullptr}; // origin
Code::Flags flags = Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState);
Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState, kCacheOnReceiver);
Handle<Code> self_ref; Handle<Code> self_ref;
return isolate->factory()->NewCode(desc, flags, self_ref); return isolate->factory()->NewCode(desc, flags, self_ref);
} }
...@@ -60,9 +59,7 @@ TEST(CodeCache) { ...@@ -60,9 +59,7 @@ TEST(CodeCache) {
codes.Add(GetDummyCode(isolate)); codes.Add(GetDummyCode(isolate));
} }
Handle<Name> bad_name = isolate->factory()->NewSymbol(); Handle<Name> bad_name = isolate->factory()->NewSymbol();
Code::Flags bad_flags = Code::Flags flags = Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState);
Code::ComputeFlags(Code::LOAD_IC, kNoExtraICState, kCacheOnPrototype);
DCHECK(bad_flags != codes[0]->flags());
// Cache name/code pairs. // Cache name/code pairs.
for (int i = 0; i < kEntries; i++) { for (int i = 0; i < kEntries; i++) {
...@@ -70,9 +67,8 @@ TEST(CodeCache) { ...@@ -70,9 +67,8 @@ TEST(CodeCache) {
Handle<Code> code = codes.at(i); Handle<Code> code = codes.at(i);
Map::UpdateCodeCache(map, name, code); Map::UpdateCodeCache(map, name, code);
CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags())); CHECK_EQ(*code, map->LookupInCodeCache(*name, code->flags()));
CHECK_NULL(map->LookupInCodeCache(*name, bad_flags));
} }
CHECK_NULL(map->LookupInCodeCache(*bad_name, bad_flags)); CHECK_NULL(map->LookupInCodeCache(*bad_name, flags));
// Check that lookup works not only right after storing. // Check that lookup works not only right after storing.
for (int i = 0; i < kEntries; i++) { for (int i = 0; i < kEntries; i++) {
......
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