Skip to content

Commit f424431

Browse files
authored
make CodeInstance 1 word smaller by moving the trailing UInt8 field (#47146)
1 parent 8bdd52d commit f424431

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/jltypes.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -2551,8 +2551,8 @@ void jl_init_types(void) JL_GC_DISABLED
25512551
//"absolute_max",
25522552
"ipo_purity_bits", "purity_bits",
25532553
"argescapes",
2554-
"isspecsig", "precompile", "invoke", "specptr", // function object decls
2555-
"relocatability"),
2554+
"isspecsig", "precompile", "relocatability",
2555+
"invoke", "specptr"), // function object decls
25562556
jl_svec(15,
25572557
jl_method_instance_type,
25582558
jl_any_type,
@@ -2567,13 +2567,13 @@ void jl_init_types(void) JL_GC_DISABLED
25672567
jl_any_type,
25682568
jl_bool_type,
25692569
jl_bool_type,
2570-
jl_any_type, jl_any_type, // fptrs
2571-
jl_uint8_type),
2570+
jl_uint8_type,
2571+
jl_any_type, jl_any_type), // fptrs
25722572
jl_emptysvec,
25732573
0, 1, 1);
25742574
jl_svecset(jl_code_instance_type->types, 1, jl_code_instance_type);
25752575
const static uint32_t code_instance_constfields[1] = { 0b000001010111101 }; // Set fields 1, 3-6, 8, 10 as const
2576-
const static uint32_t code_instance_atomicfields[1] = { 0b011100101000010 }; // Set fields 2, 7, 9, 12-14 as atomic
2576+
const static uint32_t code_instance_atomicfields[1] = { 0b110100101000010 }; // Set fields 2, 7, 9, 12, 14-15 as atomic
25772577
//Fields 11 and 15 must be protected by locks, and thus all operations on jl_code_instance_t are threadsafe
25782578
jl_code_instance_type->name->constfields = code_instance_constfields;
25792579
jl_code_instance_type->name->atomicfields = code_instance_atomicfields;
@@ -2730,8 +2730,8 @@ void jl_init_types(void) JL_GC_DISABLED
27302730
jl_svecset(jl_methtable_type->types, 11, jl_uint8_type);
27312731
jl_svecset(jl_method_type->types, 12, jl_method_instance_type);
27322732
jl_svecset(jl_method_instance_type->types, 6, jl_code_instance_type);
2733-
jl_svecset(jl_code_instance_type->types, 12, jl_voidpointer_type);
27342733
jl_svecset(jl_code_instance_type->types, 13, jl_voidpointer_type);
2734+
jl_svecset(jl_code_instance_type->types, 14, jl_voidpointer_type);
27352735

27362736
jl_compute_field_offsets(jl_datatype_type);
27372737
jl_compute_field_offsets(jl_typename_type);

src/julia.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ typedef struct _jl_code_instance_t {
433433
// compilation state cache
434434
uint8_t isspecsig; // if specptr is a specialized function signature for specTypes->rettype
435435
_Atomic(uint8_t) precompile; // if set, this will be added to the output system image
436+
uint8_t relocatability; // nonzero if all roots are built into sysimg or tagged by module key
436437
_Atomic(jl_callptr_t) invoke; // jlcall entry point
437438
union _jl_generic_specptr_t {
438439
_Atomic(void*) fptr;
@@ -441,7 +442,6 @@ typedef struct _jl_code_instance_t {
441442
_Atomic(jl_fptr_sparam_t) fptr3;
442443
// 4 interpreter
443444
} specptr; // private data for `jlcall entry point
444-
uint8_t relocatability; // nonzero if all roots are built into sysimg or tagged by module key
445445
} jl_code_instance_t;
446446

447447
// all values are callable as Functions

0 commit comments

Comments
 (0)