Reviewers: Vitaly,
Description:
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).
Please review this at http://codereview.chromium.org/5148002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/accessors.cc
M src/handles.cc
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index
7c21659ebc4d95d5fc5a2a07ba98f9ef356a07c3..ae9b0f329abd2c1557b5a5fd206229798e60d6d2
100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -316,8 +316,9 @@ MaybeObject* Accessors::ScriptGetLineEnds(Object*
object, void*) {
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->map() == Heap::fixed_cow_array_map());
+ Handle<JSArray> js_array = Factory::NewJSArrayWithElements(line_ends);
return *js_array;
}
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index
7a46bc3ea251fc6232b769ee0c4232c279306ae2..319547d473dd35dbca9f161bc63580ba732010d9
100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -499,6 +499,7 @@ void InitScriptLineEnds(Handle<Script> script) {
Handle<FixedArray> array = CalculateLineEnds(src, true);
+ 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