Revision: 5839
Author: [email protected]
Date: Wed Nov 17 04:49:27 2010
Log: Store script's line ends in copy-on-write fixed array.

This allows to remove explicit copy from line ends JS accessor which is used for formatting of stack traces.

Eager copying of line ends array might cause multiple full GC collections for huge scripts (e.g. scripts generated by GWT compiler with PRETY preset).

Review URL: http://codereview.chromium.org/5148002
http://code.google.com/p/v8/source/detail?r=5839

Modified:
 /branches/bleeding_edge/src/accessors.cc
 /branches/bleeding_edge/src/handles.cc

=======================================
--- /branches/bleeding_edge/src/accessors.cc    Mon Oct 25 08:22:03 2010
+++ /branches/bleeding_edge/src/accessors.cc    Wed Nov 17 04:49:27 2010
@@ -316,8 +316,10 @@
   InitScriptLineEnds(script);
   ASSERT(script->line_ends()->IsFixedArray());
   Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
-  Handle<FixedArray> copy = Factory::CopyFixedArray(line_ends);
-  Handle<JSArray> js_array = Factory::NewJSArrayWithElements(copy);
+  // We do not want anyone to modify this array from JS.
+  ASSERT(*line_ends == Heap::empty_fixed_array() ||
+         line_ends->map() == Heap::fixed_cow_array_map());
+  Handle<JSArray> js_array = Factory::NewJSArrayWithElements(line_ends);
   return *js_array;
 }

=======================================
--- /branches/bleeding_edge/src/handles.cc      Thu Oct 21 07:21:00 2010
+++ /branches/bleeding_edge/src/handles.cc      Wed Nov 17 04:49:27 2010
@@ -499,6 +499,10 @@

   Handle<FixedArray> array = CalculateLineEnds(src, true);

+  if (*array != Heap::empty_fixed_array()) {
+    array->set_map(Heap::fixed_cow_array_map());
+  }
+
   script->set_line_ends(*array);
   ASSERT(script->line_ends()->IsFixedArray());
 }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to