mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
Compare commits
4 Commits
7ea00a3954
...
2f296994ae
Author | SHA1 | Date | |
---|---|---|---|
|
2f296994ae | ||
|
1194497b5c | ||
|
152d6bbd49 | ||
|
7d484f8fa3 |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@ -162,7 +162,7 @@ jobs:
|
|||||||
uses: jirutka/setup-alpine@v1
|
uses: jirutka/setup-alpine@v1
|
||||||
with:
|
with:
|
||||||
arch: ${{ matrix.arch }}
|
arch: ${{ matrix.arch }}
|
||||||
packages: gcc g++ make cmake libc-dev linux-headers python3
|
packages: gcc g++ make cmake libc-dev linux-headers python3 git
|
||||||
- name: Build and Test
|
- name: Build and Test
|
||||||
run: |
|
run: |
|
||||||
echo "Building for architecture: ${{ matrix.arch }}"
|
echo "Building for architecture: ${{ matrix.arch }}"
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -40,3 +40,4 @@ docs/C-API/functions.md
|
|||||||
|
|
||||||
|
|
||||||
cmake-build-*
|
cmake-build-*
|
||||||
|
tmp/
|
@ -5,6 +5,7 @@ project(pocketpy)
|
|||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
include(FetchContent)
|
||||||
include(CMakeOptions.txt)
|
include(CMakeOptions.txt)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
@ -13,8 +14,7 @@ endif()
|
|||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /experimental:c11atomics")
|
add_compile_options(/wd4267 /wd4244 /wd4146 /experimental:c11atomics)
|
||||||
add_compile_options(/wd4267 /wd4244 /wd4146)
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox")
|
||||||
@ -76,6 +76,28 @@ else()
|
|||||||
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=0)
|
add_definitions(-DPK_ENABLE_CUSTOM_SNAME=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(PK_ENABLE_MIMALLOC)
|
||||||
|
message(">> Fetching mimalloc")
|
||||||
|
FetchContent_Declare(
|
||||||
|
mimalloc
|
||||||
|
GIT_REPOSITORY https://github.com/microsoft/mimalloc.git
|
||||||
|
GIT_TAG v3.1.5
|
||||||
|
)
|
||||||
|
|
||||||
|
set(MI_OVERRIDE OFF CACHE BOOL "" FORCE)
|
||||||
|
set(MI_NO_USE_CXX ON CACHE BOOL "" FORCE)
|
||||||
|
set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
||||||
|
set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE)
|
||||||
|
set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
||||||
|
set(MI_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
FetchContent_MakeAvailable(mimalloc)
|
||||||
|
include_directories(${mimalloc_SOURCE_DIR}/include)
|
||||||
|
|
||||||
|
add_definitions(-DPK_ENABLE_MIMALLOC=1)
|
||||||
|
else()
|
||||||
|
add_definitions(-DPK_ENABLE_MIMALLOC=0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(PK_BUILD_MODULE_LZ4)
|
if(PK_BUILD_MODULE_LZ4)
|
||||||
add_subdirectory(3rd/lz4)
|
add_subdirectory(3rd/lz4)
|
||||||
@ -87,6 +109,7 @@ if(PK_BUILD_MODULE_LIBHV)
|
|||||||
add_definitions(-DPK_BUILD_MODULE_LIBHV)
|
add_definitions(-DPK_BUILD_MODULE_LIBHV)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(PK_BUILD_SHARED_LIB)
|
if(PK_BUILD_SHARED_LIB)
|
||||||
message(">> Building shared library")
|
message(">> Building shared library")
|
||||||
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
||||||
@ -149,4 +172,8 @@ endif()
|
|||||||
|
|
||||||
if(PK_BUILD_MODULE_LIBHV)
|
if(PK_BUILD_MODULE_LIBHV)
|
||||||
target_link_libraries(${PROJECT_NAME} libhv_bindings)
|
target_link_libraries(${PROJECT_NAME} libhv_bindings)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PK_ENABLE_MIMALLOC)
|
||||||
|
target_link_libraries(${PROJECT_NAME} mimalloc-static)
|
||||||
endif()
|
endif()
|
@ -11,6 +11,7 @@ option(PK_ENABLE_THREADS "" ON)
|
|||||||
option(PK_ENABLE_DETERMINISM "" OFF)
|
option(PK_ENABLE_DETERMINISM "" OFF)
|
||||||
option(PK_ENABLE_WATCHDOG "" OFF)
|
option(PK_ENABLE_WATCHDOG "" OFF)
|
||||||
option(PK_ENABLE_CUSTOM_SNAME "" OFF)
|
option(PK_ENABLE_CUSTOM_SNAME "" OFF)
|
||||||
|
option(PK_ENABLE_MIMALLOC "" OFF)
|
||||||
|
|
||||||
# modules
|
# modules
|
||||||
option(PK_BUILD_MODULE_LZ4 "" OFF)
|
option(PK_BUILD_MODULE_LZ4 "" OFF)
|
||||||
|
@ -20,7 +20,7 @@ assert config in ['Debug', 'Release', 'RelWithDebInfo']
|
|||||||
|
|
||||||
os.chdir("build")
|
os.chdir("build")
|
||||||
|
|
||||||
code = os.system(f"cmake .. -DPK_ENABLE_DETERMINISM=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}")
|
code = os.system(f"cmake .. -DPK_ENABLE_MIMALLOC=ON -DPK_ENABLE_DETERMINISM=ON -DCMAKE_BUILD_TYPE={config} {extra_flags}")
|
||||||
assert code == 0
|
assert code == 0
|
||||||
code = os.system(f"cmake --build . --config {config} -j 4")
|
code = os.system(f"cmake --build . --config {config} -j 4")
|
||||||
assert code == 0
|
assert code == 0
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "pocketpy/common/vector.h"
|
#include "pocketpy/common/vector.h"
|
||||||
|
|
||||||
typedef struct c11_chunkedvector_chunk {
|
typedef struct c11_chunkedvector_chunk {
|
||||||
int length;
|
int length;
|
||||||
int capacity;
|
int capacity;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#define PK_REGION(name) 1
|
#define PK_REGION(name) 1
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
@ -27,24 +27,15 @@
|
|||||||
#define PK_ENABLE_CUSTOM_SNAME 0
|
#define PK_ENABLE_CUSTOM_SNAME 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef PK_ENABLE_MIMALLOC // can be overridden by cmake
|
||||||
|
#define PK_ENABLE_MIMALLOC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
// GC min threshold
|
// GC min threshold
|
||||||
#ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
|
#ifndef PK_GC_MIN_THRESHOLD // can be overridden by cmake
|
||||||
#define PK_GC_MIN_THRESHOLD 32768
|
#define PK_GC_MIN_THRESHOLD 32768
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Memory allocation functions
|
|
||||||
#ifndef PK_MALLOC
|
|
||||||
#ifndef __cplusplus
|
|
||||||
#define PK_MALLOC(size) malloc(size)
|
|
||||||
#define PK_REALLOC(ptr, size) realloc(ptr, size)
|
|
||||||
#define PK_FREE(ptr) free(ptr)
|
|
||||||
#else
|
|
||||||
#define PK_MALLOC(size) std::malloc(size)
|
|
||||||
#define PK_REALLOC(ptr, size) std::realloc(ptr, size)
|
|
||||||
#define PK_FREE(ptr) std::free(ptr)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This is the maximum size of the value stack in py_TValue units
|
// This is the maximum size of the value stack in py_TValue units
|
||||||
// The actual size in bytes equals `sizeof(py_TValue) * PK_VM_STACK_SIZE`
|
// The actual size in bytes equals `sizeof(py_TValue) * PK_VM_STACK_SIZE`
|
||||||
#ifndef PK_VM_STACK_SIZE // can be overridden by cmake
|
#ifndef PK_VM_STACK_SIZE // can be overridden by cmake
|
||||||
@ -90,3 +81,25 @@
|
|||||||
#else
|
#else
|
||||||
#define PK_THREAD_LOCAL
|
#define PK_THREAD_LOCAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Memory allocation functions
|
||||||
|
#ifndef PK_MALLOC
|
||||||
|
#if PK_ENABLE_MIMALLOC
|
||||||
|
#include "mimalloc.h"
|
||||||
|
#define PK_MALLOC(size) mi_malloc(size)
|
||||||
|
#define PK_REALLOC(ptr, size) mi_realloc(ptr, size)
|
||||||
|
#define PK_FREE(ptr) mi_free(ptr)
|
||||||
|
#else
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdlib.h>
|
||||||
|
#define PK_MALLOC(size) malloc(size)
|
||||||
|
#define PK_REALLOC(ptr, size) realloc(ptr, size)
|
||||||
|
#define PK_FREE(ptr) free(ptr)
|
||||||
|
#else
|
||||||
|
#include <cstdlib>
|
||||||
|
#define PK_MALLOC(size) std::malloc(size)
|
||||||
|
#define PK_REALLOC(ptr, size) std::realloc(ptr, size)
|
||||||
|
#define PK_FREE(ptr) std::free(ptr)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "pocketpy/common/algorithm.h"
|
#include "pocketpy/common/algorithm.h"
|
||||||
#include "pocketpy/config.h"
|
#include "pocketpy/config.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
static bool _stable_sort_merge(char* a,
|
static bool _stable_sort_merge(char* a,
|
||||||
char* a_end,
|
char* a_end,
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
#include "pocketpy/common/chunkedvector.h"
|
#include "pocketpy/common/chunkedvector.h"
|
||||||
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdlib.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
|
||||||
#include "pocketpy/common/utils.h"
|
|
||||||
#include "pocketpy/config.h"
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline static int c11_bit_length(unsigned long x) {
|
PK_INLINE static int c11__bit_length(unsigned long x) {
|
||||||
#if(defined(__clang__) || defined(__GNUC__))
|
#if(defined(__clang__) || defined(__GNUC__))
|
||||||
return x == 0 ? 0 : (int)sizeof(unsigned long) * 8 - __builtin_clzl(x);
|
return x == 0 ? 0 : (int)sizeof(unsigned long) * 8 - __builtin_clzl(x);
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
@ -39,7 +36,6 @@ void c11_chunkedvector__ctor(c11_chunkedvector* self, int elem_size, int initial
|
|||||||
self->initial_chunks = initial_chunks;
|
self->initial_chunks = initial_chunks;
|
||||||
void* chunks_data = PK_MALLOC(elem_size * ((1U << (unsigned int)initial_chunks) - 1));
|
void* chunks_data = PK_MALLOC(elem_size * ((1U << (unsigned int)initial_chunks) - 1));
|
||||||
for(int i = 0; i < initial_chunks; i++) {
|
for(int i = 0; i < initial_chunks; i++) {
|
||||||
// TODO: optimize?
|
|
||||||
c11_chunkedvector_chunk chunk = {.length = 0,
|
c11_chunkedvector_chunk chunk = {.length = 0,
|
||||||
.capacity = 1U << i,
|
.capacity = 1U << i,
|
||||||
.data = (char*)chunks_data + elem_size * ((1U << i) - 1U)};
|
.data = (char*)chunks_data + elem_size * ((1U << i) - 1U)};
|
||||||
@ -59,10 +55,11 @@ void c11_chunkedvector__dtor(c11_chunkedvector* self) {
|
|||||||
|
|
||||||
void* c11_chunkedvector__emplace(c11_chunkedvector* self) {
|
void* c11_chunkedvector__emplace(c11_chunkedvector* self) {
|
||||||
if(self->length == self->capacity) {
|
if(self->length == self->capacity) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
c11_chunkedvector_chunk last_chunk = c11_vector__back(c11_chunkedvector_chunk, &self->chunks);
|
c11_chunkedvector_chunk last_chunk =
|
||||||
assert(last_chunk.capacity == last_chunk.length);
|
c11_vector__back(c11_chunkedvector_chunk, &self->chunks);
|
||||||
#endif
|
assert(last_chunk.capacity == last_chunk.length);
|
||||||
|
#endif
|
||||||
c11_chunkedvector_chunk chunk = {
|
c11_chunkedvector_chunk chunk = {
|
||||||
.length = 0,
|
.length = 0,
|
||||||
.capacity = 1U << (unsigned int)self->chunks.length,
|
.capacity = 1U << (unsigned int)self->chunks.length,
|
||||||
@ -70,9 +67,14 @@ void* c11_chunkedvector__emplace(c11_chunkedvector* self) {
|
|||||||
self->capacity += chunk.capacity;
|
self->capacity += chunk.capacity;
|
||||||
c11_vector__push(c11_chunkedvector_chunk, &self->chunks, chunk);
|
c11_vector__push(c11_chunkedvector_chunk, &self->chunks, chunk);
|
||||||
}
|
}
|
||||||
int last_chunk_index = c11_bit_length(self->length + 1) - 1;
|
#if 1
|
||||||
|
int last_chunk_index = c11__bit_length(self->length + 1) - 1;
|
||||||
c11_chunkedvector_chunk* last_chunk =
|
c11_chunkedvector_chunk* last_chunk =
|
||||||
c11__at(c11_chunkedvector_chunk, &self->chunks, last_chunk_index);
|
c11__at(c11_chunkedvector_chunk, &self->chunks, last_chunk_index);
|
||||||
|
#else
|
||||||
|
// This is not correct, because there is some pre-allocated chunks
|
||||||
|
c11_chunkedvector_chunk* last_chunk = &c11_vector__back(c11_chunkedvector_chunk, &self->chunks);
|
||||||
|
#endif
|
||||||
void* p = (char*)last_chunk->data + self->elem_size * last_chunk->length;
|
void* p = (char*)last_chunk->data + self->elem_size * last_chunk->length;
|
||||||
last_chunk->length++;
|
last_chunk->length++;
|
||||||
self->length++;
|
self->length++;
|
||||||
@ -80,7 +82,7 @@ void* c11_chunkedvector__emplace(c11_chunkedvector* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void* c11_chunkedvector__at(c11_chunkedvector* self, int index) {
|
void* c11_chunkedvector__at(c11_chunkedvector* self, int index) {
|
||||||
int chunk_index = c11_bit_length(index + 1) - 1;
|
int chunk_index = c11__bit_length(index + 1) - 1;
|
||||||
c11_chunkedvector_chunk* chunk = c11__at(c11_chunkedvector_chunk, &self->chunks, chunk_index);
|
c11_chunkedvector_chunk* chunk = c11__at(c11_chunkedvector_chunk, &self->chunks, chunk_index);
|
||||||
return (char*)chunk->data + (index + 1 - (1U << (unsigned int)chunk_index)) * self->elem_size;
|
return (char*)chunk->data + (index + 1 - (1U << (unsigned int)chunk_index)) * self->elem_size;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "pocketpy/common/memorypool.h"
|
#include "pocketpy/common/memorypool.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/config.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int BlockCount) {
|
void FixedMemoryPool__ctor(FixedMemoryPool* self, int BlockSize, int BlockCount) {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "pocketpy/common/str.h"
|
#include "pocketpy/common/str.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include "pocketpy/common/threads.h"
|
#include "pocketpy/common/threads.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
typedef struct NameBucket NameBucket;
|
typedef struct NameBucket NameBucket;
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "pocketpy/objects/sourcedata.h"
|
#include "pocketpy/objects/sourcedata.h"
|
||||||
#include "pocketpy/common/sstream.h"
|
#include "pocketpy/common/sstream.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void SourceData__ctor(struct SourceData* self,
|
static void SourceData__ctor(struct SourceData* self,
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -2,11 +2,9 @@
|
|||||||
#include "pocketpy/common/sstream.h"
|
#include "pocketpy/common/sstream.h"
|
||||||
#include "pocketpy/common/utils.h"
|
#include "pocketpy/common/utils.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
c11_string* c11_string__new(const char* data) { return c11_string__new2(data, strlen(data)); }
|
c11_string* c11_string__new(const char* data) { return c11_string__new2(data, strlen(data)); }
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "pocketpy/common/vector.h"
|
#include "pocketpy/common/vector.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "pocketpy/common/utils.h"
|
#include "pocketpy/common/utils.h"
|
||||||
#include "pocketpy/config.h"
|
#include "pocketpy/config.h"
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include "pocketpy/objects/error.h"
|
#include "pocketpy/objects/error.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
static bool stack_format_object(VM* self, c11_sv spec);
|
static bool stack_format_object(VM* self, c11_sv spec);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "pocketpy/objects/codeobject.h"
|
#include "pocketpy/objects/codeobject.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void ValueStack__ctor(ValueStack* self) {
|
void ValueStack__ctor(ValueStack* self) {
|
||||||
self->sp = self->begin;
|
self->sp = self->begin;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "pocketpy/objects/base.h"
|
#include "pocketpy/objects/base.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void pk_newgenerator(py_Ref out, py_Frame* frame, py_TValue* begin, py_TValue* end) {
|
void pk_newgenerator(py_Ref out, py_Frame* frame, py_TValue* begin, py_TValue* end) {
|
||||||
Generator* ud = py_newobject(out, tp_generator, 1, sizeof(Generator));
|
Generator* ud = py_newobject(out, tp_generator, 1, sizeof(Generator));
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "pocketpy/interpreter/objectpool.h"
|
#include "pocketpy/interpreter/objectpool.h"
|
||||||
#include "pocketpy/objects/base.h"
|
#include "pocketpy/objects/base.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void ManagedHeap__ctor(ManagedHeap* self) {
|
void ManagedHeap__ctor(ManagedHeap* self) {
|
||||||
MultiPool__ctor(&self->small_objects);
|
MultiPool__ctor(&self->small_objects);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "pocketpy/interpreter/line_profiler.h"
|
#include "pocketpy/interpreter/line_profiler.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void LineProfiler__ctor(LineProfiler* self) {
|
void LineProfiler__ctor(LineProfiler* self) {
|
||||||
c11_smallmap_p2i__ctor(&self->records);
|
c11_smallmap_p2i__ctor(&self->records);
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#include "pocketpy/interpreter/objectpool.h"
|
#include "pocketpy/interpreter/objectpool.h"
|
||||||
|
|
||||||
#include "pocketpy/config.h"
|
|
||||||
#include "pocketpy/objects/object.h"
|
#include "pocketpy/objects/object.h"
|
||||||
#include "pocketpy/common/sstream.h"
|
#include "pocketpy/common/sstream.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static PoolArena* PoolArena__new(int block_size) {
|
static PoolArena* PoolArena__new(int block_size) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "pocketpy/interpreter/vm.h"
|
#include "pocketpy/interpreter/vm.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
py_ItemRef pk_tpfindname(py_TypeInfo* ti, py_Name name) {
|
py_ItemRef pk_tpfindname(py_TypeInfo* ti, py_Name name) {
|
||||||
assert(ti != NULL);
|
assert(ti != NULL);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include "pocketpy/interpreter/vm.h"
|
#include "pocketpy/interpreter/vm.h"
|
||||||
#include "pocketpy/common/memorypool.h"
|
#include "pocketpy/common/memorypool.h"
|
||||||
#include "pocketpy/common/sstream.h"
|
|
||||||
#include "pocketpy/common/utils.h"
|
#include "pocketpy/common/utils.h"
|
||||||
#include "pocketpy/interpreter/generator.h"
|
#include "pocketpy/interpreter/generator.h"
|
||||||
#include "pocketpy/interpreter/modules.h"
|
#include "pocketpy/interpreter/modules.h"
|
||||||
@ -10,6 +9,7 @@
|
|||||||
#include "pocketpy/common/_generated.h"
|
#include "pocketpy/common/_generated.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
static char* pk_default_importfile(const char* path) {
|
static char* pk_default_importfile(const char* path) {
|
||||||
#if PK_ENABLE_OS
|
#if PK_ENABLE_OS
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "pocketpy/interpreter/vm.h"
|
#include "pocketpy/interpreter/vm.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void pk_print_stack(VM* self, py_Frame* frame, Bytecode byte) {
|
void pk_print_stack(VM* self, py_Frame* frame, Bytecode byte) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#if PY_SYS_PLATFORM == 0
|
#if PY_SYS_PLATFORM == 0
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#ifdef PK_BUILD_MODULE_LZ4
|
#ifdef PK_BUILD_MODULE_LZ4
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#include "pocketpy/objects/base.h"
|
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
static bool traceback_format_exc(int argc, py_Ref argv) {
|
static bool traceback_format_exc(int argc, py_Ref argv) {
|
||||||
PY_CHECK_ARGC(0);
|
PY_CHECK_ARGC(0);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "pocketpy/common/utils.h"
|
#include "pocketpy/common/utils.h"
|
||||||
#include "pocketpy/pocketpy.h"
|
#include "pocketpy/pocketpy.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
void Bytecode__set_signed_arg(Bytecode* self, int arg) {
|
void Bytecode__set_signed_arg(Bytecode* self, int arg) {
|
||||||
self->arg = (int16_t)arg;
|
self->arg = (int16_t)arg;
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#define HASH_PROBE_0(__k, ok, i) \
|
#define HASH_PROBE_0(__k, ok, i) \
|
||||||
ok = false; \
|
ok = false; \
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ static char* read_file(const char* path) {
|
|||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
long size = ftell(file);
|
long size = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
char* buffer = malloc(size + 1);
|
char* buffer = PK_MALLOC(size + 1);
|
||||||
size = fread(buffer, 1, size, file);
|
size = fread(buffer, 1, size, file);
|
||||||
buffer[size] = 0;
|
buffer[size] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
@ -85,7 +84,7 @@ int main(int argc, char** argv) {
|
|||||||
char* source = read_file(filename);
|
char* source = read_file(filename);
|
||||||
if(source) {
|
if(source) {
|
||||||
if(!py_exec(source, filename, EXEC_MODE, NULL)) py_printexc();
|
if(!py_exec(source, filename, EXEC_MODE, NULL)) py_printexc();
|
||||||
free(source);
|
PK_FREE(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user