VectorICs: megamorphic keyed loads in crankshaft don't need a vector.

This needs "Pass load ic state through the Oracle"
(https://codereview.chromium.org/1083933002/) to land first.

BUG=
R=dcarney@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#27827}
This commit is contained in:
mvstanton 2015-04-14 19:35:39 -07:00 committed by Commit bot
parent 4598f1d376
commit 776770c0e4
11 changed files with 33 additions and 25 deletions

View File

@ -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);
}

View File

@ -3620,7 +3620,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);
}

View File

@ -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));

View File

@ -6667,7 +6667,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);

View File

@ -5407,11 +5407,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());
}
@ -6902,10 +6899,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);
}
@ -6925,13 +6920,17 @@ HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric(
HValue* key,
HValue* value) {
if (access_type == LOAD) {
InlineCacheState initial_state =
FLAG_vector_ics ? expr->AsProperty()->GetInlineCacheState()
: PREMONOMORPHIC;
HLoadKeyedGeneric* result =
New<HLoadKeyedGeneric>(object, key, PREMONOMORPHIC);
if (FLAG_vector_ics) {
Handle<SharedFunctionInfo> current_shared =
function_state()->compilation_info()->shared_info();
New<HLoadKeyedGeneric>(object, key, initial_state);
// HLoadKeyedGeneric with vector ics benefits from being encoded as
// MEGAMORPHIC because the vector/slot combo becomes unnecessary.
if (initial_state != MEGAMORPHIC) {
// We need to pass vector information.
Handle<TypeFeedbackVector> vector =
handle(current_shared->feedback_vector(), isolate());
handle(current_feedback_vector(), isolate());
FeedbackVectorICSlot slot = expr->AsProperty()->PropertyFeedbackSlot();
result->SetVectorAndSlot(vector, slot);
}
@ -9316,10 +9315,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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}