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

Rewrite SMLserver #88

Open
2 tasks
melsman opened this issue Nov 14, 2021 · 2 comments
Open
2 tasks

Rewrite SMLserver #88

melsman opened this issue Nov 14, 2021 · 2 comments
Assignees

Comments

@melsman
Copy link
Owner

melsman commented Nov 14, 2021

The aim of this task is to make it possible to rewrite SMLserver to make it work with native x64 machine code. Such a rewrite allows for removing the KAM backend, which is currently not maintained (it does not work on 64-bit architectures). The strategy is to remove SMLserver entirely from the MLKit source repository and instead make it possible to craft an efficient web-server outside of the MLKit code base.

Design

Here is a possible design that will make it possible to craft an efficient web server in C:

  1. Add the following functionality to an o-file generated by the MLKit compiler:
typedef struct {
  uintptr_t *sp_top, *sp_bot; 
  Region topregion;       // top-most region
  uintptr_t *exn_ptr;     // exn-pointer 
  char *exn_msg;          // NULL if no exception
} *Context;
typedef struct {..} *Snapshot; 
Context eval_libs (void);                // Evaluate all libraries in MLB-files (except last or the 
                                         //  multiple scripts in script...end constructs)
Context eval (Context c, char *punit);   // Evaluate a program unit (last entry in MLB
                                         //  file or entry in script...end construct) 
char **punits (int **n);
Snapshot snap (Context c);
Context resnap (Snapshot s, Context c);

With the above functionality, we can write a web-server in C that is multi threaded, makes use of pre-evaluated libraries (using the snapshot functionality), and pools database connections.

Features

  1. The functionality can be tested in isolation.
  2. The functionality can perhaps be used to write a REPL (given dynamic linking).
  3. Contexts can be built for different thread stacks and each thread can snapshot the thread-specific context for the benefit of increased performance.
  4. The snapshot functionality can be left out initially.
  5. The web-server code (or the REPL code) can be held outside of the MLKit repository.

Tasks

  • Remove the KAM (bytecode) backend and the apache2 module code.
  • Set aside a register to hold the execution context pointer throughout execution. When the top-region is manipulated or accessed, it can be done through the context pointer; the context pointer can also be used for accessing the current exception pointer. Finally, it can be used for the parallelism mechanism (thread context).
@melsman melsman self-assigned this Nov 14, 2021
@Munksgaard
Copy link

Does this need to be a part of the compiler? Couldn't it just be a separate library that allows you to build HTTP servers?

@melsman
Copy link
Owner Author

melsman commented Nov 16, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants