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