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

Side by Side Diff: tests/corelib/regexp/regress-regexp-codeflush_test.dart

Issue 691473002: Reapply "Port regexp tests from V8 to Dart." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: RC and rebase Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright (c) 2014, the Dart project authors. All rights reserved.
2 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 3 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 4 // modification, are permitted provided that the following conditions are
4 // met: 5 // met:
5 // 6 //
6 // * Redistributions of source code must retain the above copyright 7 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 9 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 10 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 11 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 12 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 13 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 14 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 15 // from this software without specific prior written permission.
15 // 16 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 28
29 import 'v8_regexp_utils.dart';
30 import 'package:expect/expect.dart';
28 31
29 #include "diy-fp.h" 32 void main() {
30 #include "utils.h" 33 // Flags: --gc_global
31 34
32 namespace double_conversion { 35 // Regression test for regexp that has multiple matches and which
36 // internally calls RegExpImpl::IrregexpExecOnce more than once without
37 // ensuring that the regexp is compiled.
38 // This can create a crash if the code was exchanged with the sweep
39 // generation (for code flushing support) in GC durring the matching.
33 40
34 void DiyFp::Multiply(const DiyFp& other) { 41 var re = new RegExp('(s)');
35 // Simply "emulates" a 128 bit multiplication. 42
36 // However: the resulting number only contains 64 bits. The least 43 dynamic foo(Match m) {
37 // significant 64 bits are only used for rounding the most significant 64 44 return "42";
38 // bits. 45 }
39 const uint64_t kM32 = 0xFFFFFFFFU; 46
40 uint64_t a = f_ >> 32; 47 // Run enough times to get a number of GC's (all mark sweep because of the
41 uint64_t b = f_ & kM32; 48 // --gc_global) flag.
42 uint64_t c = other.f_ >> 32; 49 for ( var i = 0; i < 10; i++) {
43 uint64_t d = other.f_ & kM32; 50 // Make a long string with plenty of matches for re.
44 uint64_t ac = a * c; 51 var x = "s foo s bar s foo s bar s";
45 uint64_t bc = b * c; 52 x = x + x;
46 uint64_t ad = a * d; 53 x = x + x;
47 uint64_t bd = b * d; 54 x = x + x;
48 uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32); 55 x = x + x;
49 // By adding 1U << 31 to tmp we round the final result. 56 x = x + x;
50 // Halfway cases will be round up. 57 x = x + x;
51 tmp += 1U << 31; 58 x = x + x;
52 uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32); 59 x.replaceAllMapped(re, foo);
53 e_ += other.e_ + 64; 60 }
54 f_ = result_f;
55 } 61 }
56
57 } // namespace double_conversion
OLDNEW
« 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