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

Unified Diff: test/mjsunit/compiler/inline-construct.js

Issue 9597017: Fix inlining of strict mode constructors. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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
« no previous file with comments | « src/hydrogen.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/inline-construct.js
diff --git a/test/mjsunit/compiler/inline-construct.js b/test/mjsunit/compiler/inline-construct.js
index 16e19a7d7c885e40b96bdce069bf2b3fbd2017ea..af9e69c94020e2ea44283e689d9dd0d0b4809223 100644
--- a/test/mjsunit/compiler/inline-construct.js
+++ b/test/mjsunit/compiler/inline-construct.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax --inline-construct
+// Flags: --allow-natives-syntax --expose-gc --inline-construct
// Test inlining of constructor calls.
@@ -47,29 +47,37 @@ function TestInlinedConstructor(closure) {
assertEquals(4, counter.value);
}
+function TestInAllContexts(constructor) {
+ function value_context(a, b, counter) {
+ var obj = new constructor(a, b, counter);
+ return obj.x;
+ }
+ function test_context(a, b, counter) {
+ if (!new constructor(a, b, counter)) {
+ assertUnreachable("should not happen");
+ }
+ return a + b;
+ }
+ function effect_context(a, b, counter) {
+ new constructor(a, b, counter);
+ return a + b;
+ }
+ TestInlinedConstructor(value_context);
+ TestInlinedConstructor(test_context);
+ TestInlinedConstructor(effect_context);
+ %DeoptimizeFunction(value_context);
+ %DeoptimizeFunction(test_context);
+ %DeoptimizeFunction(effect_context);
+ gc(); // Makes V8 forget about type information for *_context.
+}
+
// Test constructor returning nothing in all contexts.
function c1(a, b, counter) {
this.x = a + b;
counter.value++;
}
-function c1_value_context(a, b, counter) {
- var obj = new c1(a, b, counter);
- return obj.x;
-}
-function c1_test_context(a, b, counter) {
- if (!new c1(a, b, counter)) {
- assertUnreachable("should not happen");
- }
- return a + b;
-}
-function c1_effect_context(a, b, counter) {
- new c1(a, b, counter);
- return a + b;
-}
-TestInlinedConstructor(c1_value_context);
-TestInlinedConstructor(c1_test_context);
-TestInlinedConstructor(c1_effect_context);
+TestInAllContexts(c1);
// Test constructor returning an object in all contexts.
@@ -79,23 +87,7 @@ function c2(a, b, counter) {
counter.value++;
return obj;
}
-function c2_value_context(a, b, counter) {
- var obj = new c2(a, b, counter);
- return obj.x;
-}
-function c2_test_context(a, b, counter) {
- if (!new c2(a, b, counter)) {
- assertUnreachable("should not happen");
- }
- return a + b;
-}
-function c2_effect_context(a, b, counter) {
- new c2(a, b, counter);
- return a + b;
-}
-TestInlinedConstructor(c2_value_context);
-TestInlinedConstructor(c2_test_context);
-TestInlinedConstructor(c2_effect_context);
+TestInAllContexts(c2);
// Test constructor returning a primitive value in all contexts.
@@ -104,23 +96,7 @@ function c3(a, b, counter) {
counter.value++;
return "not an object";
}
-function c3_value_context(a, b, counter) {
- var obj = new c3(a, b, counter);
- return obj.x;
-}
-function c3_test_context(a, b, counter) {
- if (!new c3(a, b, counter)) {
- assertUnreachable("should not happen");
- }
- return a + b;
-}
-function c3_effect_context(a, b, counter) {
- new c3(a, b, counter);
- return a + b;
-}
-TestInlinedConstructor(c3_value_context);
-TestInlinedConstructor(c3_test_context);
-TestInlinedConstructor(c3_effect_context);
+TestInAllContexts(c3);
// Test constructor called with too many arguments.
@@ -163,8 +139,14 @@ function c_unsupported_syntax(a, b, counter) {
throw new Error();
}
}
-function f_unsupported_syntax(a, b, counter) {
- var obj = new c_unsupported_syntax(a, b, counter);
- return obj.x;
+TestInAllContexts(c_unsupported_syntax);
+
+
+// Regression test: Inlined constructors called as functions do not get their
+// implicit receiver object set to undefined, even in strict mode.
+function c_strict(a, b, counter) {
+ "use strict";
+ this.x = a + b;
+ counter.value++;
}
-TestInlinedConstructor(f_unsupported_syntax);
+TestInAllContexts(c_strict);
« no previous file with comments | « src/hydrogen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698