Explicitly use a Zone when allocating Range.

This CL is a step towards removing ZoneObject's new operator without a Zone
parameter, which uses Isolate::Current. For e.g. the bulletben benchmark, this
CL reduces the number of calls to this new operator by roughly 120k, but we are
still left with 780k calls from other sites...

Review URL: https://chromiumcodereview.appspot.com/9487010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10860 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 22e66d39
...@@ -495,9 +495,9 @@ void HValue::RegisterUse(int index, HValue* new_value) { ...@@ -495,9 +495,9 @@ void HValue::RegisterUse(int index, HValue* new_value) {
} }
void HValue::AddNewRange(Range* r) { void HValue::AddNewRange(Range* r, Zone* zone) {
if (!HasRange()) ComputeInitialRange(); if (!HasRange()) ComputeInitialRange(zone);
if (!HasRange()) range_ = new Range(); if (!HasRange()) range_ = new(zone) Range();
ASSERT(HasRange()); ASSERT(HasRange());
r->StackUpon(range_); r->StackUpon(range_);
range_ = r; range_ = r;
...@@ -511,9 +511,9 @@ void HValue::RemoveLastAddedRange() { ...@@ -511,9 +511,9 @@ void HValue::RemoveLastAddedRange() {
} }
void HValue::ComputeInitialRange() { void HValue::ComputeInitialRange(Zone* zone) {
ASSERT(!HasRange()); ASSERT(!HasRange());
range_ = InferRange(); range_ = InferRange(zone);
ASSERT(HasRange()); ASSERT(HasRange());
} }
...@@ -986,15 +986,15 @@ void HInstanceOf::PrintDataTo(StringStream* stream) { ...@@ -986,15 +986,15 @@ void HInstanceOf::PrintDataTo(StringStream* stream) {
} }
Range* HValue::InferRange() { Range* HValue::InferRange(Zone* zone) {
// Untagged integer32 cannot be -0, all other representations can. // Untagged integer32 cannot be -0, all other representations can.
Range* result = new Range(); Range* result = new(zone) Range();
result->set_can_be_minus_zero(!representation().IsInteger32()); result->set_can_be_minus_zero(!representation().IsInteger32());
return result; return result;
} }
Range* HChange::InferRange() { Range* HChange::InferRange(Zone* zone) {
Range* input_range = value()->range(); Range* input_range = value()->range();
if (from().IsInteger32() && if (from().IsInteger32() &&
to().IsTagged() && to().IsTagged() &&
...@@ -1002,46 +1002,46 @@ Range* HChange::InferRange() { ...@@ -1002,46 +1002,46 @@ Range* HChange::InferRange() {
set_type(HType::Smi()); set_type(HType::Smi());
} }
Range* result = (input_range != NULL) Range* result = (input_range != NULL)
? input_range->Copy() ? input_range->Copy(zone)
: HValue::InferRange(); : HValue::InferRange(zone);
if (to().IsInteger32()) result->set_can_be_minus_zero(false); if (to().IsInteger32()) result->set_can_be_minus_zero(false);
return result; return result;
} }
Range* HConstant::InferRange() { Range* HConstant::InferRange(Zone* zone) {
if (has_int32_value_) { if (has_int32_value_) {
Range* result = new Range(int32_value_, int32_value_); Range* result = new(zone) Range(int32_value_, int32_value_);
result->set_can_be_minus_zero(false); result->set_can_be_minus_zero(false);
return result; return result;
} }
return HValue::InferRange(); return HValue::InferRange(zone);
} }
Range* HPhi::InferRange() { Range* HPhi::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
if (block()->IsLoopHeader()) { if (block()->IsLoopHeader()) {
Range* range = new Range(kMinInt, kMaxInt); Range* range = new(zone) Range(kMinInt, kMaxInt);
return range; return range;
} else { } else {
Range* range = OperandAt(0)->range()->Copy(); Range* range = OperandAt(0)->range()->Copy(zone);
for (int i = 1; i < OperandCount(); ++i) { for (int i = 1; i < OperandCount(); ++i) {
range->Union(OperandAt(i)->range()); range->Union(OperandAt(i)->range());
} }
return range; return range;
} }
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
Range* HAdd::InferRange() { Range* HAdd::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
Range* a = left()->range(); Range* a = left()->range();
Range* b = right()->range(); Range* b = right()->range();
Range* res = a->Copy(); Range* res = a->Copy(zone);
if (!res->AddAndCheckOverflow(b)) { if (!res->AddAndCheckOverflow(b)) {
ClearFlag(kCanOverflow); ClearFlag(kCanOverflow);
} }
...@@ -1049,32 +1049,32 @@ Range* HAdd::InferRange() { ...@@ -1049,32 +1049,32 @@ Range* HAdd::InferRange() {
res->set_can_be_minus_zero(m0); res->set_can_be_minus_zero(m0);
return res; return res;
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
Range* HSub::InferRange() { Range* HSub::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
Range* a = left()->range(); Range* a = left()->range();
Range* b = right()->range(); Range* b = right()->range();
Range* res = a->Copy(); Range* res = a->Copy(zone);
if (!res->SubAndCheckOverflow(b)) { if (!res->SubAndCheckOverflow(b)) {
ClearFlag(kCanOverflow); ClearFlag(kCanOverflow);
} }
res->set_can_be_minus_zero(a->CanBeMinusZero() && b->CanBeZero()); res->set_can_be_minus_zero(a->CanBeMinusZero() && b->CanBeZero());
return res; return res;
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
Range* HMul::InferRange() { Range* HMul::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
Range* a = left()->range(); Range* a = left()->range();
Range* b = right()->range(); Range* b = right()->range();
Range* res = a->Copy(); Range* res = a->Copy(zone);
if (!res->MulAndCheckOverflow(b)) { if (!res->MulAndCheckOverflow(b)) {
ClearFlag(kCanOverflow); ClearFlag(kCanOverflow);
} }
...@@ -1083,14 +1083,14 @@ Range* HMul::InferRange() { ...@@ -1083,14 +1083,14 @@ Range* HMul::InferRange() {
res->set_can_be_minus_zero(m0); res->set_can_be_minus_zero(m0);
return res; return res;
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
Range* HDiv::InferRange() { Range* HDiv::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
Range* result = new Range(); Range* result = new(zone) Range();
if (left()->range()->CanBeMinusZero()) { if (left()->range()->CanBeMinusZero()) {
result->set_can_be_minus_zero(true); result->set_can_be_minus_zero(true);
} }
...@@ -1108,15 +1108,15 @@ Range* HDiv::InferRange() { ...@@ -1108,15 +1108,15 @@ Range* HDiv::InferRange() {
} }
return result; return result;
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
Range* HMod::InferRange() { Range* HMod::InferRange(Zone* zone) {
if (representation().IsInteger32()) { if (representation().IsInteger32()) {
Range* a = left()->range(); Range* a = left()->range();
Range* result = new Range(); Range* result = new(zone) Range();
if (a->CanBeMinusZero() || a->CanBeNegative()) { if (a->CanBeMinusZero() || a->CanBeNegative()) {
result->set_can_be_minus_zero(true); result->set_can_be_minus_zero(true);
} }
...@@ -1125,7 +1125,7 @@ Range* HMod::InferRange() { ...@@ -1125,7 +1125,7 @@ Range* HMod::InferRange() {
} }
return result; return result;
} else { } else {
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
...@@ -1324,8 +1324,8 @@ void HBinaryOperation::PrintDataTo(StringStream* stream) { ...@@ -1324,8 +1324,8 @@ void HBinaryOperation::PrintDataTo(StringStream* stream) {
} }
Range* HBitwise::InferRange() { Range* HBitwise::InferRange(Zone* zone) {
if (op() == Token::BIT_XOR) return HValue::InferRange(); if (op() == Token::BIT_XOR) return HValue::InferRange(zone);
int32_t left_mask = (left()->range() != NULL) int32_t left_mask = (left()->range() != NULL)
? left()->range()->Mask() ? left()->range()->Mask()
: 0xffffffff; : 0xffffffff;
...@@ -1336,28 +1336,28 @@ Range* HBitwise::InferRange() { ...@@ -1336,28 +1336,28 @@ Range* HBitwise::InferRange() {
? left_mask & right_mask ? left_mask & right_mask
: left_mask | right_mask; : left_mask | right_mask;
return (result_mask >= 0) return (result_mask >= 0)
? new Range(0, result_mask) ? new(zone) Range(0, result_mask)
: HValue::InferRange(); : HValue::InferRange(zone);
} }
Range* HSar::InferRange() { Range* HSar::InferRange(Zone* zone) {
if (right()->IsConstant()) { if (right()->IsConstant()) {
HConstant* c = HConstant::cast(right()); HConstant* c = HConstant::cast(right());
if (c->HasInteger32Value()) { if (c->HasInteger32Value()) {
Range* result = (left()->range() != NULL) Range* result = (left()->range() != NULL)
? left()->range()->Copy() ? left()->range()->Copy(zone)
: new Range(); : new(zone) Range();
result->Sar(c->Integer32Value()); result->Sar(c->Integer32Value());
result->set_can_be_minus_zero(false); result->set_can_be_minus_zero(false);
return result; return result;
} }
} }
return HValue::InferRange(); return HValue::InferRange(zone);
} }
Range* HShr::InferRange() { Range* HShr::InferRange(Zone* zone) {
if (right()->IsConstant()) { if (right()->IsConstant()) {
HConstant* c = HConstant::cast(right()); HConstant* c = HConstant::cast(right());
if (c->HasInteger32Value()) { if (c->HasInteger32Value()) {
...@@ -1365,53 +1365,54 @@ Range* HShr::InferRange() { ...@@ -1365,53 +1365,54 @@ Range* HShr::InferRange() {
if (left()->range()->CanBeNegative()) { if (left()->range()->CanBeNegative()) {
// Only compute bounds if the result always fits into an int32. // Only compute bounds if the result always fits into an int32.
return (shift_count >= 1) return (shift_count >= 1)
? new Range(0, static_cast<uint32_t>(0xffffffff) >> shift_count) ? new(zone) Range(0,
: new Range(); static_cast<uint32_t>(0xffffffff) >> shift_count)
: new(zone) Range();
} else { } else {
// For positive inputs we can use the >> operator. // For positive inputs we can use the >> operator.
Range* result = (left()->range() != NULL) Range* result = (left()->range() != NULL)
? left()->range()->Copy() ? left()->range()->Copy(zone)
: new Range(); : new(zone) Range();
result->Sar(c->Integer32Value()); result->Sar(c->Integer32Value());
result->set_can_be_minus_zero(false); result->set_can_be_minus_zero(false);
return result; return result;
} }
} }
} }
return HValue::InferRange(); return HValue::InferRange(zone);
} }
Range* HShl::InferRange() { Range* HShl::InferRange(Zone* zone) {
if (right()->IsConstant()) { if (right()->IsConstant()) {
HConstant* c = HConstant::cast(right()); HConstant* c = HConstant::cast(right());
if (c->HasInteger32Value()) { if (c->HasInteger32Value()) {
Range* result = (left()->range() != NULL) Range* result = (left()->range() != NULL)
? left()->range()->Copy() ? left()->range()->Copy(zone)
: new Range(); : new(zone) Range();
result->Shl(c->Integer32Value()); result->Shl(c->Integer32Value());
result->set_can_be_minus_zero(false); result->set_can_be_minus_zero(false);
return result; return result;
} }
} }
return HValue::InferRange(); return HValue::InferRange(zone);
} }
Range* HLoadKeyedSpecializedArrayElement::InferRange() { Range* HLoadKeyedSpecializedArrayElement::InferRange(Zone* zone) {
switch (elements_kind()) { switch (elements_kind()) {
case EXTERNAL_PIXEL_ELEMENTS: case EXTERNAL_PIXEL_ELEMENTS:
return new Range(0, 255); return new(zone) Range(0, 255);
case EXTERNAL_BYTE_ELEMENTS: case EXTERNAL_BYTE_ELEMENTS:
return new Range(-128, 127); return new(zone) Range(-128, 127);
case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
return new Range(0, 255); return new(zone) Range(0, 255);
case EXTERNAL_SHORT_ELEMENTS: case EXTERNAL_SHORT_ELEMENTS:
return new Range(-32768, 32767); return new(zone) Range(-32768, 32767);
case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
return new Range(0, 65535); return new(zone) Range(0, 65535);
default: default:
return HValue::InferRange(); return HValue::InferRange(zone);
} }
} }
......
...@@ -236,10 +236,14 @@ class Range: public ZoneObject { ...@@ -236,10 +236,14 @@ class Range: public ZoneObject {
int32_t upper() const { return upper_; } int32_t upper() const { return upper_; }
int32_t lower() const { return lower_; } int32_t lower() const { return lower_; }
Range* next() const { return next_; } Range* next() const { return next_; }
Range* CopyClearLower() const { return new Range(kMinInt, upper_); } Range* CopyClearLower(Zone* zone) const {
Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); } return new(zone) Range(kMinInt, upper_);
Range* Copy() const { }
Range* result = new Range(lower_, upper_); Range* CopyClearUpper(Zone* zone) const {
return new(zone) Range(lower_, kMaxInt);
}
Range* Copy(Zone* zone) const {
Range* result = new(zone) Range(lower_, upper_);
result->set_can_be_minus_zero(CanBeMinusZero()); result->set_can_be_minus_zero(CanBeMinusZero());
return result; return result;
} }
...@@ -683,9 +687,9 @@ class HValue: public ZoneObject { ...@@ -683,9 +687,9 @@ class HValue: public ZoneObject {
Range* range() const { return range_; } Range* range() const { return range_; }
bool HasRange() const { return range_ != NULL; } bool HasRange() const { return range_ != NULL; }
void AddNewRange(Range* r); void AddNewRange(Range* r, Zone* zone);
void RemoveLastAddedRange(); void RemoveLastAddedRange();
void ComputeInitialRange(); void ComputeInitialRange(Zone* zone);
// Representation helpers. // Representation helpers.
virtual Representation RequiredInputRepresentation(int index) = 0; virtual Representation RequiredInputRepresentation(int index) = 0;
...@@ -730,7 +734,7 @@ class HValue: public ZoneObject { ...@@ -730,7 +734,7 @@ class HValue: public ZoneObject {
return false; return false;
} }
virtual void RepresentationChanged(Representation to) { } virtual void RepresentationChanged(Representation to) { }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
virtual void DeleteFromGraph() = 0; virtual void DeleteFromGraph() = 0;
virtual void InternalSetOperandAt(int index, HValue* value) = 0; virtual void InternalSetOperandAt(int index, HValue* value) = 0;
void clear_block() { void clear_block() {
...@@ -1208,7 +1212,7 @@ class HChange: public HUnaryOperation { ...@@ -1208,7 +1212,7 @@ class HChange: public HUnaryOperation {
return from(); return from();
} }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
virtual void PrintDataTo(StringStream* stream); virtual void PrintDataTo(StringStream* stream);
...@@ -2299,7 +2303,7 @@ class HPhi: public HValue { ...@@ -2299,7 +2303,7 @@ class HPhi: public HValue {
return Representation::None(); return Representation::None();
} }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
virtual Representation RequiredInputRepresentation(int index) { virtual Representation RequiredInputRepresentation(int index) {
return representation(); return representation();
} }
...@@ -2477,7 +2481,7 @@ class HConstant: public HTemplateInstruction<0> { ...@@ -2477,7 +2481,7 @@ class HConstant: public HTemplateInstruction<0> {
DECLARE_CONCRETE_INSTRUCTION(Constant) DECLARE_CONCRETE_INSTRUCTION(Constant)
protected: protected:
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
virtual bool DataEquals(HValue* other) { virtual bool DataEquals(HValue* other) {
HConstant* other_constant = HConstant::cast(other); HConstant* other_constant = HConstant::cast(other);
...@@ -3155,7 +3159,7 @@ class HAdd: public HArithmeticBinaryOperation { ...@@ -3155,7 +3159,7 @@ class HAdd: public HArithmeticBinaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
}; };
...@@ -3178,7 +3182,7 @@ class HSub: public HArithmeticBinaryOperation { ...@@ -3178,7 +3182,7 @@ class HSub: public HArithmeticBinaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
}; };
...@@ -3206,7 +3210,7 @@ class HMul: public HArithmeticBinaryOperation { ...@@ -3206,7 +3210,7 @@ class HMul: public HArithmeticBinaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
}; };
...@@ -3239,7 +3243,7 @@ class HMod: public HArithmeticBinaryOperation { ...@@ -3239,7 +3243,7 @@ class HMod: public HArithmeticBinaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
}; };
...@@ -3264,7 +3268,7 @@ class HDiv: public HArithmeticBinaryOperation { ...@@ -3264,7 +3268,7 @@ class HDiv: public HArithmeticBinaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
}; };
...@@ -3296,7 +3300,7 @@ class HBitwise: public HBitwiseBinaryOperation { ...@@ -3296,7 +3300,7 @@ class HBitwise: public HBitwiseBinaryOperation {
return op() == HBitwise::cast(other)->op(); return op() == HBitwise::cast(other)->op();
} }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
private: private:
Token::Value op_; Token::Value op_;
...@@ -3308,7 +3312,7 @@ class HShl: public HBitwiseBinaryOperation { ...@@ -3308,7 +3312,7 @@ class HShl: public HBitwiseBinaryOperation {
HShl(HValue* context, HValue* left, HValue* right) HShl(HValue* context, HValue* left, HValue* right)
: HBitwiseBinaryOperation(context, left, right) { } : HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
static HInstruction* NewHShl(Zone* zone, static HInstruction* NewHShl(Zone* zone,
HValue* context, HValue* context,
...@@ -3327,7 +3331,7 @@ class HShr: public HBitwiseBinaryOperation { ...@@ -3327,7 +3331,7 @@ class HShr: public HBitwiseBinaryOperation {
HShr(HValue* context, HValue* left, HValue* right) HShr(HValue* context, HValue* left, HValue* right)
: HBitwiseBinaryOperation(context, left, right) { } : HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
static HInstruction* NewHShr(Zone* zone, static HInstruction* NewHShr(Zone* zone,
HValue* context, HValue* context,
...@@ -3346,7 +3350,7 @@ class HSar: public HBitwiseBinaryOperation { ...@@ -3346,7 +3350,7 @@ class HSar: public HBitwiseBinaryOperation {
HSar(HValue* context, HValue* left, HValue* right) HSar(HValue* context, HValue* left, HValue* right)
: HBitwiseBinaryOperation(context, left, right) { } : HBitwiseBinaryOperation(context, left, right) { }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
static HInstruction* NewHSar(Zone* zone, static HInstruction* NewHSar(Zone* zone,
HValue* context, HValue* context,
...@@ -3936,7 +3940,7 @@ class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> { ...@@ -3936,7 +3940,7 @@ class HLoadKeyedSpecializedArrayElement: public HTemplateInstruction<2> {
HValue* key() { return OperandAt(1); } HValue* key() { return OperandAt(1); }
ElementsKind elements_kind() const { return elements_kind_; } ElementsKind elements_kind() const { return elements_kind_; }
virtual Range* InferRange(); virtual Range* InferRange(Zone* zone);
DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement)
...@@ -4304,8 +4308,8 @@ class HStringCharCodeAt: public HTemplateInstruction<3> { ...@@ -4304,8 +4308,8 @@ class HStringCharCodeAt: public HTemplateInstruction<3> {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange() { virtual Range* InferRange(Zone* zone) {
return new Range(0, String::kMaxUC16CharCode); return new(zone) Range(0, String::kMaxUC16CharCode);
} }
}; };
...@@ -4357,8 +4361,8 @@ class HStringLength: public HUnaryOperation { ...@@ -4357,8 +4361,8 @@ class HStringLength: public HUnaryOperation {
protected: protected:
virtual bool DataEquals(HValue* other) { return true; } virtual bool DataEquals(HValue* other) { return true; }
virtual Range* InferRange() { virtual Range* InferRange(Zone* zone) {
return new Range(0, String::kMaxLength); return new(zone) Range(0, String::kMaxLength);
} }
}; };
......
...@@ -979,7 +979,8 @@ void HGraph::InferTypes(ZoneList<HValue*>* worklist) { ...@@ -979,7 +979,8 @@ void HGraph::InferTypes(ZoneList<HValue*>* worklist) {
class HRangeAnalysis BASE_EMBEDDED { class HRangeAnalysis BASE_EMBEDDED {
public: public:
explicit HRangeAnalysis(HGraph* graph) : graph_(graph), changed_ranges_(16) {} explicit HRangeAnalysis(HGraph* graph) :
graph_(graph), zone_(graph->isolate()->zone()), changed_ranges_(16) { }
void Analyze(); void Analyze();
...@@ -993,6 +994,7 @@ class HRangeAnalysis BASE_EMBEDDED { ...@@ -993,6 +994,7 @@ class HRangeAnalysis BASE_EMBEDDED {
void AddRange(HValue* value, Range* range); void AddRange(HValue* value, Range* range);
HGraph* graph_; HGraph* graph_;
Zone* zone_;
ZoneList<HValue*> changed_ranges_; ZoneList<HValue*> changed_ranges_;
}; };
...@@ -1079,14 +1081,14 @@ void HRangeAnalysis::UpdateControlFlowRange(Token::Value op, ...@@ -1079,14 +1081,14 @@ void HRangeAnalysis::UpdateControlFlowRange(Token::Value op,
if (op == Token::EQ || op == Token::EQ_STRICT) { if (op == Token::EQ || op == Token::EQ_STRICT) {
// The same range has to apply for value. // The same range has to apply for value.
new_range = range->Copy(); new_range = range->Copy(zone_);
} else if (op == Token::LT || op == Token::LTE) { } else if (op == Token::LT || op == Token::LTE) {
new_range = range->CopyClearLower(); new_range = range->CopyClearLower(zone_);
if (op == Token::LT) { if (op == Token::LT) {
new_range->AddConstant(-1); new_range->AddConstant(-1);
} }
} else if (op == Token::GT || op == Token::GTE) { } else if (op == Token::GT || op == Token::GTE) {
new_range = range->CopyClearUpper(); new_range = range->CopyClearUpper(zone_);
if (op == Token::GT) { if (op == Token::GT) {
new_range->AddConstant(1); new_range->AddConstant(1);
} }
...@@ -1101,7 +1103,7 @@ void HRangeAnalysis::UpdateControlFlowRange(Token::Value op, ...@@ -1101,7 +1103,7 @@ void HRangeAnalysis::UpdateControlFlowRange(Token::Value op,
void HRangeAnalysis::InferRange(HValue* value) { void HRangeAnalysis::InferRange(HValue* value) {
ASSERT(!value->HasRange()); ASSERT(!value->HasRange());
if (!value->representation().IsNone()) { if (!value->representation().IsNone()) {
value->ComputeInitialRange(); value->ComputeInitialRange(zone_);
Range* range = value->range(); Range* range = value->range();
TraceRange("Initial inferred range of %d (%s) set to [%d,%d]\n", TraceRange("Initial inferred range of %d (%s) set to [%d,%d]\n",
value->id(), value->id(),
...@@ -1122,7 +1124,7 @@ void HRangeAnalysis::RollBackTo(int index) { ...@@ -1122,7 +1124,7 @@ void HRangeAnalysis::RollBackTo(int index) {
void HRangeAnalysis::AddRange(HValue* value, Range* range) { void HRangeAnalysis::AddRange(HValue* value, Range* range) {
Range* original_range = value->range(); Range* original_range = value->range();
value->AddNewRange(range); value->AddNewRange(range, zone_);
changed_ranges_.Add(value); changed_ranges_.Add(value);
Range* new_range = value->range(); Range* new_range = value->range();
TraceRange("Updated range of %d set to [%d,%d]\n", TraceRange("Updated range of %d set to [%d,%d]\n",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment