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

Side by Side Diff: test/codegen/expect/DeltaBlue.js

Issue 1145283002: Use short array syntax in method signatures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Address comments Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « test/codegen/expect/BenchmarkBase.js ('k') | test/codegen/expect/cascade.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 var DeltaBlue = dart.defineLibrary(DeltaBlue, {}); 1 var DeltaBlue = dart.defineLibrary(DeltaBlue, {});
2 var BenchmarkBase = dart.import(BenchmarkBase); 2 var BenchmarkBase = dart.import(BenchmarkBase);
3 var core = dart.import(core); 3 var core = dart.import(core);
4 (function(exports, BenchmarkBase, core) { 4 (function(exports, BenchmarkBase, core) {
5 'use strict'; 5 'use strict';
6 function main() { 6 function main() {
7 new DeltaBlue().report(); 7 new DeltaBlue().report();
8 } 8 }
9 dart.fn(main); 9 dart.fn(main);
10 class DeltaBlue extends BenchmarkBase.BenchmarkBase { 10 class DeltaBlue extends BenchmarkBase.BenchmarkBase {
(...skipping 20 matching lines...) Expand all
31 return dart.notNull(s1.value) > dart.notNull(s2.value); 31 return dart.notNull(s1.value) > dart.notNull(s2.value);
32 } 32 }
33 static weakest(s1, s2) { 33 static weakest(s1, s2) {
34 return Strength.weaker(s1, s2) ? s1 : s2; 34 return Strength.weaker(s1, s2) ? s1 : s2;
35 } 35 }
36 static strongest(s1, s2) { 36 static strongest(s1, s2) {
37 return Strength.stronger(s1, s2) ? s1 : s2; 37 return Strength.stronger(s1, s2) ? s1 : s2;
38 } 38 }
39 } 39 }
40 dart.setSignature(Strength, { 40 dart.setSignature(Strength, {
41 methods: () => ({nextWeaker: dart.functionType(Strength, [])}), 41 methods: () => ({nextWeaker: [Strength, []]}),
42 statics: () => ({ 42 statics: () => ({
43 stronger: dart.functionType(core.bool, [Strength, Strength]), 43 stronger: [core.bool, [Strength, Strength]],
44 weaker: dart.functionType(core.bool, [Strength, Strength]), 44 weaker: [core.bool, [Strength, Strength]],
45 weakest: dart.functionType(Strength, [Strength, Strength]), 45 weakest: [Strength, [Strength, Strength]],
46 strongest: dart.functionType(Strength, [Strength, Strength]) 46 strongest: [Strength, [Strength, Strength]]
47 }), 47 }),
48 names: ['stronger', 'weaker', 'weakest', 'strongest'] 48 names: ['stronger', 'weaker', 'weakest', 'strongest']
49 }); 49 });
50 let REQUIRED = dart.const(new Strength(0, "required")); 50 let REQUIRED = dart.const(new Strength(0, "required"));
51 let STRONG_PREFERRED = dart.const(new Strength(1, "strongPreferred")); 51 let STRONG_PREFERRED = dart.const(new Strength(1, "strongPreferred"));
52 let PREFERRED = dart.const(new Strength(2, "preferred")); 52 let PREFERRED = dart.const(new Strength(2, "preferred"));
53 let STRONG_DEFAULT = dart.const(new Strength(3, "strongDefault")); 53 let STRONG_DEFAULT = dart.const(new Strength(3, "strongDefault"));
54 let NORMAL = dart.const(new Strength(4, "normal")); 54 let NORMAL = dart.const(new Strength(4, "normal"));
55 let WEAK_DEFAULT = dart.const(new Strength(5, "weakDefault")); 55 let WEAK_DEFAULT = dart.const(new Strength(5, "weakDefault"));
56 let WEAKEST = dart.const(new Strength(6, "weakest")); 56 let WEAKEST = dart.const(new Strength(6, "weakest"));
(...skipping 28 matching lines...) Expand all
85 if (this.isSatisfied()) 85 if (this.isSatisfied())
86 exports.planner.incrementalRemove(this); 86 exports.planner.incrementalRemove(this);
87 this.removeFromGraph(); 87 this.removeFromGraph();
88 } 88 }
89 isInput() { 89 isInput() {
90 return false; 90 return false;
91 } 91 }
92 } 92 }
93 dart.setSignature(Constraint, { 93 dart.setSignature(Constraint, {
94 methods: () => ({ 94 methods: () => ({
95 addConstraint: dart.functionType(dart.void, []), 95 addConstraint: [dart.void, []],
96 satisfy: dart.functionType(Constraint, [dart.dynamic]), 96 satisfy: [Constraint, [dart.dynamic]],
97 destroyConstraint: dart.functionType(dart.void, []), 97 destroyConstraint: [dart.void, []],
98 isInput: dart.functionType(core.bool, []) 98 isInput: [core.bool, []]
99 }) 99 })
100 }); 100 });
101 class UnaryConstraint extends Constraint { 101 class UnaryConstraint extends Constraint {
102 UnaryConstraint(myOutput, strength) { 102 UnaryConstraint(myOutput, strength) {
103 this.myOutput = myOutput; 103 this.myOutput = myOutput;
104 this.satisfied = false; 104 this.satisfied = false;
105 super.Constraint(strength); 105 super.Constraint(strength);
106 this.addConstraint(); 106 this.addConstraint();
107 } 107 }
108 addToGraph() { 108 addToGraph() {
(...skipping 23 matching lines...) Expand all
132 return true; 132 return true;
133 } 133 }
134 removeFromGraph() { 134 removeFromGraph() {
135 if (this.myOutput != null) 135 if (this.myOutput != null)
136 this.myOutput.removeConstraint(this); 136 this.myOutput.removeConstraint(this);
137 this.satisfied = false; 137 this.satisfied = false;
138 } 138 }
139 } 139 }
140 dart.setSignature(UnaryConstraint, { 140 dart.setSignature(UnaryConstraint, {
141 methods: () => ({ 141 methods: () => ({
142 addToGraph: dart.functionType(dart.void, []), 142 addToGraph: [dart.void, []],
143 chooseMethod: dart.functionType(dart.void, [core.int]), 143 chooseMethod: [dart.void, [core.int]],
144 isSatisfied: dart.functionType(core.bool, []), 144 isSatisfied: [core.bool, []],
145 markInputs: dart.functionType(dart.void, [core.int]), 145 markInputs: [dart.void, [core.int]],
146 output: dart.functionType(Variable, []), 146 output: [Variable, []],
147 recalculate: dart.functionType(dart.void, []), 147 recalculate: [dart.void, []],
148 markUnsatisfied: dart.functionType(dart.void, []), 148 markUnsatisfied: [dart.void, []],
149 inputsKnown: dart.functionType(core.bool, [core.int]), 149 inputsKnown: [core.bool, [core.int]],
150 removeFromGraph: dart.functionType(dart.void, []) 150 removeFromGraph: [dart.void, []]
151 }) 151 })
152 }); 152 });
153 class StayConstraint extends UnaryConstraint { 153 class StayConstraint extends UnaryConstraint {
154 StayConstraint(v, str) { 154 StayConstraint(v, str) {
155 super.UnaryConstraint(v, str); 155 super.UnaryConstraint(v, str);
156 } 156 }
157 execute() {} 157 execute() {}
158 } 158 }
159 dart.setSignature(StayConstraint, { 159 dart.setSignature(StayConstraint, {
160 methods: () => ({execute: dart.functionType(dart.void, [])}) 160 methods: () => ({execute: [dart.void, []]})
161 }); 161 });
162 class EditConstraint extends UnaryConstraint { 162 class EditConstraint extends UnaryConstraint {
163 EditConstraint(v, str) { 163 EditConstraint(v, str) {
164 super.UnaryConstraint(v, str); 164 super.UnaryConstraint(v, str);
165 } 165 }
166 isInput() { 166 isInput() {
167 return true; 167 return true;
168 } 168 }
169 execute() {} 169 execute() {}
170 } 170 }
171 dart.setSignature(EditConstraint, { 171 dart.setSignature(EditConstraint, {
172 <<<<<<< HEAD
172 methods: () => ({execute: dart.functionType(dart.void, [])}) 173 methods: () => ({execute: dart.functionType(dart.void, [])})
174 ||||||| merged common ancestors
175 methods: () => ({
176 isInput: dart.functionType(core.bool, []),
177 execute: dart.functionType(dart.void, [])
178 })
179 =======
180 methods: () => ({
181 isInput: [core.bool, []],
182 execute: [dart.void, []]
183 })
184 >>>>>>> Use short array syntax in method signatures
173 }); 185 });
174 let NONE = 1; 186 let NONE = 1;
175 let FORWARD = 2; 187 let FORWARD = 2;
176 let BACKWARD = 0; 188 let BACKWARD = 0;
177 class BinaryConstraint extends Constraint { 189 class BinaryConstraint extends Constraint {
178 BinaryConstraint(v1, v2, strength) { 190 BinaryConstraint(v1, v2, strength) {
179 this.v1 = v1; 191 this.v1 = v1;
180 this.v2 = v2; 192 this.v2 = v2;
181 this.direction = NONE; 193 this.direction = NONE;
182 super.Constraint(strength); 194 super.Constraint(strength);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 removeFromGraph() { 241 removeFromGraph() {
230 if (this.v1 != null) 242 if (this.v1 != null)
231 this.v1.removeConstraint(this); 243 this.v1.removeConstraint(this);
232 if (this.v2 != null) 244 if (this.v2 != null)
233 this.v2.removeConstraint(this); 245 this.v2.removeConstraint(this);
234 this.direction = NONE; 246 this.direction = NONE;
235 } 247 }
236 } 248 }
237 dart.setSignature(BinaryConstraint, { 249 dart.setSignature(BinaryConstraint, {
238 methods: () => ({ 250 methods: () => ({
239 chooseMethod: dart.functionType(dart.void, [core.int]), 251 chooseMethod: [dart.void, [core.int]],
240 addToGraph: dart.functionType(dart.void, []), 252 addToGraph: [dart.void, []],
241 isSatisfied: dart.functionType(core.bool, []), 253 isSatisfied: [core.bool, []],
242 markInputs: dart.functionType(dart.void, [core.int]), 254 markInputs: [dart.void, [core.int]],
243 input: dart.functionType(Variable, []), 255 input: [Variable, []],
244 output: dart.functionType(Variable, []), 256 output: [Variable, []],
245 recalculate: dart.functionType(dart.void, []), 257 recalculate: [dart.void, []],
246 markUnsatisfied: dart.functionType(dart.void, []), 258 markUnsatisfied: [dart.void, []],
247 inputsKnown: dart.functionType(core.bool, [core.int]), 259 inputsKnown: [core.bool, [core.int]],
248 removeFromGraph: dart.functionType(dart.void, []) 260 removeFromGraph: [dart.void, []]
249 }) 261 })
250 }); 262 });
251 class ScaleConstraint extends BinaryConstraint { 263 class ScaleConstraint extends BinaryConstraint {
252 ScaleConstraint(src, scale, offset, dest, strength) { 264 ScaleConstraint(src, scale, offset, dest, strength) {
253 this.scale = scale; 265 this.scale = scale;
254 this.offset = offset; 266 this.offset = offset;
255 super.BinaryConstraint(src, dest, strength); 267 super.BinaryConstraint(src, dest, strength);
256 } 268 }
257 addToGraph() { 269 addToGraph() {
258 super.addToGraph(); 270 super.addToGraph();
(...skipping 20 matching lines...) Expand all
279 } 291 }
280 recalculate() { 292 recalculate() {
281 let ihn = this.input(), out = this.output(); 293 let ihn = this.input(), out = this.output();
282 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength); 294 out.walkStrength = Strength.weakest(this.strength, ihn.walkStrength);
283 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart .notNull(this.offset.stay); 295 out.stay = dart.notNull(ihn.stay) && dart.notNull(this.scale.stay) && dart .notNull(this.offset.stay);
284 if (out.stay) 296 if (out.stay)
285 this.execute(); 297 this.execute();
286 } 298 }
287 } 299 }
288 dart.setSignature(ScaleConstraint, { 300 dart.setSignature(ScaleConstraint, {
301 <<<<<<< HEAD
289 methods: () => ({execute: dart.functionType(dart.void, [])}) 302 methods: () => ({execute: dart.functionType(dart.void, [])})
303 ||||||| merged common ancestors
304 methods: () => ({
305 addToGraph: dart.functionType(dart.void, []),
306 removeFromGraph: dart.functionType(dart.void, []),
307 markInputs: dart.functionType(dart.void, [core.int]),
308 execute: dart.functionType(dart.void, []),
309 recalculate: dart.functionType(dart.void, [])
310 })
311 =======
312 methods: () => ({
313 addToGraph: [dart.void, []],
314 removeFromGraph: [dart.void, []],
315 markInputs: [dart.void, [core.int]],
316 execute: [dart.void, []],
317 recalculate: [dart.void, []]
318 })
319 >>>>>>> Use short array syntax in method signatures
290 }); 320 });
291 class EqualityConstraint extends BinaryConstraint { 321 class EqualityConstraint extends BinaryConstraint {
292 EqualityConstraint(v1, v2, strength) { 322 EqualityConstraint(v1, v2, strength) {
293 super.BinaryConstraint(v1, v2, strength); 323 super.BinaryConstraint(v1, v2, strength);
294 } 324 }
295 execute() { 325 execute() {
296 this.output().value = this.input().value; 326 this.output().value = this.input().value;
297 } 327 }
298 } 328 }
299 dart.setSignature(EqualityConstraint, { 329 dart.setSignature(EqualityConstraint, {
300 methods: () => ({execute: dart.functionType(dart.void, [])}) 330 methods: () => ({execute: [dart.void, []]})
301 }); 331 });
302 class Variable extends core.Object { 332 class Variable extends core.Object {
303 Variable(name, value) { 333 Variable(name, value) {
304 this.constraints = dart.setType([], core.List$(Constraint)); 334 this.constraints = dart.setType([], core.List$(Constraint));
305 this.name = name; 335 this.name = name;
306 this.value = value; 336 this.value = value;
307 this.determinedBy = null; 337 this.determinedBy = null;
308 this.mark = 0; 338 this.mark = 0;
309 this.walkStrength = WEAKEST; 339 this.walkStrength = WEAKEST;
310 this.stay = true; 340 this.stay = true;
311 } 341 }
312 addConstraint(c) { 342 addConstraint(c) {
313 this.constraints[core.$add](c); 343 this.constraints[core.$add](c);
314 } 344 }
315 removeConstraint(c) { 345 removeConstraint(c) {
316 this.constraints[core.$remove](c); 346 this.constraints[core.$remove](c);
317 if (dart.equals(this.determinedBy, c)) 347 if (dart.equals(this.determinedBy, c))
318 this.determinedBy = null; 348 this.determinedBy = null;
319 } 349 }
320 } 350 }
321 dart.setSignature(Variable, { 351 dart.setSignature(Variable, {
322 methods: () => ({ 352 methods: () => ({
323 addConstraint: dart.functionType(dart.void, [Constraint]), 353 addConstraint: [dart.void, [Constraint]],
324 removeConstraint: dart.functionType(dart.void, [Constraint]) 354 removeConstraint: [dart.void, [Constraint]]
325 }) 355 })
326 }); 356 });
327 class Planner extends core.Object { 357 class Planner extends core.Object {
328 Planner() { 358 Planner() {
329 this.currentMark = 0; 359 this.currentMark = 0;
330 } 360 }
331 incrementalAdd(c) { 361 incrementalAdd(c) {
332 let mark = this.newMark(); 362 let mark = this.newMark();
333 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark)) 363 for (let overridden = c.satisfy(mark); overridden != null; overridden = ov erridden.satisfy(mark))
334 ; 364 ;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 let determining = v.determinedBy; 445 let determining = v.determinedBy;
416 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints[core.$length] ); i = dart.notNull(i) + 1) { 446 for (let i = 0; dart.notNull(i) < dart.notNull(v.constraints[core.$length] ); i = dart.notNull(i) + 1) {
417 let c = v.constraints[core.$get](i); 447 let c = v.constraints[core.$get](i);
418 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied())) 448 if (dart.notNull(!dart.equals(c, determining)) && dart.notNull(c.isSatis fied()))
419 coll[core.$add](c); 449 coll[core.$add](c);
420 } 450 }
421 } 451 }
422 } 452 }
423 dart.setSignature(Planner, { 453 dart.setSignature(Planner, {
424 methods: () => ({ 454 methods: () => ({
425 incrementalAdd: dart.functionType(dart.void, [Constraint]), 455 incrementalAdd: [dart.void, [Constraint]],
426 incrementalRemove: dart.functionType(dart.void, [Constraint]), 456 incrementalRemove: [dart.void, [Constraint]],
427 newMark: dart.functionType(core.int, []), 457 newMark: [core.int, []],
428 makePlan: dart.functionType(Plan, [core.List$(Constraint)]), 458 makePlan: [Plan, [core.List$(Constraint)]],
429 extractPlanFromConstraints: dart.functionType(Plan, [core.List$(Constraint )]), 459 extractPlanFromConstraints: [Plan, [core.List$(Constraint)]],
430 addPropagate: dart.functionType(core.bool, [Constraint, core.int]), 460 addPropagate: [core.bool, [Constraint, core.int]],
431 removePropagateFrom: dart.functionType(core.List$(Constraint), [Variable]) , 461 removePropagateFrom: [core.List$(Constraint), [Variable]],
432 addConstraintsConsumingTo: dart.functionType(dart.void, [Variable, core.Li st$(Constraint)]) 462 addConstraintsConsumingTo: [dart.void, [Variable, core.List$(Constraint)]]
433 }) 463 })
434 }); 464 });
435 class Plan extends core.Object { 465 class Plan extends core.Object {
436 Plan() { 466 Plan() {
437 this.list = dart.setType([], core.List$(Constraint)); 467 this.list = dart.setType([], core.List$(Constraint));
438 } 468 }
439 addConstraint(c) { 469 addConstraint(c) {
440 this.list[core.$add](c); 470 this.list[core.$add](c);
441 } 471 }
442 size() { 472 size() {
443 return this.list[core.$length]; 473 return this.list[core.$length];
444 } 474 }
445 execute() { 475 execute() {
446 for (let i = 0; dart.notNull(i) < dart.notNull(this.list[core.$length]); i = dart.notNull(i) + 1) { 476 for (let i = 0; dart.notNull(i) < dart.notNull(this.list[core.$length]); i = dart.notNull(i) + 1) {
447 this.list[core.$get](i).execute(); 477 this.list[core.$get](i).execute();
448 } 478 }
449 } 479 }
450 } 480 }
451 dart.setSignature(Plan, { 481 dart.setSignature(Plan, {
452 methods: () => ({ 482 methods: () => ({
453 addConstraint: dart.functionType(dart.void, [Constraint]), 483 addConstraint: [dart.void, [Constraint]],
454 size: dart.functionType(core.int, []), 484 size: [core.int, []],
455 execute: dart.functionType(dart.void, []) 485 execute: [dart.void, []]
456 }) 486 })
457 }); 487 });
458 function chainTest(n) { 488 function chainTest(n) {
459 exports.planner = new Planner(); 489 exports.planner = new Planner();
460 let prev = null, first = null, last = null; 490 let prev = null, first = null, last = null;
461 for (let i = 0; dart.notNull(i) <= dart.notNull(n); i = dart.notNull(i) + 1) { 491 for (let i = 0; dart.notNull(i) <= dart.notNull(n); i = dart.notNull(i) + 1) {
462 let v = new Variable("v", 0); 492 let v = new Variable("v", 0);
463 if (prev != null) 493 if (prev != null)
464 new EqualityConstraint(prev, v, REQUIRED); 494 new EqualityConstraint(prev, v, REQUIRED);
465 if (i == 0) 495 if (i == 0)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 exports.BinaryConstraint = BinaryConstraint; 574 exports.BinaryConstraint = BinaryConstraint;
545 exports.ScaleConstraint = ScaleConstraint; 575 exports.ScaleConstraint = ScaleConstraint;
546 exports.EqualityConstraint = EqualityConstraint; 576 exports.EqualityConstraint = EqualityConstraint;
547 exports.Variable = Variable; 577 exports.Variable = Variable;
548 exports.Planner = Planner; 578 exports.Planner = Planner;
549 exports.Plan = Plan; 579 exports.Plan = Plan;
550 exports.chainTest = chainTest; 580 exports.chainTest = chainTest;
551 exports.projectionTest = projectionTest; 581 exports.projectionTest = projectionTest;
552 exports.change = change; 582 exports.change = change;
553 })(DeltaBlue, BenchmarkBase, core); 583 })(DeltaBlue, BenchmarkBase, core);
OLDNEW
« no previous file with comments | « test/codegen/expect/BenchmarkBase.js ('k') | test/codegen/expect/cascade.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698