Commit e1b46f7a authored by mvstanton's avatar mvstanton Committed by Commit bot

Vector ICs: Adapting store ic classes for vectors.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30512}
parent 39085348
......@@ -49,5 +49,25 @@ Register* PropertyAccessCompiler::GetCallingConvention(Code::Kind kind) {
DCHECK(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC);
return store_calling_convention();
}
Register PropertyAccessCompiler::slot() const {
if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
return LoadDescriptor::SlotRegister();
}
DCHECK(FLAG_vector_stores &&
(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC));
return VectorStoreICDescriptor::SlotRegister();
}
Register PropertyAccessCompiler::vector() const {
if (kind() == Code::LOAD_IC || kind() == Code::KEYED_LOAD_IC) {
return LoadWithVectorDescriptor::VectorRegister();
}
DCHECK(FLAG_vector_stores &&
(kind() == Code::STORE_IC || kind() == Code::KEYED_STORE_IC));
return VectorStoreICDescriptor::VectorRegister();
}
} // namespace internal
} // namespace v8
......@@ -54,8 +54,8 @@ class PropertyAccessCompiler BASE_EMBEDDED {
Register receiver() const { return registers_[0]; }
Register name() const { return registers_[1]; }
Register slot() const { return LoadDescriptor::SlotRegister(); }
Register vector() const { return LoadWithVectorDescriptor::VectorRegister(); }
Register slot() const;
Register vector() const;
Register scratch1() const { return registers_[2]; }
Register scratch2() const { return registers_[3]; }
Register scratch3() const { return registers_[4]; }
......
......@@ -424,6 +424,8 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
Handle<Map> transition, Handle<Name> name) {
Label miss;
if (FLAG_vector_stores) PushVectorAndSlot();
// Check that we are allowed to write this.
bool is_nonexistent = holder()->map() == transition->GetBackPointer();
if (is_nonexistent) {
......@@ -454,16 +456,19 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
DCHECK(!transition->is_access_check_needed());
// Call to respective StoreTransitionStub.
Register transition_map_reg = StoreTransitionDescriptor::MapRegister();
bool push_map_on_stack = transition_map_reg.is(no_reg);
Register map_reg = push_map_on_stack ? scratch1() : transition_map_reg;
Register transition_map_reg = StoreTransitionHelper::MapRegister();
bool stack_args = StoreTransitionHelper::UsesStackArgs();
Register map_reg = stack_args ? scratch1() : transition_map_reg;
if (details.type() == DATA_CONSTANT) {
DCHECK(descriptors->GetValue(descriptor)->IsJSFunction());
GenerateRestoreMap(transition, map_reg, scratch2(), &miss);
GenerateConstantCheck(map_reg, descriptor, value(), scratch2(), &miss);
if (push_map_on_stack) {
if (stack_args) {
// Also pushes vector and slot.
GeneratePushMap(map_reg, scratch2());
} else if (FLAG_vector_stores) {
PopVectorAndSlot();
}
GenerateRestoreName(name);
StoreTransitionStub stub(isolate());
......@@ -480,8 +485,11 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
: StoreTransitionStub::StoreMapAndValue;
GenerateRestoreMap(transition, map_reg, scratch2(), &miss);
if (push_map_on_stack) {
if (stack_args) {
// Also pushes vector and slot.
GeneratePushMap(map_reg, scratch2());
} else if (FLAG_vector_stores) {
PopVectorAndSlot();
}
GenerateRestoreName(name);
StoreTransitionStub stub(isolate(),
......@@ -491,21 +499,37 @@ Handle<Code> NamedStoreHandlerCompiler::CompileStoreTransition(
}
GenerateRestoreName(&miss, name);
if (FLAG_vector_stores) PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
return GetCode(kind(), Code::FAST, name);
}
bool NamedStoreHandlerCompiler::RequiresFieldTypeChecks(
HeapType* field_type) const {
return !field_type->Classes().Done();
}
Handle<Code> NamedStoreHandlerCompiler::CompileStoreField(LookupIterator* it) {
Label miss;
DCHECK(it->representation().IsHeapObject());
GenerateFieldTypeChecks(*it->GetFieldType(), value(), &miss);
HeapType* field_type = *it->GetFieldType();
bool need_save_restore = false;
if (RequiresFieldTypeChecks(field_type)) {
need_save_restore = IC::ICUseVector(kind());
if (need_save_restore) PushVectorAndSlot();
GenerateFieldTypeChecks(field_type, value(), &miss);
if (need_save_restore) PopVectorAndSlot();
}
StoreFieldStub stub(isolate(), it->GetFieldIndex(), it->representation());
GenerateTailCall(masm(), stub.GetCode());
__ bind(&miss);
if (need_save_restore) PopVectorAndSlot();
TailCallBuiltin(masm(), MissBuiltin(kind()));
return GetCode(kind(), Code::FAST, it->name());
}
......
......@@ -262,6 +262,7 @@ class NamedStoreHandlerCompiler : public PropertyHandlerCompiler {
Register value_reg, Register scratch,
Label* miss_label);
bool RequiresFieldTypeChecks(HeapType* field_type) const;
void GenerateFieldTypeChecks(HeapType* field_type, Register value_reg,
Label* miss_label);
......
......@@ -119,6 +119,25 @@ Handle<Code> PropertyICCompiler::ComputeKeyedLoadMonomorphicHandler(
}
Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode) {
Isolate* isolate = receiver_map->GetIsolate();
ExtraICState extra_state =
KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
DCHECK(store_mode == STANDARD_STORE ||
store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
store_mode == STORE_NO_TRANSITION_HANDLE_COW);
PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
Handle<Code> code =
compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode);
return code;
}
Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic(
Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode) {
......@@ -220,31 +239,6 @@ Handle<Code> PropertyICCompiler::ComputeCompareNil(Handle<Map> receiver_map,
}
Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic(
MapHandleList* receiver_maps, LanguageMode language_mode) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT);
Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
Handle<PolymorphicCodeCache> cache =
isolate->factory()->polymorphic_code_cache();
Handle<Object> probe = cache->Lookup(receiver_maps, flags);
if (probe->IsCode()) return Handle<Code>::cast(probe);
CodeHandleList handlers(receiver_maps->length());
ElementHandlerCompiler compiler(isolate);
compiler.CompileElementHandlers(receiver_maps, &handlers, language_mode);
PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC);
Handle<Code> code = ic_compiler.CompilePolymorphic(
receiver_maps, &handlers, isolate->factory()->empty_string(),
Code::NORMAL, ELEMENT);
isolate->counters()->keyed_load_polymorphic_stubs()->Increment();
PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
return code;
}
Handle<Code> PropertyICCompiler::ComputePolymorphic(
Code::Kind kind, MapHandleList* maps, CodeHandleList* handlers,
int valid_maps, Handle<Name> name, ExtraICState extra_ic_state) {
......@@ -256,6 +250,23 @@ Handle<Code> PropertyICCompiler::ComputePolymorphic(
}
void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers(
MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
CodeHandleList* handlers, KeyedAccessStoreMode store_mode,
LanguageMode language_mode) {
Isolate* isolate = receiver_maps->at(0)->GetIsolate();
DCHECK(store_mode == STANDARD_STORE ||
store_mode == STORE_AND_GROW_NO_TRANSITION ||
store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
store_mode == STORE_NO_TRANSITION_HANDLE_COW);
ExtraICState extra_state =
KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
compiler.CompileKeyedStorePolymorphicHandlers(
receiver_maps, transitioned_maps, handlers, store_mode);
}
Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
LanguageMode language_mode) {
......@@ -338,11 +349,9 @@ Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Code::StubType type,
}
Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode) {
// Collect MONOMORPHIC stubs for all |receiver_maps|.
CodeHandleList handlers(receiver_maps->length());
MapHandleList transitioned_maps(receiver_maps->length());
void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers(
MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
CodeHandleList* handlers, KeyedAccessStoreMode store_mode) {
for (int i = 0; i < receiver_maps->length(); ++i) {
Handle<Map> receiver_map(receiver_maps->at(i));
Handle<Code> cached_stub;
......@@ -379,9 +388,19 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
}
}
DCHECK(!cached_stub.is_null());
handlers.Add(cached_stub);
transitioned_maps.Add(transitioned_map);
handlers->Add(cached_stub);
transitioned_maps->Add(transitioned_map);
}
}
Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode) {
// Collect MONOMORPHIC stubs for all |receiver_maps|.
CodeHandleList handlers(receiver_maps->length());
MapHandleList transitioned_maps(receiver_maps->length());
CompileKeyedStorePolymorphicHandlers(receiver_maps, &transitioned_maps,
&handlers, store_mode);
Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers,
&transitioned_maps);
......@@ -394,7 +413,7 @@ Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
#define __ ACCESS_MASM(masm())
Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic(
Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphicHandler(
Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
ElementsKind elements_kind = receiver_map->elements_kind();
bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
......@@ -408,6 +427,14 @@ Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic(
} else {
stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode();
}
return stub;
}
Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic(
Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
Handle<Code> stub =
CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode);
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
......
......@@ -34,10 +34,15 @@ class PropertyICCompiler : public PropertyAccessCompiler {
static Handle<Code> ComputeKeyedLoadMonomorphicHandler(
Handle<Map> receiver_map, ExtraICState extra_ic_state);
static Handle<Code> ComputeKeyedStoreMonomorphicHandler(
Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode);
static Handle<Code> ComputeKeyedStoreMonomorphic(
Handle<Map> receiver_map, LanguageMode language_mode,
KeyedAccessStoreMode store_mode);
static Handle<Code> ComputeKeyedLoadPolymorphic(MapHandleList* receiver_maps,
static void ComputeKeyedStorePolymorphicHandlers(
MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
CodeHandleList* handlers, KeyedAccessStoreMode store_mode,
LanguageMode language_mode);
static Handle<Code> ComputeKeyedStorePolymorphic(
MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
......@@ -78,10 +83,16 @@ class PropertyICCompiler : public PropertyAccessCompiler {
Handle<Name> name, Code::StubType type,
IcCheckType check);
Handle<Code> CompileKeyedStoreMonomorphicHandler(
Handle<Map> receiver_map, KeyedAccessStoreMode store_mode);
Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map,
KeyedAccessStoreMode store_mode);
Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
KeyedAccessStoreMode store_mode);
void CompileKeyedStorePolymorphicHandlers(MapHandleList* receiver_maps,
MapHandleList* transitioned_maps,
CodeHandleList* handlers,
KeyedAccessStoreMode store_mode);
Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps,
CodeHandleList* handler_stubs,
MapHandleList* transitioned_maps);
......
This diff is collapsed.
......@@ -122,6 +122,11 @@ class IC {
// Configure the vector for POLYMORPHIC.
void ConfigureVectorState(Handle<Name> name, MapHandleList* maps,
CodeHandleList* handlers);
// Configure the vector for POLYMORPHIC with transitions (only for element
// keyed stores).
void ConfigureVectorState(MapHandleList* maps,
MapHandleList* transitioned_maps,
CodeHandleList* handlers);
char TransitionMarkFromState(IC::State state);
void TraceIC(const char* type, Handle<Object> name);
......@@ -538,10 +543,17 @@ class KeyedStoreIC : public StoreIC {
static KeyedAccessStoreMode GetKeyedAccessStoreMode(
ExtraICState extra_state) {
DCHECK(!FLAG_vector_stores);
return ExtraICStateKeyedAccessStoreMode::decode(extra_state);
}
KeyedAccessStoreMode GetKeyedAccessStoreMode() {
DCHECK(FLAG_vector_stores);
return casted_nexus<KeyedStoreICNexus>()->GetKeyedAccessStoreMode();
}
static IcCheckType GetKeyType(ExtraICState extra_state) {
DCHECK(!FLAG_vector_stores);
return IcCheckTypeField::decode(extra_state);
}
......@@ -571,6 +583,8 @@ class KeyedStoreIC : public StoreIC {
static Handle<Code> initialize_stub_in_optimized_code(
Isolate* isolate, LanguageMode language_mode, State initialization_state);
static Handle<Code> ChooseMegamorphicStub(Isolate* isolate,
ExtraICState extra_state);
static void Clear(Isolate* isolate, Code* host, KeyedStoreICNexus* nexus);
......
......@@ -407,6 +407,10 @@ class KeyedStoreICNexus : public FeedbackNexus {
: FeedbackNexus(vector, slot) {
DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_IC);
}
explicit KeyedStoreICNexus(Isolate* isolate)
: FeedbackNexus(TypeFeedbackVector::DummyVector(isolate),
TypeFeedbackVector::DummySlot(
TypeFeedbackVector::kDummyKeyedStoreICSlot)) {}
KeyedStoreICNexus(TypeFeedbackVector* vector, FeedbackVectorICSlot slot)
: FeedbackNexus(vector, slot) {
DCHECK(vector->GetKind(slot) == Code::KEYED_STORE_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