Revision: 13337
Author:   [email protected]
Date:     Wed Jan  9 01:32:12 2013
Log:      Added %FlattenString and use it to speed up a regression test.

Flattening strings is relatively costly and by doing it after every duplication
we avoid combinatorial explosion.

Note that flattening could have been done by e.g. using a regular expression,
too, but this is just another implementation detail and %FlattenString seems
general enough to be useful in other tests, too.

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

Modified:
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h
 /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-160010.js

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Mon Jan  7 02:06:11 2013
+++ /branches/bleeding_edge/src/runtime.cc      Wed Jan  9 01:32:12 2013
@@ -13240,6 +13240,15 @@
   UNREACHABLE();
   return NULL;
 }
+
+
+RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) {
+  HandleScope scope(isolate);
+  ASSERT(args.length() == 1);
+  CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
+  FlattenString(str);
+  return isolate->heap()->undefined_value();
+}


 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFromCache) {
=======================================
--- /branches/bleeding_edge/src/runtime.h       Mon Jan  7 02:06:11 2013
+++ /branches/bleeding_edge/src/runtime.h       Wed Jan  9 01:32:12 2013
@@ -104,6 +104,7 @@
   F(StoreArrayLiteralElement, 5, 1) \
   F(DebugCallbackSupportsStepping, 1, 1) \
   F(DebugPrepareStepInIfStepping, 1, 1) \
+  F(FlattenString, 1, 1) \
   \
   /* Array join support */ \
   F(PushIfAbsent, 2, 1) \
=======================================
--- /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-160010.js Mon Nov 12 02:20:07 2012 +++ /branches/bleeding_edge/test/mjsunit/regress/regress-crbug-160010.js Wed Jan 9 01:32:12 2013
@@ -25,9 +25,11 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+// Flags: --allow-natives-syntax
+
 var str = "a";
 for (var i = 0; i < 28; i++) {
   str += str;
+  %FlattenString(str);  // Evil performance hack
 }
 JSON.stringify(str);
-

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

Reply via email to