Skip to content

Commit

Permalink
VectorICs: megamorphic keyed loads in crankshaft don't need a vector.
Browse files Browse the repository at this point in the history
They are content with a dummy vector, as MISSES won't result in
changing the real vector/slot at all.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#27788}
  • Loading branch information
ripsawridge authored and Commit bot committed Apr 13, 2015
1 parent ffe290f commit c8e4d57
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/arm/lithium-codegen-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3399,7 +3399,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));

if (FLAG_vector_ics) {
if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down
3 changes: 2 additions & 1 deletion src/arm64/lithium-codegen-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,8 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->context()).is(cp));
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));
if (FLAG_vector_ics) {

if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/code-factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Callable CodeFactory::KeyedLoadICInOptimizedCode(
Isolate* isolate, InlineCacheState initialization_state) {
auto code = KeyedLoadIC::initialize_stub_in_optimized_code(
isolate, initialization_state);
if (FLAG_vector_ics) {
if (FLAG_vector_ics && initialization_state != MEGAMORPHIC) {
return Callable(code, VectorLoadICDescriptor(isolate));
}
return Callable(code, LoadDescriptor(isolate));
Expand Down
6 changes: 5 additions & 1 deletion src/hydrogen-instructions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6716,7 +6716,11 @@ class HLoadKeyedGeneric FINAL : public HTemplateInstruction<3> {
Handle<TypeFeedbackVector> feedback_vector() const {
return feedback_vector_;
}
bool HasVectorAndSlot() const { return FLAG_vector_ics; }
bool HasVectorAndSlot() const {
DCHECK(!FLAG_vector_ics || initialization_state_ == MEGAMORPHIC ||
feedback_vector_.is_null());
return !feedback_vector_.is_null();
}
void SetVectorAndSlot(Handle<TypeFeedbackVector> vector,
FeedbackVectorICSlot slot) {
DCHECK(FLAG_vector_ics);
Expand Down
29 changes: 8 additions & 21 deletions src/hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5406,11 +5406,8 @@ void HOptimizedGraphBuilder::VisitVariableProxy(VariableProxy* expr) {
variable->name(),
ast_context()->is_for_typeof());
if (FLAG_vector_ics) {
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
instr->SetVectorAndSlot(
handle(current_shared->feedback_vector(), isolate()),
expr->VariableFeedbackSlot());
instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()),
expr->VariableFeedbackSlot());
}
return ast_context()->ReturnInstruction(instr, expr->id());
}
Expand Down Expand Up @@ -6901,10 +6898,8 @@ HInstruction* HOptimizedGraphBuilder::BuildNamedGeneric(
HLoadNamedGeneric* result =
New<HLoadNamedGeneric>(object, name, PREMONOMORPHIC);
if (FLAG_vector_ics) {
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
Handle<TypeFeedbackVector> vector =
handle(current_shared->feedback_vector(), isolate());
handle(current_feedback_vector(), isolate());
FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
result->SetVectorAndSlot(vector, slot);
}
Expand All @@ -6924,16 +6919,10 @@ HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric(
HValue* key,
HValue* value) {
if (access_type == LOAD) {
HLoadKeyedGeneric* result =
New<HLoadKeyedGeneric>(object, key, PREMONOMORPHIC);
if (FLAG_vector_ics) {
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
Handle<TypeFeedbackVector> vector =
handle(current_shared->feedback_vector(), isolate());
FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
result->SetVectorAndSlot(vector, slot);
}
// HLoadKeyedGeneric with vector ics benefits from being encoded as
// MEGAMORPHIC because the vector/slot combo becomes unnecessary.
HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>(
object, key, FLAG_vector_ics ? MEGAMORPHIC : PREMONOMORPHIC);
return result;
} else {
return New<HStoreKeyedGeneric>(object, key, value, function_language_mode(),
Expand Down Expand Up @@ -9325,10 +9314,8 @@ void HOptimizedGraphBuilder::VisitCall(Call* expr) {
expr->IsUsingCallFeedbackICSlot(isolate())) {
// We've never seen this call before, so let's have Crankshaft learn
// through the type vector.
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
Handle<TypeFeedbackVector> vector =
handle(current_shared->feedback_vector(), isolate());
handle(current_feedback_vector(), isolate());
FeedbackVectorICSlot slot = expr->CallFeedbackICSlot();
call_function->SetVectorAndSlot(vector, slot);
}
Expand Down
6 changes: 6 additions & 0 deletions src/hydrogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,12 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
TestContext* inlined_test_context() const {
return function_state()->test_context();
}
Handle<SharedFunctionInfo> current_shared_info() const {
return current_info()->shared_info();
}
TypeFeedbackVector* current_feedback_vector() const {
return current_shared_info()->feedback_vector();
}
void ClearInlinedTestContext() {
function_state()->ClearInlinedTestContext();
}
Expand Down
2 changes: 1 addition & 1 deletion src/ia32/lithium-codegen-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3235,7 +3235,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));

if (FLAG_vector_ics) {
if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/ic/ic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ Handle<Code> KeyedLoadIC::initialize_stub(Isolate* isolate) {

Handle<Code> KeyedLoadIC::initialize_stub_in_optimized_code(
Isolate* isolate, State initialization_state) {
if (FLAG_vector_ics) {
if (FLAG_vector_ics && initialization_state != MEGAMORPHIC) {
return VectorRawKeyedLoadStub(isolate).GetCode();
}
switch (initialization_state) {
Expand Down
2 changes: 1 addition & 1 deletion src/mips/lithium-codegen-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));

if (FLAG_vector_ics) {
if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/mips64/lithium-codegen-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3397,7 +3397,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));

if (FLAG_vector_ics) {
if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down
2 changes: 1 addition & 1 deletion src/x64/lithium-codegen-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,7 @@ void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
DCHECK(ToRegister(instr->object()).is(LoadDescriptor::ReceiverRegister()));
DCHECK(ToRegister(instr->key()).is(LoadDescriptor::NameRegister()));

if (FLAG_vector_ics) {
if (instr->hydrogen()->HasVectorAndSlot()) {
EmitVectorLoadICRegisters<LLoadKeyedGeneric>(instr);
}

Expand Down

0 comments on commit c8e4d57

Please sign in to comment.