Revision: 21851
Author:   [email protected]
Date:     Mon Jun 16 10:42:39 2014 UTC
Log:      Reuse AstValueFactory when optimizing.

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=
[email protected]

Review URL: https://codereview.chromium.org/334173003
http://code.google.com/p/v8/source/detail?r=21851

Modified:
 /branches/bleeding_edge/src/compiler.cc
 /branches/bleeding_edge/src/compiler.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/parser.cc

=======================================
--- /branches/bleeding_edge/src/compiler.cc     Fri Jun 13 13:31:56 2014 UTC
+++ /branches/bleeding_edge/src/compiler.cc     Mon Jun 16 10:42:39 2014 UTC
@@ -39,7 +39,8 @@
       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);
 }

@@ -53,7 +54,8 @@
       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);
 }

@@ -69,7 +71,8 @@
       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);
 }

@@ -82,7 +85,8 @@
       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;
 }
@@ -135,7 +139,7 @@
 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.
=======================================
--- /branches/bleeding_edge/src/compiler.h      Fri Jun 13 13:31:56 2014 UTC
+++ /branches/bleeding_edge/src/compiler.h      Mon Jun 16 10:42:39 2014 UTC
@@ -323,8 +323,10 @@
   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:
@@ -471,6 +473,7 @@
   int optimization_id_;

   AstValueFactory* ast_value_factory_;
+  bool ast_value_factory_owned_;

   DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
 };
=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Mon Jun 16 08:41:29 2014 UTC
+++ /branches/bleeding_edge/src/hydrogen.cc     Mon Jun 16 10:42:39 2014 UTC
@@ -7625,6 +7625,9 @@

   // 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()) {
=======================================
--- /branches/bleeding_edge/src/parser.cc       Fri Jun 13 13:31:56 2014 UTC
+++ /branches/bleeding_edge/src/parser.cc       Mon Jun 16 10:42:39 2014 UTC
@@ -4793,9 +4793,11 @@

 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
@@ -4830,7 +4832,9 @@
   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);
 }

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to