Commit 13a7c993 authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Add phase zone to CompilationInfo and use it in GVN pass.

The phase_zone of CompilationInfo is intended for local allocations that
are freed at the end of the phase.

R=danno@chromium.org
BUG=

Review URL: https://codereview.chromium.org/17573003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15294 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 264b7255
...@@ -53,46 +53,56 @@ namespace v8 { ...@@ -53,46 +53,56 @@ namespace v8 {
namespace internal { namespace internal {
CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone) CompilationInfo::CompilationInfo(Handle<Script> script,
Zone* zone,
Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE)), : flags_(LanguageModeField::encode(CLASSIC_MODE)),
script_(script), script_(script),
osr_ast_id_(BailoutId::None()) { osr_ast_id_(BailoutId::None()) {
Initialize(script->GetIsolate(), BASE, zone); Initialize(script->GetIsolate(), BASE, zone, phase_zone);
} }
CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone) Zone* zone,
Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
shared_info_(shared_info), shared_info_(shared_info),
script_(Handle<Script>(Script::cast(shared_info->script()))), script_(Handle<Script>(Script::cast(shared_info->script()))),
osr_ast_id_(BailoutId::None()) { osr_ast_id_(BailoutId::None()) {
Initialize(script_->GetIsolate(), BASE, zone); Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
} }
CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone) CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
Zone* zone,
Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)), : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
closure_(closure), closure_(closure),
shared_info_(Handle<SharedFunctionInfo>(closure->shared())), shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
script_(Handle<Script>(Script::cast(shared_info_->script()))), script_(Handle<Script>(Script::cast(shared_info_->script()))),
context_(closure->context()), context_(closure->context()),
osr_ast_id_(BailoutId::None()) { osr_ast_id_(BailoutId::None()) {
Initialize(script_->GetIsolate(), BASE, zone); Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
} }
CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, CompilationInfo::CompilationInfo(HydrogenCodeStub* stub,
Isolate* isolate, Zone* zone) Isolate* isolate,
Zone* zone,
Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | : flags_(LanguageModeField::encode(CLASSIC_MODE) |
IsLazy::encode(true)), IsLazy::encode(true)),
osr_ast_id_(BailoutId::None()) { osr_ast_id_(BailoutId::None()) {
Initialize(isolate, STUB, zone); Initialize(isolate, STUB, zone, phase_zone);
code_stub_ = stub; code_stub_ = stub;
} }
void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) { void CompilationInfo::Initialize(Isolate* isolate,
Mode mode,
Zone* zone,
Zone* phase_zone) {
isolate_ = isolate; isolate_ = isolate;
function_ = NULL; function_ = NULL;
scope_ = NULL; scope_ = NULL;
...@@ -100,6 +110,7 @@ void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) { ...@@ -100,6 +110,7 @@ void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) {
extension_ = NULL; extension_ = NULL;
pre_parse_data_ = NULL; pre_parse_data_ = NULL;
zone_ = zone; zone_ = zone;
phase_zone_ = phase_zone;
deferred_handles_ = NULL; deferred_handles_ = NULL;
code_stub_ = NULL; code_stub_ = NULL;
prologue_offset_ = kPrologueOffsetNotSet; prologue_offset_ = kPrologueOffsetNotSet;
......
...@@ -57,7 +57,7 @@ struct OffsetRange { ...@@ -57,7 +57,7 @@ struct OffsetRange {
// is constructed based on the resources available at compile-time. // is constructed based on the resources available at compile-time.
class CompilationInfo { class CompilationInfo {
public: public:
CompilationInfo(Handle<JSFunction> closure, Zone* zone); CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_zone);
virtual ~CompilationInfo(); virtual ~CompilationInfo();
Isolate* isolate() { Isolate* isolate() {
...@@ -65,6 +65,7 @@ class CompilationInfo { ...@@ -65,6 +65,7 @@ class CompilationInfo {
return isolate_; return isolate_;
} }
Zone* zone() { return zone_; } Zone* zone() { return zone_; }
Zone* phase_zone() { return phase_zone_; }
bool is_lazy() const { return IsLazy::decode(flags_); } bool is_lazy() const { return IsLazy::decode(flags_); }
bool is_eval() const { return IsEval::decode(flags_); } bool is_eval() const { return IsEval::decode(flags_); }
bool is_global() const { return IsGlobal::decode(flags_); } bool is_global() const { return IsGlobal::decode(flags_); }
...@@ -300,9 +301,16 @@ class CompilationInfo { ...@@ -300,9 +301,16 @@ class CompilationInfo {
} }
protected: protected:
CompilationInfo(Handle<Script> script, Zone* zone); CompilationInfo(Handle<Script> script,
CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone); Zone* zone,
CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone); Zone* phase_zone);
CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone,
Zone* phase_zone);
CompilationInfo(HydrogenCodeStub* stub,
Isolate* isolate,
Zone* zone,
Zone* phase_zone);
private: private:
Isolate* isolate_; Isolate* isolate_;
...@@ -320,7 +328,7 @@ class CompilationInfo { ...@@ -320,7 +328,7 @@ class CompilationInfo {
DEPENDENT_MAP_ABORT DEPENDENT_MAP_ABORT
}; };
void Initialize(Isolate* isolate, Mode mode, Zone* zone); void Initialize(Isolate* isolate, Mode mode, Zone* zone, Zone* phase_zone);
void SetMode(Mode mode) { void SetMode(Mode mode) {
ASSERT(V8::UseCrankshaft()); ASSERT(V8::UseCrankshaft());
...@@ -394,6 +402,9 @@ class CompilationInfo { ...@@ -394,6 +402,9 @@ class CompilationInfo {
// The zone from which the compilation pipeline working on this // The zone from which the compilation pipeline working on this
// CompilationInfo allocates. // CompilationInfo allocates.
Zone* zone_; Zone* zone_;
// The phase zone where allocations local to a specific phase are
// performed; be aware that this zone is cleared after each phase
Zone* phase_zone_;
DeferredHandles* deferred_handles_; DeferredHandles* deferred_handles_;
...@@ -428,21 +439,25 @@ class CompilationInfo { ...@@ -428,21 +439,25 @@ class CompilationInfo {
class CompilationInfoWithZone: public CompilationInfo { class CompilationInfoWithZone: public CompilationInfo {
public: public:
explicit CompilationInfoWithZone(Handle<Script> script) explicit CompilationInfoWithZone(Handle<Script> script)
: CompilationInfo(script, &zone_), : CompilationInfo(script, &zone_, &phase_zone_),
zone_(script->GetIsolate()), zone_(script->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {} zone_scope_(&zone_, DELETE_ON_EXIT),
phase_zone_(script->GetIsolate()) {}
explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info) explicit CompilationInfoWithZone(Handle<SharedFunctionInfo> shared_info)
: CompilationInfo(shared_info, &zone_), : CompilationInfo(shared_info, &zone_, &phase_zone_),
zone_(shared_info->GetIsolate()), zone_(shared_info->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {} zone_scope_(&zone_, DELETE_ON_EXIT),
phase_zone_(shared_info->GetIsolate()) {}
explicit CompilationInfoWithZone(Handle<JSFunction> closure) explicit CompilationInfoWithZone(Handle<JSFunction> closure)
: CompilationInfo(closure, &zone_), : CompilationInfo(closure, &zone_, &phase_zone_),
zone_(closure->GetIsolate()), zone_(closure->GetIsolate()),
zone_scope_(&zone_, DELETE_ON_EXIT) {} zone_scope_(&zone_, DELETE_ON_EXIT),
phase_zone_(closure->GetIsolate()) {}
CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate) CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
: CompilationInfo(stub, isolate, &zone_), : CompilationInfo(stub, isolate, &zone_, &phase_zone_),
zone_(isolate), zone_(isolate),
zone_scope_(&zone_, DELETE_ON_EXIT) {} zone_scope_(&zone_, DELETE_ON_EXIT),
phase_zone_(isolate) {}
// Virtual destructor because a CompilationInfoWithZone has to exit the // Virtual destructor because a CompilationInfoWithZone has to exit the
// zone scope and get rid of dependent maps even when the destructor is // zone scope and get rid of dependent maps even when the destructor is
...@@ -454,6 +469,7 @@ class CompilationInfoWithZone: public CompilationInfo { ...@@ -454,6 +469,7 @@ class CompilationInfoWithZone: public CompilationInfo {
private: private:
Zone zone_; Zone zone_;
ZoneScope zone_scope_; ZoneScope zone_scope_;
Zone phase_zone_;
}; };
......
...@@ -365,14 +365,16 @@ HGlobalValueNumberer::HGlobalValueNumberer(HGraph* graph, CompilationInfo* info) ...@@ -365,14 +365,16 @@ HGlobalValueNumberer::HGlobalValueNumberer(HGraph* graph, CompilationInfo* info)
: graph_(graph), : graph_(graph),
info_(info), info_(info),
removed_side_effects_(false), removed_side_effects_(false),
block_side_effects_(graph->blocks()->length(), graph->zone()), phase_zone_(info->phase_zone()),
loop_side_effects_(graph->blocks()->length(), graph->zone()), phase_zone_scope_(phase_zone_, DELETE_ON_EXIT),
visited_on_paths_(graph->zone(), graph->blocks()->length()) { block_side_effects_(graph->blocks()->length(), phase_zone_),
loop_side_effects_(graph->blocks()->length(), phase_zone_),
visited_on_paths_(phase_zone_, graph->blocks()->length()) {
ASSERT(!AllowHandleAllocation::IsAllowed()); ASSERT(!AllowHandleAllocation::IsAllowed());
block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
graph_->zone()); phase_zone_);
loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(), loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
graph_->zone()); phase_zone_);
} }
bool HGlobalValueNumberer::Analyze() { bool HGlobalValueNumberer::Analyze() {
...@@ -756,9 +758,9 @@ class GvnBasicBlockState: public ZoneObject { ...@@ -756,9 +758,9 @@ class GvnBasicBlockState: public ZoneObject {
// GvnBasicBlockState instances. // GvnBasicBlockState instances.
void HGlobalValueNumberer::AnalyzeGraph() { void HGlobalValueNumberer::AnalyzeGraph() {
HBasicBlock* entry_block = graph_->entry_block(); HBasicBlock* entry_block = graph_->entry_block();
HValueMap* entry_map = new(zone()) HValueMap(zone()); HValueMap* entry_map = new(phase_zone()) HValueMap(phase_zone());
GvnBasicBlockState* current = GvnBasicBlockState* current =
GvnBasicBlockState::CreateEntry(zone(), entry_block, entry_map); GvnBasicBlockState::CreateEntry(phase_zone(), entry_block, entry_map);
while (current != NULL) { while (current != NULL) {
HBasicBlock* block = current->block(); HBasicBlock* block = current->block();
...@@ -800,7 +802,7 @@ void HGlobalValueNumberer::AnalyzeGraph() { ...@@ -800,7 +802,7 @@ void HGlobalValueNumberer::AnalyzeGraph() {
if (instr->HasSideEffects()) removed_side_effects_ = true; if (instr->HasSideEffects()) removed_side_effects_ = true;
instr->DeleteAndReplaceWith(other); instr->DeleteAndReplaceWith(other);
} else { } else {
map->Add(instr, zone()); map->Add(instr, phase_zone());
} }
} }
if (instr->IsLinked() && if (instr->IsLinked() &&
...@@ -826,7 +828,8 @@ void HGlobalValueNumberer::AnalyzeGraph() { ...@@ -826,7 +828,8 @@ void HGlobalValueNumberer::AnalyzeGraph() {
HBasicBlock* dominator_block; HBasicBlock* dominator_block;
GvnBasicBlockState* next = GvnBasicBlockState* next =
current->next_in_dominator_tree_traversal(zone(), &dominator_block); current->next_in_dominator_tree_traversal(phase_zone(),
&dominator_block);
if (next != NULL) { if (next != NULL) {
HBasicBlock* dominated = next->block(); HBasicBlock* dominated = next->block();
......
...@@ -100,12 +100,15 @@ class HGlobalValueNumberer BASE_EMBEDDED { ...@@ -100,12 +100,15 @@ class HGlobalValueNumberer BASE_EMBEDDED {
HGraph* graph() { return graph_; } HGraph* graph() { return graph_; }
CompilationInfo* info() { return info_; } CompilationInfo* info() { return info_; }
Zone* zone() const { return graph_->zone(); } Zone* phase_zone() const { return info_->phase_zone(); }
HGraph* graph_; HGraph* graph_;
CompilationInfo* info_; CompilationInfo* info_;
bool removed_side_effects_; bool removed_side_effects_;
Zone* phase_zone_;
ZoneScope phase_zone_scope_;
// A map of block IDs to their side effects. // A map of block IDs to their side effects.
ZoneList<GVNFlagSet> block_side_effects_; ZoneList<GVNFlagSet> block_side_effects_;
......
...@@ -7938,7 +7938,7 @@ bool HOptimizedGraphBuilder::TryInline(CallKind call_kind, ...@@ -7938,7 +7938,7 @@ bool HOptimizedGraphBuilder::TryInline(CallKind call_kind,
} }
// Parse and allocate variables. // Parse and allocate variables.
CompilationInfo target_info(target, zone()); CompilationInfo target_info(target, zone(), current_info()->phase_zone());
Handle<SharedFunctionInfo> target_shared(target->shared()); Handle<SharedFunctionInfo> target_shared(target->shared());
if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) { if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) {
if (target_info.isolate()->has_pending_exception()) { if (target_info.isolate()->has_pending_exception()) {
......
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