Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: tests/corelib/regexp/regress-regexp-codeflush_test.dart

Issue 667043003: Port regexp tests from V8 to Dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: dart authors copyright Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/corelib/regexp/regress-regexp-codeflush_test.dart
diff --git a/runtime/third_party/double-conversion/src/diy-fp.cc b/tests/corelib/regexp/regress-regexp-codeflush_test.dart
similarity index 60%
copy from runtime/third_party/double-conversion/src/diy-fp.cc
copy to tests/corelib/regexp/regress-regexp-codeflush_test.dart
index ddd1891b168ada0b67b3d124ff3c63b352d7fda6..23a4954a16683693f4e04bbd57e17208c02036aa 100644
--- a/runtime/third_party/double-conversion/src/diy-fp.cc
+++ b/tests/corelib/regexp/regress-regexp-codeflush_test.dart
@@ -1,4 +1,5 @@
-// Copyright 2010 the V8 project authors. All rights reserved.
+// Copyright (c) 2014, the Dart project authors. All rights reserved.
+// Copyright 2011 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -25,33 +26,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import 'v8_regexp_utils.dart';
+import 'package:expect/expect.dart';
-#include "diy-fp.h"
-#include "utils.h"
+void main() {
+ // Flags: --gc_global
-namespace double_conversion {
+ // Regression test for regexp that has multiple matches and which
+ // internally calls RegExpImpl::IrregexpExecOnce more than once without
+ // ensuring that the regexp is compiled.
+ // This can create a crash if the code was exchanged with the sweep
+ // generation (for code flushing support) in GC durring the matching.
-void DiyFp::Multiply(const DiyFp& other) {
- // Simply "emulates" a 128 bit multiplication.
- // However: the resulting number only contains 64 bits. The least
- // significant 64 bits are only used for rounding the most significant 64
- // bits.
- const uint64_t kM32 = 0xFFFFFFFFU;
- uint64_t a = f_ >> 32;
- uint64_t b = f_ & kM32;
- uint64_t c = other.f_ >> 32;
- uint64_t d = other.f_ & kM32;
- uint64_t ac = a * c;
- uint64_t bc = b * c;
- uint64_t ad = a * d;
- uint64_t bd = b * d;
- uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
- // By adding 1U << 31 to tmp we round the final result.
- // Halfway cases will be round up.
- tmp += 1U << 31;
- uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
- e_ += other.e_ + 64;
- f_ = result_f;
-}
+ var re = new RegExp('(s)');
+
+ dynamic foo(Match m) {
+ return "42";
+ }
-} // namespace double_conversion
+ // Run enough times to get a number of GC's (all mark sweep because of the
+ // --gc_global) flag.
+ for ( var i = 0; i < 10; i++) {
+ // Make a long string with plenty of matches for re.
+ var x = "s foo s bar s foo s bar s";
+ x = x + x;
+ x = x + x;
+ x = x + x;
+ x = x + x;
+ x = x + x;
+ x = x + x;
+ x = x + x;
+ x.replaceAllMapped(re, foo);
+ }
+}
« no previous file with comments | « tests/corelib/regexp/regress-6-9-regexp_test.dart ('k') | tests/corelib/regexp/regress-regexp-construct-result_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698