Eliminate use of ZONE macro in BitVector class and pass a zone explicitly.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10791 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
fschneider@chromium.org 2012-02-22 11:40:28 +00:00
parent c9aa19afcd
commit 7de6be06cf
6 changed files with 35 additions and 33 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2011 the V8 project authors. All rights reserved. // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
@ -85,18 +85,18 @@ class BitVector: public ZoneObject {
friend class BitVector; friend class BitVector;
}; };
explicit BitVector(int length) BitVector(int length, Zone* zone)
: length_(length), : length_(length),
data_length_(SizeFor(length)), data_length_(SizeFor(length)),
data_(ZONE->NewArray<uint32_t>(data_length_)) { data_(zone->NewArray<uint32_t>(data_length_)) {
ASSERT(length > 0); ASSERT(length > 0);
Clear(); Clear();
} }
BitVector(const BitVector& other) BitVector(const BitVector& other, Zone* zone)
: length_(other.length()), : length_(other.length()),
data_length_(SizeFor(length_)), data_length_(SizeFor(length_)),
data_(ZONE->NewArray<uint32_t>(data_length_)) { data_(zone->NewArray<uint32_t>(data_length_)) {
CopyFrom(other); CopyFrom(other);
} }

View File

@ -446,7 +446,7 @@ class ReachabilityAnalyzer BASE_EMBEDDED {
HBasicBlock* dont_visit) HBasicBlock* dont_visit)
: visited_count_(0), : visited_count_(0),
stack_(16), stack_(16),
reachable_(block_count), reachable_(block_count, ZONE),
dont_visit_(dont_visit) { dont_visit_(dont_visit) {
PushBlock(entry_block); PushBlock(entry_block);
Analyze(); Analyze();
@ -744,7 +744,7 @@ void HGraph::Canonicalize() {
void HGraph::OrderBlocks() { void HGraph::OrderBlocks() {
HPhase phase("Block ordering"); HPhase phase("Block ordering");
BitVector visited(blocks_.length()); BitVector visited(blocks_.length(), zone());
ZoneList<HBasicBlock*> reverse_result(8); ZoneList<HBasicBlock*> reverse_result(8);
HBasicBlock* start = blocks_[0]; HBasicBlock* start = blocks_[0];
@ -955,7 +955,7 @@ void HGraph::CollectPhis() {
void HGraph::InferTypes(ZoneList<HValue*>* worklist) { void HGraph::InferTypes(ZoneList<HValue*>* worklist) {
BitVector in_worklist(GetMaximumValueID()); BitVector in_worklist(GetMaximumValueID(), zone());
for (int i = 0; i < worklist->length(); ++i) { for (int i = 0; i < worklist->length(); ++i) {
ASSERT(!in_worklist.Contains(worklist->at(i)->id())); ASSERT(!in_worklist.Contains(worklist->at(i)->id()));
in_worklist.Add(worklist->at(i)->id()); in_worklist.Add(worklist->at(i)->id());
@ -1719,7 +1719,9 @@ void HGlobalValueNumberer::AnalyzeBlock(HBasicBlock* block, HValueMap* map) {
class HInferRepresentation BASE_EMBEDDED { class HInferRepresentation BASE_EMBEDDED {
public: public:
explicit HInferRepresentation(HGraph* graph) explicit HInferRepresentation(HGraph* graph)
: graph_(graph), worklist_(8), in_worklist_(graph->GetMaximumValueID()) {} : graph_(graph),
worklist_(8),
in_worklist_(graph->GetMaximumValueID(), graph->zone()) { }
void Analyze(); void Analyze();
@ -1836,7 +1838,7 @@ void HInferRepresentation::Analyze() {
ZoneList<BitVector*> connected_phis(phi_count); ZoneList<BitVector*> connected_phis(phi_count);
for (int i = 0; i < phi_count; ++i) { for (int i = 0; i < phi_count; ++i) {
phi_list->at(i)->InitRealUses(i); phi_list->at(i)->InitRealUses(i);
BitVector* connected_set = new(zone()) BitVector(phi_count); BitVector* connected_set = new(zone()) BitVector(phi_count, graph_->zone());
connected_set->Add(i); connected_set->Add(i);
connected_phis.Add(connected_set); connected_phis.Add(connected_set);
} }
@ -2126,7 +2128,7 @@ void HGraph::MarkDeoptimizeOnUndefined() {
void HGraph::ComputeMinusZeroChecks() { void HGraph::ComputeMinusZeroChecks() {
BitVector visited(GetMaximumValueID()); BitVector visited(GetMaximumValueID(), zone());
for (int i = 0; i < blocks_.length(); ++i) { for (int i = 0; i < blocks_.length(); ++i) {
for (HInstruction* current = blocks_[i]->first(); for (HInstruction* current = blocks_[i]->first();
current != NULL; current != NULL;

View File

@ -1,4 +1,4 @@
// Copyright 2011 the V8 project authors. All rights reserved. // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
@ -584,7 +584,7 @@ void LAllocator::InitializeLivenessAnalysis() {
BitVector* LAllocator::ComputeLiveOut(HBasicBlock* block) { BitVector* LAllocator::ComputeLiveOut(HBasicBlock* block) {
// Compute live out for the given block, except not including backward // Compute live out for the given block, except not including backward
// successor edges. // successor edges.
BitVector* live_out = new(zone_) BitVector(next_virtual_register_); BitVector* live_out = new(zone_) BitVector(next_virtual_register_, zone_);
// Process all successor blocks. // Process all successor blocks.
for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) { for (HSuccessorIterator it(block->end()); !it.Done(); it.Advance()) {

View File

@ -1,4 +1,4 @@
// Copyright 2011 the V8 project authors. All rights reserved. // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
@ -424,7 +424,7 @@ class GrowableBitVector BASE_EMBEDDED {
if (InBitsRange(value)) return; if (InBitsRange(value)) return;
int new_length = bits_ == NULL ? kInitialLength : bits_->length(); int new_length = bits_ == NULL ? kInitialLength : bits_->length();
while (new_length <= value) new_length *= 2; while (new_length <= value) new_length *= 2;
BitVector* new_bits = new(zone) BitVector(new_length); BitVector* new_bits = new(zone) BitVector(new_length, zone);
if (bits_ != NULL) new_bits->CopyFrom(*bits_); if (bits_ != NULL) new_bits->CopyFrom(*bits_);
bits_ = new_bits; bits_ = new_bits;
} }

View File

@ -453,11 +453,10 @@ class LEnvironment: public ZoneObject {
parameter_count_(parameter_count), parameter_count_(parameter_count),
pc_offset_(-1), pc_offset_(-1),
values_(value_count), values_(value_count),
is_tagged_(value_count), is_tagged_(value_count, closure->GetHeap()->isolate()->zone()),
spilled_registers_(NULL), spilled_registers_(NULL),
spilled_double_registers_(NULL), spilled_double_registers_(NULL),
outer_(outer) { outer_(outer) { }
}
Handle<JSFunction> closure() const { return closure_; } Handle<JSFunction> closure() const { return closure_; }
int arguments_stack_height() const { return arguments_stack_height_; } int arguments_stack_height() const { return arguments_stack_height_; }

View File

@ -1,4 +1,4 @@
// Copyright 2010 the V8 project authors. All rights reserved. // Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are // modification, are permitted provided that the following conditions are
// met: // met:
@ -36,16 +36,17 @@ using namespace v8::internal;
TEST(BitVector) { TEST(BitVector) {
v8::internal::V8::Initialize(NULL); v8::internal::V8::Initialize(NULL);
ZoneScope zone(Isolate::Current(), DELETE_ON_EXIT); ZoneScope zone_scope(Isolate::Current(), DELETE_ON_EXIT);
Zone* zone = ZONE;
{ {
BitVector v(15); BitVector v(15, zone);
v.Add(1); v.Add(1);
CHECK(v.Contains(1)); CHECK(v.Contains(1));
v.Remove(0); v.Remove(0);
CHECK(!v.Contains(0)); CHECK(!v.Contains(0));
v.Add(0); v.Add(0);
v.Add(1); v.Add(1);
BitVector w(15); BitVector w(15, zone);
w.Add(1); w.Add(1);
v.Intersect(w); v.Intersect(w);
CHECK(!v.Contains(0)); CHECK(!v.Contains(0));
@ -53,7 +54,7 @@ TEST(BitVector) {
} }
{ {
BitVector v(64); BitVector v(64, zone);
v.Add(27); v.Add(27);
v.Add(30); v.Add(30);
v.Add(31); v.Add(31);
@ -71,9 +72,9 @@ TEST(BitVector) {
} }
{ {
BitVector v(15); BitVector v(15, zone);
v.Add(0); v.Add(0);
BitVector w(15); BitVector w(15, zone);
w.Add(1); w.Add(1);
v.Union(w); v.Union(w);
CHECK(v.Contains(0)); CHECK(v.Contains(0));
@ -81,13 +82,13 @@ TEST(BitVector) {
} }
{ {
BitVector v(15); BitVector v(15, zone);
v.Add(0); v.Add(0);
BitVector w(15); BitVector w(15, zone);
w = v; w = v;
CHECK(w.Contains(0)); CHECK(w.Contains(0));
w.Add(1); w.Add(1);
BitVector u(w); BitVector u(w, zone);
CHECK(u.Contains(0)); CHECK(u.Contains(0));
CHECK(u.Contains(1)); CHECK(u.Contains(1));
v.Union(w); v.Union(w);
@ -96,9 +97,9 @@ TEST(BitVector) {
} }
{ {
BitVector v(35); BitVector v(35, zone);
v.Add(0); v.Add(0);
BitVector w(35); BitVector w(35, zone);
w.Add(33); w.Add(33);
v.Union(w); v.Union(w);
CHECK(v.Contains(0)); CHECK(v.Contains(0));
@ -106,15 +107,15 @@ TEST(BitVector) {
} }
{ {
BitVector v(35); BitVector v(35, zone);
v.Add(32); v.Add(32);
v.Add(33); v.Add(33);
BitVector w(35); BitVector w(35, zone);
w.Add(33); w.Add(33);
v.Intersect(w); v.Intersect(w);
CHECK(!v.Contains(32)); CHECK(!v.Contains(32));
CHECK(v.Contains(33)); CHECK(v.Contains(33));
BitVector r(35); BitVector r(35, zone);
r.CopyFrom(v); r.CopyFrom(v);
CHECK(!r.Contains(32)); CHECK(!r.Contains(32));
CHECK(r.Contains(33)); CHECK(r.Contains(33));