OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function SimpleCtor() { | 5 function SimpleCtor() { |
6 new RegExp("[Cz]"); | 6 new RegExp("[Cz]"); |
7 } | 7 } |
8 | 8 |
9 function FlagsCtor() { | 9 function FlagsCtor() { |
10 new RegExp("[Cz]", "guiym"); | 10 new RegExp("[Cz]", "guiym"); |
11 } | 11 } |
12 | 12 |
13 function SimpleCtorWithoutNew() { | 13 function SimpleCtorWithoutNew() { |
14 RegExp("[Cz]"); | 14 RegExp("[Cz]"); |
15 } | 15 } |
16 | 16 |
17 function FlagsCtorWithoutNew() { | 17 function FlagsCtorWithoutNew() { |
18 RegExp("[Cz]", "guiym"); | 18 RegExp("[Cz]", "guiym"); |
19 } | 19 } |
20 | 20 |
21 function CtorWithRegExpPattern() { | 21 function CtorWithRegExpPattern() { |
22 new RegExp(/[Cz]/); | 22 new RegExp(/[Cz]/); |
23 } | 23 } |
24 | 24 |
25 function CtorWithRegExpPatternAndFlags() { | 25 function CtorWithRegExpPatternAndFlags() { |
26 new RegExp(/[Cz]/, "guiym"); | 26 new RegExp(/[Cz]/, "guiym"); |
27 } | 27 } |
28 | 28 |
| 29 class SubRegExp extends RegExp { |
| 30 get source() { return "[Cz]"; } |
| 31 get flags() { return "guiym"; } |
| 32 } |
| 33 |
29 function CtorWithRegExpSubclassPattern() { | 34 function CtorWithRegExpSubclassPattern() { |
30 class SubRegExp extends RegExp { | |
31 get source() { return "[Cz]"; } | |
32 get flags() { return "guiym"; } | |
33 } | |
34 new RegExp(new SubRegExp(/[Cz]/)); | 35 new RegExp(new SubRegExp(/[Cz]/)); |
35 } | 36 } |
36 | 37 |
37 function CtorWithUndefinedPattern() { | 38 function CtorWithUndefinedPattern() { |
38 new RegExp(); | 39 new RegExp(); |
39 } | 40 } |
40 | 41 |
41 function CtorWithFlagsAndUndefinedPattern() { | 42 function CtorWithFlagsAndUndefinedPattern() { |
42 new RegExp(undefined, "guiym"); | 43 new RegExp(undefined, "guiym"); |
43 } | 44 } |
44 | 45 |
45 var benchmarks = [ [SimpleCtor, undefined], | 46 var benchmarks = [ [SimpleCtor, undefined], |
46 [FlagsCtor, undefined], | 47 [FlagsCtor, undefined], |
47 [SimpleCtorWithoutNew, undefined], | 48 [SimpleCtorWithoutNew, undefined], |
48 [FlagsCtorWithoutNew, undefined], | 49 [FlagsCtorWithoutNew, undefined], |
49 [CtorWithRegExpPattern, undefined], | 50 [CtorWithRegExpPattern, undefined], |
50 [CtorWithRegExpPatternAndFlags, undefined], | 51 [CtorWithRegExpPatternAndFlags, undefined], |
51 [CtorWithRegExpSubclassPattern, undefined], | 52 [CtorWithRegExpSubclassPattern, undefined], |
52 [CtorWithUndefinedPattern, undefined], | 53 [CtorWithUndefinedPattern, undefined], |
53 [CtorWithFlagsAndUndefinedPattern, undefined], | 54 [CtorWithFlagsAndUndefinedPattern, undefined], |
54 ]; | 55 ]; |
OLD | NEW |