From a298666fae84fc89e343b6b40dcfa92c6a648aa1 Mon Sep 17 00:00:00 2001 From: "vegorov@chromium.org" Date: Wed, 17 Nov 2010 12:49:27 +0000 Subject: [PATCH] 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 --- src/accessors.cc | 6 ++++-- src/handles.cc | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/accessors.cc b/src/accessors.cc index 7c21659..08ef41b 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -316,8 +316,10 @@ MaybeObject* Accessors::ScriptGetLineEnds(Object* object, void*) { InitScriptLineEnds(script); ASSERT(script->line_ends()->IsFixedArray()); Handle line_ends(FixedArray::cast(script->line_ends())); - Handle copy = Factory::CopyFixedArray(line_ends); - Handle 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 js_array = Factory::NewJSArrayWithElements(line_ends); return *js_array; } diff --git a/src/handles.cc b/src/handles.cc index 7a46bc3..1364951 100644 --- a/src/handles.cc +++ b/src/handles.cc @@ -499,6 +499,10 @@ void InitScriptLineEnds(Handle