namespace internal {
-CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone)
+CompilationInfo::CompilationInfo(Handle<Script> script,
+ Zone* zone,
+ Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE)),
script_(script),
osr_ast_id_(BailoutId::None()) {
- Initialize(script->GetIsolate(), BASE, zone);
+ Initialize(script->GetIsolate(), BASE, zone, phase_zone);
}
CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
- Zone* zone)
+ Zone* zone,
+ Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
shared_info_(shared_info),
script_(Handle<Script>(Script::cast(shared_info->script()))),
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)),
closure_(closure),
shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
script_(Handle<Script>(Script::cast(shared_info_->script()))),
context_(closure->context()),
osr_ast_id_(BailoutId::None()) {
- Initialize(script_->GetIsolate(), BASE, zone);
+ Initialize(script_->GetIsolate(), BASE, zone, phase_zone);
}
CompilationInfo::CompilationInfo(HydrogenCodeStub* stub,
- Isolate* isolate, Zone* zone)
+ Isolate* isolate,
+ Zone* zone,
+ Zone* phase_zone)
: flags_(LanguageModeField::encode(CLASSIC_MODE) |
IsLazy::encode(true)),
osr_ast_id_(BailoutId::None()) {
- Initialize(isolate, STUB, zone);
+ Initialize(isolate, STUB, zone, phase_zone);
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;
function_ = NULL;
scope_ = NULL;
extension_ = NULL;
pre_parse_data_ = NULL;
zone_ = zone;
+ phase_zone_ = phase_zone;
deferred_handles_ = NULL;
code_stub_ = NULL;
prologue_offset_ = kPrologueOffsetNotSet;
// is constructed based on the resources available at compile-time.
class CompilationInfo {
public:
- CompilationInfo(Handle<JSFunction> closure, Zone* zone);
+ CompilationInfo(Handle<JSFunction> closure, Zone* zone, Zone* phase_zone);
virtual ~CompilationInfo();
Isolate* isolate() {
return isolate_;
}
Zone* zone() { return zone_; }
+ Zone* phase_zone() { return phase_zone_; }
bool is_lazy() const { return IsLazy::decode(flags_); }
bool is_eval() const { return IsEval::decode(flags_); }
bool is_global() const { return IsGlobal::decode(flags_); }
}
protected:
- CompilationInfo(Handle<Script> script, Zone* zone);
- CompilationInfo(Handle<SharedFunctionInfo> shared_info, Zone* zone);
- CompilationInfo(HydrogenCodeStub* stub, Isolate* isolate, Zone* zone);
+ CompilationInfo(Handle<Script> script,
+ 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:
Isolate* isolate_;
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) {
ASSERT(V8::UseCrankshaft());
// The zone from which the compilation pipeline working on this
// CompilationInfo allocates.
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_;
class CompilationInfoWithZone: public CompilationInfo {
public:
explicit CompilationInfoWithZone(Handle<Script> script)
- : CompilationInfo(script, &zone_),
+ : CompilationInfo(script, &zone_, &phase_zone_),
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)
- : CompilationInfo(shared_info, &zone_),
+ : CompilationInfo(shared_info, &zone_, &phase_zone_),
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)
- : CompilationInfo(closure, &zone_),
+ : CompilationInfo(closure, &zone_, &phase_zone_),
zone_(closure->GetIsolate()),
- zone_scope_(&zone_, DELETE_ON_EXIT) {}
+ zone_scope_(&zone_, DELETE_ON_EXIT),
+ phase_zone_(closure->GetIsolate()) {}
CompilationInfoWithZone(HydrogenCodeStub* stub, Isolate* isolate)
- : CompilationInfo(stub, isolate, &zone_),
+ : CompilationInfo(stub, isolate, &zone_, &phase_zone_),
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
// zone scope and get rid of dependent maps even when the destructor is
private:
Zone zone_;
ZoneScope zone_scope_;
+ Zone phase_zone_;
};
: graph_(graph),
info_(info),
removed_side_effects_(false),
- block_side_effects_(graph->blocks()->length(), graph->zone()),
- loop_side_effects_(graph->blocks()->length(), graph->zone()),
- visited_on_paths_(graph->zone(), graph->blocks()->length()) {
+ phase_zone_(info->phase_zone()),
+ phase_zone_scope_(phase_zone_, DELETE_ON_EXIT),
+ 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());
block_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
- graph_->zone());
+ phase_zone_);
loop_side_effects_.AddBlock(GVNFlagSet(), graph_->blocks()->length(),
- graph_->zone());
+ phase_zone_);
}
bool HGlobalValueNumberer::Analyze() {
// GvnBasicBlockState instances.
void HGlobalValueNumberer::AnalyzeGraph() {
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::CreateEntry(zone(), entry_block, entry_map);
+ GvnBasicBlockState::CreateEntry(phase_zone(), entry_block, entry_map);
while (current != NULL) {
HBasicBlock* block = current->block();
if (instr->HasSideEffects()) removed_side_effects_ = true;
instr->DeleteAndReplaceWith(other);
} else {
- map->Add(instr, zone());
+ map->Add(instr, phase_zone());
}
}
if (instr->IsLinked() &&
HBasicBlock* dominator_block;
GvnBasicBlockState* next =
- current->next_in_dominator_tree_traversal(zone(), &dominator_block);
+ current->next_in_dominator_tree_traversal(phase_zone(),
+ &dominator_block);
if (next != NULL) {
HBasicBlock* dominated = next->block();
HGraph* graph() { return graph_; }
CompilationInfo* info() { return info_; }
- Zone* zone() const { return graph_->zone(); }
+ Zone* phase_zone() const { return info_->phase_zone(); }
HGraph* graph_;
CompilationInfo* info_;
bool removed_side_effects_;
+ Zone* phase_zone_;
+ ZoneScope phase_zone_scope_;
+
// A map of block IDs to their side effects.
ZoneList<GVNFlagSet> block_side_effects_;
}
// Parse and allocate variables.
- CompilationInfo target_info(target, zone());
+ CompilationInfo target_info(target, zone(), current_info()->phase_zone());
Handle<SharedFunctionInfo> target_shared(target->shared());
if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) {
if (target_info.isolate()->has_pending_exception()) {