Revision: 14926
Author: [email protected]
Date: Mon Jun 3 09:57:36 2013
Log: Improve smi support in crankshaft
- Recover smi in phis if inputs are smi-typed
- Don't record smi-typed values as pointers
BUG=
[email protected]
Review URL: https://chromiumcodereview.appspot.com/16240003
http://code.google.com/p/v8/source/detail?r=14926
Modified:
/branches/bleeding_edge/src/hydrogen-instructions.cc
/branches/bleeding_edge/src/hydrogen-instructions.h
/branches/bleeding_edge/src/hydrogen.cc
/branches/bleeding_edge/src/lithium-allocator.cc
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.cc Thu May 30
02:11:06 2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Mon Jun 3
09:57:36 2013
@@ -124,20 +124,9 @@
const char* reason) {
Representation r = representation();
if (new_rep.is_more_general_than(r)) {
- // When an HConstant is marked "not convertible to integer", then
- // never try to represent it as an integer.
- if (new_rep.IsInteger32() && !IsConvertibleToInteger()) {
- new_rep = Representation::Tagged();
- if (FLAG_trace_representation) {
- PrintF("Changing #%d %s representation %s -> %s because it's NCTI"
- " (%s want i)\n",
- id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason);
- }
- } else {
- if (FLAG_trace_representation) {
- PrintF("Changing #%d %s representation %s -> %s based on %s\n",
- id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason);
- }
+ if (FLAG_trace_representation) {
+ PrintF("Changing #%d %s representation %s -> %s based on %s\n",
+ id(), Mnemonic(), r.Mnemonic(), new_rep.Mnemonic(), reason);
}
ChangeRepresentation(new_rep);
AddDependantsToWorklist(h_infer);
@@ -1926,7 +1915,6 @@
int32_non_phi_uses() + int32_indirect_uses(),
double_non_phi_uses() + double_indirect_uses(),
tagged_non_phi_uses() + tagged_indirect_uses());
- if (!IsConvertibleToInteger()) stream->Add("_ncti");
PrintRangeTo(stream);
PrintTypeTo(stream);
stream->Add("]");
@@ -3565,48 +3553,11 @@
Representation HPhi::RepresentationFromInputs() {
- bool double_occurred = false;
- bool int32_occurred = false;
- bool smi_occurred = false;
+ Representation r = Representation::None();
for (int i = 0; i < OperandCount(); ++i) {
- HValue* value = OperandAt(i);
- if (value->IsUnknownOSRValue()) {
- HPhi* hint_value = HUnknownOSRValue::cast(value)->incoming_value();
- if (hint_value != NULL) {
- Representation hint = hint_value->representation();
- if (hint.IsTagged()) return hint;
- if (hint.IsDouble()) double_occurred = true;
- if (hint.IsInteger32()) int32_occurred = true;
- if (hint.IsSmi()) smi_occurred = true;
- }
- continue;
- }
- if (value->representation().IsDouble()) double_occurred = true;
- if (value->representation().IsInteger32()) int32_occurred = true;
- if (value->representation().IsSmi()) smi_occurred = true;
- if (value->representation().IsTagged()) {
- if (value->IsConstant()) {
- HConstant* constant = HConstant::cast(value);
- if (constant->IsConvertibleToInteger()) {
- int32_occurred = true;
- } else if (constant->HasNumberValue()) {
- double_occurred = true;
- } else {
- return Representation::Tagged();
- }
- } else {
- if (value->IsPhi() && !IsConvertibleToInteger()) {
- return Representation::Tagged();
- }
- }
- }
+ r = r.generalize(OperandAt(i)->KnownOptimalRepresentation());
}
-
- if (double_occurred) return Representation::Double();
- if (int32_occurred) return Representation::Integer32();
- if (smi_occurred) return Representation::Smi();
-
- return Representation::None();
+ return r;
}
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Jun 3 08:32:22
2013
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Mon Jun 3 09:57:36
2013
@@ -885,7 +885,17 @@
}
virtual void AssumeRepresentation(Representation r);
- virtual bool IsConvertibleToInteger() const { return true; }
+ virtual Representation KnownOptimalRepresentation() {
+ Representation r = representation();
+ if (r.IsTagged()) {
+ HType t = type();
+ if (t.IsSmi()) return Representation::Smi();
+ if (t.IsHeapNumber()) return Representation::Double();
+ if (t.IsHeapObject()) return r;
+ return Representation::None();
+ }
+ return r;
+ }
HType type() const { return type_; }
void set_type(HType new_type) {
@@ -2449,7 +2459,7 @@
public:
explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) {
set_type(HType::Smi());
- set_representation(Representation::Tagged());
+ set_representation(Representation::Smi());
SetFlag(kUseGVN);
SetGVNFlag(kDependsOnMaps);
}
@@ -2940,8 +2950,7 @@
HPhi(int merged_index, Zone* zone)
: inputs_(2, zone),
merged_index_(merged_index),
- phi_id_(-1),
- is_convertible_to_integer_(true) {
+ phi_id_(-1) {
for (int i = 0; i < Representation::kNumRepresentations; i++) {
non_phi_uses_[i] = 0;
indirect_uses_[i] = 0;
@@ -2959,6 +2968,9 @@
virtual Representation RequiredInputRepresentation(int index) {
return representation();
}
+ virtual Representation KnownOptimalRepresentation() {
+ return representation();
+ }
virtual HType CalculateInferredType();
virtual int OperandCount() { return inputs_.length(); }
virtual HValue* OperandAt(int index) const { return inputs_[index]; }
@@ -3013,28 +3025,6 @@
return reinterpret_cast<HPhi*>(value);
}
virtual Opcode opcode() const { return HValue::kPhi; }
-
- virtual bool IsConvertibleToInteger() const {
- return is_convertible_to_integer_;
- }
-
- void set_is_convertible_to_integer(bool b) {
- is_convertible_to_integer_ = b;
- }
-
- bool AllOperandsConvertibleToInteger() {
- for (int i = 0; i < OperandCount(); ++i) {
- if (!OperandAt(i)->IsConvertibleToInteger()) {
- if (FLAG_trace_representation) {
- HValue* input = OperandAt(i);
- PrintF("#%d %s: Input #%d %s at %d is NCTI\n",
- id(), Mnemonic(), input->id(), input->Mnemonic(), i);
- }
- return false;
- }
- }
- return true;
- }
void SimplifyConstantInputs();
@@ -3059,7 +3049,6 @@
int non_phi_uses_[Representation::kNumRepresentations];
int indirect_uses_[Representation::kNumRepresentations];
int phi_id_;
- bool is_convertible_to_integer_;
};
@@ -3196,8 +3185,11 @@
return Representation::None();
}
- virtual bool IsConvertibleToInteger() const {
- return has_int32_value_;
+ virtual Representation KnownOptimalRepresentation() {
+ if (HasSmiValue()) return Representation::Smi();
+ if (HasInteger32Value()) return Representation::Integer32();
+ if (HasNumberValue()) return Representation::Double();
+ return Representation::Tagged();
}
virtual bool EmitAtUses() { return !representation().IsDouble(); }
@@ -3211,9 +3203,7 @@
ASSERT(HasInteger32Value());
return int32_value_;
}
- bool HasSmiValue() const {
- return has_smi_value_;
- }
+ bool HasSmiValue() const { return has_smi_value_; }
bool HasDoubleValue() const { return has_double_value_; }
double DoubleValue() const {
ASSERT(HasDoubleValue());
@@ -4715,6 +4705,11 @@
HPhi* incoming_value() {
return incoming_value_;
}
+
+ virtual Representation KnownOptimalRepresentation() {
+ if (incoming_value_ == NULL) return Representation::None();
+ return incoming_value_->KnownOptimalRepresentation();
+ }
DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue)
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Jun 3 08:32:22 2013
+++ /branches/bleeding_edge/src/hydrogen.cc Mon Jun 3 09:57:36 2013
@@ -2878,23 +2878,6 @@
for (int i = 0; i < phi_count; ++i) {
phi_list->at(i)->SimplifyConstantInputs();
}
-
- // Use the phi reachability information from step 2 to
- // push information about values which can't be converted to integer
- // without deoptimization through the phi use-def chains, avoiding
- // unnecessary deoptimizations later.
- for (int i = 0; i < phi_count; ++i) {
- HPhi* phi = phi_list->at(i);
- bool cti = phi->AllOperandsConvertibleToInteger();
- if (cti) continue;
-
- for (BitVector::Iterator it(connected_phis.at(i));
- !it.Done();
- it.Advance()) {
- HPhi* phi = phi_list->at(it.Current());
- phi->set_is_convertible_to_integer(false);
- }
- }
// Use the phi reachability information from step 2 to
// sum up the non-phi use counts of all connected phis.
=======================================
--- /branches/bleeding_edge/src/lithium-allocator.cc Thu May 23 01:32:07
2013
+++ /branches/bleeding_edge/src/lithium-allocator.cc Mon Jun 3 09:57:36
2013
@@ -1057,7 +1057,7 @@
LInstruction* branch =
InstructionAt(cur_block->last_instruction_index());
if (branch->HasPointerMap()) {
- if (phi->representation().IsSmiOrTagged()) {
+ if (phi->representation().IsTagged() && !phi->type().IsSmi()) {
branch->pointer_map()->RecordPointer(phi_operand, zone());
} else if (!phi->representation().IsDouble()) {
branch->pointer_map()->RecordUntagged(phi_operand, zone());
@@ -1640,7 +1640,7 @@
bool LAllocator::HasTaggedValue(int virtual_register) const {
HValue* value = graph_->LookupValue(virtual_register);
if (value == NULL) return false;
- return value->representation().IsSmiOrTagged();
+ return value->representation().IsTagged() && !value->type().IsSmi();
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.