const char* reason) {
Representation r = representation();
if (new_rep.is_more_general_than(r)) {
+ if (CheckFlag(kCannotBeTagged) && r.IsTagged()) return;
if (FLAG_trace_representation) {
PrintF("Changing #%d %s representation %s -> %s based on %s\n",
id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason);
enum Flag {
kFlexibleRepresentation,
+ kCannotBeTagged,
// Participate in Global Value Numbering, i.e. elimination of
// unnecessary recomputations. If an instruction sets this flag, it must
// implement DataEquals(), which will be used to determine if other
ASSERT(CheckFlag(kFlexibleRepresentation));
RepresentationChanged(r);
representation_ = r;
- if (r.IsTagged()) {
+ if (r.IsTagged() ||
+ (r.IsDouble() && CheckFlag(kCannotBeTagged))) {
// Tagged is the bottom of the lattice, don't go any further.
ClearFlag(kFlexibleRepresentation);
}
current != NULL; current = current->next()) {
if (current->representation().IsNone() &&
current->CheckFlag(HInstruction::kFlexibleRepresentation)) {
- current->ChangeRepresentation(Representation::Tagged());
+ if (current->CheckFlag(HInstruction::kCannotBeTagged)) {
+ current->ChangeRepresentation(Representation::Double());
+ } else {
+ current->ChangeRepresentation(Representation::Tagged());
+ }
}
}
}
// The input to the count operation is on top of the expression stack.
TypeInfo info = expr->type();
Representation rep = ToRepresentation(info);
- if (rep.IsTagged()) {
- rep = Representation::Integer32();
+ if (rep.IsNone() || rep.IsTagged()) {
+ rep = Representation::Smi();
}
if (returns_original_input) {
// phase, so it is not available now to be used as an input to HAdd and
// as the return value.
HInstruction* number_input = new(zone()) HForceRepresentation(Pop(), rep);
+ if (!rep.IsDouble()) {
+ number_input->SetFlag(HInstruction::kFlexibleRepresentation);
+ number_input->SetFlag(HInstruction::kCannotBeTagged);
+ }
AddInstruction(number_input);
Push(number_input);
}
: graph()->GetConstantMinus1();
HValue* context = environment()->LookupContext();
HInstruction* instr = HAdd::New(zone(), context, Top(), delta);
- // We can't insert a simulate here, because it would break deoptimization,
- // so the HAdd must not have side effects, so we must freeze its
- // representation.
- instr->AssumeRepresentation(rep);
+ instr->SetFlag(HInstruction::kCannotBeTagged);
instr->ClearAllSideEffects();
AddInstruction(instr);
return instr;