Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SomSom, A Metacircular SOM #29

Merged
merged 53 commits into from
Apr 11, 2021
Merged

Implement SomSom, A Metacircular SOM #29

merged 53 commits into from
Apr 11, 2021

Conversation

smarr
Copy link
Member

@smarr smarr commented Mar 16, 2020

This PR implements SOM in SOM.
It's a pretty direct translation of the basic version of the SOM bytecode interpreter with 16 bytecodes.
It is able to execute all tests of the standard SOM test suite.
Though, it's pretty darn slow.

It also runs Hello World and probably some of the benchmarks, but I haven't confirmed this yet, because it's very very slow. Oops. I was running multiple levels of interpreters.

To run, it needs the primitives introduced in #67.
It may also need changes to how the command line arguments are handled so that the options are passed to SomSom and not consumed by the host SOM, for example see: smarr/TruffleSOM@7f0f26c

It should also be able to run multiple "storeys" of a tower of interpreters. Though, I haven't tested this recently. Yep. Works. See comment below.

Adoption/Integration Status

Status SOM PR
SOM (java) SOM-st/som-java#11
TruffleSOM SOM-st/TruffleSOM#53
SOM++
CSOM
PySOM
JsSOM
SOM-RS
ykSOM

PR History

Originally, this started out as a PR just for the lexer:
Implement the SOM Lexer in SOM.

This requires three new primitives and a new string escape code:

  • String>>#isWhiteSpace
  • String>>#isLetter
  • String>>#isDigit
  • and the \0 escape code, which should be pretty standard, but we haven't had need for it before

@sophie-kaleba could you review this please, too?

@ltratt I thought this might be of interest to you. Well, perhaps not quite yet, but, it's also a nice test case for the parser and string support logic.

@ltratt
Copy link

ltratt commented Mar 16, 2020

This slightly exceeds my ability to quickly understand, but one suggestion based on previous SOM tests experience is that it might be worth having a number of "negative" tests in here so that you can also ensure the lexer doesn't match things you don't think it should match. AFAICS it only has "positive" tests at the moment. Warning: I might be wrong.

.travis.yml Outdated
- language: java
dist: trusty
env: SOM=TruffleSOM REPO=https://github.com/SOM-st/TruffleSOM.git BUILD=make SOM="./som -G"
jdk: [oraclejdk8]
addons: {apt: {packages: [libc6-dev-i386]}}

- language: java
env: SOM=spec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you need trusty as well for spec?

.travis.yml Outdated
git --no-pager log -n 1
eval $BUILD
$SOM -cp ../Smalltalk ../TestSuite/TestHarness.som
$SOM -cp ../Smalltalk:../TestSuite:../SomSom/src/compiler ../SomSom/tests/SomSomTests.som
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect the CI to go red because of those tests, except for som-java once it will be updated.
Should we keep it red for now / allow failure for the others ?

@smarr smarr force-pushed the som-som branch 3 times, most recently from a783c68 to 3c13530 Compare March 20, 2020 20:23
@smarr smarr force-pushed the som-som branch 5 times, most recently from 93aff7b to 41de83e Compare April 10, 2021 15:00
@smarr smarr changed the title SomSom Lexer Implement SomSom Apr 10, 2021
smarr added 15 commits April 10, 2021 17:37
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
This should fix all the off-by-one errors caused by the switch from 0-based to 1-based indexing

Signed-off-by: Stefan Marr <[email protected]>
smarr added 22 commits April 10, 2021 17:37
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
The result of a impl-level operation needs a impl-level class test.

Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
@smarr
Copy link
Member Author

smarr commented Apr 10, 2021

Took a year, but SomSom seems to be read for merge.
PR description update.

It runs the SOM test suite, and hello world, and I think also itself, but haven't tested that recently.

@sophie-kaleba should be ready for experiments.

@smarr
Copy link
Member Author

smarr commented Apr 10, 2021

Towers of Interpreters: Hello World

Level 0:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk ./Examples/Hello.som
Hello, World from SOM
real         4.37
user         3.00
sys          1.44

Level 1:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk ./Examples/Hello.som
Hello, World from SOM
real         5.12
user         7.88
sys          1.58

Level 2:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk ./Examples/Hello.som
Hello, World from SOM
real        41.95
user       106.31
sys          2.77

Level 3:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk ./Examples/Hello.som
timed out...

Towers of Interpreters: TestSuite

Level 0:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk ./TestSuite/TestHarness.som
Total number of tests:           115
Number of unsupported optionals: 2
Number of successful tests:      115
Number of assertions tested:     614
real         4.92
user         4.80
sys          1.65

Level 1:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk ./TestSuite/TestHarness.som
Total number of tests:           115
Number of unsupported optionals: 0
Number of successful tests:      115
Number of assertions tested:     614
real         9.52
user        25.42
sys          2.11

Level 2:

/usr/bin/time -p ./som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk:core-lib/TestSuite:core-lib/SomSom/src/compiler:core-lib/SomSom/src/vm:core-lib/SomSom/src/vmobjects:core-lib/SomSom/src/interpreter:core-lib/SomSom/src/primitives \
  core-lib/SomSom/src/vm/Main.som \
  -cp core-lib/Smalltalk ./TestSuite/TestHarness.som
Total number of tests:           115
Number of unsupported optionals: 0
Number of successful tests:      115
Number of assertions tested:     614
real       847.37
user      1015.02
sys         15.99

@smarr smarr merged commit 302a28a into SOM-st:master Apr 11, 2021
@smarr smarr deleted the som-som branch April 11, 2021 10:57
@smarr smarr changed the title Implement SomSom Implement SomSom, A Metacircular SOM Apr 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants