Code Monkey home page Code Monkey logo

omtalk's Introduction

Omtalk

Omtalk is a static compiler for SOM, a derivative of smalltalk. Omtalk is built with MLIR and LLVM.

Code Generation Example

Omtalk currently compiles SOM code to a high-level representation in MLIR. Lowering to LLVM is WIP. The Omtalk runtime uses a single tagged value type, called an !omtalk.box<?> in MLIR.

Fibonacci

The following code:

Fibonacci = (          "defines a subclass of Object"
    fib: n = (         "defines the fib method with the argument n"
        ^ n <= 1
            ifTrue:  1
            ifFalse: [ self fib: (n - 1) + (self fib: (n - 2)) ]
    )
)

Compiles to the MLIR code:

module {
  omtalk.klass @Fibonacci : @Object {
    "omtalk.method"() ( {
    ^bb0(%arg0: !omtalk.box<?>):  // no predecessors
      %0 = "omtalk.constant_int"() {value = 1 : i64} : () -> !omtalk.box<int>
      %1 = "omtalk.send"(%arg0, %0) {message = @"<="} : (!omtalk.box<?>, !omtalk.box<int>) -> !omtalk.box<?>
      %2 = "omtalk.constant_int"() {value = 1 : i64} : () -> !omtalk.box<int>
      %3 = "omtalk.block"() ( {
        %5 = "omtalk.self"() : () -> !omtalk.box<ref>
        %6 = "omtalk.constant_int"() {value = 1 : i64} : () -> !omtalk.box<int>
        %7 = "omtalk.send"(%arg0, %6) {message = @"-"} : (!omtalk.box<?>, !omtalk.box<int>) -> !omtalk.box<?>
        %8 = "omtalk.self"() : () -> !omtalk.box<ref>
        %9 = "omtalk.constant_int"() {value = 2 : i64} : () -> !omtalk.box<int>
        %10 = "omtalk.send"(%arg0, %9) {message = @"-"} : (!omtalk.box<?>, !omtalk.box<int>) -> !omtalk.box<?>
        %11 = "omtalk.send"(%8, %10) {message = @"fib:"} : (!omtalk.box<ref>, !omtalk.box<?>) -> !omtalk.box<?>
        %12 = "omtalk.send"(%7, %11) {message = @"+"} : (!omtalk.box<?>, !omtalk.box<?>) -> !omtalk.box<?>
        %13 = "omtalk.send"(%5, %12) {message = @"fib:"} : (!omtalk.box<ref>, !omtalk.box<?>) -> !omtalk.box<?>
        "omtalk.return"(%13) : (!omtalk.box<?>) -> ()
      }) {type = () -> !omtalk.box<?>} : () -> !omtalk.box<?>
      %4 = "omtalk.send"(%1, %2, %3) {message = @"ifTrue:ifFalse:"} : (!omtalk.box<?>, !omtalk.box<int>, !omtalk.box<?>) -> !omtalk.box<?>
      "omtalk.return"(%4) : (!omtalk.box<?>) -> ()
    }) {sym_name = "fib:", type = (!omtalk.box<?>) -> !omtalk.box<?>} : () -> ()
  }
}

Building

To build Omtalk and all tests, run:

mkdir build; cd build
cmake -G Ninja -C ../cmake/caches/dev.cmake ..
ninja

omtalk's People

Contributors

youngar avatar devin122 avatar rwy7 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

devin122

omtalk's Issues

Find a tracing/logging solution

We need a fast logging library.
Options are:

  • structured logging vs text based logging.
  • binary output vs text based output.
  • schema-full vs schema-less (for structured logging).

Primary contenders are (listed slow -> fast)

  • std::iostream
  • textual unstructured logs: rapidjson, pugixml
  • textual unstructured logs: spdlog
  • binary unstructured logs: nanolog or binlog
  • binary schema-less structured logs: msgpack
  • binary schema-full structured logs: flatbuffers
  • raw struct dumps

Any other suggestions?

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.