Coder Social home page Coder Social logo

som-st / trufflesom Goto Github PK

View Code? Open in Web Editor NEW

This project forked from smarr/trufflesom

31.0 31.0 6.0 6.88 MB

A SOM Smalltalk implemented on top of Oracle's Truffle Framework

Home Page: http://som-st.github.io/

License: Other

Java 96.51% Python 3.07% Shell 0.43%

trufflesom's People

Contributors

charig avatar gpummer avatar humphreyhcb avatar smarr avatar sophie-kaleba avatar zapster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

trufflesom's Issues

Reading of uninitialized local variables is broken

Reading of uninitialized variables in methods is likely broken. At least it is in SOMns.

The following test fails with an assertion, because the read evaluates to null:

class Test usingPlatform: platform = Value ()(
  protected foo = (
    | a |
    a println.
    a := 1.
    a println.
  )

  public main: args = (
    foo.
    foo.
    ^ 0
  )
)

A fix could be:

diff --git a/src/som/compiler/MethodBuilder.java b/src/som/compiler/MethodBuilder.java
index 1598a2b..20e8757 100644
--- a/src/som/compiler/MethodBuilder.java
+++ b/src/som/compiler/MethodBuilder.java
@@ -101,7 +102,8 @@ public final class MethodBuilder {
     MethodScope outer = (outerBuilder != null)
         ? outerBuilder.getCurrentMethodScope()
         : null;
-    this.currentScope   = new MethodScope(new FrameDescriptor(), outer, clsScope);
+    assert Nil.nilObject != null;
+    this.currentScope   = new MethodScope(new FrameDescriptor(Nil.nilObject), outer, clsScope);

     accessesVariablesOfOuterScope = false;
     throwsNonLocalReturn          = false;

/cc @charig

AST inlining breaks capture semantics

@eregon found a bug in the AST inlining in SOMns. The following test does not result in the correct output:

class Test usingPlatform: platform = Value (
| private Array = platform kernel Array. |
)(
  public main: args = (
    | arr b |
    arr := Array new: 10.
    args from: 2 to: args size do: [ :arg | arg print. ' ' print ].

    'Correct Semantics' println.
    b := [ :i  |
        arr at: i put: [ i ]].
    1 to: 10 do: b.

    1 to: 10 do: [ :i  |
        (arr at: i) value println ].

    'Broken Semantics' println.
    1 to: 10 do: [ :i  |
        arr at: i put: [ i ]].

    1 to: 10 do: [ :i  |
        (arr at: i) value println ].
    ^ 0
  ) 
)

This issue is very likely to be a problem for TruffleSOM, too.

Refactor the handling of eager specializations

From @smarr on September 15, 2014 16:30

The hardcoding in MessageSendNode is getting annoying.

We should do something similar to the solution in RTruffleSOM, where each specialization knows the conditions under which it applies. So that it moves to the actual implementation and is not part of the MeSeNode anymore.

Copied from original issue: smarr/TruffleSOM#6

TruffleSOM does not accept writes to method arguments

SOM accepts writes to method arguments. TruffleSOM throws a runtime exception at compile time. Is this the expected behaviour?

I have written the following attached TestCase ArgumentReadonlyTest.som.txt. The runtime exception is found in the attached file
exception.txt.
('mysom' is 'som' with the change from 'som.vm.Universe' to 'trufflesom.vm.Universe'.)

Maybe the root cause has something to do with the setting von JAVA_HOME and GRAAL_HOME? I'm only able to run the provided samples in truffleSOM if JAVA_HOME is identical to GRAAL_HOME and points to the 'normal' Java VM. If GRAAL_HOME points to '... graalvm-ce-1.0.0-rc8/Contents/Home' I get the exception, that 'Caused by: java.lang.AssertionError: Only one implementation Engine.Impl allowed.'.

Parser fails on inlining nested blocks

In SOMns, the following code is problematic:

  false whileFalse: [
    | resrv |
    critical: [ resrv ] ] ].

The inlining of whileFalse: did not properly initialize the inliner with the local variables of the inlined block. This was covered up by on-demand adding the local information for writes.

A solution and tests are here: smarr/SOMns#72

The division of `Long.MIN_VALUE / -1` overflows

Normally, we handle overflows with Math.*Exact operations, but we don't have one in this case, because:

In cases where the size is int or long and overflow errors need to be detected, the methods addExact, subtractExact, multiplyExact, and toIntExact throw an ArithmeticException when the results overflow. For other arithmetic operations such as divide, absolute value, increment, decrement, and negation overflow occurs only with a specific minimum or maximum value and should be checked against the minimum or maximum as appropriate.

See https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html

Possible solution proposed by @fniephaus: smarr/SOMns#292

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.