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

Unified 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: Created 5 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« src/compiler/js-operator.cc ('K') | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/receiver-conversion.js
diff --git a/test/mjsunit/compiler/receiver-conversion.js b/test/mjsunit/compiler/receiver-conversion.js
new file mode 100644
index 0000000000000000000000000000000000000000..3c113406b8724e21bf83865ed26ed0bbaf8bca52
--- /dev/null
+++ b/test/mjsunit/compiler/receiver-conversion.js
@@ -0,0 +1,126 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --function-context-specialization
Benedikt Meurer 2015/10/27 11:24:42 Can we have a test that does not require --functio
Michael Starzinger 2015/10/27 11:35:55 Done.
+
+// This test suite checks that the receiver value (i.e. the 'this' binding) is
+// correctly converted even when the callee function is inlined. This behavior
+// is specified by ES6, section 9.2.1.2 "OrdinaryCallBindThis".
+
+var global = this;
+function test(outer, inner, check) {
+ check(outer());
+ check(outer());
+ %OptimizeFunctionOnNextCall(outer);
+ check(outer());
+}
+
+
+// -----------------------------------------------------------------------------
+// Test undefined in sloppy mode.
+(function UndefinedSloppy() {
+ function check(x) {
+ assertEquals("object", typeof x);
+ assertSame(global, x);
+ }
+ function inner(x) {
+ return this;
+ }
+ function outer() {
+ return inner();
+ }
+ test(outer, inner, check);
+})();
+
+
+// -----------------------------------------------------------------------------
+// Test undefined in sloppy mode.
+(function UndefinedSloppy() {
+ function check(x) {
+ assertEquals("undefined", typeof x);
+ assertSame(undefined, x);
+ }
+ function inner(x) {
+ "use strict";
+ return this;
+ }
+ function outer() {
+ return inner();
+ }
+ test(outer, inner, check);
+})();
+
+
+// -----------------------------------------------------------------------------
+// Test primitive number in sloppy mode.
+(function NumberSloppy() {
+ function check(x) {
+ assertEquals("object", typeof x);
+ assertInstanceof(x, Number);
+ }
+ function inner(x) {
+ return this;
+ }
+ function outer() {
+ return (0).sloppy();
+ }
+ Number.prototype.sloppy = inner;
+ test(outer, inner, check);
+})();
+
+
+// -----------------------------------------------------------------------------
+// Test primitive number in strict mode.
+(function NumberStrict() {
+ function check(x) {
+ assertEquals("number", typeof x);
+ assertSame(0, x);
+ }
+ function inner(x) {
+ "use strict";
+ return this;
+ }
+ function outer() {
+ return (0).strict();
+ }
+ Number.prototype.strict = inner;
+ test(outer, inner, check);
+})();
+
+
+// -----------------------------------------------------------------------------
+// Test primitive string in sloppy mode.
+(function StringSloppy() {
+ function check(x) {
+ assertEquals("object", typeof x);
+ assertInstanceof(x, String);
+ }
+ function inner(x) {
+ return this;
+ }
+ function outer() {
+ return ("s").sloppy();
+ }
+ String.prototype.sloppy = inner;
+ test(outer, inner, check);
+})();
+
+
+// -----------------------------------------------------------------------------
+// Test primitive string in strict mode.
+(function StringStrict() {
+ function check(x) {
+ assertEquals("string", typeof x);
+ assertSame("s", x);
+ }
+ function inner(x) {
+ "use strict";
+ return this;
+ }
+ function outer() {
+ return ("s").strict();
+ }
+ String.prototype.strict = inner;
+ test(outer, inner, check);
+})();
« src/compiler/js-operator.cc ('K') | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698