Move enum definitions out of struct definition
This commit is contained in:
parent
c7fd015d83
commit
e763b1118b
Notes:
git
2022-07-22 23:10:46 +09:00
@ -98,6 +98,34 @@ PACKED_STRUCT_UNALIGNED(struct rb_io_buffer_t {
|
|||||||
/** @alias{rb_io_buffer_t} */
|
/** @alias{rb_io_buffer_t} */
|
||||||
typedef struct rb_io_buffer_t rb_io_buffer_t;
|
typedef struct rb_io_buffer_t rb_io_buffer_t;
|
||||||
|
|
||||||
|
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
|
||||||
|
/*
|
||||||
|
* enc enc2 read action write action
|
||||||
|
* NULL NULL force_encoding(default_external) write the byte sequence of str
|
||||||
|
* e1 NULL force_encoding(e1) convert str.encoding to e1
|
||||||
|
* e1 e2 convert from e2 to e1 convert str.encoding to e2
|
||||||
|
*/
|
||||||
|
struct rb_io_enc_t {
|
||||||
|
/** Internal encoding. */
|
||||||
|
rb_encoding *enc;
|
||||||
|
/** External encoding. */
|
||||||
|
rb_encoding *enc2;
|
||||||
|
/**
|
||||||
|
* Flags.
|
||||||
|
*
|
||||||
|
* @see enum ::ruby_econv_flag_type
|
||||||
|
*/
|
||||||
|
int ecflags;
|
||||||
|
/**
|
||||||
|
* Flags as Ruby hash.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
*
|
||||||
|
* This is set. But used from nowhere maybe?
|
||||||
|
*/
|
||||||
|
VALUE ecopts;
|
||||||
|
};
|
||||||
|
|
||||||
/** Ruby's IO, metadata and buffers. */
|
/** Ruby's IO, metadata and buffers. */
|
||||||
typedef struct rb_io_t {
|
typedef struct rb_io_t {
|
||||||
|
|
||||||
@ -141,36 +169,7 @@ typedef struct rb_io_t {
|
|||||||
*/
|
*/
|
||||||
VALUE tied_io_for_writing;
|
VALUE tied_io_for_writing;
|
||||||
|
|
||||||
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
|
struct rb_io_enc_t encs; /**< Decomposed encoding flags. */
|
||||||
/*
|
|
||||||
* enc enc2 read action write action
|
|
||||||
* NULL NULL force_encoding(default_external) write the byte sequence of str
|
|
||||||
* e1 NULL force_encoding(e1) convert str.encoding to e1
|
|
||||||
* e1 e2 convert from e2 to e1 convert str.encoding to e2
|
|
||||||
*/
|
|
||||||
struct rb_io_enc_t {
|
|
||||||
/** Internal encoding. */
|
|
||||||
rb_encoding *enc;
|
|
||||||
|
|
||||||
/** External encoding. */
|
|
||||||
rb_encoding *enc2;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flags.
|
|
||||||
*
|
|
||||||
* @see enum ::ruby_econv_flag_type
|
|
||||||
*/
|
|
||||||
int ecflags;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flags as Ruby hash.
|
|
||||||
*
|
|
||||||
* @internal
|
|
||||||
*
|
|
||||||
* This is set. But used from nowhere maybe?
|
|
||||||
*/
|
|
||||||
VALUE ecopts;
|
|
||||||
} encs; /**< Decomposed encoding flags. */
|
|
||||||
|
|
||||||
/** Encoding converter used when reading from this IO. */
|
/** Encoding converter used when reading from this IO. */
|
||||||
rb_econv_t *readconv;
|
rb_econv_t *readconv;
|
||||||
|
43
iseq.h
43
iseq.h
@ -241,28 +241,29 @@ struct iseq_insn_info_entry {
|
|||||||
rb_event_flag_t events;
|
rb_event_flag_t events;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct iseq_catch_table_entry {
|
/*
|
||||||
enum catch_type {
|
* iseq type:
|
||||||
CATCH_TYPE_RESCUE = INT2FIX(1),
|
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
||||||
CATCH_TYPE_ENSURE = INT2FIX(2),
|
* use iseq as continuation.
|
||||||
CATCH_TYPE_RETRY = INT2FIX(3),
|
*
|
||||||
CATCH_TYPE_BREAK = INT2FIX(4),
|
* CATCH_TYPE_BREAK (iter):
|
||||||
CATCH_TYPE_REDO = INT2FIX(5),
|
* use iseq as key.
|
||||||
CATCH_TYPE_NEXT = INT2FIX(6)
|
*
|
||||||
} type;
|
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
||||||
|
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
||||||
|
* NULL.
|
||||||
|
*/
|
||||||
|
enum catch_type {
|
||||||
|
CATCH_TYPE_RESCUE = INT2FIX(1),
|
||||||
|
CATCH_TYPE_ENSURE = INT2FIX(2),
|
||||||
|
CATCH_TYPE_RETRY = INT2FIX(3),
|
||||||
|
CATCH_TYPE_BREAK = INT2FIX(4),
|
||||||
|
CATCH_TYPE_REDO = INT2FIX(5),
|
||||||
|
CATCH_TYPE_NEXT = INT2FIX(6)
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
struct iseq_catch_table_entry {
|
||||||
* iseq type:
|
enum catch_type type;
|
||||||
* CATCH_TYPE_RESCUE, CATCH_TYPE_ENSURE:
|
|
||||||
* use iseq as continuation.
|
|
||||||
*
|
|
||||||
* CATCH_TYPE_BREAK (iter):
|
|
||||||
* use iseq as key.
|
|
||||||
*
|
|
||||||
* CATCH_TYPE_BREAK (while), CATCH_TYPE_RETRY,
|
|
||||||
* CATCH_TYPE_REDO, CATCH_TYPE_NEXT:
|
|
||||||
* NULL.
|
|
||||||
*/
|
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
|
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
|
@ -40,6 +40,24 @@ struct rb_ractor_waiting_list {
|
|||||||
rb_ractor_t **ractors;
|
rb_ractor_t **ractors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ractor_wait_status {
|
||||||
|
wait_none = 0x00,
|
||||||
|
wait_receiving = 0x01,
|
||||||
|
wait_taking = 0x02,
|
||||||
|
wait_yielding = 0x04,
|
||||||
|
wait_moving = 0x08,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ractor_wakeup_status {
|
||||||
|
wakeup_none,
|
||||||
|
wakeup_by_send,
|
||||||
|
wakeup_by_yield,
|
||||||
|
wakeup_by_take,
|
||||||
|
wakeup_by_close,
|
||||||
|
wakeup_by_interrupt,
|
||||||
|
wakeup_by_retry,
|
||||||
|
};
|
||||||
|
|
||||||
struct rb_ractor_sync {
|
struct rb_ractor_sync {
|
||||||
// ractor lock
|
// ractor lock
|
||||||
rb_nativethread_lock_t lock;
|
rb_nativethread_lock_t lock;
|
||||||
@ -56,29 +74,34 @@ struct rb_ractor_sync {
|
|||||||
bool outgoing_port_closed;
|
bool outgoing_port_closed;
|
||||||
|
|
||||||
struct ractor_wait {
|
struct ractor_wait {
|
||||||
enum ractor_wait_status {
|
enum ractor_wait_status status;
|
||||||
wait_none = 0x00,
|
enum ractor_wakeup_status wakeup_status;
|
||||||
wait_receiving = 0x01,
|
|
||||||
wait_taking = 0x02,
|
|
||||||
wait_yielding = 0x04,
|
|
||||||
wait_moving = 0x08,
|
|
||||||
} status;
|
|
||||||
|
|
||||||
enum ractor_wakeup_status {
|
|
||||||
wakeup_none,
|
|
||||||
wakeup_by_send,
|
|
||||||
wakeup_by_yield,
|
|
||||||
wakeup_by_take,
|
|
||||||
wakeup_by_close,
|
|
||||||
wakeup_by_interrupt,
|
|
||||||
wakeup_by_retry,
|
|
||||||
} wakeup_status;
|
|
||||||
|
|
||||||
struct rb_ractor_basket yielded_basket;
|
struct rb_ractor_basket yielded_basket;
|
||||||
struct rb_ractor_basket taken_basket;
|
struct rb_ractor_basket taken_basket;
|
||||||
} wait;
|
} wait;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// created
|
||||||
|
// | ready to run
|
||||||
|
// ====================== inserted to vm->ractor
|
||||||
|
// v
|
||||||
|
// blocking <---+ all threads are blocking
|
||||||
|
// | |
|
||||||
|
// v |
|
||||||
|
// running -----+
|
||||||
|
// | all threads are terminated.
|
||||||
|
// ====================== removed from vm->ractor
|
||||||
|
// v
|
||||||
|
// terminated
|
||||||
|
//
|
||||||
|
// status is protected by VM lock (global state)
|
||||||
|
enum ractor_status {
|
||||||
|
ractor_created,
|
||||||
|
ractor_running,
|
||||||
|
ractor_blocking,
|
||||||
|
ractor_terminated,
|
||||||
|
};
|
||||||
|
|
||||||
struct rb_ractor_struct {
|
struct rb_ractor_struct {
|
||||||
struct rb_ractor_pub pub;
|
struct rb_ractor_pub pub;
|
||||||
|
|
||||||
@ -104,27 +127,7 @@ struct rb_ractor_struct {
|
|||||||
VALUE name;
|
VALUE name;
|
||||||
VALUE loc;
|
VALUE loc;
|
||||||
|
|
||||||
// created
|
enum ractor_status status_;
|
||||||
// | ready to run
|
|
||||||
// ====================== inserted to vm->ractor
|
|
||||||
// v
|
|
||||||
// blocking <---+ all threads are blocking
|
|
||||||
// | |
|
|
||||||
// v |
|
|
||||||
// running -----+
|
|
||||||
// | all threads are terminated.
|
|
||||||
// ====================== removed from vm->ractor
|
|
||||||
// v
|
|
||||||
// terminated
|
|
||||||
//
|
|
||||||
// status is protected by VM lock (global state)
|
|
||||||
|
|
||||||
enum ractor_status {
|
|
||||||
ractor_created,
|
|
||||||
ractor_running,
|
|
||||||
ractor_blocking,
|
|
||||||
ractor_terminated,
|
|
||||||
} status_;
|
|
||||||
|
|
||||||
struct ccan_list_node vmlr_node;
|
struct ccan_list_node vmlr_node;
|
||||||
|
|
||||||
|
25
vm_core.h
25
vm_core.h
@ -339,18 +339,21 @@ typedef uintptr_t iseq_bits_t;
|
|||||||
|
|
||||||
#define ISEQ_IS_SIZE(body) (body->ic_size + body->ivc_size + body->ise_size + body->icvarc_size)
|
#define ISEQ_IS_SIZE(body) (body->ic_size + body->ivc_size + body->ise_size + body->icvarc_size)
|
||||||
|
|
||||||
|
/* instruction sequence type */
|
||||||
|
enum iseq_type {
|
||||||
|
ISEQ_TYPE_TOP,
|
||||||
|
ISEQ_TYPE_METHOD,
|
||||||
|
ISEQ_TYPE_BLOCK,
|
||||||
|
ISEQ_TYPE_CLASS,
|
||||||
|
ISEQ_TYPE_RESCUE,
|
||||||
|
ISEQ_TYPE_ENSURE,
|
||||||
|
ISEQ_TYPE_EVAL,
|
||||||
|
ISEQ_TYPE_MAIN,
|
||||||
|
ISEQ_TYPE_PLAIN
|
||||||
|
};
|
||||||
|
|
||||||
struct rb_iseq_constant_body {
|
struct rb_iseq_constant_body {
|
||||||
enum iseq_type {
|
enum iseq_type type;
|
||||||
ISEQ_TYPE_TOP,
|
|
||||||
ISEQ_TYPE_METHOD,
|
|
||||||
ISEQ_TYPE_BLOCK,
|
|
||||||
ISEQ_TYPE_CLASS,
|
|
||||||
ISEQ_TYPE_RESCUE,
|
|
||||||
ISEQ_TYPE_ENSURE,
|
|
||||||
ISEQ_TYPE_EVAL,
|
|
||||||
ISEQ_TYPE_MAIN,
|
|
||||||
ISEQ_TYPE_PLAIN
|
|
||||||
} type; /* instruction sequence type */
|
|
||||||
|
|
||||||
unsigned int iseq_size;
|
unsigned int iseq_size;
|
||||||
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
VALUE *iseq_encoded; /* encoded iseq (insn addr and operands) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user