Skip to content

Instantly share code, notes, and snippets.

@tkelman
Last active August 29, 2015 14:23
Show Gist options
  • Save tkelman/49f213f46d7e078a1a43 to your computer and use it in GitHub Desktop.
Save tkelman/49f213f46d7e078a1a43 to your computer and use it in GitHub Desktop.
diff --git a/base/string.jl b/base/string.jl
index 1542296..7b1f9ce 100644
--- a/base/string.jl
+++ b/base/string.jl
@@ -1562,7 +1562,7 @@ function tryparse_internal{T<:Integer}(::Type{T}, s::AbstractString, startpos::I
end
base = convert(T,base)
- m::T = div(typemax(T)-base+1,base)
+ m::T = T===UInt128 || T===Int128 ? typemax(T) : div(typemax(T)-base+1,base)
n::T = 0
while n <= m
d::T = '0' <= c <= '9' ? c-'0' :
diff --git a/src/alloc.c b/src/alloc.c
index 4fb1181..0a36acc 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -380,7 +380,7 @@ static jl_sym_t *mk_symbol(const char *str)
#endif
jl_sym_t *sym;
size_t len = strlen(str);
- size_t nb = (sizeof(jl_taggedvalue_t)+sizeof(jl_sym_t)+len+1+7)&-8;
+ size_t nb = (sizeof_jl_taggedvalue_t+sizeof(jl_sym_t)+len+1+7)&-8;
if (nb >= SYM_POOL_SIZE) {
jl_exceptionf(jl_argumenterror_type, "Symbol length exceeds maximum length");
diff --git a/src/gc.c b/src/gc.c
index 02e2485..4ca9d62 100644
--- a/src/gc.c
+++ b/src/gc.c
@@ -213,7 +213,7 @@ typedef buff_t gcval_t;
#define GC_PAGE_LG2 14 // log2(size of a page)
#define GC_PAGE_SZ (1 << GC_PAGE_LG2) // 16k
-#define GC_PAGE_OFFSET (16 - (sizeof(jl_taggedvalue_t) % 16))
+#define GC_PAGE_OFFSET (16 - (sizeof_jl_taggedvalue_t % 16))
// pool page metadata
typedef struct _gcpage_t {
@@ -631,7 +631,7 @@ static inline int gc_setmark_pool(void *o, int mark_mode)
static inline int gc_setmark(jl_value_t *v, int sz, int mark_mode)
{
jl_taggedvalue_t *o = jl_astaggedvalue(v);
- sz += sizeof(jl_taggedvalue_t);
+ sz += sizeof_jl_taggedvalue_t;
#ifdef MEMDEBUG
return gc_setmark_big(o, mark_mode);
#endif
@@ -2438,7 +2438,7 @@ void *reallocb(void *b, size_t sz)
DLLEXPORT jl_value_t *allocobj(size_t sz)
{
- size_t allocsz = sz + sizeof(jl_taggedvalue_t);
+ size_t allocsz = sz + sizeof_jl_taggedvalue_t;
if (allocsz < sz) // overflow in adding offs, size was "negative"
jl_throw(jl_memory_exception);
#ifdef MEMDEBUG
@@ -2452,7 +2452,7 @@ DLLEXPORT jl_value_t *allocobj(size_t sz)
DLLEXPORT jl_value_t *alloc_0w(void)
{
- const int sz = sizeof(jl_taggedvalue_t);
+ const int sz = sizeof_jl_taggedvalue_t;
#ifdef MEMDEBUG
return jl_valueof(alloc_big(sz));
#endif
@@ -2461,7 +2461,7 @@ DLLEXPORT jl_value_t *alloc_0w(void)
DLLEXPORT jl_value_t *alloc_1w(void)
{
- const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*), 16);
+ const int sz = LLT_ALIGN(sizeof_jl_taggedvalue_t + sizeof(void*), 16);
#ifdef MEMDEBUG
return jl_valueof(alloc_big(sz));
#endif
@@ -2470,7 +2470,7 @@ DLLEXPORT jl_value_t *alloc_1w(void)
DLLEXPORT jl_value_t *alloc_2w(void)
{
- const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*) * 2, 16);
+ const int sz = LLT_ALIGN(sizeof_jl_taggedvalue_t + sizeof(void*) * 2, 16);
#ifdef MEMDEBUG
return jl_valueof(alloc_big(sz));
#endif
@@ -2479,7 +2479,7 @@ DLLEXPORT jl_value_t *alloc_2w(void)
DLLEXPORT jl_value_t *alloc_3w(void)
{
- const int sz = LLT_ALIGN(sizeof(jl_taggedvalue_t) + sizeof(void*) * 3, 16);
+ const int sz = LLT_ALIGN(sizeof_jl_taggedvalue_t + sizeof(void*) * 3, 16);
#ifdef MEMDEBUG
return jl_valueof(alloc_big(sz));
#endif
@@ -2681,7 +2681,7 @@ static void big_obj_stats(void)
#else //JL_GC_MARKSWEEP
DLLEXPORT jl_value_t *allocobj(size_t sz)
{
- size_t allocsz = sz + sizeof(jl_taggedvalue_t);
+ size_t allocsz = sz + sizeof_jl_taggedvalue_t;
if (allocsz < sz) // overflow in adding offs, size was "negative"
jl_throw(jl_memory_exception);
allocd_bytes += allocsz;
diff --git a/src/julia_internal.h b/src/julia_internal.h
index 1d3aef7..687bce4 100644
--- a/src/julia_internal.h
+++ b/src/julia_internal.h
@@ -40,6 +40,7 @@ STATIC_INLINE jl_value_t *newstruct(jl_datatype_t *type)
}
#define GC_MAX_SZCLASS (2032-sizeof(void*))
+#define sizeof_jl_taggedvalue_t (8)
int jl_assign_type_uid(void);
jl_value_t *jl_cache_type_(jl_datatype_t *type);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment