| Index: runtime/vm/flow_graph_optimizer.cc
|
| ===================================================================
|
| --- runtime/vm/flow_graph_optimizer.cc (revision 12765)
|
| +++ runtime/vm/flow_graph_optimizer.cc (working copy)
|
| @@ -7,6 +7,7 @@
|
| #include "vm/bit_vector.h"
|
| #include "vm/cha.h"
|
| #include "vm/flow_graph_builder.h"
|
| +#include "vm/flow_graph_compiler.h"
|
| #include "vm/hash_map.h"
|
| #include "vm/il_printer.h"
|
| #include "vm/intermediate_language.h"
|
| @@ -80,7 +81,14 @@
|
| Representation to,
|
| Definition* def,
|
| Instruction* deopt_target) {
|
| - if ((from == kUnboxedDouble) && (to == kTagged)) {
|
| + if (from == kTagged && to == kUnboxedInteger) {
|
| + const intptr_t deopt_id = (deopt_target != NULL) ?
|
| + deopt_target->DeoptimizationTarget() : Isolate::kNoDeoptId;
|
| + ASSERT((deopt_target != NULL) || (def->GetPropagatedCid() == kDoubleCid));
|
| + return new UnboxIntegerInstr(new Value(def), deopt_id);
|
| + } else if (from == kUnboxedInteger && to == kTagged) {
|
| + return new BoxIntegerInstr(new Value(def));
|
| + } else if ((from == kUnboxedDouble) && (to == kTagged)) {
|
| return new BoxDoubleInstr(new Value(def), NULL);
|
| } else if ((from == kTagged) && (to == kUnboxedDouble)) {
|
| const intptr_t deopt_id = (deopt_target != NULL) ?
|
| @@ -484,19 +492,20 @@
|
| // TODO(vegorov): implement fast path code for modulo.
|
| return false;
|
| case Token::kBIT_AND:
|
| + case Token::kBIT_OR:
|
| + case Token::kBIT_XOR:
|
| if (HasOnlyTwoSmi(ic_data)) {
|
| operands_type = kSmiCid;
|
| - } else if (HasTwoMintOrSmi(ic_data)) {
|
| + } else if (HasTwoMintOrSmi(ic_data) &&
|
| + FlowGraphCompiler::SupportsUnboxedMints()) {
|
| operands_type = kMintCid;
|
| } else {
|
| return false;
|
| }
|
| break;
|
| - case Token::kBIT_OR:
|
| - case Token::kBIT_XOR:
|
| case Token::kTRUNCDIV:
|
| + case Token::kSHL:
|
| case Token::kSHR:
|
| - case Token::kSHL:
|
| if (HasOnlyTwoSmi(ic_data)) {
|
| operands_type = kSmiCid;
|
| } else {
|
| @@ -531,10 +540,8 @@
|
| } else if (operands_type == kMintCid) {
|
| Value* left = call->ArgumentAt(0)->value();
|
| Value* right = call->ArgumentAt(1)->value();
|
| - BinaryMintOpInstr* bin_op = new BinaryMintOpInstr(op_kind,
|
| - call,
|
| - left,
|
| - right);
|
| + UnboxedMintBinaryOpInstr* bin_op =
|
| + new UnboxedMintBinaryOpInstr(op_kind, left, right, call);
|
| call->ReplaceWith(bin_op, current_iterator());
|
| RemovePushArguments(call);
|
| } else {
|
| @@ -984,7 +991,8 @@
|
| GrowableArray<intptr_t> class_ids;
|
| Function& target = Function::Handle();
|
| comp->ic_data()->GetCheckAt(0, &class_ids, &target);
|
| - // TODO(srdjan): allow for mixed mode comparison.
|
| + // TODO(srdjan): allow for mixed mode int/double comparison.
|
| +
|
| if ((class_ids[0] == kSmiCid) && (class_ids[1] == kSmiCid)) {
|
| optimizer->InsertBefore(
|
| instr,
|
| @@ -999,9 +1007,14 @@
|
| comp->set_receiver_class_id(kSmiCid);
|
| } else if ((class_ids[0] == kDoubleCid) && (class_ids[1] == kDoubleCid)) {
|
| comp->set_receiver_class_id(kDoubleCid);
|
| + } else if (HasTwoMintOrSmi(*comp->ic_data()) &&
|
| + FlowGraphCompiler::SupportsUnboxedMints()) {
|
| + comp->set_receiver_class_id(kMintCid);
|
| } else {
|
| ASSERT(comp->receiver_class_id() == kIllegalCid);
|
| }
|
| + } else if (HasTwoMintOrSmi(*comp->ic_data())) {
|
| + comp->set_receiver_class_id(kMintCid);
|
| } else if (comp->ic_data()->AllReceiversAreNumbers()) {
|
| comp->set_receiver_class_id(kNumberCid);
|
| }
|
| @@ -2714,18 +2727,24 @@
|
| }
|
|
|
|
|
| -void ConstantPropagator::VisitBinaryMintOp(BinaryMintOpInstr* instr) {
|
| - const Object& left = instr->left()->definition()->constant_value();
|
| - const Object& right = instr->right()->definition()->constant_value();
|
| - if (IsNonConstant(left) || IsNonConstant(right)) {
|
| - SetValue(instr, non_constant_);
|
| - } else if (IsConstant(left) && IsConstant(right)) {
|
| - // TODO(kmillikin): Handle binary operations.
|
| - SetValue(instr, non_constant_);
|
| - }
|
| +void ConstantPropagator::VisitBoxInteger(BoxIntegerInstr* instr) {
|
| + // TODO(kmillikin): Handle box operation.
|
| + SetValue(instr, non_constant_);
|
| }
|
|
|
|
|
| +void ConstantPropagator::VisitUnboxInteger(UnboxIntegerInstr* instr) {
|
| + // TODO(kmillikin): Handle unbox operation.
|
| + SetValue(instr, non_constant_);
|
| +}
|
| +
|
| +
|
| +void ConstantPropagator::VisitUnboxedMintBinaryOp(
|
| + UnboxedMintBinaryOpInstr* instr) {
|
| + // TODO(kmillikin): Handle binary operations.
|
| + SetValue(instr, non_constant_);
|
| +}
|
| +
|
| void ConstantPropagator::VisitUnarySmiOp(UnarySmiOpInstr* instr) {
|
| const Object& value = instr->value()->definition()->constant_value();
|
| if (IsNonConstant(value)) {
|
|
|