HOptimizedGraphBuilder::TryInline creates a temporary CompilationInfo and
destroys it, but we don't want the AstValueFactory to be destroyed at the same
time. Reuse the upper CompilationInfo's AstValueFactory.
BUG=
R=yangguo@chromium.org
Review URL: https://codereview.chromium.org/
334173003
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21851
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
parameter_count_(0),
this_has_uses_(true),
optimization_id_(-1),
- ast_value_factory_(NULL) {
+ ast_value_factory_(NULL),
+ ast_value_factory_owned_(false) {
Initialize(script->GetIsolate(), BASE, zone);
}
parameter_count_(0),
this_has_uses_(true),
optimization_id_(-1),
- ast_value_factory_(NULL) {
+ ast_value_factory_(NULL),
+ ast_value_factory_owned_(false) {
Initialize(script_->GetIsolate(), BASE, zone);
}
parameter_count_(0),
this_has_uses_(true),
optimization_id_(-1),
- ast_value_factory_(NULL) {
+ ast_value_factory_(NULL),
+ ast_value_factory_owned_(false) {
Initialize(script_->GetIsolate(), BASE, zone);
}
parameter_count_(0),
this_has_uses_(true),
optimization_id_(-1),
- ast_value_factory_(NULL) {
+ ast_value_factory_(NULL),
+ ast_value_factory_owned_(false) {
Initialize(isolate, STUB, zone);
code_stub_ = stub;
}
CompilationInfo::~CompilationInfo() {
delete deferred_handles_;
delete no_frame_ranges_;
- delete ast_value_factory_;
+ if (ast_value_factory_owned_) delete ast_value_factory_;
#ifdef DEBUG
// Check that no dependent maps have been added or added dependent maps have
// been rolled back or committed.
int optimization_id() const { return optimization_id_; }
AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
- void SetAstValueFactory(AstValueFactory* ast_value_factory) {
+ void SetAstValueFactory(AstValueFactory* ast_value_factory,
+ bool owned = true) {
ast_value_factory_ = ast_value_factory;
+ ast_value_factory_owned_ = owned;
}
protected:
int optimization_id_;
AstValueFactory* ast_value_factory_;
+ bool ast_value_factory_owned_;
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
};
// Parse and allocate variables.
CompilationInfo target_info(target, zone());
+ // Use the same AstValueFactory for creating strings in the sub-compilation
+ // step, but don't transfer ownership to target_info.
+ target_info.SetAstValueFactory(top_info()->ast_value_factory(), false);
Handle<SharedFunctionInfo> target_shared(target->shared());
if (!Parser::Parse(&target_info) || !Scope::Analyze(&target_info)) {
if (target_info.isolate()->has_pending_exception()) {
bool Parser::Parse() {
ASSERT(info()->function() == NULL);
- ASSERT(info()->ast_value_factory() == NULL);
FunctionLiteral* result = NULL;
- ast_value_factory_ = new AstValueFactory(zone());
+ ast_value_factory_ = info()->ast_value_factory();
+ if (ast_value_factory_ == NULL) {
+ ast_value_factory_ = new AstValueFactory(zone());
+ }
if (allow_natives_syntax() || extension_ != NULL) {
// If intrinsics are allowed, the Parser cannot operate independent of the
// V8 heap because of Rumtime. Tell the string table to internalize strings
info()->SetFunction(result);
ast_value_factory_->Internalize(isolate());
// info takes ownership of ast_value_factory_.
- info()->SetAstValueFactory(ast_value_factory_);
+ if (info()->ast_value_factory() == NULL) {
+ info()->SetAstValueFactory(ast_value_factory_);
+ }
ast_value_factory_ = NULL;
return (result != NULL);
}