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

Side by Side Diff: test/mjsunit/assert-opt-and-deopt.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/array-unshift.js ('k') | test/mjsunit/break.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 OptTracker.prototype.AssertDeoptHappened = function(func, expect_deopt) { 76 OptTracker.prototype.AssertDeoptHappened = function(func, expect_deopt) {
77 if (this.DisableAsserts_(func)) { 77 if (this.DisableAsserts_(func)) {
78 return; 78 return;
79 } 79 }
80 if (expect_deopt) { 80 if (expect_deopt) {
81 assertTrue(this.GetDeoptCount_(func) > 0); 81 assertTrue(this.GetDeoptCount_(func) > 0);
82 } else { 82 } else {
83 assertEquals(0, this.GetDeoptCount_(func)); 83 assertEquals(0, this.GetDeoptCount_(func));
84 } 84 }
85 } 85 };
86 86
87 OptTracker.prototype.AssertIsOptimized = function(func, expect_optimized) { 87 OptTracker.prototype.AssertIsOptimized = function(func, expect_optimized) {
88 if (this.DisableAsserts_(func)) { 88 if (this.DisableAsserts_(func)) {
89 return; 89 return;
90 } 90 }
91 var raw_optimized = %GetOptimizationStatus(func); 91 var raw_optimized = %GetOptimizationStatus(func);
92 if (expect_optimized) { 92 if (expect_optimized) {
93 assertEquals(OptTracker.OptimizationState.YES, raw_optimized); 93 assertEquals(OptTracker.OptimizationState.YES, raw_optimized);
94 } else { 94 } else {
95 assertEquals(OptTracker.OptimizationState.NO, raw_optimized); 95 assertEquals(OptTracker.OptimizationState.NO, raw_optimized);
96 } 96 }
97 } 97 };
98 98
99 /** 99 /**
100 * @private 100 * @private
101 */ 101 */
102 OptTracker.prototype.GetOptCount_ = function(func) { 102 OptTracker.prototype.GetOptCount_ = function(func) {
103 var raw_count = %GetOptimizationCount(func); 103 var raw_count = %GetOptimizationCount(func);
104 if (func in this.opt_counts_) { 104 if (func in this.opt_counts_) {
105 var checkpointed_count = this.opt_counts_[func]; 105 var checkpointed_count = this.opt_counts_[func];
106 return raw_count - checkpointed_count; 106 return raw_count - checkpointed_count;
107 } 107 }
108 return raw_count; 108 return raw_count;
109 } 109 };
110 110
111 /** 111 /**
112 * @private 112 * @private
113 */ 113 */
114 OptTracker.prototype.GetDeoptCount_ = function(func) { 114 OptTracker.prototype.GetDeoptCount_ = function(func) {
115 var count = this.GetOptCount_(func); 115 var count = this.GetOptCount_(func);
116 if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) { 116 if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) {
117 count -= 1; 117 count -= 1;
118 } 118 }
119 return count; 119 return count;
120 } 120 };
121 121
122 /** 122 /**
123 * @private 123 * @private
124 */ 124 */
125 OptTracker.prototype.DisableAsserts_ = function(func) { 125 OptTracker.prototype.DisableAsserts_ = function(func) {
126 switch(%GetOptimizationStatus(func)) { 126 switch(%GetOptimizationStatus(func)) {
127 case OptTracker.OptimizationState.YES: 127 case OptTracker.OptimizationState.YES:
128 case OptTracker.OptimizationState.NO: 128 case OptTracker.OptimizationState.NO:
129 return false; 129 return false;
130 case OptTracker.OptimizationState.ALWAYS: 130 case OptTracker.OptimizationState.ALWAYS:
131 case OptTracker.OptimizationState.NEVER: 131 case OptTracker.OptimizationState.NEVER:
132 return true; 132 return true;
133 } 133 }
134 return false; 134 return false;
135 } 135 };
136 // (End of class OptTracker.) 136 // (End of class OptTracker.)
137 137
138 // Example function used by the test below. 138 // Example function used by the test below.
139 function f(a) { 139 function f(a) {
140 return a+1; 140 return a+1;
141 } 141 }
142 142
143 var tracker = new OptTracker(); 143 var tracker = new OptTracker();
144 tracker.CheckpointOptCount(f); 144 tracker.CheckpointOptCount(f);
145 145
(...skipping 22 matching lines...) Expand all
168 // Let's trigger optimization for another type. 168 // Let's trigger optimization for another type.
169 for (var i = 0; i < 5; i++) f("a"); 169 for (var i = 0; i < 5; i++) f("a");
170 170
171 %OptimizeFunctionOnNextCall(f); 171 %OptimizeFunctionOnNextCall(f);
172 f("b"); 172 f("b");
173 173
174 tracker.AssertOptCount(f, 2); 174 tracker.AssertOptCount(f, 2);
175 tracker.AssertIsOptimized(f, true); 175 tracker.AssertIsOptimized(f, true);
176 tracker.AssertDeoptHappened(f, true); 176 tracker.AssertDeoptHappened(f, true);
177 tracker.AssertDeoptCount(f, 1); 177 tracker.AssertDeoptCount(f, 1);
OLDNEW
« no previous file with comments | « test/mjsunit/array-unshift.js ('k') | test/mjsunit/break.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698