diff --git a/BUILD.gn b/BUILD.gn index ff89ecb..f756b4d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -95,8 +95,6 @@ executable("vm") { "vm/port.h", "vm/primitives.cc", "vm/primitives.h", - "vm/primordial_soup.cc", - "vm/primordial_soup.h", "vm/random.h", "vm/snapshot.cc", "vm/snapshot.h", diff --git a/SConstruct b/SConstruct index 0b92974..21f0c44 100644 --- a/SConstruct +++ b/SConstruct @@ -220,7 +220,6 @@ def BuildVM(cxx, arch, target_os, debug, sanitize): 'os_win', 'port', 'primitives', - 'primordial_soup', 'snapshot', 'thread_emscripten', 'thread_pool', diff --git a/vm/main.cc b/vm/main.cc index 133626b..99dfc5b 100644 --- a/vm/main.cc +++ b/vm/main.cc @@ -7,12 +7,15 @@ #include +#include "vm/isolate.h" +#include "vm/message_loop.h" #include "vm/os.h" -#include "vm/primordial_soup.h" +#include "vm/port.h" +#include "vm/primitives.h" #include "vm/virtual_memory.h" static void SIGINT_handler(int sig) { - PrimordialSoup_InterruptAll(); + psoup::Isolate::InterruptAll(); } int main(int argc, const char** argv) { @@ -22,15 +25,25 @@ int main(int argc, const char** argv) { } psoup::MappedMemory snapshot = psoup::MappedMemory::MapReadOnly(argv[1]); - PrimordialSoup_Startup(); + psoup::OS::Startup(); + psoup::Primitives::Startup(); + psoup::PortMap::Startup(); + psoup::Isolate::Startup(); void (*defaultSIGINT)(int) = signal(SIGINT, SIGINT_handler); - intptr_t exit_code = - PrimordialSoup_RunIsolate(snapshot.address(), snapshot.size(), - argc - 2, &argv[2]); + uint64_t seed = psoup::OS::CurrentMonotonicNanos(); + psoup::Isolate* isolate = new psoup::Isolate(snapshot.address(), + snapshot.size(), seed); + isolate->loop()->PostMessage(new psoup::IsolateMessage(ILLEGAL_PORT, + argc - 2, &argv[2])); + intptr_t exit_code = isolate->loop()->Run(); + delete isolate; signal(SIGINT, defaultSIGINT); - PrimordialSoup_Shutdown(); + psoup::Isolate::Shutdown(); + psoup::PortMap::Shutdown(); + psoup::Primitives::Shutdown(); + psoup::OS::Shutdown(); snapshot.Free(); diff --git a/vm/main_emscripten.cc b/vm/main_emscripten.cc index bb563b5..71db3f0 100644 --- a/vm/main_emscripten.cc +++ b/vm/main_emscripten.cc @@ -11,7 +11,7 @@ #include "vm/message_loop.h" #include "vm/os.h" #include "vm/port.h" -#include "vm/primordial_soup.h" +#include "vm/primitives.h" EM_JS(void, _JS_initializeAliens, (), { var aliens = new Array(); @@ -25,7 +25,10 @@ EM_JS(void, _JS_initializeAliens, (), { static psoup::Isolate* isolate; extern "C" void load_snapshot(const void* snapshot, size_t snapshot_length) { - PrimordialSoup_Startup(); + psoup::OS::Startup(); + psoup::Primitives::Startup(); + psoup::PortMap::Startup(); + psoup::Isolate::Startup(); _JS_initializeAliens(); uint64_t seed = psoup::OS::CurrentMonotonicNanos(); diff --git a/vm/message_loop.h b/vm/message_loop.h index f83e1f5..31ffd05 100644 --- a/vm/message_loop.h +++ b/vm/message_loop.h @@ -5,6 +5,7 @@ #ifndef VM_MESSAGE_LOOP_H_ #define VM_MESSAGE_LOOP_H_ +#include "vm/globals.h" #include "vm/port.h" namespace psoup { diff --git a/vm/message_loop_emscripten.cc b/vm/message_loop_emscripten.cc index 7790469..1528a80 100644 --- a/vm/message_loop_emscripten.cc +++ b/vm/message_loop_emscripten.cc @@ -9,6 +9,7 @@ #include +#include "vm/assert.h" #include "vm/os.h" namespace psoup { diff --git a/vm/primordial_soup.cc b/vm/primordial_soup.cc deleted file mode 100644 index 1bd73f5..0000000 --- a/vm/primordial_soup.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) 2017, the Newspeak project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -#include "vm/primordial_soup.h" - -#include "vm/flags.h" -#include "vm/globals.h" -#include "vm/isolate.h" -#include "vm/message_loop.h" -#include "vm/os.h" -#include "vm/port.h" -#include "vm/primitives.h" -#include "vm/snapshot.h" -#include "vm/thread.h" - -PSOUP_EXTERN_C void PrimordialSoup_Startup() { - psoup::OS::Startup(); - psoup::Primitives::Startup(); - psoup::PortMap::Startup(); - psoup::Isolate::Startup(); -} - -PSOUP_EXTERN_C void PrimordialSoup_Shutdown() { - psoup::Isolate::Shutdown(); - psoup::PortMap::Shutdown(); - psoup::Primitives::Shutdown(); - psoup::OS::Shutdown(); -} - -PSOUP_EXTERN_C intptr_t PrimordialSoup_RunIsolate(const void* snapshot, - size_t snapshot_length, - int argc, - const char** argv) { - uint64_t seed = psoup::OS::CurrentMonotonicNanos(); - psoup::Isolate* isolate = new psoup::Isolate(snapshot, snapshot_length, seed); - isolate->loop()->PostMessage(new psoup::IsolateMessage(ILLEGAL_PORT, - argc, argv)); - intptr_t exit_code = isolate->loop()->Run(); - delete isolate; - return exit_code; -} - -PSOUP_EXTERN_C void PrimordialSoup_InterruptAll() { - psoup::Isolate::InterruptAll(); -} diff --git a/vm/primordial_soup.h b/vm/primordial_soup.h deleted file mode 100644 index a4e20f4..0000000 --- a/vm/primordial_soup.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017, the Newspeak project authors. Please see the AUTHORS file - * for details. All rights reserved. Use of this source code is governed by a - * BSD-style license that can be found in the LICENSE file. - */ - -#ifndef VM_PRIMORDIAL_SOUP_H_ -#define VM_PRIMORDIAL_SOUP_H_ - -#include -#include - -#ifdef __cplusplus -#define PSOUP_EXTERN_C extern "C" -#else -#define PSOUP_EXTERN_C -#endif - -PSOUP_EXTERN_C void PrimordialSoup_Startup(); -PSOUP_EXTERN_C void PrimordialSoup_Shutdown(); -PSOUP_EXTERN_C intptr_t PrimordialSoup_RunIsolate(const void* snapshot, - size_t snapshot_length, - int argc, const char** argv); -PSOUP_EXTERN_C void PrimordialSoup_InterruptAll(); - -#endif /* VM_PRIMORDIAL_SOUP_H_ */