Reviewers: Michael Starzinger,
Description:
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.
Please review this at https://codereview.chromium.org/11828014/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/runtime.h
M src/runtime.cc
M test/mjsunit/regress/regress-crbug-160010.js
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
70f0d3628f01b1f109f546e85253d04bcb1c8f10..906dfb7bb032ce74c3038f150ae04cab5514ec8a
100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -13242,6 +13242,15 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) {
}
+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) {
// This is only called from codegen, so checks might be more lax.
CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0);
Index: src/runtime.h
diff --git a/src/runtime.h b/src/runtime.h
index
c9795e1abce7aae01cc38e1317c684a0cfd63e30..cb4a9a241967271c54aa0b892320acde7fa363fd
100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -374,6 +374,7 @@ namespace internal {
F(TraceEnter, 0, 1) \
F(TraceExit, 1, 1) \
F(Abort, 2, 1) \
+ F(FlattenString, 1, 1) \
/* Logging */ \
F(Log, 2, 1) \
/* ES5 */ \
Index: test/mjsunit/regress/regress-crbug-160010.js
diff --git a/test/mjsunit/regress/regress-crbug-160010.js
b/test/mjsunit/regress/regress-crbug-160010.js
index
266e54532597d060b699788fc210d566941fba60..586bddd7c23c38d6218eea69c4c790566c52225b
100644
--- a/test/mjsunit/regress/regress-crbug-160010.js
+++ b/test/mjsunit/regress/regress-crbug-160010.js
@@ -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