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

Update Om to latest #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ endif(B9_UBSAN)

# OMR Configuration

set(OMR_COMPILER ON CACHE INTERNAL "Enable the Compiler.")
set(OMR_JITBUILDER ON CACHE INTERNAL "We use OMR's jitbuilder tool for the b9 JIT")
set(OMR_EXAMPLE OFF CACHE INTERNAL "Disable the GC example")
set(OMR_OM ON CACHE INTERNAL "Enable OMR Om, a GC object model")
set(OMR_GC ON CACHE INTERNAL "Enable the GC")
set(OMR_FVTEST OFF CACHE INTERNAL "Disable OMR's internal test suite, it's incompatible with b9")
set(OMR_COMPILER ON CACHE INTERNAL "Enable the Compiler.")
set(OMR_JITBUILDER ON CACHE INTERNAL "We use OMR's jitbuilder tool for the b9 JIT")
set(OMR_EXAMPLE OFF CACHE INTERNAL "Disable the GC example")
set(OMR_OM ON CACHE INTERNAL "Enable OMR Om, a GC object model")
set(OMR_GC ON CACHE INTERNAL "Enable the GC")
set(OMR_GC_EXTENDED_API ON CACHE INTERNAL "Required for Om.")
set(OMR_FVTEST OFF CACHE INTERNAL "Disable OMR's internal test suite, it's incompatible with b9")
set(OMR_WARNINGS_AS_ERRORS OFF CACHE INTERNAL "OMR doesn't compile cleanly on my laptop :p")

# Compile a b9-js *.js to C++
Expand Down
16 changes: 8 additions & 8 deletions b9/include/b9/VirtualMachine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
#include <b9/compiler/Compiler.hpp>
#include <b9/instructions.hpp>

#include <OMR/Om/Context.inl.hpp>
#include <OMR/Om/MemorySystem.hpp>
#include <OMR/GC/StackRoot.hpp>
#include <OMR/Om/Context.hpp>
#include <OMR/Om/ObjectOperations.hpp>
#include <OMR/Om/RootRef.hpp>
#include <OMR/Om/Runtime.hpp>
#include <OMR/Om/ShapeOperations.hpp>
#include <OMR/Om/Value.hpp>
#include <OMR/Runtime.hpp>

#include <cstring>
#include <map>
Expand All @@ -30,6 +29,7 @@ b9::PrimitiveFunction b9_prim_print_stack;
namespace b9 {

namespace Om = ::OMR::Om;
namespace GC = ::OMR::GC;

class Compiler;
class ExecutionContext;
Expand Down Expand Up @@ -65,7 +65,7 @@ extern "C" typedef Om::RawValue (*JitFunction)(void *executionContext, ...);

class VirtualMachine {
public:
VirtualMachine(Om::ProcessRuntime &runtime, const Config &cfg);
VirtualMachine(OMR::Runtime &runtime, const Config &cfg);

~VirtualMachine() noexcept;

Expand Down Expand Up @@ -96,9 +96,9 @@ class VirtualMachine {

const std::shared_ptr<const Module> &module() { return module_; }

Om::MemorySystem &memoryManager() { return memoryManager_; }
Om::System &memoryManager() { return memoryManager_; }

const Om::MemorySystem &memoryManager() const { return memoryManager_; }
const Om::System &memoryManager() const { return memoryManager_; }

std::shared_ptr<Compiler> compiler() { return compiler_; }

Expand All @@ -109,7 +109,7 @@ class VirtualMachine {
b9_prim_print_string, b9_prim_print_number, b9_prim_print_stack};

Config cfg_;
Om::MemorySystem memoryManager_;
Om::System memoryManager_;
std::shared_ptr<Compiler> compiler_;
std::shared_ptr<const Module> module_;
std::vector<JitFunction> compiledFunctions_;
Expand Down
10 changes: 5 additions & 5 deletions b9/src/ExecutionContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <OMR/Om/ArrayOperations.hpp>
#include <OMR/Om/ObjectOperations.hpp>
#include <OMR/Om/RootRef.hpp>
#include <OMR/GC/StackRoot.hpp>
#include <OMR/Om/ShapeOperations.hpp>
#include <OMR/Om/Value.hpp>

Expand All @@ -27,8 +27,8 @@ ExecutionContext::ExecutionContext(VirtualMachine &virtualMachine,
: omContext_(virtualMachine.memoryManager()),
virtualMachine_(&virtualMachine),
cfg_(&cfg) {
omContext().userMarkingFns().push_back(
[this](Om::MarkingVisitor &v) { this->visit(v); });
omContext().gc().markingFns().push_back(
[this](GC::MarkingVisitor &v) { this->visit(v); });
}

void ExecutionContext::reset() {
Expand Down Expand Up @@ -426,7 +426,7 @@ void ExecutionContext::doPopIntoObject(Om::Id slotId) {
if (!found) {
static constexpr Om::SlotType type(Om::Id(0), Om::CoreType::VALUE);

Om::RootRef<Om::Object> root(*this, object);
GC::StackRoot<Om::Object> root(omContext().gc(), object);
auto map = Om::transitionLayout(*this, root, {{type, slotId}});
assert(map != nullptr);

Expand All @@ -446,7 +446,7 @@ void ExecutionContext::doCallIndirect() {

void ExecutionContext::doSystemCollect() {
std::cout << "SYSTEM COLLECT!!!" << std::endl;
OMR_GC_SystemCollect(omContext_.vmContext(), 0);
OMR_GC_SystemCollect(omContext().gc().vm(), 0);
}

} // namespace b9
4 changes: 2 additions & 2 deletions b9/src/VirtualMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include <b9/VirtualMachine.hpp>
#include <b9/compiler/Compiler.hpp>

#include <OMR/GC/StackRoot.hpp>
#include <OMR/Om/Allocator.hpp>
#include <OMR/Om/ArrayOperations.hpp>
#include <OMR/Om/ObjectOperations.hpp>
#include <OMR/Om/RootRef.hpp>
#include <OMR/Om/ShapeOperations.hpp>
#include <OMR/Om/Value.hpp>

Expand All @@ -25,7 +25,7 @@ namespace b9 {

constexpr PrimitiveFunction *const VirtualMachine::primitives_[3];

VirtualMachine::VirtualMachine(Om::ProcessRuntime &runtime, const Config &cfg)
VirtualMachine::VirtualMachine(OMR::Runtime &runtime, const Config &cfg)
: cfg_{cfg}, memoryManager_(runtime), compiler_{nullptr} {
if (cfg_.verbose) std::cout << "VM initializing..." << std::endl;

Expand Down
11 changes: 5 additions & 6 deletions b9run/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
#include <b9/compiler/Compiler.hpp>
#include <b9/deserialize.hpp>

#include <OMR/Om/Context.inl.hpp>
#include <OMR/Om/MemorySystem.hpp>
#include <OMR/Om/RootRef.hpp>
#include <OMR/Om/Runtime.hpp>
#include <OMR/GC/StackRoot.hpp>
#include <OMR/Om/Context.hpp>
#include <OMR/Runtime.hpp>

#include <strings.h>
#include <cstdio>
Expand Down Expand Up @@ -117,7 +116,7 @@ static bool parseArguments(RunConfig& cfg, const int argc, char* argv[]) {
return true;
}

static void run(Om::ProcessRuntime& runtime, const RunConfig& cfg) {
static void run(OMR::Runtime& runtime, const RunConfig& cfg) {
b9::VirtualMachine vm{runtime, cfg.b9};

std::ifstream file(cfg.moduleName, std::ios_base::in | std::ios_base::binary);
Expand All @@ -134,7 +133,7 @@ static void run(Om::ProcessRuntime& runtime, const RunConfig& cfg) {
}

int main(int argc, char* argv[]) {
Om::ProcessRuntime runtime;
OMR::Runtime runtime;
RunConfig cfg;

if (!parseArguments(cfg, argc, argv)) {
Expand Down
17 changes: 9 additions & 8 deletions test/b9test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace b9 {
namespace test {

using namespace OMR::Om;
namespace Om = OMR::Om;
namespace GC = OMR::GC;

// clang-format off
const std::vector<const char*> TEST_NAMES = {
Expand Down Expand Up @@ -44,7 +45,7 @@ const std::vector<const char*> TEST_NAMES = {
};
// clang-format on

Om::ProcessRuntime runtime;
OMR::Runtime runtime;

class InterpreterTest : public ::testing::Test {
public:
Expand Down Expand Up @@ -141,8 +142,8 @@ TEST(MyTest, arguments) {
END_SECTION};
m->functions.push_back(b9::FunctionDef{"add_args", i, 2, 0});
vm.load(m);
auto r = vm.run("add_args", {{AS_INT48, 1}, {AS_INT48, 2}});
EXPECT_EQ(r, Value(AS_INT48, 3));
auto r = vm.run("add_args", {{Om::AS_INT48, 1}, {Om::AS_INT48, 2}});
EXPECT_EQ(r, Om::Value(Om::AS_INT48, 3));
}

TEST(MyTest, jitSimpleProgram) {
Expand All @@ -157,7 +158,7 @@ TEST(MyTest, jitSimpleProgram) {
vm.load(m);
vm.generateAllCode();
auto r = vm.run("add", {});
EXPECT_EQ(r, Value(AS_INT48, 0xdead));
EXPECT_EQ(r, Om::Value(Om::AS_INT48, 0xdead));
}

TEST(MyTest, haveAVariable) {
Expand All @@ -172,7 +173,7 @@ TEST(MyTest, haveAVariable) {
vm.load(m);
vm.generateAllCode();
auto r = vm.run("add", {});
EXPECT_EQ(r, Value(AS_INT48, 0xdead));
EXPECT_EQ(r, Om::Value(Om::AS_INT48, 0xdead));
}

TEST(ObjectTest, allocateSomething) {
Expand All @@ -193,8 +194,8 @@ TEST(ObjectTest, allocateSomething) {
m->strings.push_back("Hello, World");
m->functions.push_back(b9::FunctionDef{"allocate_object", i, 0, 1});
vm.load(m);
Value r = vm.run("allocate_object", {});
EXPECT_EQ(r, Value(AS_INT48, 0));
Om::Value r = vm.run("allocate_object", {});
EXPECT_EQ(r, Om::Value(Om::AS_INT48, 0));
}

} // namespace test
Expand Down
2 changes: 1 addition & 1 deletion test/testDisasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ TEST(ReadBinaryTest, runValidModule) {
serialize(buffer, *m1);

auto m2 = deserialize(buffer);
Om::ProcessRuntime runtime;
OMR::Runtime runtime;
VirtualMachine vm(runtime, {});
vm.load(m2);
vm.run(0, {Om::Value(Om::AS_INT48, 1), Om::Value(Om::AS_INT48, 2)});
Expand Down
2 changes: 1 addition & 1 deletion third_party/omr
Submodule omr updated 490 files