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

Side by Side Diff: test/mjsunit/compiler/inline-two.js

Issue 8888006: Make more JS files beter match the coding standard. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/compiler/inline-context-slots.js ('k') | test/mjsunit/compiler/literals.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 24 matching lines...) Expand all
35 var x = o.g(); 35 var x = o.g();
36 assertEquals(42, x); 36 assertEquals(42, x);
37 assertEquals(42, o.g()); 37 assertEquals(42, o.g());
38 // Test context. 38 // Test context.
39 if (!o.g()) { 39 if (!o.g()) {
40 assertTrue(false); // Should not happen. 40 assertTrue(false); // Should not happen.
41 } 41 }
42 } 42 }
43 43
44 var o2 = {}; 44 var o2 = {};
45 o2.size = function() { return 42; } 45 o2.size = function() { return 42; };
46 o2.g = function() { return this.size(); }; 46 o2.g = function() { return this.size(); };
47 for (var i = 0; i < 5; i++) TestInlineX(o2); 47 for (var i = 0; i < 5; i++) TestInlineX(o2);
48 %OptimizeFunctionOnNextCall(TestInlineX); 48 %OptimizeFunctionOnNextCall(TestInlineX);
49 TestInlineX(o2); 49 TestInlineX(o2);
50 TestInlineX({g: o2.g, size:o2.size}); 50 TestInlineX({g: o2.g, size:o2.size});
51 51
52 52
53 // Test that we can inline a call on a non-variable receiver. 53 // Test that we can inline a call on a non-variable receiver.
54 function TestInlineX2(o) { 54 function TestInlineX2(o) {
55 // Effect context. 55 // Effect context.
56 o.h(); 56 o.h();
57 // Value context. 57 // Value context.
58 var x = o.h(); 58 var x = o.h();
59 assertEquals(42, x); 59 assertEquals(42, x);
60 assertEquals(42, o.h()); 60 assertEquals(42, o.h());
61 // Test context. 61 // Test context.
62 if (!o.h()) { 62 if (!o.h()) {
63 assertTrue(false); // Should not happen. 63 assertTrue(false); // Should not happen.
64 } 64 }
65 } 65 }
66 66
67 var obj = {} 67 var obj = {};
68 obj.foo = function() { return 42; } 68 obj.foo = function() { return 42; };
69 var o3 = {}; 69 var o3 = {};
70 o3.v = obj; 70 o3.v = obj;
71 o3.h = function() { return this.v.foo(); }; 71 o3.h = function() { return this.v.foo(); };
72 for (var i = 0; i < 5; i++) TestInlineX2(o3); 72 for (var i = 0; i < 5; i++) TestInlineX2(o3);
73 %OptimizeFunctionOnNextCall(TestInlineX2); 73 %OptimizeFunctionOnNextCall(TestInlineX2);
74 TestInlineX2(o3); 74 TestInlineX2(o3);
75 TestInlineX2({h: o3.h, v:obj}); 75 TestInlineX2({h: o3.h, v:obj});
76 76
77 77
78 // Test that we can inline a call on a non-variable receiver. 78 // Test that we can inline a call on a non-variable receiver.
79 function TestInlineFG(o) { 79 function TestInlineFG(o) {
80 // Effect context. 80 // Effect context.
81 o.h(); 81 o.h();
82 // Value context. 82 // Value context.
83 var x = o.h(); 83 var x = o.h();
84 assertEquals(42, x); 84 assertEquals(42, x);
85 assertEquals(42, o.h()); 85 assertEquals(42, o.h());
86 // Test context. 86 // Test context.
87 if (!o.h()) { 87 if (!o.h()) {
88 assertTrue(false); // Should not happen. 88 assertTrue(false); // Should not happen.
89 } 89 }
90 } 90 }
91 91
92 var obj = {} 92 var obj = {};
93 obj.g = function() { return 42; } 93 obj.g = function() { return 42; };
94 var o3 = {}; 94 var o3 = {};
95 o3.v = obj; 95 o3.v = obj;
96 o3.f = function() { return this.v; } 96 o3.f = function() { return this.v; };
97 o3.h = function() { return this.f().g(); }; 97 o3.h = function() { return this.f().g(); };
98 for (var i = 0; i < 5; i++) TestInlineFG(o3); 98 for (var i = 0; i < 5; i++) TestInlineFG(o3);
99 %OptimizeFunctionOnNextCall(TestInlineFG); 99 %OptimizeFunctionOnNextCall(TestInlineFG);
100 TestInlineFG(o3); 100 TestInlineFG(o3);
101 TestInlineFG({h: o3.h, f: o3.f, v:obj}); 101 TestInlineFG({h: o3.h, f: o3.f, v:obj});
OLDNEW
« no previous file with comments | « test/mjsunit/compiler/inline-context-slots.js ('k') | test/mjsunit/compiler/literals.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698