Skip to content

Commit 52e655f

Browse files
committed
Import SOM sourcecode
This is the code currently made available via http://www.hpi.uni-potsdam.de/hirschfeld/projects/som/ This is, what looks to be the most recent version based on SOM and SOM++. However, it does not seem to include improvements made for CSOM. Signed-off-by: Stefan Marr <[email protected]>
0 parents  commit 52e655f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+4812
-0
lines changed

AUTHORS

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
This file lists all people who have contributed to the SOM VM.
2+
3+
SOM was originally implemented at the University of Aarhus (Denmark) in
4+
2001/2002. The implementation of SOM was done by Jakob Roland Andersen, Kasper
5+
Verdich Lund, Lars Bak, Mads Torgersen, and Ulrik Pagh Schultz. They also
6+
wrote the original versions of the SOM Smalltalk libraries, test suites, and
7+
benchmarks, that are (in extended versions) bundled with SOM.
8+
9+
SOM was used by Michael Haupt in courses on virtual machines at Lancaster
10+
University and Technische Universitaet Darmstadt (Germany) in VM courses in
11+
2006. During that time, some changes were applied to SOM by Michael Haupt and
12+
Sebastian Kanthak.
13+
14+
SOM is currently maintained by Michael Haupt at the Hasso-Plattner-Institut,
15+
University of Potsdam, Germany.
16+
17+
2009-08-14, Michael Haupt
18+

Examples/Benchmarks/All.som

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"
2+
3+
$Id: All.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
All = (
27+
28+
run = (
29+
| total |
30+
total := 0.
31+
32+
Fibonacci, Dispatch, Bounce, Loop, Permute, Queens, List, Recurse,
33+
Storage, Sieve, BubbleSort, QuickSort, Sum, Towers, TreeSort,
34+
IntegerLoop
35+
do: [ :benchmark | total := total + benchmark new run ].
36+
37+
('All tests completed (' + total + ' ms)') println.
38+
)
39+
40+
)

Examples/Benchmarks/Ball.som

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"
2+
3+
$Id: Ball.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
Ball = (
27+
28+
| x y xVel yVel |
29+
30+
bounce = (
31+
| xLimit yLimit bounced |
32+
xLimit := yLimit := 500.
33+
bounced := false.
34+
35+
x := x + xVel.
36+
y := y + yVel.
37+
(x > xLimit)
38+
ifTrue: [ x := xLimit. xVel := 0 - xVel abs. bounced := true ].
39+
(x < 0)
40+
ifTrue: [ x := 0. xVel := xVel abs. bounced := true ].
41+
(y > yLimit)
42+
ifTrue: [ y := yLimit. yVel := 0 - yVel abs. bounced := true ].
43+
(y < 0)
44+
ifTrue: [ y := 0. yVel := yVel abs. bounced := true ].
45+
^bounced
46+
)
47+
48+
initialize = (
49+
x := Random next % 500.
50+
y := Random next % 500.
51+
xVel := (Random next % 300) - 150.
52+
yVel := (Random next % 300) - 150.
53+
)
54+
55+
-----------------
56+
57+
new = ( ^super new initialize )
58+
59+
)

Examples/Benchmarks/Benchmark.som

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"
2+
3+
$Id: Benchmark.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
Benchmark = (
27+
28+
run = (
29+
| startTime elapsedTime measuredTime minTime iterations |
30+
31+
(('Starting ' + (self name)) + ' benchmark ... ') println.
32+
33+
iterations := elapsedTime := 0.
34+
minTime := 100000.
35+
36+
[ elapsedTime < 2000 or: [ iterations < 5 ] ]
37+
whileTrue: [
38+
system fullGC.
39+
startTime := system time.
40+
self benchmark.
41+
measuredTime := system time - startTime.
42+
elapsedTime := elapsedTime + measuredTime.
43+
minTime > measuredTime ifTrue: [ minTime := measuredTime ].
44+
iterations := iterations + 1. ].
45+
46+
(' Iterations: ' + iterations + ' (elapsed time ' + elapsedTime
47+
+ ' ms)') println.
48+
(' RESULT: ' + minTime + ' ms') println.
49+
'' println.
50+
^minTime
51+
)
52+
53+
benchmark = ( self subclassResponsibility )
54+
name = ( ^self class name asString )
55+
56+
)

Examples/Benchmarks/Bounce.som

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"
2+
3+
$Id: Bounce.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
Bounce = Benchmark (
27+
28+
benchmark = (
29+
| ballCount balls bounces |
30+
31+
Random initialize.
32+
33+
ballCount := 100.
34+
bounces := 0.
35+
balls := Array new: ballCount withAll: [ Ball new ].
36+
37+
1 to: 50 do: [ :i |
38+
balls do: [ :ball |
39+
(ball bounce) ifTrue: [ bounces := bounces + 1 ] ] ].
40+
41+
(bounces = 1331)
42+
ifFalse: [
43+
self error: 'Wrong result: ' + bounces + ' should be: 1331' ]
44+
)
45+
46+
)

Examples/Benchmarks/BubbleSort.som

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"
2+
3+
$Id: BubbleSort.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
BubbleSort = Sort (
27+
28+
sort: array = (
29+
| top |
30+
31+
"array length - 1 downTo: 0 do: [ :i |
32+
0 to: i - 1 do: [ :j |"
33+
array length downTo: 1 do: [ :i |
34+
1 to: i - 1 do: [ :j |
35+
| current next |
36+
current := array at: j.
37+
next := array at: j + 1.
38+
(current > next)
39+
ifTrue: [
40+
array at: j put: next.
41+
array at: j + 1 put: current ] ] ]
42+
)
43+
44+
dataSize = ( ^130 )
45+
46+
)

Examples/Benchmarks/Dispatch.som

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"
2+
3+
$Id: Dispatch.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
Dispatch = Benchmark (
27+
28+
benchmark = (
29+
1 to: 20000 do: [ :i | self method: i ]
30+
)
31+
32+
method: argument = ( ^argument )
33+
34+
)

Examples/Benchmarks/Fibonacci.som

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"
2+
3+
$Id: Fibonacci.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
Fibonacci = Benchmark (
27+
28+
benchmark = ( | result |
29+
result := self fibonacci: 20.
30+
(result = 10946)
31+
ifFalse: [
32+
self error: 'Wrong result: ' + result + ' should be: 10946' ]
33+
)
34+
35+
fibonacci: n = (
36+
^(n <= 1)
37+
ifTrue: 1
38+
ifFalse: [ (self fibonacci: (n - 1)) + (self fibonacci: (n - 2)) ]
39+
)
40+
41+
)

Examples/Benchmarks/IntegerLoop.som

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"
2+
3+
$Id: IntegerLoop.som 31 2009-07-31 12:25:18Z michael.haupt $
4+
5+
Copyright (c) 2001-2007 see AUTHORS file
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the 'Software'), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
THE SOFTWARE.
24+
"
25+
26+
IntegerLoop = Benchmark (
27+
28+
benchmark = ( | bounds |
29+
30+
bounds := 20000.
31+
32+
bounds negated to: bounds by: 1 do: [:value | |a| a := value-value].
33+
)
34+
)

0 commit comments

Comments
 (0)