Skip to content

Commit 5b48480

Browse files
committedDec 14, 2011
Merge branch 'master' of github.com:JuliaLang/julia
* 'master' of github.com:JuliaLang/julia: closing issue #197, hex literals give unsigned ints sized by digits storing ASTs serialized to save memory part of issue #261 significantly cuts the number of live objects, making GC much faster
2 parents 1051578 + 6cbe21a commit 5b48480

File tree

9 files changed

+201
-67
lines changed

9 files changed

+201
-67
lines changed
 

Diff for: ‎j/inference.j

+31-13
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,10 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
837837
tf = def.tfunc
838838
while !is(tf,())
839839
if typeseq(tf[1],atypes)
840+
if isa(tf[2],Tuple)
841+
# compressed tree format
842+
return (tf[2], tf[2][3])
843+
end
840844
# if the frame above this one recurred, rerun type inf
841845
# here instead of returning, and update the cache, until the new
842846
# inferred type equals the cached type (fixed point)
@@ -885,11 +889,12 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
885889
#print("typeinf ", linfo.name, " ", atypes, "\n")
886890

887891
if redo
888-
elseif cop
889-
sparams = append(sparams, linfo.sparams)
890-
ast = ccall(:jl_prepare_ast, Any, (Any,Any), linfo.ast, sparams)::Expr
891892
else
892893
ast = linfo.ast
894+
if cop
895+
sparams = append(sparams, linfo.sparams)
896+
ast = ccall(:jl_prepare_ast, Any, (Any,Any), ast, sparams)::Expr
897+
end
893898
end
894899

895900
assert(is(ast.head,:lambda), "inference.j:745")
@@ -1059,14 +1064,19 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
10591064
fulltree = type_annotate(ast, s, sv,
10601065
rec ? RecPending{frame.result} : frame.result,
10611066
vars)
1062-
if !redo
1063-
def.tfunc = (atypes, fulltree, def.tfunc)
1064-
end
10651067
if !rec
10661068
fulltree.args[3] = inlining_pass(fulltree.args[3], s[1])
10671069
tuple_elim_pass(fulltree)
10681070
linfo.inferred = true
10691071
end
1072+
if !redo
1073+
vals = {}
1074+
treedata = ccall(:jl_compress_ast, Any, (Any, Any), fulltree, vals)
1075+
compressed = (treedata, vals, frame.result)
1076+
fulltree = compressed
1077+
#compressed = fulltree
1078+
def.tfunc = (atypes, compressed, def.tfunc)
1079+
end
10701080
inference_stack = (inference_stack::CallStack).prev
10711081
return (fulltree, frame.result)
10721082
end
@@ -1295,17 +1305,21 @@ function inlineable(f, e::Expr, vars)
12951305
return NF
12961306
end
12971307
end
1298-
for vi = meth[3].ast.args[2].args[2]
1308+
(ast, ty) = typeinf(meth[3], meth[1], meth[2], meth[3])
1309+
if is(ast,())
1310+
return NF
1311+
end
1312+
if isa(ast,Tuple)
1313+
ast = ccall(:jl_uncompress_ast, Any, (Any,), ast)
1314+
end
1315+
ast = ast::Expr
1316+
for vi = ast.args[2].args[2]
12991317
if (vi[3]&1)!=0
13001318
# captures variables (TODO)
13011319
return NF
13021320
end
13031321
end
1304-
(ast, ty) = typeinf(meth[3], meth[1], meth[2], meth[3])
1305-
if is(ast,())
1306-
return NF
1307-
end
1308-
body = without_linenums(ast.args[3].args)
1322+
body = without_linenums(ast.args[3].args)::Array{Any,1}
13091323
# see if body is only "return <expr>"
13101324
if length(body) != 1
13111325
return NF
@@ -1543,7 +1557,11 @@ end
15431557
15441558
function finfer(f, types)
15451559
x = getmethods(f,types)[1]
1546-
typeinf(x[3], x[1], x[2])[1]
1560+
(tree, ty) = typeinf(x[3], x[1], x[2])
1561+
if isa(tree,Tuple)
1562+
return ccall(:jl_uncompress_ast, Any, (Any,), tree)
1563+
end
1564+
tree
15471565
end
15481566
15491567
tfunc(f,t) = (getmethods(f,t)[1][3]).tfunc

Diff for: ‎src/ast.c

+18-8
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,24 @@ static jl_value_t *scm_to_julia(value_t e)
197197
static jl_value_t *scm_to_julia_(value_t e)
198198
{
199199
if (fl_isnumber(e)) {
200-
if (iscprim(e) && cp_numtype((cprim_t*)ptr(e))==T_DOUBLE) {
201-
return (jl_value_t*)jl_box_float64(*(double*)cp_data((cprim_t*)ptr(e)));
202-
}
203-
if (iscprim(e) && cp_numtype((cprim_t*)ptr(e))==T_INT64) {
204-
return (jl_value_t*)jl_box_int64(*(int64_t*)cp_data((cprim_t*)ptr(e)));
205-
}
206-
if (iscprim(e) && cp_numtype((cprim_t*)ptr(e))==T_UINT64) {
207-
return (jl_value_t*)jl_box_uint64(*(uint64_t*)cp_data((cprim_t*)ptr(e)));
200+
if (iscprim(e)) {
201+
numerictype_t nt = cp_numtype((cprim_t*)ptr(e));
202+
switch (nt) {
203+
case T_DOUBLE:
204+
return (jl_value_t*)jl_box_float64(*(double*)cp_data((cprim_t*)ptr(e)));
205+
case T_INT64:
206+
return (jl_value_t*)jl_box_int64(*(int64_t*)cp_data((cprim_t*)ptr(e)));
207+
case T_UINT8:
208+
return (jl_value_t*)jl_box_uint8(*(uint8_t*)cp_data((cprim_t*)ptr(e)));
209+
case T_UINT16:
210+
return (jl_value_t*)jl_box_uint16(*(uint16_t*)cp_data((cprim_t*)ptr(e)));
211+
case T_UINT32:
212+
return (jl_value_t*)jl_box_uint32(*(uint32_t*)cp_data((cprim_t*)ptr(e)));
213+
case T_UINT64:
214+
return (jl_value_t*)jl_box_uint64(*(uint64_t*)cp_data((cprim_t*)ptr(e)));
215+
default:
216+
;
217+
}
208218
}
209219
if (isfixnum(e)) {
210220
int64_t ne = numval(e);

Diff for: ‎src/codegen.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ static Function *to_function(jl_lambda_info_t *li)
143143
JL_SIGATOMIC_BEGIN();
144144
Function *f = Function::Create(jl_func_sig, Function::ExternalLinkage,
145145
li->name->name, jl_Module);
146-
assert(jl_is_expr(li->ast));
147146
assert(!li->inInference);
148147
li->functionObject = (void*)f;
149148
BasicBlock *old = nested_compile ? builder.GetInsertBlock() : NULL;
@@ -356,11 +355,14 @@ static void make_gcroot(Value *v, jl_codectx_t *ctx)
356355

357356
// --- lambda ---
358357

358+
extern "C" jl_value_t *jl_uncompress_ast(jl_tuple_t *data);
359+
359360
static Value *emit_lambda_closure(jl_value_t *expr, jl_codectx_t *ctx)
360361
{
361362
assert(jl_is_lambda_info(expr));
362363
size_t i;
363-
jl_array_t *capt = jl_lam_capt((jl_expr_t*)((jl_lambda_info_t*)expr)->ast);
364+
jl_value_t *ast = ((jl_lambda_info_t*)expr)->ast;
365+
jl_array_t *capt = jl_lam_capt((jl_expr_t*)ast);
364366
if (capt->length == 0) {
365367
// no captured vars; lift
366368
jl_value_t *fun = jl_new_closure_internal((jl_lambda_info_t*)expr,
@@ -1327,6 +1329,11 @@ extern "C" jl_tuple_t *jl_tuple_tvars_to_symbols(jl_tuple_t *t);
13271329
static void emit_function(jl_lambda_info_t *lam, Function *f)
13281330
{
13291331
jl_expr_t *ast = (jl_expr_t*)lam->ast;
1332+
if (jl_is_tuple(ast)) {
1333+
ast = (jl_expr_t*)jl_uncompress_ast((jl_tuple_t*)ast);
1334+
}
1335+
assert(jl_is_expr(ast));
1336+
jl_gc_preserve((jl_value_t*)ast);
13301337
//jl_print((jl_value_t*)ast);
13311338
//ios_printf(ios_stdout, "\n");
13321339
BasicBlock *b0 = BasicBlock::Create(jl_LLVMContext, "top", f);
@@ -1700,6 +1707,7 @@ static void emit_function(jl_lambda_info_t *lam, Function *f)
17001707
//used_roots += ctx.maxDepth;
17011708
//JL_GC_POP();
17021709
jl_gc_unpreserve();
1710+
jl_gc_unpreserve();
17031711
}
17041712

17051713
// --- initialization ---

Diff for: ‎src/dump.c

+106-28
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ static htable_t id_to_fptr;
2424
static const ptrint_t LongSymbol_tag = 23;
2525
static const ptrint_t LongTuple_tag = 24;
2626
static const ptrint_t LongExpr_tag = 25;
27+
static const ptrint_t LiteralVal_tag = 26;
2728
static const ptrint_t Null_tag = 254;
2829
static const ptrint_t BackRef_tag = 255;
2930

3031
static ptrint_t VALUE_TAGS;
3132

33+
// pointers to non-AST-ish objects in a compressed tree
34+
static jl_array_t *tree_literal_values=NULL;
35+
3236
#define write_uint8(s, n) ios_putc((n), (s))
3337
#define read_uint8(s) ((uint8_t)ios_getc(s))
3438
#define write_int8(s, n) write_uint8(s, n)
@@ -67,17 +71,17 @@ static void write_as_tag(ios_t *s, uint8_t tag)
6771

6872
#define jl_serialize_value(s, v) jl_serialize_value_(s,(jl_value_t*)(v))
6973

70-
void jl_serialize_value_(ios_t *s, jl_value_t *v);
74+
static void jl_serialize_value_(ios_t *s, jl_value_t *v);
7175

72-
void jl_serialize_fptr(ios_t *s, void *fptr)
76+
static void jl_serialize_fptr(ios_t *s, void *fptr)
7377
{
7478
void **pbp = ptrhash_bp(&fptr_to_id, fptr);
7579
if (*pbp == HT_NOTFOUND)
7680
jl_error("unknown function pointer");
7781
write_int32(s, *(ptrint_t*)pbp);
7882
}
7983

80-
void jl_serialize_tag_type(ios_t *s, jl_value_t *v)
84+
static void jl_serialize_tag_type(ios_t *s, jl_value_t *v)
8185
{
8286
if (jl_is_struct_type(v)) {
8387
writetag(s, (jl_value_t*)jl_struct_kind);
@@ -119,7 +123,7 @@ void jl_serialize_tag_type(ios_t *s, jl_value_t *v)
119123
}
120124
}
121125

122-
void jl_serialize_methlist(ios_t *s, jl_methlist_t *ml)
126+
static void jl_serialize_methlist(ios_t *s, jl_methlist_t *ml)
123127
{
124128
while (ml != NULL) {
125129
jl_serialize_value(s, ml->sig);
@@ -134,7 +138,7 @@ void jl_serialize_methlist(ios_t *s, jl_methlist_t *ml)
134138
jl_serialize_value(s, NULL);
135139
}
136140

137-
void jl_serialize_typecache(ios_t *s, jl_typename_t *tn)
141+
static void jl_serialize_typecache(ios_t *s, jl_typename_t *tn)
138142
{
139143
typekey_stack_t *tc = (typekey_stack_t*)tn->cache;
140144
while (tc != NULL) {
@@ -150,7 +154,27 @@ void jl_serialize_typecache(ios_t *s, jl_typename_t *tn)
150154
jl_serialize_value(s, NULL);
151155
}
152156

153-
void jl_serialize_value_(ios_t *s, jl_value_t *v)
157+
static int is_ast_node(jl_value_t *v)
158+
{
159+
return jl_is_symbol(v) || jl_is_expr(v) ||
160+
jl_typeis(v, jl_array_any_type) ||
161+
jl_is_tuple(v) || jl_is_typevar(v) ||
162+
jl_is_symbolnode(v) || jl_is_bool(v) ||
163+
jl_is_topnode(v) || jl_is_quotenode(v) || jl_is_gotonode(v) ||
164+
jl_is_labelnode(v) || jl_is_linenode(v);
165+
}
166+
167+
static int literal_val_id(jl_value_t *v)
168+
{
169+
for(int i=0; i < jl_array_len(tree_literal_values); i++) {
170+
if (jl_cellref(tree_literal_values,i) == v)
171+
return i;
172+
}
173+
jl_cell_1d_push(tree_literal_values, v);
174+
return jl_array_len(tree_literal_values)-1;
175+
}
176+
177+
static void jl_serialize_value_(ios_t *s, jl_value_t *v)
154178
{
155179
if (v == NULL) {
156180
write_uint8(s, Null_tag);
@@ -163,13 +187,23 @@ void jl_serialize_value_(ios_t *s, jl_value_t *v)
163187
return;
164188
}
165189

166-
bp = ptrhash_bp(&backref_table, v);
167-
if (*bp != HT_NOTFOUND) {
168-
write_uint8(s, BackRef_tag);
169-
write_int32(s, (ptrint_t)*bp);
170-
return;
190+
if (tree_literal_values) {
191+
// compressing tree
192+
if (!is_ast_node(v)) {
193+
writetag(s, (jl_value_t*)LiteralVal_tag);
194+
write_int32(s, literal_val_id(v));
195+
return;
196+
}
197+
}
198+
else {
199+
bp = ptrhash_bp(&backref_table, v);
200+
if (*bp != HT_NOTFOUND) {
201+
write_uint8(s, BackRef_tag);
202+
write_int32(s, (ptrint_t)*bp);
203+
return;
204+
}
205+
ptrhash_put(&backref_table, v, (void*)(ptrint_t)ios_pos(s));
171206
}
172-
ptrhash_put(&backref_table, v, (void*)(ptrint_t)ios_pos(s));
173207

174208
size_t i;
175209
if (jl_is_tuple(v)) {
@@ -254,7 +288,8 @@ void jl_serialize_value_(ios_t *s, jl_value_t *v)
254288
jl_function_t *f = (jl_function_t*)v;
255289
jl_serialize_value(s, (jl_value_t*)f->linfo);
256290
jl_serialize_value(s, f->env);
257-
if (f->linfo && f->linfo->ast && jl_is_expr(f->linfo->ast) &&
291+
if (f->linfo && f->linfo->ast &&
292+
(jl_is_expr(f->linfo->ast) || jl_is_tuple(f->linfo->ast)) &&
258293
f->fptr != &jl_trampoline) {
259294
write_int32(s, 0);
260295
}
@@ -310,7 +345,7 @@ void jl_serialize_value_(ios_t *s, jl_value_t *v)
310345
}
311346
}
312347

313-
void jl_serialize_module(ios_t *s, jl_module_t *m)
348+
static void jl_serialize_module(ios_t *s, jl_module_t *m)
314349
{
315350
size_t i;
316351
void **table = m->bindings.table;
@@ -336,8 +371,8 @@ void jl_serialize_module(ios_t *s, jl_module_t *m)
336371
}
337372

338373
htable_t *jl_gc_get_finalizer_table();
339-
340-
void jl_serialize_finalizers(ios_t *s)
374+
/*
375+
static void jl_serialize_finalizers(ios_t *s)
341376
{
342377
htable_t *finalizer_table = jl_gc_get_finalizer_table();
343378
int i;
@@ -349,12 +384,12 @@ void jl_serialize_finalizers(ios_t *s)
349384
}
350385
jl_serialize_value(s, NULL);
351386
}
352-
387+
*/
353388
// --- deserialize ---
354389

355-
jl_value_t *jl_deserialize_value(ios_t *s);
390+
static jl_value_t *jl_deserialize_value(ios_t *s);
356391

357-
jl_fptr_t jl_deserialize_fptr(ios_t *s)
392+
static jl_fptr_t jl_deserialize_fptr(ios_t *s)
358393
{
359394
int fptr = read_int32(s);
360395
if (fptr == 0)
@@ -365,7 +400,7 @@ jl_fptr_t jl_deserialize_fptr(ios_t *s)
365400
return *(jl_fptr_t*)pbp;
366401
}
367402

368-
jl_value_t *jl_deserialize_tag_type(ios_t *s, jl_struct_type_t *kind, int pos)
403+
static jl_value_t *jl_deserialize_tag_type(ios_t *s, jl_struct_type_t *kind, int pos)
369404
{
370405
if (kind == jl_struct_kind) {
371406
jl_struct_type_t *st =
@@ -428,7 +463,7 @@ jl_value_t *jl_deserialize_tag_type(ios_t *s, jl_struct_type_t *kind, int pos)
428463
return NULL;
429464
}
430465

431-
jl_methlist_t *jl_deserialize_methlist(ios_t *s)
466+
static jl_methlist_t *jl_deserialize_methlist(ios_t *s)
432467
{
433468
jl_methlist_t *ml = NULL;
434469
jl_methlist_t **pnext = &ml;
@@ -451,7 +486,7 @@ jl_methlist_t *jl_deserialize_methlist(ios_t *s)
451486
return ml;
452487
}
453488

454-
typekey_stack_t *jl_deserialize_typecache(ios_t *s)
489+
static typekey_stack_t *jl_deserialize_typecache(ios_t *s)
455490
{
456491
typekey_stack_t *tk = NULL;
457492
typekey_stack_t **pnext = &tk;
@@ -480,7 +515,7 @@ typekey_stack_t *jl_deserialize_typecache(ios_t *s)
480515
jl_struct_type_t *jl_idtable_type=NULL;
481516
void jl_idtable_rehash(jl_array_t **pa, size_t newsz);
482517

483-
jl_value_t *jl_deserialize_value(ios_t *s)
518+
static jl_value_t *jl_deserialize_value(ios_t *s)
484519
{
485520
int pos = ios_pos(s);
486521
int32_t tag = read_uint8(s);
@@ -491,6 +526,7 @@ jl_value_t *jl_deserialize_value(ios_t *s)
491526
return (jl_value_t*)ptrhash_get(&deser_tag, (void*)(ptrint_t)tag);
492527
}
493528
if (tag == BackRef_tag) {
529+
assert(tree_literal_values == NULL);
494530
ptrint_t offs = read_int32(s);
495531
void **bp = ptrhash_bp(&backref_table, (void*)(ptrint_t)offs);
496532
assert(*bp != HT_NOTFOUND);
@@ -564,6 +600,9 @@ jl_value_t *jl_deserialize_value(ios_t *s)
564600
}
565601
return (jl_value_t*)e;
566602
}
603+
else if (vtag == (jl_value_t*)LiteralVal_tag) {
604+
return jl_cellref(tree_literal_values, read_int32(s));
605+
}
567606
else if (vtag == (jl_value_t*)jl_typename_type) {
568607
jl_sym_t *name = (jl_sym_t*)jl_deserialize_value(s);
569608
jl_typename_t *tn = jl_new_typename(name);
@@ -682,7 +721,7 @@ jl_value_t *jl_deserialize_value(ios_t *s)
682721
return NULL;
683722
}
684723

685-
void jl_deserialize_module(ios_t *s, jl_module_t *m)
724+
static void jl_deserialize_module(ios_t *s, jl_module_t *m)
686725
{
687726
while (1) {
688727
jl_value_t *name = jl_deserialize_value(s);
@@ -702,8 +741,8 @@ void jl_deserialize_module(ios_t *s, jl_module_t *m)
702741
(jl_function_t*)jl_deserialize_value(s));
703742
}
704743
}
705-
706-
void jl_deserialize_finalizers(ios_t *s)
744+
/*
745+
static void jl_deserialize_finalizers(ios_t *s)
707746
{
708747
htable_t *finalizer_table = jl_gc_get_finalizer_table();
709748
while (1) {
@@ -714,7 +753,7 @@ void jl_deserialize_finalizers(ios_t *s)
714753
*bp = jl_deserialize_value(s);
715754
}
716755
}
717-
756+
*/
718757
// --- entry points ---
719758

720759
DLLEXPORT
@@ -822,6 +861,44 @@ void jl_restore_system_image(char *fname)
822861
JL_GC_POP();
823862
}
824863

864+
DLLEXPORT
865+
jl_value_t *jl_compress_ast(jl_value_t *ast, jl_array_t *vals)
866+
{
867+
ios_t dest;
868+
jl_ios_mem(&dest, 0);
869+
int en = jl_gc_is_enabled();
870+
jl_gc_disable();
871+
872+
tree_literal_values = vals;
873+
jl_serialize_value(&dest, ast);
874+
tree_literal_values = NULL;
875+
876+
//ios_printf(ios_stderr, "%d bytes, %d values\n", dest.size, vals->length);
877+
878+
jl_value_t *v = (jl_value_t*)jl_takebuf_array(&dest);
879+
if (en)
880+
jl_gc_enable();
881+
return v;
882+
}
883+
884+
DLLEXPORT
885+
jl_value_t *jl_uncompress_ast(jl_tuple_t *data)
886+
{
887+
jl_array_t *bytes = (jl_array_t*)jl_tupleref(data, 0);
888+
tree_literal_values = (jl_array_t*)jl_tupleref(data, 1);
889+
ios_t src;
890+
jl_ios_mem(&src, 0);
891+
ios_setbuf(&src, bytes->data, bytes->length, 0);
892+
src.size = bytes->length;
893+
int en = jl_gc_is_enabled();
894+
jl_gc_disable();
895+
jl_value_t *v = jl_deserialize_value(&src);
896+
if (en)
897+
jl_gc_enable();
898+
tree_literal_values = NULL;
899+
return v;
900+
}
901+
825902
// --- init ---
826903

827904
void jl_init_serializer(void)
@@ -835,7 +912,8 @@ void jl_init_serializer(void)
835912
void *tags[] = { jl_symbol_type, jl_tag_kind, jl_bits_kind, jl_struct_kind,
836913
jl_func_kind, jl_tuple_type, jl_array_type, jl_expr_type,
837914
(void*)LongSymbol_tag, (void*)LongTuple_tag,
838-
(void*)LongExpr_tag, jl_intrinsic_type, jl_methtable_type,
915+
(void*)LongExpr_tag, (void*)LiteralVal_tag,
916+
jl_intrinsic_type, jl_methtable_type,
839917
jl_typename_type, jl_lambda_info_type, jl_tvar_type,
840918

841919
jl_null, jl_any_type, jl_symbol("Any"),

Diff for: ‎src/flisp/equal.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,13 @@ static value_t bounded_compare(value_t a, value_t b, int bound, int eq)
7979
return bounded_vector_compare(a, b, bound, eq);
8080
break;
8181
case TAG_CPRIM:
82-
if (cp_class((cprim_t*)ptr(a)) == wchartype &&
83-
(!iscprim(b) ||
84-
cp_class((cprim_t*)ptr(b)) != wchartype))
85-
return fixnum(-1);
82+
if (cp_class((cprim_t*)ptr(a)) == wchartype) {
83+
if (!iscprim(b) || cp_class((cprim_t*)ptr(b)) != wchartype)
84+
return fixnum(-1);
85+
}
86+
else if (iscprim(b) && cp_class((cprim_t*)ptr(b)) == wchartype) {
87+
return fixnum(1);
88+
}
8689
c = numeric_compare(a, b, eq, 1, NULL);
8790
if (c != 2)
8891
return fixnum(c);

Diff for: ‎src/gc.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
//#define MEMPROFILE
2121
//#define GCTIME
2222

23-
#define GC_PAGE_SZ (2048*sizeof(void*))//bytes
23+
#define GC_PAGE_SZ (1536*sizeof(void*))//bytes
2424

2525
typedef struct _gcpage_t {
2626
union {
@@ -91,7 +91,7 @@ static bigval_t *big_objects = NULL;
9191
static pool_t pools[N_POOLS];
9292

9393
static size_t allocd_bytes = 0;
94-
static size_t collect_interval = 4096*1024*sizeof(void*);
94+
static size_t collect_interval = 3200*1024*sizeof(void*);
9595

9696
static htable_t finalizer_table;
9797
static arraylist_t to_finalize;
@@ -836,13 +836,16 @@ static size_t pool_stats(pool_t *p, size_t *pwaste)
836836
static void all_pool_stats(void)
837837
{
838838
int i;
839-
size_t nb=0, w, tw=0;
839+
size_t nb=0, w, tw=0, no=0, b;
840840
for(i=0; i < N_POOLS; i++) {
841-
nb += pool_stats(&pools[i], &w);
841+
b = pool_stats(&pools[i], &w);
842+
nb += b;
843+
no += (b/pools[i].osize);
842844
tw += w;
843845
}
844-
ios_printf(ios_stdout, "%d total allocated, %d total fragments\n",
845-
nb, tw);
846+
ios_printf(ios_stdout,
847+
"%d objects, %d total allocated, %d total fragments\n",
848+
no, nb, tw);
846849
}
847850

848851
static void big_obj_stats(void)

Diff for: ‎src/jltypes.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ void jl_init_types(void)
24912491
jl_symbol(""), jl_symbol(""),
24922492
jl_symbol(""), jl_symbol(""),
24932493
jl_symbol("inferred")),
2494-
jl_tuple(9, jl_expr_type, jl_tuple_type,
2494+
jl_tuple(9, jl_any_type, jl_tuple_type,
24952495
jl_any_type, jl_sym_type,
24962496
jl_any_type, jl_tuple_type,
24972497
jl_function_type, jl_tuple_type,

Diff for: ‎src/julia-parser.scm

+17-5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@
135135
(loop (cons c str) (peek-char port)))
136136
(list->string (reverse str)))))
137137

138+
(define (char-hex? c)
139+
(or (char-numeric? c)
140+
(and (>= c #\a) (<= c #\f))
141+
(and (>= c #\A) (<= c #\F))))
142+
138143
(define (read-number port . leadingdot)
139144
(let ((str (open-output-string))
140145
(pred char-numeric?))
@@ -157,10 +162,7 @@
157162
(if (eqv? (peek-char port) #\0)
158163
(begin (write-char (read-char port) str)
159164
(if (allow #\x)
160-
(set! pred (lambda (c)
161-
(or (char-numeric? c)
162-
(and (>= c #\a) (<= c #\f))
163-
(and (>= c #\A) (<= c #\F)))))))
165+
(set! pred char-hex?)))
164166
(allow #\.)))
165167
(read-digs)
166168
(if (eqv? (peek-char port) #\.)
@@ -176,9 +178,19 @@
176178
(disallow #\.)))
177179
(let* ((s (get-output-string str))
178180
(n (string->number s)))
179-
(if n n
181+
(if n
182+
(if (eq? pred char-hex?)
183+
(sized-uint-literal n s)
184+
n)
180185
(error (string "invalid numeric constant " s))))))
181186

187+
(define (sized-uint-literal n s)
188+
(let ((l (length s)))
189+
(cond ((< l 5) (uint8 n))
190+
((< l 7) (uint16 n))
191+
((< l 11) (uint32 n))
192+
(else (uint64 n)))))
193+
182194
(define (skip-ws-and-comments port)
183195
(skip-ws port #t)
184196
(if (eqv? (peek-char port) #\#)

Diff for: ‎src/julia.expmap

+2
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@
153153
jl_start_io_thread;
154154
jl_save_system_image;
155155
jl_restore_system_image;
156+
jl_compress_ast;
157+
jl_uncompress_ast;
156158
jl_current_task;
157159
jl_get_current_task;
158160
jl_enter_handler;

0 commit comments

Comments
 (0)
Please sign in to comment.