2018-01-20 16:04:30 +00:00
|
|
|
/*
|
2018-05-18 03:41:20 +00:00
|
|
|
* Copyright (c) 2018 Calvin Rose
|
2018-01-20 16:04:30 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DST_STATE_H_defined
|
|
|
|
#define DST_STATE_H_defined
|
|
|
|
|
2018-01-27 20:15:09 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-01-20 16:04:30 +00:00
|
|
|
#include <stdint.h>
|
2018-03-31 20:40:36 +00:00
|
|
|
#include <dst/dstconfig.h>
|
|
|
|
#include <dst/dsttypes.h>
|
2018-01-20 16:04:30 +00:00
|
|
|
|
|
|
|
/* The VM state. Rather than a struct that is passed
|
2018-04-30 21:05:42 +00:00
|
|
|
* around, the vm state is global for simplicity. If
|
2018-05-14 13:55:34 +00:00
|
|
|
* at some point a a global state object, or context,
|
2018-04-30 21:05:42 +00:00
|
|
|
* is required to be passed around, this is waht would
|
2018-05-14 13:55:34 +00:00
|
|
|
* be in it. However, thread local globals for interpreter
|
|
|
|
* state should allow easy multithreading. */
|
2018-01-20 16:04:30 +00:00
|
|
|
|
2018-03-04 23:56:13 +00:00
|
|
|
/* How many VM stacks have been entered */
|
2018-03-30 20:12:30 +00:00
|
|
|
extern DST_THREAD_LOCAL int dst_vm_stackn;
|
2018-03-04 23:56:13 +00:00
|
|
|
|
2018-05-14 13:55:34 +00:00
|
|
|
/* The current running fiber on the current thread.
|
|
|
|
* Set and unset by dst_run. */
|
|
|
|
extern DST_THREAD_LOCAL DstFiber *dst_vm_fiber;
|
|
|
|
|
2018-01-20 16:04:30 +00:00
|
|
|
/* Immutable value cache */
|
2018-03-30 20:12:30 +00:00
|
|
|
extern DST_THREAD_LOCAL const uint8_t **dst_vm_cache;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_cache_capacity;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_cache_count;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_cache_deleted;
|
2018-01-20 16:04:30 +00:00
|
|
|
|
2018-03-31 20:40:36 +00:00
|
|
|
/* Garbage collection */
|
|
|
|
extern DST_THREAD_LOCAL void *dst_vm_blocks;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_gc_interval;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_next_collection;
|
|
|
|
extern DST_THREAD_LOCAL int dst_vm_gc_suspend;
|
|
|
|
|
2018-01-20 16:04:30 +00:00
|
|
|
/* GC roots */
|
2018-03-30 20:12:30 +00:00
|
|
|
extern DST_THREAD_LOCAL Dst *dst_vm_roots;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_root_count;
|
|
|
|
extern DST_THREAD_LOCAL uint32_t dst_vm_root_capacity;
|
2018-01-20 16:04:30 +00:00
|
|
|
|
2018-01-27 20:15:09 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-20 16:04:30 +00:00
|
|
|
#endif /* DST_STATE_H_defined */
|