Skip to content

Commit

Permalink
enable inline allocation of structs with pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Apr 9, 2020
1 parent 70d7e1e commit 198567a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ Language changes

* Color now defaults to on when stdout and stderr are TTYs ([#34347])

Compiler/Runtime improvements
-----------------------------

* Immutable structs (including tuples) that contain references can now be allocated
on the stack, and allocated inline within arrays and other structs ([#33886]).
This significantly reduces the number of heap allocations in some workloads.
Code that requires assumptions about object layout and addresses (usually for
interoperability with C or other languages) might need to be updated; for
example any object that needs a stable address should be a `mutable struct`.

Multi-threading changes
-----------------------

Expand Down
9 changes: 4 additions & 5 deletions src/datatype.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,10 @@ void jl_compute_field_offsets(jl_datatype_t *st)
// now finish deciding if this instantiation qualifies for special properties
assert(!isbitstype || st->layout->npointers == 0); // the definition of isbits
if (isinlinealloc && st->layout->npointers > 0) {
//if (st->ninitialized != nfields)
// isinlinealloc = 0;
//else if (st->layout->fielddesc_type != 0) // GC only implements support for this
// isinlinealloc = 0;
isinlinealloc = 0;
if (st->ninitialized != nfields)
isinlinealloc = 0;
else if (st->layout->fielddesc_type != 0) // GC only implements support for this
isinlinealloc = 0;
}
st->isbitstype = isbitstype;
st->isinlinealloc = isinlinealloc;
Expand Down

0 comments on commit 198567a

Please sign in to comment.