Skip to content

Commit

Permalink
FIXED: Trie handling of floats on 32-bit hardware
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed May 16, 2024
1 parent 6bd4950 commit af3ec2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 11 additions & 9 deletions src/pl-trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -2786,10 +2786,11 @@ compile_trie_value(DECL_LD Word v, trie_compile_state *state)
}
break;
case TAG_FLOAT:
{ Word ip = valIndirectP(w);
add_vmi_d(state, T_FLOAT, (code)ip[0]);
{ Code ip = (Code)valIndirectP(w);
add_vmi_d(state, T_FLOAT, ip[0]);
#if SIZEOF_CODE == 4
addBuffer(&state->codes, (code)ip[1], code);
static_assertion(sizeof(double) == sizeof(code)*2);
addBuffer(&state->codes, ip[1], code);
#endif
break;
}
Expand Down Expand Up @@ -2896,12 +2897,13 @@ compile_trie_node(DECL_LD trie_node *n, trie_compile_state *state)
add_vmi_w(state, T_STRING, h->header);
break;
case TAG_FLOAT:
{ static_assertion(sizeof(h->data[0]) == sizeof(word)); }
if ( state->try )
add_vmi_else_w(state, T_TRY_FLOAT, h->data[0]);
else
add_vmi_w(state, T_FLOAT, h->data[0]);
goto indirect_done;
{ static_assertion(sizeof(h->data[0]) == sizeof(double));
if ( state->try )
add_vmi_else_w(state, T_TRY_FLOAT, h->data[0]);
else
add_vmi_w(state, T_FLOAT, h->data[0]);
goto indirect_done;
}
}

addMultipleBuffer(&state->codes, h->data, wsize, word);
Expand Down
6 changes: 3 additions & 3 deletions src/pl-vmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6324,9 +6324,9 @@ VMI(T_FLOAT, 0, CODES_PER_DOUBLE, (CA1_FLOAT))
TrieNextArg();
NEXT_INSTRUCTION;
} else if ( isFloat(*k) )
{ Word p = valIndirectP(*k);
{ Code p = (Code)valIndirectP(*k);

switch(WORDS_PER_DOUBLE) /* depend on compiler to clean up */
switch(CODES_PER_DOUBLE) /* depend on compiler to clean up */
{ case 2:
if ( *p++ != *PC++ )
CLAUSE_FAILED;
Expand Down Expand Up @@ -6418,7 +6418,7 @@ END_VMI

VMI(T_TRY_SMALLINTW, 0, 1+CODES_PER_WORD, (CA1_JUMP,CA1_WORD))
{ TRIE_TRY;
VMI_GOTO(T_SMALLINT);
VMI_GOTO(T_SMALLINTW);
}
END_VMI

Expand Down

0 comments on commit af3ec2d

Please sign in to comment.