From: fschneider@chromium.org Date: Thu, 6 Jan 2011 10:10:26 +0000 (+0000) Subject: Clean up code for type feedback a bit. X-Git-Tag: upstream/4.7.83~20672 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35533bee369e4ae1202d832bd58d39d56a95cebf;p=platform%2Fupstream%2Fv8.git Clean up code for type feedback a bit. Remove unused functions and parameters and remove the parts of the code that mention the old GenericBinaryOpStub. It is not used together with Crankshaft and replaced with TypeRecordingBinaryOpStub. Review URL: http://codereview.chromium.org/6075012 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6194 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/ast.cc b/src/ast.cc index 1a6e768..1da9347 100644 --- a/src/ast.cc +++ b/src/ast.cc @@ -649,19 +649,11 @@ void Call::RecordTypeFeedback(TypeFeedbackOracle* oracle) { } -void BinaryOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { - TypeInfo left = oracle->BinaryType(this, TypeFeedbackOracle::LEFT); - TypeInfo right = oracle->BinaryType(this, TypeFeedbackOracle::RIGHT); - is_smi_only_ = left.IsSmi() && right.IsSmi(); -} - - void CompareOperation::RecordTypeFeedback(TypeFeedbackOracle* oracle) { - TypeInfo left = oracle->CompareType(this, TypeFeedbackOracle::LEFT); - TypeInfo right = oracle->CompareType(this, TypeFeedbackOracle::RIGHT); - if (left.IsSmi() && right.IsSmi()) { + TypeInfo info = oracle->CompareType(this); + if (info.IsSmi()) { compare_type_ = SMI_ONLY; - } else if (left.IsNonPrimitive() && right.IsNonPrimitive()) { + } else if (info.IsNonPrimitive()) { compare_type_ = OBJECT_ONLY; } else { ASSERT(compare_type_ == NONE); diff --git a/src/ast.h b/src/ast.h index ba422fd..d33f908 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1392,7 +1392,7 @@ class BinaryOperation: public Expression { Expression* left, Expression* right, int pos) - : op_(op), left_(left), right_(right), pos_(pos), is_smi_only_(false) { + : op_(op), left_(left), right_(right), pos_(pos) { ASSERT(Token::IsBinaryOp(op)); right_id_ = (op == Token::AND || op == Token::OR) ? static_cast(GetNextId()) @@ -1413,10 +1413,6 @@ class BinaryOperation: public Expression { Expression* right() const { return right_; } int position() const { return pos_; } - // Type feedback information. - void RecordTypeFeedback(TypeFeedbackOracle* oracle); - bool IsSmiOnly() const { return is_smi_only_; } - // Bailout support. int RightId() const { return right_id_; } @@ -1425,7 +1421,6 @@ class BinaryOperation: public Expression { Expression* left_; Expression* right_; int pos_; - bool is_smi_only_; // The short-circuit logical operations have an AST ID for their // right-hand subexpression. int right_id_; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 0d92b2e..d97c4e3 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -3366,7 +3366,6 @@ void HGraphBuilder::HandleCompoundAssignment(Assignment* expr) { // We have a second position recorded in the FullCodeGenerator to have // type feedback for the binary operation. BinaryOperation* operation = expr->binary_operation(); - operation->RecordTypeFeedback(oracle()); if (var != NULL) { if (!var->is_global() && !var->IsStackAllocated()) { @@ -4731,7 +4730,7 @@ HInstruction* HGraphBuilder::BuildBinaryOperation(BinaryOperation* expr, default: UNREACHABLE(); } - TypeInfo info = oracle()->BinaryType(expr, TypeFeedbackOracle::RESULT); + TypeInfo info = oracle()->BinaryType(expr); // If we hit an uninitialized binary op stub we will get type info // for a smi operation. If one of the operands is a constant string // do not generate code assuming it is a smi operation. @@ -4876,7 +4875,7 @@ void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { HValue* left = Pop(); Token::Value op = expr->op(); - TypeInfo info = oracle()->CompareType(expr, TypeFeedbackOracle::RESULT); + TypeInfo info = oracle()->CompareType(expr); HInstruction* instr = NULL; if (op == Token::INSTANCEOF) { // Check to see if the rhs of the instanceof is a global function not diff --git a/src/type-info.cc b/src/type-info.cc index 8719439..e2004fa 100644 --- a/src/type-info.cc +++ b/src/type-info.cc @@ -132,7 +132,7 @@ bool TypeFeedbackOracle::LoadIsBuiltin(Property* expr, Builtins::Name id) { } -TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr, Side side) { +TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr) { Handle object = GetElement(map_, expr->position()); TypeInfo unknown = TypeInfo::Unknown(); if (!object->IsCode()) return unknown; @@ -159,27 +159,12 @@ TypeInfo TypeFeedbackOracle::CompareType(CompareOperation* expr, Side side) { } -TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr, Side side) { +TypeInfo TypeFeedbackOracle::BinaryType(BinaryOperation* expr) { Handle object = GetElement(map_, expr->position()); TypeInfo unknown = TypeInfo::Unknown(); if (!object->IsCode()) return unknown; Handle code = Handle::cast(object); - if (code->is_binary_op_stub()) { - BinaryOpIC::TypeInfo type = static_cast( - code->binary_op_type()); - switch (type) { - case BinaryOpIC::UNINIT_OR_SMI: - return TypeInfo::Smi(); - case BinaryOpIC::DEFAULT: - return (expr->op() == Token::DIV || expr->op() == Token::MUL) - ? TypeInfo::Double() - : TypeInfo::Integer32(); - case BinaryOpIC::HEAP_NUMBERS: - return TypeInfo::Double(); - default: - return unknown; - } - } else if (code->is_type_recording_binary_op_stub()) { + if (code->is_type_recording_binary_op_stub()) { TRBinaryOpIC::TypeInfo type = static_cast( code->type_recording_binary_op_type()); TRBinaryOpIC::TypeInfo result_type = static_cast( @@ -291,8 +276,7 @@ void TypeFeedbackOracle::PopulateMap(Handle code) { int position = source_positions[i]; InlineCacheState state = target->ic_state(); Code::Kind kind = target->kind(); - if (kind == Code::BINARY_OP_IC || - kind == Code::TYPE_RECORDING_BINARY_OP_IC || + if (kind == Code::TYPE_RECORDING_BINARY_OP_IC || kind == Code::COMPARE_IC) { // TODO(kasperl): Avoid having multiple ICs with the same // position by making sure that we have position information @@ -332,19 +316,17 @@ void TypeFeedbackOracle::CollectPositions(Code* code, if (target->is_inline_cache_stub()) { InlineCacheState state = target->ic_state(); Code::Kind kind = target->kind(); - if (kind == Code::BINARY_OP_IC) { - if (target->binary_op_type() == BinaryOpIC::GENERIC) continue; - } else if (kind == Code::TYPE_RECORDING_BINARY_OP_IC) { - if (target->type_recording_binary_op_type() == - TRBinaryOpIC::GENERIC) { - continue; - } - } else if (kind == Code::COMPARE_IC) { - if (target->compare_state() == CompareIC::GENERIC) continue; - } else { - if (kind == Code::CALL_IC && state == MONOMORPHIC && - target->check_type() != RECEIVER_MAP_CHECK) continue; - if (state != MONOMORPHIC && state != MEGAMORPHIC) continue; + if (kind == Code::TYPE_RECORDING_BINARY_OP_IC && + target->type_recording_binary_op_type() == TRBinaryOpIC::GENERIC) { + continue; + } else if (kind == Code::COMPARE_IC && + target->compare_state() == CompareIC::GENERIC) { + continue; + } else if (kind == Code::CALL_IC && state == MONOMORPHIC && + target->check_type() != RECEIVER_MAP_CHECK) { + continue; + } else if (state != MONOMORPHIC && state != MEGAMORPHIC) { + continue; } code_positions->Add( static_cast(info->pc() - code->instruction_start())); diff --git a/src/type-info.h b/src/type-info.h index cb3e75d..06ae894 100644 --- a/src/type-info.h +++ b/src/type-info.h @@ -230,12 +230,6 @@ class CaseClause; class TypeFeedbackOracle BASE_EMBEDDED { public: - enum Side { - LEFT, - RIGHT, - RESULT - }; - explicit TypeFeedbackOracle(Handle code); bool LoadIsMonomorphic(Property* expr); @@ -253,8 +247,8 @@ class TypeFeedbackOracle BASE_EMBEDDED { bool LoadIsBuiltin(Property* expr, Builtins::Name id); // Get type information for arithmetic operations and compares. - TypeInfo BinaryType(BinaryOperation* expr, Side side); - TypeInfo CompareType(CompareOperation* expr, Side side); + TypeInfo BinaryType(BinaryOperation* expr); + TypeInfo CompareType(CompareOperation* expr); TypeInfo SwitchType(CaseClause* clause); private: