2014-12-07
2014-12-07 15:40:05 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
cc063bc1ddd3d9c509a9cd47e7c79f10053a2bc5
(52 lines)
(+33/-19)
[
Show
| Annotate
]
Branch: 8.1
Runtime: Renumbered the types for lvalue types.
Stack types for values that aren't reference counted
MUST NOT have bit 3 (8) set.
Fixes type corruption bug for amd64 and T_SVALUE_PTR (and
probably some others).
204:
#define T_UNFINISHED 7
+ /*
+ * NOTE: The following types may show up on the stack, but are NOT
+ * reference counted there. There they are mainly used for
+ * lvalues. They MUST NOT have a value that has bit 3 (8) set.
+ */
+
#define T_VOID 16 /**< Can't return any value. Also used on stack to fill out the second
* svalue on an lvalue when it isn't used. */
-
+
#define T_MANY 17
#define PIKE_T_INT_UNTYPED 18 /* Optimization of int type size */
- #define PIKE_T_GET_SET 32 /* Getter setter.
- * Only valid in struct identifier */
-
+
/* Type to put in freed svalues. Only the type field in such svalues
* is defined. Freeing a PIKE_T_FREE svalue is allowed and does
* nothing. mark_free_svalue() is preferably used to set this type.
224:
* NUMBER_NUMBER.
*
* PIKE_T_FREE svalues are recorded as BIT_INT in type hint fields.
- *
- * Please avoid letting pike_t_free & 8 be anything but 0.
+
*/
- #define PIKE_T_FREE 229
+ #define PIKE_T_FREE 19
-
+ /** svalue.u.lval points to an svalue. Primarily used in lvalues on
+ * stack, but can also occur in arrays containing lvalue pairs.
+ */
+ #define T_SVALUE_PTR 20
+
+ /** svalue.u.identifer is an identifier index in an object. Primarily
+ * used in lvalues on stack, but can also occur in arrays containing
+ * lvalue pairs.
+ */
+ #define T_OBJ_INDEX 21
+ #define T_ARRAY_LVALUE 22
+
+ /* No types above this value should appear on the stack. */
+ #define PIKE_T_STACK_MAX T_ARRAY_LVALUE
+
+ /*
+ * The following types are only used in compile-time types and
+ * as markers in struct identifier.
+ */
+
+ #define PIKE_T_GET_SET 32 /* Getter setter.
+ * Only valid in struct identifier */
+
#define PIKE_T_ATTRIBUTE 238 /* Attribute node. */
#define PIKE_T_NSTRING 239 /* Narrow string. Only for serialization. */
#define PIKE_T_RING 240
239:
#define T_DELETED 246
#define PIKE_T_UNKNOWN 247
- /** svalue.u.identifer is an identifier index in an object. Primarily
- * used in lvalues on stack, but can also occur in arrays containing
- * lvalue pairs. */
- #define T_OBJ_INDEX 248
-
- /** svalue.u.lval points to an svalue. Primarily used in lvalues on
- * stack, but can also occur in arrays containing lvalue pairs. */
- #define T_SVALUE_PTR 249
-
- #define T_ARRAY_LVALUE 250
+
#define PIKE_T_MIXED 251
#define T_NOT 253
#define T_AND 254
487: Inside #if defined(PIKE_DEBUG)
PMOD_EXPORT extern const char msg_type_error[];
PMOD_EXPORT extern const char msg_assign_svalue_error[];
- #define IS_INVALID_TYPE(T) \
- ((T > MAX_TYPE && T < T_OBJ_INDEX && T != T_VOID) || T > T_ARRAY_LVALUE)
+ #define IS_INVALID_TYPE(T) is_invalid_stack_type(T)
#define check_type(T) do { \
TYPE_T typ_ = (T); \
522:
void check_short_svalue(const union anything *u, TYPE_T type);
PMOD_EXPORT void debug_svalue_type_error (const struct svalue *s);
+ PMOD_EXPORT int is_invalid_stack_type(unsigned int t);
PMOD_EXPORT void debug_check_svalue(const struct svalue *s);
void debug_check_type_hint (const struct svalue *svals, size_t num, TYPE_FIELD type_hint);
PMOD_EXPORT void real_gc_mark_external_svalues(const struct svalue *s, ptrdiff_t num,