Revision: 17863
Author: [email protected]
Date: Tue Nov 19 11:41:04 2013 UTC
Log: Constant-folding through HForceRepresentation fix.
Reverts changes in HValue::IsInteger32Constant() made in
https://code.google.com/p/v8/source/detail?r=17787
[email protected], [email protected]
Review URL: https://codereview.chromium.org/68493005
http://code.google.com/p/v8/source/detail?r=17863
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/hydrogen-instructions.cc Mon Nov 18
14:17:33 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.cc Tue Nov 19
11:41:04 2013 UTC
@@ -521,19 +521,12 @@
bool HValue::IsInteger32Constant() {
- HValue* value_to_check = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return value_to_check->IsConstant() &&
- HConstant::cast(value_to_check)->HasInteger32Value();
+ return IsConstant() && HConstant::cast(this)->HasInteger32Value();
}
int32_t HValue::GetInteger32Constant() {
- HValue* constant_value = IsForceRepresentation()
- ? HForceRepresentation::cast(this)->value()
- : this;
- return HConstant::cast(constant_value)->Integer32Value();
+ return HConstant::cast(this)->Integer32Value();
}
@@ -1340,6 +1333,23 @@
void HTypeof::PrintDataTo(StringStream* stream) {
value()->PrintNameTo(stream);
}
+
+
+HInstruction* HForceRepresentation::New(Zone* zone, HValue* context,
+ HValue* value, Representation required_representation) {
+ if (FLAG_fold_constants && value->IsConstant()) {
+ HConstant* c = HConstant::cast(value);
+ if (c->HasNumberValue()) {
+ double double_res = c->DoubleValue();
+ if (TypeInfo::IsInt32Double(double_res)) {
+ return HConstant::New(zone, context,
+ static_cast<int32_t>(double_res),
+ required_representation);
+ }
+ }
+ }
+ return new(zone) HForceRepresentation(value, required_representation);
+}
void HForceRepresentation::PrintDataTo(StringStream* stream) {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Mon Nov 18 17:24:00
2013 UTC
+++ /branches/bleeding_edge/src/hydrogen-instructions.h Tue Nov 19 11:41:04
2013 UTC
@@ -1675,7 +1675,8 @@
class HForceRepresentation V8_FINAL : public HTemplateInstruction<1> {
public:
- DECLARE_INSTRUCTION_FACTORY_P2(HForceRepresentation, HValue*,
Representation);
+ static HInstruction* New(Zone* zone, HValue* context, HValue* value,
+ Representation required_representation);
HValue* value() { return OperandAt(0); }
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc Mon Nov 18 17:24:00 2013 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc Tue Nov 19 11:41:04 2013 UTC
@@ -2078,7 +2078,7 @@
// deopt, leaving the backing store in an invalid state.
if (is_store && IsFastSmiElementsKind(elements_kind) &&
!val->type().IsSmi()) {
- val = Add<HForceRepresentation>(val, Representation::Smi());
+ val = AddUncasted<HForceRepresentation>(val, Representation::Smi());
}
if (IsGrowStoreMode(store_mode)) {
@@ -2195,7 +2195,7 @@
HValue* capacity) {
// The HForceRepresentation is to prevent possible deopt on int-smi
// conversion after allocation but before the new object fields are set.
- capacity = Add<HForceRepresentation>(capacity, Representation::Smi());
+ capacity = AddUncasted<HForceRepresentation>(capacity,
Representation::Smi());
HValue* new_elements = BuildAllocateElements(kind, capacity);
BuildInitializeElementsHeader(new_elements, kind, capacity);
return new_elements;
@@ -2714,10 +2714,12 @@
// These HForceRepresentations are because we store these as fields in
the
// objects we construct, and an int32-to-smi HChange could deopt. Accept
// the deopt possibility now, before allocation occurs.
- capacity = builder()->Add<HForceRepresentation>(capacity,
- Representation::Smi());
- length_field = builder()->Add<HForceRepresentation>(length_field,
-
Representation::Smi());
+ capacity =
+ builder()->AddUncasted<HForceRepresentation>(capacity,
+ Representation::Smi());
+ length_field =
+ builder()->AddUncasted<HForceRepresentation>(length_field,
+ Representation::Smi());
// Allocate (dealing with failure appropriately)
HAllocate* new_object = builder()->Add<HAllocate>(size_in_bytes,
HType::JSArray(), NOT_TENURED, JS_ARRAY_TYPE);
@@ -8267,7 +8269,7 @@
// actual HChange instruction we need is (sometimes) added in a later
// phase, so it is not available now to be used as an input to HAdd and
// as the return value.
- HInstruction* number_input = Add<HForceRepresentation>(Pop(), rep);
+ HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(),
rep);
if (!rep.IsDouble()) {
number_input->SetFlag(HInstruction::kFlexibleRepresentation);
number_input->SetFlag(HInstruction::kCannotBeTagged);
@@ -8514,10 +8516,11 @@
HValue* HGraphBuilder::EnforceNumberType(HValue* number,
Handle<Type> expected) {
if (expected->Is(Type::Smi())) {
- return Add<HForceRepresentation>(number, Representation::Smi());
+ return AddUncasted<HForceRepresentation>(number,
Representation::Smi());
}
if (expected->Is(Type::Signed32())) {
- return Add<HForceRepresentation>(number, Representation::Integer32());
+ return AddUncasted<HForceRepresentation>(number,
+ Representation::Integer32());
}
return number;
}
--
--
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.