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

Unified Diff: test/mjsunit/compiler/immutable-load-inline.js

Issue 220163012: Inline loading of immutable properties (Closed) Base URL: https://github.com/v8/v8.git@master
Patch Set: Support loads from prototypes as well Created 6 years, 9 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/immutable-load-inline.js
diff --git a/test/mjsunit/regress/regress-3183.js b/test/mjsunit/compiler/immutable-load-inline.js
similarity index 54%
copy from test/mjsunit/regress/regress-3183.js
copy to test/mjsunit/compiler/immutable-load-inline.js
index 0c915b0aec6890faba6d70026f1b465fcd9ee36e..5ebf3fabdf344e324dc851cdabbbf53f23ca173c 100644
--- a/test/mjsunit/regress/regress-3183.js
+++ b/test/mjsunit/compiler/immutable-load-inline.js
@@ -25,72 +25,63 @@
// (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
+// Flags: --allow-natives-syntax --noalways-opt
-(function DeoptimizeArgCallFunctionGeneric() {
- var a = [];
+function GrandGrandParent() {}
+GrandGrandParent.prototype = Object.freeze({constant: 2});
- function f1(method, array, elem, deopt) {
- assertEquals('push', method);
- }
+function GrandParent() {}
+GrandParent.prototype = Object.create(GrandGrandParent.prototype);
- function f2() { }
+function Parent() {}
+Parent.prototype = Object.create(GrandParent.prototype);
- function bar(x, deopt, f) {
- f('push', a, [x], deopt + 0);
- }
+function Child() {}
+Child.prototype = Object.create(Parent.prototype);
- function foo() { return bar(arguments[0], arguments[1], arguments[2]); }
- function baz(f, deopt) { return foo("x", deopt, f); }
+Child.prototype.method1 = function() {
+ return this.constant * this.constant;
+};
- baz(f1, 0);
- baz(f2, 0);
- %OptimizeFunctionOnNextCall(baz);
- baz(f1, "deopt");
-})();
+var a = new Child();
+assertEquals(a.method1(), 4);
+a.method1();
+%OptimizeFunctionOnNextCall(a.method1);
+assertEquals(a.method1(), 4);
+assertEquals(a.method1(), 4);
-(function DeoptimizeArgGlobalFunctionGeneric() {
- var a = [];
+// Immutable properties cannot be shadowed so the only way
+// is to snip the whole chain
+a.__proto__.__proto__ = {constant: 4};
- var f1;
+assertEquals(a.method1(), 16);
+assertEquals(a.method1(), 16);
+%OptimizeFunctionOnNextCall(a.method1);
+assertEquals(a.method1(), 16);
+assertEquals(a.method1(), 16);
- f1 = function(method, array, elem, deopt) {
- assertEquals('push', method);
- }
+var ceil = Math.ceil;
+function GetMathPi() {
+ return ceil(Math.PI * Math.PI);
+}
- function bar(x, deopt, f) {
- f1('push', a, [x], deopt + 0);
- }
+assertEquals(GetMathPi(), 10);
+GetMathPi();
- function foo() { return bar(arguments[0], arguments[1]); }
- function baz(deopt) { return foo("x", deopt); }
+%OptimizeFunctionOnNextCall(GetMathPi);
- baz(0);
- baz(0);
- %OptimizeFunctionOnNextCall(baz);
- baz("deopt");
-})();
+assertEquals(GetMathPi(), 10);
+assertEquals(GetMathPi(), 10);
-(function DeoptimizeArgCallFunctionRuntime() {
- var a = [];
- var f1;
+new Function("Math = {PI: 1}")();
- f1 = function(method, array, elem, deopt) {
- assertEquals('push', method);
- }
+assertEquals(GetMathPi(), 1);
+assertEquals(GetMathPi(), 1);
- function bar(x, deopt) {
- %_CallFunction(null, 'push', [x][0], ((deopt + 0), 1), f1);
- }
+%OptimizeFunctionOnNextCall(GetMathPi);
- function foo() { return bar(arguments[0], arguments[1]); }
- function baz(deopt) { return foo(0, deopt); }
-
- baz(0);
- baz(0);
- %OptimizeFunctionOnNextCall(baz);
- baz("deopt");
-})();
+assertEquals(GetMathPi(), 1);
+assertEquals(GetMathPi(), 1);
« 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