Skip to content

Commit

Permalink
Merge branch 'headless' into idle
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Jan 13, 2020
2 parents 2635b75 + 0ed8e2c commit a54bda3
Show file tree
Hide file tree
Showing 34 changed files with 493 additions and 314 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
117 changes: 117 additions & 0 deletions .github/workflows/continuous-integration-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Continuous integration
on: [push, pull_request]

jobs:
build-unixes:
name: Build Unixes
runs-on: ${{ matrix.variant.os }}
strategy:
matrix:
variant:
- os: ubuntu-18.04
appname: Pharo
vmExecutable: pharo
- os: macos-latest
appname: Pharo
vmExecutable: Pharo
env:
APPNAME: ${{matrix.variant.appname}}
VM_EXECUTABLE_NAME: ${{ matrix.variant.vmExecutable }}
CC: clang
CXX: clang++
steps:
- name: Install dependencies
if: matrix.variant.os == 'ubuntu-18.04'
run: sudo apt-get install uuid-dev

- uses: actions/checkout@v1

- name: CMake configuration
run: |
mkdir -p build
cd build
cmake .. -DAPPNAME=$APPNAME -DVM_EXECUTABLE_NAME=$VM_EXECUTABLE_NAME
- name: make
run: cd build && make
- name: make install
run: cd build && make install

- name: Package artifacts
run: |
cd build
make package
mkdir -p ../artifacts
cp -f build/packages/*.zip build/packages/*.sha1 ../artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: build-artifacts
path: artifacts

- name: Run tests
continue-on-error: true
run: scripts/runTests.sh
- name: Upload test results
continue-on-error: true
uses: actions/upload-artifact@v1
with:
name: test-results
path: test-results

build-windows-cygwin:
name: Build Windows Cygwin
runs-on: windows-2016
strategy:
matrix:
variant:
- appname: Pharo
vmExecutable: Pharo
env:
APPNAME: ${{matrix.variant.appname}}
VM_EXECUTABLE_NAME: ${{ matrix.variant.vmExecutable }}
steps:
- uses: actions/checkout@v1

- name: Install Cygwin
run: .\scripts\installCygwin.ps1 "setup-x86_64.exe" x86_64

- name: CMake configuration
run: |
mkdir -p build
cd build
cmake .. -DAPPNAME=$APPNAME -DVM_EXECUTABLE_NAME=$VM_EXECUTABLE_NAME
shell: pwsh.exe -File .\scripts\runScriptInCygwinBash.ps1 {0}

- name: make
run: cd build && make
shell: pwsh.exe -File .\scripts\runScriptInCygwinBash.ps1 {0}
- name: make install
run: cd build && make install
shell: pwsh.exe -File .\scripts\runScriptInCygwinBash.ps1 {0}

- name: Package artifacts
run: |
cd build
make package
mkdir -p ../artifacts
cp -f build/packages/*.zip build/packages/*.sha1 ../artifacts
shell: pwsh.exe -File .\scripts\runScriptInCygwinBash.ps1 {0}

- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: build-artifacts
path: artifacts

- name: Run tests
continue-on-error: true
run: scripts/runTests.sh
shell: pwsh.exe -File .\scripts\runScriptInCygwinBash.ps1 {0}

- name: Upload test results
continue-on-error: true
uses: actions/upload-artifact@v1
with:
name: test-results
path: test-results
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ check_include_files(sys/ndir.h HAVE_SYS_NDIR_H)
check_include_files(sys/dir.h HAVE_SYS_DIR_H)
check_include_files(sys/filio.h HAVE_SYS_FILIO_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(execinfo.h HAVE_EXECINFO_H)

check_include_files(dlfcn.h HAVE_DLFCN_H)
check_library_exists(dl dlopen "" HAVE_LIBDL)
Expand Down Expand Up @@ -291,6 +292,7 @@ set(SUPPORT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/parameters.c
${CMAKE_CURRENT_SOURCE_DIR}/src/fileDialogCommon.c
${CMAKE_CURRENT_SOURCE_DIR}/src/stringUtilities.c
${CMAKE_CURRENT_SOURCE_DIR}/src/imageAccess.c
${CMAKE_CURRENT_SOURCE_DIR}/src/semaphores/platformSemaphore.c
${CMAKE_CURRENT_SOURCE_DIR}/extracted/vm/src/common/heartbeat.c
)
Expand Down Expand Up @@ -329,11 +331,6 @@ add_third_party_dependencies_per_platform()
configure_installables(bin)

install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/extracted/vm/include/common/sq.h
${CMAKE_CURRENT_SOURCE_DIR}/extracted/vm/include/common/sqMemoryAccess.h
${CMAKE_CURRENT_SOURCE_DIR}/extracted/vm/include/common/sqVirtualMachine.h
${CMAKE_CURRENT_BINARY_DIR}/generated/vm/include/interp.h
${CMAKE_CURRENT_BINARY_DIR}/generated/vm/include/vmCallback.h
${CMAKE_CURRENT_BINARY_DIR}/build/include/pharovm/config.h
DESTINATION include/pharovm
COMPONENT include)
Expand All @@ -344,6 +341,18 @@ install(
COMPONENT include
FILES_MATCHING PATTERN *.h)

install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/extracted/vm/include/common/"
DESTINATION include/pharovm
COMPONENT include
FILES_MATCHING PATTERN *.h)

install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/generated/vm/include/"
DESTINATION include/pharovm
COMPONENT include
FILES_MATCHING PATTERN *.h)

# Packaging Setup

make_directory("build/packages")
Expand Down
83 changes: 11 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ The image running on the VM is responsible of handling the UI and the events.

The image includes a default implementation of the handling of UI through the use of SDL2.

For more details about the whole Pharo VM project refer to our [wiki](https://github.com/pharo-project/opensmalltalk-vm/wiki).

This is a fork of [OpenSmalltalk-vm](https://github.com/OpenSmalltalk/opensmalltalk-vm).
We are doing our best to keep compatibility and contribute back, as long as it fits the objective of Pharo community.

## CI

This project is continuously built and test in the CI infrastructure located at:
Expand Down Expand Up @@ -44,7 +49,7 @@ unzip
wget

```bash
$ cmake . -DWIN=1
$ cmake .
$ make install
```

Expand All @@ -64,8 +69,7 @@ The accepted flavours for the moment are as follows:
- *CoInterpreterWithQueueFFI*: VM including JIT
- *StackVM*: VM with context to native stack mapping, without JI

Source Directory Structure
--------------------------
## Source Directory Structure

The headless mode is developed on top of code of the Cog branch of Opensmalltalk-vm.
The code that is used without changes is stored in the *extracted* directory.
Expand All @@ -81,74 +85,9 @@ The code that has been specially created or modified for this branch is stored i
- extracted: This code is literally the same code base used in the normal OpenSmalltalk-VM build.
- plugins: The code of the different plugins developed for headless mode.

## Editing the VM code in your image

Overview of OpenSmalltalk-VM
----------------------------

This branch is based on the open-smalltalk vm (https://github.com/OpenSmalltalk/opensmalltalk-vm).
Opensmalltalk-vm (a.k.a. the Cog VM) is the virtual machine beneath the
Cuis, Pharo and Squeak Smalltalk dialects and one of the VMs beneath the
Newspeak language. For issues related to these systems that are unrelated to
the VM itself, please use their forums:
* http://www.cuis-smalltalk.org
* http://pharo.org/community
* http://squeak.org/community/
* http://newspeaklanguage.org

Second, the core VM, which comprises the execution engine and garbage collector,
and the core plugins, is developed in Smalltalk, using the *VM Simulator*. This
repository contains the code generated by the Simulator, and the platform support
code for the entire VM, its CI infrastructure and so on. The core VM **should
not** be developed by editing the generated code. The core VM should be
developed using Smalltalk. You can find scripts to build a Smalltalk image in
which to do core VM development in the [image](https://github.com/OpenSmalltalk/opensmalltalk-vm/tree/Cog/image) directory in this repository.
You can read about the Simulator here:
* https://www.researchgate.net/publication/328509577_Two_Decades_of_Smalltalk_VM_Development_Live_VM_Development_through_Simulation_Tools
* https://hal.archives-ouvertes.fr/hal-01883380/document

Cog is an evolution of the Squeak Back-to-the-future Smalltalk virtual machine
that provides a number of different Smalltalk virtual machines. The VMs are
developed in Smalltalk, using all the dynamic and reflective facilities of the
Squeak/Pharo Smalltalk system. As such, developing in Cog is a delight. The
Smalltalk framework comprising the various Cog VMs is translated into C by its
Slang component to produce VM source that is combined with platform-specific
support sources and compiled via a C compiler to obtain a fast production VM.
This directory tree includes the output of Slang for various configurations of
"Cog VM" and the associated platform support code, plus build directories that
can be used to produce production VMs.

This directory tree also includes an instance of the Smalltalk Cog development
system, suitable for developing the VM in Smalltalk, and for generating new
VM sources.

The "Cog VM" comes in a bewildering variety of forms. The first distinction
is between Squeak/Croquet VMs that run Squeak, Pharo, Cuis, Croquet images
and their ilk, and between Newspeak VMs that run Newspeak.

Another distinction is between Stack, Cog and Sista VMs. Stack VMs are those
with context-to-stack mapping that optimise message sending by keeping method
activations on a stack instead of in contexts. These are pure interpreters but
are significantly faster than the standard context-based Interpreter VM. Cog
VMs add a JIT to the mix, compiling methods used more than once to machine code
on the fly. Sista VMs, as yet unrealised and in development, add support for
adaptive optimization that does speculative inlining at the bytecode-to-bytecode
level. These are under development and targeted for release in 2015.

Another distinction is between "v3" VMs and Spur VMs. "v3" is the original
object representation for Squeak as described in the back-to-the-future paper.
Spur, as described on the www.mirandabanda.org blog, is a faster object
representation which uses generation scavenging, lazy forwarding for fast
become, a single object header format common to 32 and 64 bit versions, and a
segmented heap that can grow and shrink, releasing memory back to the host OS.
Newspeak, Squeak 5.0 and Pharo 5 use Spur.

Another distinction is between normal single-threaded VMs that schedule "green"
Smalltalk light-weight processes above a single-threaded VM, and multi-threaded
VMs that share the VM between any number of native threads such that only one
native thread owns the VM at any one time, switching between threads on FFI
calls and callbacks or on Smalltalk process switches when Smalltalk processes
are owned by threads. This architecture offers non-blocking FFI calls and
interoperability with multiple native threads, but does /not/ provide true
concurrency. This multi-threaded support is as yet experimental.

You can load the Pharo code of the VM using Pharo's git client Iceberg.
You can do so by cloning directly this repository from Iceberg, or by adding an already existing clone to it.

Alternatively, if you're building the VM using the instructions above, the build process does already generate a Pharo image with the VM code loaded. You'll find such Image in the `build/vmmaker` directory inside your build directory.
1 change: 1 addition & 0 deletions extracted/plugins/FilePlugin/src/common/FilePlugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static char __buildInfo[] = "FilePlugin VMMaker.oscog-eem.2498 uuid: f4233232-2c
# define EXPORT(returnType) static returnType
#endif

#include "pharovm/imageAccess.h"
#include "FilePlugin.h"
#include "sqMemoryAccess.h"

Expand Down
100 changes: 0 additions & 100 deletions extracted/plugins/FilePlugin/src/win/sqWin32FilePrims.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,104 +456,4 @@ size_t sqFileWriteFromAt(SQFile *f, size_t count, char* byteArrayIndex, size_t s
return dwReallyWritten;
}

/***************************************************************************/
/* Image file functions */
/***************************************************************************/
sqInt sqImageFileClose(sqImageFile h)
{
SetEndOfFile((HANDLE)(h-1));
return CloseHandle((HANDLE)(h-1));
}

sqImageFile sqImageFileOpen(const char *fileName, const char *mode)
{ const char *modePtr;
int writeFlag = 0;
WCHAR *win32Path = NULL;
HANDLE h;

if(!mode) return 0;
modePtr = mode;
while(*modePtr)
{
if(*modePtr == 'w') writeFlag = 1;
/* Note: We cannot append here */
if(*modePtr == 'a') return 0;
modePtr++;
}
/* convert the file name into a null-terminated C string */
ALLOC_WIN32_PATH(win32Path, fileName, -1);

if(hasCaseSensitiveDuplicate(win32Path))
return 0;

h = CreateFileW(win32Path,
writeFlag ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_READ,
writeFlag ? FILE_SHARE_READ : (FILE_SHARE_READ | FILE_SHARE_WRITE),
NULL, /* No security descriptor */
writeFlag ? CREATE_ALWAYS : OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL /* No template */);

if(h == INVALID_HANDLE_VALUE)
return 0;

return (usqIntptr_t)h+1;
}

squeakFileOffsetType sqImageFilePosition(sqImageFile h)
{
win32FileOffset ofs;
ofs.offset = 0;
ofs.dwLow = SetFilePointer((HANDLE)(h-1), 0, &ofs.dwHigh, FILE_CURRENT);
return ofs.offset;
}

size_t sqImageFileRead(void *ptr, size_t sz, size_t count, sqImageFile h)
{
DWORD dwReallyRead;
squeakFileOffsetType position;

position = sqImageFilePosition(h);
ReadFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyRead, NULL);
while(dwReallyRead != (DWORD)(count*sz)) {
DWORD err = GetLastError();
if(sqMessageBox(MB_ABORTRETRYIGNORE, TEXT("Squeak Warning"),TEXT("Image file read problem (%d out of %d bytes read)"), dwReallyRead, count*sz)
== IDABORT) return (dwReallyRead / sz);
sqImageFileSeek(h, position);
ReadFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyRead, NULL);
}
return (dwReallyRead / sz);
}

squeakFileOffsetType sqImageFileSeek(sqImageFile h, squeakFileOffsetType pos)
{
win32FileOffset ofs;
ofs.offset = pos;
ofs.dwLow = SetFilePointer((HANDLE)(h-1), ofs.dwLow, &ofs.dwHigh, FILE_BEGIN);
return ofs.offset;
}

squeakFileOffsetType sqImageFileSeekEnd(sqImageFile h, squeakFileOffsetType pos)
{
win32FileOffset ofs;
ofs.offset = pos;
ofs.dwLow = SetFilePointer((HANDLE)(h - 1), ofs.dwLow, &ofs.dwHigh, FILE_END);
return ofs.offset;
}

size_t sqImageFileWrite(const void *ptr, size_t sz, size_t count, sqImageFile h)
{
DWORD dwReallyWritten;
WriteFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyWritten, NULL);
return (size_t) (dwReallyWritten / sz);
}

squeakFileOffsetType sqImageFileSize(sqImageFile h)
{
win32FileOffset ofs;
ofs.offset = 0;
ofs.dwLow = GetFileSize((HANDLE)(h-1), &ofs.dwHigh);
return ofs.offset;
}

#endif /* WIN32_FILE_SUPPORT */
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static char __buildInfo[] = "UnixOSProcessPlugin VMConstruction-Plugins-OSProces
# undef EXPORT
# define EXPORT(returnType) static returnType
#endif
#include "pharovm/imageAccess.h"

#include "FilePlugin.h"
#include "SocketPlugin.h"
Expand Down

0 comments on commit a54bda3

Please sign in to comment.