OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --allow-natives-syntax | |
6 | |
7 function get_thin_string(a, b) { | |
8 var str = a + b; // Make a ConsString. | |
9 var o = {}; | |
10 o[str]; // Turn it into a ThinString. | |
11 return str; | |
12 } | |
13 | |
14 var str = get_thin_string("foo", "bar"); | |
15 | |
16 var re = /.o+ba./; | |
17 assertEquals(["foobar"], re.exec(str)); | |
18 assertEquals(["foobar"], re.exec(str)); | |
19 assertEquals(["foobar"], re.exec(str)); | |
20 | |
21 function CheckCS() { | |
22 assertEquals("o", str.substring(1, 2)); | |
23 assertEquals("f".charCodeAt(0), str.charCodeAt(0)); | |
24 assertEquals("f", str.split(/oo/)[0]); | |
25 } | |
26 CheckCS(); | |
27 %OptimizeFunctionOnNextCall(CheckCS); | |
28 CheckCS(); | |
29 | |
30 function CheckTF() { | |
31 try {} catch(e) {} // Turbofan. | |
32 assertEquals("o", str.substring(1, 2)); | |
33 assertEquals("f".charCodeAt(0), str.charCodeAt(0)); | |
34 assertEquals("f", str.split(/oo/)[0]); | |
35 } | |
36 CheckTF(); | |
37 %OptimizeFunctionOnNextCall(CheckTF); | |
38 CheckTF(); | |
OLD | NEW |