Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2015 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 test1(s) { |
| 8 | return s.toString; |
| 9 | } |
| 10 | assertSame(test1(Symbol()), Symbol.prototype.toString); |
| 11 | assertSame(test1(Symbol()), Symbol.prototype.toString); |
| 12 | %OptimizeFunctionOnNextCall(test1); |
| 13 | assertSame(test1(Symbol()), Symbol.prototype.toString); |
| 14 | |
| 15 | function test2(s) { |
| 16 | return s.valueOf; |
| 17 | } |
| 18 | assertSame(test2(Symbol()), Symbol.prototype.valueOf); |
| 19 | assertSame(test2(Symbol()), Symbol.prototype.valueOf); |
| 20 | %OptimizeFunctionOnNextCall(test2); |
| 21 | assertSame(test2(Symbol()), Symbol.prototype.valueOf); |
| 22 | |
| 23 | Symbol.prototype.foo = 1; |
| 24 | function test3(s) { |
| 25 | return s["foo"]; |
| 26 | } |
| 27 | assertEquals(test3(Symbol()), 1); |
| 28 | assertEquals(test3(Symbol()), 1); |
| 29 | %OptimizeFunctionOnNextCall(test3); |
| 30 | assertEquals(test3(Symbol()), 1); |
| 31 | |
| 32 | Symbol.prototype.bar = function() { "use strict"; return this; } |
| 33 | function test4(s) { |
| 34 | return s.bar(); |
| 35 | } |
| 36 | var s = Symbol("foo"); |
| 37 | assertEquals(test4(s), s); |
| 38 | assertEquals(test4(s), s); |
| 39 | %OptimizeFunctionOnNextCall(test4); |
| 40 | assertEquals(test4(s), s); |