OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Copyright 1996 John Maloney and Mario Wolczko. | 2 // Copyright 1996 John Maloney and Mario Wolczko. |
3 | 3 |
4 // This program is free software; you can redistribute it and/or modify | 4 // This program is free software; you can redistribute it and/or modify |
5 // it under the terms of the GNU General Public License as published by | 5 // it under the terms of the GNU General Public License as published by |
6 // the Free Software Foundation; either version 2 of the License, or | 6 // the Free Software Foundation; either version 2 of the License, or |
7 // (at your option) any later version. | 7 // (at your option) any later version. |
8 // | 8 // |
9 // This program is distributed in the hope that it will be useful, | 9 // This program is distributed in the hope that it will be useful, |
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 // GNU General Public License for more details. | 12 // GNU General Public License for more details. |
13 // | 13 // |
14 // You should have received a copy of the GNU General Public License | 14 // You should have received a copy of the GNU General Public License |
15 // along with this program; if not, write to the Free Software | 15 // along with this program; if not, write to the Free Software |
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | 17 |
18 | 18 |
19 // This implementation of the DeltaBlue benchmark is derived | 19 // This implementation of the DeltaBlue benchmark is derived |
20 // from the Smalltalk implementation by John Maloney and Mario | 20 // from the Smalltalk implementation by John Maloney and Mario |
21 // Wolczko. Some parts have been translated directly, whereas | 21 // Wolczko. Some parts have been translated directly, whereas |
22 // others have been modified more aggresively to make it feel | 22 // others have been modified more aggresively to make it feel |
23 // more like a JavaScript program. | 23 // more like a JavaScript program. |
24 | 24 |
25 | 25 |
26 var DeltaBlue = new BenchmarkSuite('DeltaBlue', 71104, [ | 26 var DeltaBlue = new BenchmarkSuite('DeltaBlue', 30282, [ |
27 new Benchmark('DeltaBlue', deltaBlue) | 27 new Benchmark('DeltaBlue', deltaBlue) |
28 ]); | 28 ]); |
29 | 29 |
30 | 30 |
31 /** | 31 /** |
32 * A JavaScript implementation of the DeltaBlue constrain-solving | 32 * A JavaScript implementation of the DeltaBlue constraint-solving |
33 * algorithm, as described in: | 33 * algorithm, as described in: |
34 * | 34 * |
35 * "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver" | 35 * "The DeltaBlue Algorithm: An Incremental Constraint Hierarchy Solver" |
36 * Bjorn N. Freeman-Benson and John Maloney | 36 * Bjorn N. Freeman-Benson and John Maloney |
37 * January 1990 Communications of the ACM, | 37 * January 1990 Communications of the ACM, |
38 * also available as University of Washington TR 89-08-06. | 38 * also available as University of Washington TR 89-08-06. |
39 * | 39 * |
40 * Beware: this benchmark is written in a grotesque style where | 40 * Beware: this benchmark is written in a grotesque style where |
41 * the constraint model is built by side-effects from constructors. | 41 * the constraint model is built by side-effects from constructors. |
42 * I've kept it this way to avoid deviating too much from the original | 42 * I've kept it this way to avoid deviating too much from the original |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 BinaryConstraint.superConstructor.call(this, strength); | 342 BinaryConstraint.superConstructor.call(this, strength); |
343 this.v1 = var1; | 343 this.v1 = var1; |
344 this.v2 = var2; | 344 this.v2 = var2; |
345 this.direction = Direction.NONE; | 345 this.direction = Direction.NONE; |
346 this.addConstraint(); | 346 this.addConstraint(); |
347 } | 347 } |
348 | 348 |
349 BinaryConstraint.inheritsFrom(Constraint); | 349 BinaryConstraint.inheritsFrom(Constraint); |
350 | 350 |
351 /** | 351 /** |
352 * Decides if this constratint can be satisfied and which way it | 352 * Decides if this constraint can be satisfied and which way it |
353 * should flow based on the relative strength of the variables related, | 353 * should flow based on the relative strength of the variables related, |
354 * and record that decision. | 354 * and record that decision. |
355 */ | 355 */ |
356 BinaryConstraint.prototype.chooseMethod = function (mark) { | 356 BinaryConstraint.prototype.chooseMethod = function (mark) { |
357 if (this.v1.mark == mark) { | 357 if (this.v1.mark == mark) { |
358 this.direction = (this.v1.mark != mark && Strength.stronger(this.strength, t
his.v2.walkStrength)) | 358 this.direction = (this.v2.mark != mark && Strength.stronger(this.strength, t
his.v2.walkStrength)) |
359 ? Direction.FORWARD | 359 ? Direction.FORWARD |
360 : Direction.NONE; | 360 : Direction.NONE; |
361 } | 361 } |
362 if (this.v2.mark == mark) { | 362 if (this.v2.mark == mark) { |
363 this.direction = (this.v1.mark != mark && Strength.stronger(this.strength, t
his.v1.walkStrength)) | 363 this.direction = (this.v1.mark != mark && Strength.stronger(this.strength, t
his.v1.walkStrength)) |
364 ? Direction.BACKWARD | 364 ? Direction.BACKWARD |
365 : Direction.NONE; | 365 : Direction.NONE; |
366 } | 366 } |
367 if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) { | 367 if (Strength.weaker(this.v1.walkStrength, this.v2.walkStrength)) { |
368 this.direction = Strength.stronger(this.strength, this.v1.walkStrength) | 368 this.direction = Strength.stronger(this.strength, this.v1.walkStrength) |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 edit.destroyConstraint(); | 871 edit.destroyConstraint(); |
872 } | 872 } |
873 | 873 |
874 // Global variable holding the current planner. | 874 // Global variable holding the current planner. |
875 var planner = null; | 875 var planner = null; |
876 | 876 |
877 function deltaBlue() { | 877 function deltaBlue() { |
878 chainTest(100); | 878 chainTest(100); |
879 projectionTest(100); | 879 projectionTest(100); |
880 } | 880 } |
OLD | NEW |