Skip to content

Commit c21abf8

Browse files
committed
Merge branch 'master' of github.com:JuliaLang/julia
2 parents 231d7ee + c6e77a4 commit c21abf8

File tree

7 files changed

+50
-30
lines changed

7 files changed

+50
-30
lines changed

src/builtins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ DLLEXPORT void NORETURN jl_error(const char *str)
3939
jl_throw(jl_new_struct(jl_errorexception_type, msg));
4040
}
4141

42+
extern int vasprintf(char **str, const char *fmt, va_list ap);
43+
4244
static void NORETURN jl_vexceptionf(jl_datatype_t *exception_type, const char *fmt, va_list args)
4345
{
4446
if (exception_type == NULL) {

src/codegen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ extern void _chkstk(void);
160160
#endif
161161
}
162162

163+
#if defined(_COMPILER_MICROSOFT_) && !defined(__alignof__)
164+
#define __alignof__ __alignof
165+
#endif
166+
163167
#define DISABLE_FLOAT16
164168

165169
// llvm state
@@ -791,7 +795,7 @@ static Function *jl_cfunction_object(jl_function_t *f, jl_value_t *rt, jl_value_
791795

792796
uint64_t isref = 0; // bit vector of which argument types are a subtype of Type{Ref{T}}
793797
jl_value_t *sigt; // type signature with Ref{} annotations removed
794-
JL_GC_PUSH(&sigt);
798+
JL_GC_PUSH1(&sigt);
795799
sigt = (jl_value_t*)jl_alloc_tuple(nargs);
796800
for (i = 0; i < nargs; i++) {
797801
jl_value_t *ati = jl_tupleref(argt, i);

src/dump.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
#include <string.h>
66
#include <assert.h>
77

8-
#include "valgrind.h"
9-
108
#include "julia.h"
119
#include "julia_internal.h"
1210
#include "builtin_proto.h"
@@ -15,6 +13,12 @@
1513
#include <dlfcn.h>
1614
#endif
1715

16+
#ifndef _COMPILER_MICROSOFT_
17+
#include "valgrind.h"
18+
#else
19+
#define RUNNING_ON_VALGRIND 0
20+
#endif
21+
1822
#ifdef __cplusplus
1923
extern "C" {
2024
#endif

src/gc.c

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#define FREE_PAGES_EAGER
1313
#include <stdlib.h>
1414
#include <string.h>
15+
#ifndef _MSC_VER
1516
#include <strings.h>
17+
#endif
1618
#include <assert.h>
1719
#include "julia.h"
1820
#include "julia_internal.h"
@@ -41,7 +43,9 @@ typedef struct {
4143
};
4244
// Work around a bug affecting gcc up to (at least) version 4.4.7
4345
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36839
46+
#if !defined(_COMPILER_MICROSOFT_)
4447
int _dummy[0];
48+
#endif
4549
char data[];
4650
} buff_t;
4751

@@ -80,7 +84,7 @@ typedef struct _gcpage_t {
8084

8185
// contiguous storage for up to REGION_PG_COUNT naturally aligned GC_PAGE_SZ blocks
8286
// uses a very naive allocator (see malloc_page & free_page)
83-
#ifdef _P64
87+
#if defined(_P64) && !defined(_COMPILER_MICROSOFT_)
8488
#define REGION_PG_COUNT 16*8*4096 // 8G because virtual memory is cheap
8589
#else
8690
#define REGION_PG_COUNT 8*4096 // 512M
@@ -302,9 +306,13 @@ static void add_lostval_parent(jl_value_t* parent)
302306
} \
303307
} while(0);
304308

309+
#define verify_parent1(ty,obj,slot,arg1) verify_parent(ty,obj,slot,arg1)
310+
#define verify_parent2(ty,obj,slot,arg1,arg2) verify_parent(ty,obj,slot,arg1,arg2)
311+
305312
#else
306313
#define verify_val(v)
307-
#define verify_parent(ty,obj,slot,args...)
314+
#define verify_parent1(ty,obj,slot,arg1)
315+
#define verify_parent2(ty,obj,slot,arg1,arg2)
308316
#endif
309317

310318
#ifdef OBJPROFILE
@@ -461,7 +469,7 @@ static inline void *malloc_a16(size_t sz)
461469

462470
#endif
463471

464-
static __attribute__((noinline)) void *malloc_page(void)
472+
static NOINLINE void *malloc_page(void)
465473
{
466474
void *ptr = (void*)0;
467475
int i;
@@ -471,7 +479,7 @@ static __attribute__((noinline)) void *malloc_page(void)
471479
heap = heaps[heap_i];
472480
if (heap == NULL) {
473481
#ifdef _OS_WINDOWS_
474-
char* mem = VirtualAlloc(NULL, sizeof(region_t) + GC_PAGE_SZ, MEM_RESERVE, PAGE_READWRITE);
482+
char* mem = (char*)VirtualAlloc(NULL, sizeof(region_t) + GC_PAGE_SZ, MEM_RESERVE, PAGE_READWRITE);
475483
#else
476484
char* mem = (char*)mmap(0, sizeof(region_t) + GC_PAGE_SZ, PROT_READ | PROT_WRITE, MAP_NORESERVE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
477485
mem = mem == MAP_FAILED ? NULL : mem;
@@ -507,10 +515,10 @@ static __attribute__((noinline)) void *malloc_page(void)
507515
if (heaps_ub[heap_i] < i)
508516
heaps_ub[heap_i] = i;
509517

510-
#ifdef __MINGW32__
518+
#if defined(_COMPILER_MINGW_)
511519
int j = __builtin_ffs(heap->freemap[i]) - 1;
512-
#elif _MSC_VER
513-
int j;
520+
#elif defined(_COMPILER_MICROSOFT_)
521+
unsigned long j;
514522
_BitScanForward(&j, heap->freemap[i]);
515523
#else
516524
int j = ffs(heap->freemap[i]) - 1;
@@ -780,7 +788,7 @@ void jl_finalize(jl_value_t *o)
780788

781789
// big value list
782790

783-
static __attribute__((noinline)) void *alloc_big(size_t sz)
791+
static NOINLINE void *alloc_big(size_t sz)
784792
{
785793
maybe_collect();
786794
size_t offs = BVOFFS*sizeof(void*);
@@ -964,7 +972,7 @@ static inline gcval_t *reset_page(pool_t *p, gcpage_t *pg, gcval_t *fl)
964972
return beg;
965973
}
966974

967-
static __attribute__((noinline)) void add_page(pool_t *p)
975+
static NOINLINE void add_page(pool_t *p)
968976
{
969977
char *data = (char*)malloc_page();
970978
if (data == NULL)
@@ -1404,7 +1412,7 @@ static void gc_mark_stack(jl_value_t* ta, jl_gcframe_t *s, ptrint_t offset, int
14041412
else {
14051413
for(size_t i=0; i < nr; i++) {
14061414
if (rts[i] != NULL) {
1407-
verify_parent("task", ta, &rts[i], "stack(%d)", i);
1415+
verify_parent2("task", ta, &rts[i], "stack(%d)", i);
14081416
gc_push_root(rts[i], d);
14091417
}
14101418
}
@@ -1413,7 +1421,7 @@ static void gc_mark_stack(jl_value_t* ta, jl_gcframe_t *s, ptrint_t offset, int
14131421
}
14141422
}
14151423

1416-
__attribute__((noinline)) static int gc_mark_module(jl_module_t *m, int d)
1424+
NOINLINE static int gc_mark_module(jl_module_t *m, int d)
14171425
{
14181426
size_t i;
14191427
int refyoung = 0;
@@ -1424,10 +1432,10 @@ __attribute__((noinline)) static int gc_mark_module(jl_module_t *m, int d)
14241432
gc_setmark_buf(b, gc_bits(m));
14251433
#ifdef GC_VERIFY
14261434
void* vb = gc_val_buf(b);
1427-
verify_parent("module", m, &vb, "binding_buff");
1435+
verify_parent1("module", m, &vb, "binding_buff");
14281436
#endif
14291437
if (b->value != NULL) {
1430-
verify_parent("module", m, &b->value, "binding(%s)", b->name->name);
1438+
verify_parent2("module", m, &b->value, "binding(%s)", b->name->name);
14311439
refyoung |= gc_push_root(b->value, d);
14321440
}
14331441
if (b->type != (jl_value_t*)jl_any_type) {
@@ -1443,7 +1451,7 @@ __attribute__((noinline)) static int gc_mark_module(jl_module_t *m, int d)
14431451
refyoung |= gc_push_root(m->usings.items[i], d);
14441452
}
14451453
if (m->constant_table) {
1446-
verify_parent("module", m, &m->constant_table, "constant_table");
1454+
verify_parent1("module", m, &m->constant_table, "constant_table");
14471455
refyoung |= gc_push_root(m->constant_table, d);
14481456
}
14491457
return refyoung;
@@ -1479,7 +1487,7 @@ static void mark_task_stacks(void) {
14791487
}
14801488
#endif
14811489

1482-
__attribute__((noinline)) static void gc_mark_task(jl_task_t *ta, int d)
1490+
NOINLINE static void gc_mark_task(jl_task_t *ta, int d)
14831491
{
14841492
if (ta->parent) gc_push_root(ta->parent, d);
14851493
if (ta->last) gc_push_root(ta->last, d);
@@ -1536,7 +1544,7 @@ static int push_root(jl_value_t *v, int d, int bits)
15361544
for(size_t i=0; i < l; i++) {
15371545
jl_value_t *elt = data[i];
15381546
if (elt != NULL) {
1539-
verify_parent("tuple", v, &data[i], "elem(%d)", i);
1547+
verify_parent2("tuple", v, &data[i], "elem(%d)", i);
15401548
refyoung |= gc_push_root(elt, d);
15411549
}
15421550
}
@@ -1545,12 +1553,13 @@ static int push_root(jl_value_t *v, int d, int bits)
15451553
jl_array_t *a = (jl_array_t*)v;
15461554
int todo = !(bits & GC_MARKED);
15471555
if (a->pooled)
1548-
MARK(a,
15491556
#ifdef MEMDEBUG
1550-
bits = gc_setmark_big(a, GC_MARKED_NOESC);
1557+
#define _gc_setmark_pool gc_setmark_big
15511558
#else
1552-
bits = gc_setmark_pool(a, GC_MARKED_NOESC);
1559+
#define _gc_setmark_pool gc_setmark_pool
15531560
#endif
1561+
MARK(a,
1562+
bits = _gc_setmark_pool(a, GC_MARKED_NOESC);
15541563
if (a->how == 2 && todo) {
15551564
objprofile_count(MATY, gc_bits(a) == GC_MARKED, array_nbytes(a));
15561565
if (gc_bits(a) == GC_MARKED)
@@ -1576,7 +1585,7 @@ static int push_root(jl_value_t *v, int d, int bits)
15761585
else if (a->how == 1) {
15771586
#ifdef GC_VERIFY
15781587
void* val_buf = gc_val_buf((char*)a->data - a->offset*a->elsize);
1579-
verify_parent("array", v, &val_buf, "buffer ('loc' addr is meaningless)");
1588+
verify_parent1("array", v, &val_buf, "buffer ('loc' addr is meaningless)");
15801589
#endif
15811590
gc_setmark_buf((char*)a->data - a->offset*a->elsize, gc_bits(v));
15821591
}
@@ -1592,7 +1601,7 @@ static int push_root(jl_value_t *v, int d, int bits)
15921601
for(size_t i=0; i < l; i++) {
15931602
jl_value_t *elt = ((jl_value_t**)data)[i];
15941603
if (elt != NULL) {
1595-
verify_parent("array", v, &((jl_value_t**)data)[i], "elem(%d)", i);
1604+
verify_parent2("array", v, &((jl_value_t**)data)[i], "elem(%d)", i);
15961605
refyoung |= gc_push_root(elt, d);
15971606
}
15981607
// try to split large array marking (incremental mark TODO)
@@ -1636,7 +1645,7 @@ static int push_root(jl_value_t *v, int d, int bits)
16361645
jl_value_t **slot = (jl_value_t**)((char*)v + fields[i].offset + sizeof(void*));
16371646
jl_value_t *fld = *slot;
16381647
if (fld) {
1639-
verify_parent("object", v, slot, "field(%d)", i);
1648+
verify_parent2("object", v, slot, "field(%d)", i);
16401649
//children[ci++] = fld;
16411650
refyoung |= gc_push_root(fld, d);
16421651
}

src/jl_uv.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
#include "support/ios.h"
3030
#include "uv.h"
3131

32+
#if defined(_COMPILER_MICROSOFT_) && !defined(write)
33+
#include <io.h>
34+
#define write _write
35+
#endif
36+
3237
#ifdef __cplusplus
3338
#include <cstring>
3439
extern "C" {

src/support/dtypes.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@
3737

3838
#endif /* !_COMPILER_MINGW_ */
3939

40-
#if defined(_COMPILER_MICROSOFT_)
41-
#define isnan _isnan
42-
#endif /* _COMPILER_MICROSOFT_ */
43-
4440
#endif /* _OS_WINDOWS_ */
4541

4642

src/task.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jl_gcframe_t *jl_pgcstack = NULL;
152152
#ifdef COPY_STACKS
153153
static jl_jmp_buf * volatile jl_jmp_target;
154154

155-
#if defined(_CPU_X86_64_) || defined(_CPU_X86_)
155+
#if (defined(_CPU_X86_64_) || defined(_CPU_X86_)) && !defined(_COMPILER_MICROSOFT_)
156156
#define ASM_COPY_STACKS
157157
#endif
158158
void *jl_stackbase;

0 commit comments

Comments
 (0)