Skip to content

Commit

Permalink
the last HASH functions that are used are now guarded.
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Apr 8, 2014
1 parent 846d59e commit 58a2806
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/6model/reprs/MVMContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ static void at_key(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void *d
MVMContextBody *body = (MVMContextBody *)data;
MVMFrame *frame = body->context;
MVMLexicalRegistry *lexical_names = frame->static_info->body.lexical_names, *entry;
int jen_hash_pad_to_32;
if (!lexical_names) {
MVM_exception_throw_adhoc(tc,
"Lexical with name '%s' does not exist in this frame",
MVM_string_utf8_encode_C_string(tc, name));
}
jen_hash_pad_to_32 = (name->body.flags & MVM_STRING_TYPE_MASK) == MVM_STRING_TYPE_UINT8;
MVM_HASH_GET(tc, lexical_names, name, entry);
if (!entry) {
MVM_exception_throw_adhoc(tc,
Expand All @@ -67,11 +69,13 @@ static void bind_key(MVMThreadContext *tc, MVMSTable *st, MVMObject *root, void
MVMContextBody *body = (MVMContextBody *)data;
MVMFrame *frame = body->context;
MVMLexicalRegistry *lexical_names = frame->static_info->body.lexical_names, *entry;
int jen_hash_pad_to_32;
if (!lexical_names) {
MVM_exception_throw_adhoc(tc,
"Lexical with name '%s' does not exist in this frame",
MVM_string_utf8_encode_C_string(tc, name));
}
jen_hash_pad_to_32 = (name->body.flags & MVM_STRING_TYPE_MASK) == MVM_STRING_TYPE_UINT8;
MVM_HASH_GET(tc, lexical_names, name, entry);
if (!entry) {
MVM_exception_throw_adhoc(tc,
Expand All @@ -96,8 +100,10 @@ static MVMint64 exists_key(MVMThreadContext *tc, MVMSTable *st, MVMObject *root,
MVMFrame *frame = body->context;
MVMLexicalRegistry *lexical_names = frame->static_info->body.lexical_names, *entry;
MVMString *name = (MVMString *)key;
int jen_hash_pad_to_32;
if (!lexical_names)
return 0;
jen_hash_pad_to_32 = (name->body.flags & MVM_STRING_TYPE_MASK) == MVM_STRING_TYPE_UINT8;
MVM_HASH_GET(tc, lexical_names, name, entry);
return entry ? 1 : 0;
}
Expand Down
4 changes: 4 additions & 0 deletions src/6model/sc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
MVMObject * MVM_sc_create(MVMThreadContext *tc, MVMString *handle) {
MVMSerializationContext *sc;
MVMSerializationContextBody *scb;
int jen_hash_pad_to_32;

/* Allocate. */
MVMROOT(tc, handle, {
Expand All @@ -14,6 +15,7 @@ MVMObject * MVM_sc_create(MVMThreadContext *tc, MVMString *handle) {
/* Add to weak lookup hash. */
uv_mutex_lock(&tc->instance->mutex_sc_weakhash);
MVM_string_flatten(tc, handle);
jen_hash_pad_to_32 = (handle->body.flags & MVM_STRING_TYPE_MASK) == MVM_STRING_TYPE_UINT8;
MVM_HASH_GET(tc, tc->instance->sc_weakhash, handle, scb);
if (!scb) {
sc->body = scb = calloc(1, sizeof(MVMSerializationContextBody));
Expand Down Expand Up @@ -236,7 +238,9 @@ MVMObject * MVM_sc_get_code(MVMThreadContext *tc, MVMSerializationContext *sc, M
/* Resolves an SC handle using the SC weakhash. */
MVMSerializationContext * MVM_sc_find_by_handle(MVMThreadContext *tc, MVMString *handle) {
MVMSerializationContextBody *scb;
int jen_hash_pad_to_32;
MVM_string_flatten(tc, handle);
jen_hash_pad_to_32 = (handle->body.flags & MVM_STRING_TYPE_MASK) == MVM_STRING_TYPE_UINT8;
uv_mutex_lock(&tc->instance->mutex_sc_weakhash);
MVM_HASH_GET(tc, tc->instance->sc_weakhash, handle, scb);
uv_mutex_unlock(&tc->instance->mutex_sc_weakhash);
Expand Down
1 change: 1 addition & 0 deletions src/mast/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ unsigned short get_callsite_id(VM, WriterState *ws, MASTNode *flags) {
unsigned short i;
CallsiteReuseEntry *entry = NULL;
unsigned char *identifier = (unsigned char *)malloc(elems);
int jen_hash_pad_to_32 = 0;

for (i = 0; i < elems; i++)
identifier[i] = (unsigned char)ATPOS_I_C(vm, flags, i);
Expand Down
2 changes: 2 additions & 0 deletions tools/ucd2c.pl
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ sub emit_names_hash_builder {
case $FATE_NORMAL: {
MVMint32 extent_span_index = 0;
codepoint_table_index = codepoint_extents[extent_index][2];
int jen_hash_pad_to_32 = 0;
for (; extent_span_index < length
&& codepoint_table_index < MVMCODEPOINTNAMESCOUNT; extent_span_index++) {
const char *name = codepoint_names[codepoint_table_index];
Expand All @@ -887,6 +888,7 @@ sub emit_names_hash_builder {
break;
case $FATE_SPAN: {
const char *name = codepoint_names[codepoint_table_index];
int jen_hash_pad_to_32 = 0;
if (name) {
MVMUnicodeNameRegistry *entry = malloc(sizeof(MVMUnicodeNameRegistry));
entry->name = (char *)name;
Expand Down

0 comments on commit 58a2806

Please sign in to comment.