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

Side by Side Diff: test/mjsunit/compiler/receiver-conversion.js

Issue 1412223015: [turbofan] Fix receiver binding for inlined callees. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 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
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 // This test suite checks that the receiver value (i.e. the 'this' binding) is
8 // correctly converted even when the callee function is inlined. This behavior
9 // is specified by ES6, section 9.2.1.2 "OrdinaryCallBindThis".
10
11 var global = this;
12 function test(outer, inner, check) {
13 check(outer());
14 check(outer());
15 %OptimizeFunctionOnNextCall(outer);
16 check(outer());
17 }
18
19
20 // -----------------------------------------------------------------------------
21 // Test undefined in sloppy mode.
22 (function UndefinedSloppy() {
23 function check(x) {
24 assertEquals("object", typeof x);
25 assertSame(global, x);
26 }
27 function inner(x) {
28 return this;
29 }
30 function outer() {
31 return sloppy();
32 }
33 global.sloppy = inner;
34 test(outer, inner, check);
35 })();
36
37
38 // -----------------------------------------------------------------------------
39 // Test undefined in strict mode.
40 (function UndefinedStrict() {
41 function check(x) {
42 assertEquals("undefined", typeof x);
43 assertSame(undefined, x);
44 }
45 function inner(x) {
46 "use strict";
47 return this;
48 }
49 function outer() {
50 return strict();
51 }
52 global.strict = inner;
53 test(outer, inner, check);
54 })();
55
56
57 // -----------------------------------------------------------------------------
58 // Test primitive number in sloppy mode.
59 (function NumberSloppy() {
60 function check(x) {
61 assertEquals("object", typeof x);
62 assertInstanceof(x, Number);
63 }
64 function inner(x) {
65 return this;
66 }
67 function outer() {
68 return (0).sloppy();
69 }
70 Number.prototype.sloppy = inner;
71 test(outer, inner, check);
72 })();
73
74
75 // -----------------------------------------------------------------------------
76 // Test primitive number in strict mode.
77 (function NumberStrict() {
78 function check(x) {
79 assertEquals("number", typeof x);
80 assertSame(0, x);
81 }
82 function inner(x) {
83 "use strict";
84 return this;
85 }
86 function outer() {
87 return (0).strict();
88 }
89 Number.prototype.strict = inner;
90 test(outer, inner, check);
91 })();
92
93
94 // -----------------------------------------------------------------------------
95 // Test primitive string in sloppy mode.
96 (function StringSloppy() {
97 function check(x) {
98 assertEquals("object", typeof x);
99 assertInstanceof(x, String);
100 }
101 function inner(x) {
102 return this;
103 }
104 function outer() {
105 return ("s").sloppy();
106 }
107 String.prototype.sloppy = inner;
108 test(outer, inner, check);
109 })();
110
111
112 // -----------------------------------------------------------------------------
113 // Test primitive string in strict mode.
114 (function StringStrict() {
115 function check(x) {
116 assertEquals("string", typeof x);
117 assertSame("s", x);
118 }
119 function inner(x) {
120 "use strict";
121 return this;
122 }
123 function outer() {
124 return ("s").strict();
125 }
126 String.prototype.strict = inner;
127 test(outer, inner, check);
128 })();
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698