Commit 4f41d895 authored by whesse@chromium.org's avatar whesse@chromium.org

Use type info for count operation in Crankshaft.

BUG=
TEST=

Review URL: http://codereview.chromium.org/6880276

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7717 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent f470cf27
...@@ -4653,12 +4653,18 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) { ...@@ -4653,12 +4653,18 @@ void HGraphBuilder::VisitUnaryOperation(UnaryOperation* expr) {
} }
HInstruction* HGraphBuilder::BuildIncrement(HValue* value, bool increment) { HInstruction* HGraphBuilder::BuildIncrement(HValue* value,
bool increment,
CountOperation* expr) {
HConstant* delta = increment HConstant* delta = increment
? graph_->GetConstant1() ? graph_->GetConstant1()
: graph_->GetConstantMinus1(); : graph_->GetConstantMinus1();
HInstruction* instr = new(zone()) HAdd(value, delta); HInstruction* instr = new(zone()) HAdd(value, delta);
AssumeRepresentation(instr, Representation::Integer32()); Representation rep = ToRepresentation(oracle()->IncrementType(expr));
if (rep.IsTagged()) {
rep = Representation::Integer32();
}
AssumeRepresentation(instr, rep);
return instr; return instr;
} }
...@@ -4681,7 +4687,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -4681,7 +4687,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
// element for postfix operations in a non-effect context. // element for postfix operations in a non-effect context.
bool has_extra = expr->is_postfix() && !ast_context()->IsEffect(); bool has_extra = expr->is_postfix() && !ast_context()->IsEffect();
HValue* before = has_extra ? Top() : Pop(); HValue* before = has_extra ? Top() : Pop();
HInstruction* after = BuildIncrement(before, inc); HInstruction* after = BuildIncrement(before, inc, expr);
AddInstruction(after); AddInstruction(after);
Push(after); Push(after);
...@@ -4733,7 +4739,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -4733,7 +4739,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
HValue* before = Pop(); HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't need // There is no deoptimization to after the increment, so we don't need
// to simulate the expression stack after this instruction. // to simulate the expression stack after this instruction.
HInstruction* after = BuildIncrement(before, inc); HInstruction* after = BuildIncrement(before, inc, expr);
AddInstruction(after); AddInstruction(after);
HInstruction* store = BuildStoreNamed(obj, after, prop); HInstruction* store = BuildStoreNamed(obj, after, prop);
...@@ -4769,7 +4775,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -4769,7 +4775,7 @@ void HGraphBuilder::VisitCountOperation(CountOperation* expr) {
HValue* before = Pop(); HValue* before = Pop();
// There is no deoptimization to after the increment, so we don't need // There is no deoptimization to after the increment, so we don't need
// to simulate the expression stack after this instruction. // to simulate the expression stack after this instruction.
HInstruction* after = BuildIncrement(before, inc); HInstruction* after = BuildIncrement(before, inc, expr);
AddInstruction(after); AddInstruction(after);
expr->RecordTypeFeedback(oracle()); expr->RecordTypeFeedback(oracle());
......
...@@ -831,7 +831,9 @@ class HGraphBuilder: public AstVisitor { ...@@ -831,7 +831,9 @@ class HGraphBuilder: public AstVisitor {
HInstruction* BuildBinaryOperation(BinaryOperation* expr, HInstruction* BuildBinaryOperation(BinaryOperation* expr,
HValue* left, HValue* left,
HValue* right); HValue* right);
HInstruction* BuildIncrement(HValue* value, bool increment); HInstruction* BuildIncrement(HValue* value,
bool increment,
CountOperation* expr);
HLoadNamedField* BuildLoadNamedField(HValue* object, HLoadNamedField* BuildLoadNamedField(HValue* object,
Property* expr, Property* expr,
Handle<Map> type, Handle<Map> type,
......
...@@ -334,6 +334,35 @@ TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) { ...@@ -334,6 +334,35 @@ TypeInfo TypeFeedbackOracle::SwitchType(CaseClause* clause) {
} }
TypeInfo TypeFeedbackOracle::IncrementType(CountOperation* expr) {
Handle<Object> object = GetInfo(expr->CountId());
TypeInfo unknown = TypeInfo::Unknown();
if (!object->IsCode()) return unknown;
Handle<Code> code = Handle<Code>::cast(object);
if (!code->is_type_recording_binary_op_stub()) return unknown;
TRBinaryOpIC::TypeInfo type = static_cast<TRBinaryOpIC::TypeInfo>(
code->type_recording_binary_op_type());
switch (type) {
case TRBinaryOpIC::UNINITIALIZED:
case TRBinaryOpIC::SMI:
return TypeInfo::Smi();
case TRBinaryOpIC::INT32:
return TypeInfo::Integer32();
case TRBinaryOpIC::HEAP_NUMBER:
return TypeInfo::Double();
case TRBinaryOpIC::BOTH_STRING:
case TRBinaryOpIC::STRING:
case TRBinaryOpIC::GENERIC:
return unknown;
default:
return unknown;
}
UNREACHABLE();
return unknown;
}
ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id, ZoneMapList* TypeFeedbackOracle::CollectReceiverTypes(unsigned ast_id,
Handle<String> name, Handle<String> name,
Code::Flags flags) { Code::Flags flags) {
......
...@@ -231,6 +231,7 @@ class UnaryOperation; ...@@ -231,6 +231,7 @@ class UnaryOperation;
class BinaryOperation; class BinaryOperation;
class Call; class Call;
class CompareOperation; class CompareOperation;
class CountOperation;
class CompilationInfo; class CompilationInfo;
class Property; class Property;
class CaseClause; class CaseClause;
...@@ -263,6 +264,7 @@ class TypeFeedbackOracle BASE_EMBEDDED { ...@@ -263,6 +264,7 @@ class TypeFeedbackOracle BASE_EMBEDDED {
TypeInfo BinaryType(BinaryOperation* expr); TypeInfo BinaryType(BinaryOperation* expr);
TypeInfo CompareType(CompareOperation* expr); TypeInfo CompareType(CompareOperation* expr);
TypeInfo SwitchType(CaseClause* clause); TypeInfo SwitchType(CaseClause* clause);
TypeInfo IncrementType(CountOperation* expr);
private: private:
ZoneMapList* CollectReceiverTypes(unsigned ast_id, ZoneMapList* CollectReceiverTypes(unsigned ast_id,
......
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