Commit a298666f authored by vegorov@chromium.org's avatar vegorov@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5839 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a24d6275
......@@ -316,8 +316,10 @@ 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 == Heap::empty_fixed_array() ||
line_ends->map() == Heap::fixed_cow_array_map());
Handle<JSArray> js_array = Factory::NewJSArrayWithElements(line_ends);
return *js_array;
}
......
......@@ -499,6 +499,10 @@ void InitScriptLineEnds(Handle<Script> script) {
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());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment