Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing Go runtime compilation to succeed under ARM #1990

Merged
merged 3 commits into from
Oct 27, 2017
Merged

Allowing Go runtime compilation to succeed under ARM #1990

merged 3 commits into from
Oct 27, 2017

Conversation

milanaleksic
Copy link
Contributor

@milanaleksic milanaleksic commented Aug 21, 2017

Discussion already present in #1858 - effectively the deduced type wasn't big enough to allow compilation and execution under my ARM server (Radxa Rock Pro). This change allowed compilation to succeed and I didn't find any issues so far

If tests are needed please hold the PR until I have time to add them.

This fix allows compilation and execution under ARM architecture, since default type couldn't handle all possible values
k1 *= c1_32
k1 = (k1 << 15) | (k1 >> 17) // rotl32(k1, 15)
k1 *= c2_32
var k1u uint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid defining the var if you use the := operator. (Here and elsewhere.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

var h1u = uint(h1) ^ k1u
h1u = (h1u << 13) | (h1u >> 19) // rotl32(h1u, 13)
h1u = h1u*5 + 0xe6546b64
return int(h1u)
}

func murmurFinish(h1 int, numberOfWords int) int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should fix the input type instead of relying on a cast (enforcing that there are no negative numbers passed to this function). Also might be good to document that numberOfWords is limited to be 4x less than the normal uint range.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started doing this but changing of the input arguments to uint percolates to many places, I don't have time to fix it at this moment, will push when it's ready

Copy link
Contributor

@neatnerd neatnerd Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think it is needed. I did consider suggesting this option, then i checked alg specification, to my understanding h1 and k1 cannot be negative

Wikipedia code FTW

uint32_t murmur3_32(const uint8_t* key, size_t len, uint32_t seed) {
  uint32_t h = seed;
  if (len > 3) {
    const uint32_t* key_x4 = (const uint32_t*) key;
    size_t i = len >> 2;
    do {
      uint32_t k = *key_x4++;
      k *= 0xcc9e2d51;
      k = (k << 15) | (k >> 17);
      k *= 0x1b873593;
      h ^= k;
      h = (h << 13) | (h >> 19);
      h = (h * 5) + 0xe6546b64;
    } while (--i);
    key = (const uint8_t*) key_x4;
  }
  if (len & 3) {
    size_t i = len & 3;
    uint32_t k = 0;
    key = &key[i - 1];
    do {
      k <<= 8;
      k |= *key--;
    } while (--i);
    k *= 0xcc9e2d51;
    k = (k << 15) | (k >> 17);
    k *= 0x1b873593;
    h ^= k;
  }
  h ^= len;
  h ^= h >> 16;
  h *= 0x85ebca6b;
  h ^= h >> 13;
  h *= 0xc2b2ae35;
  h ^= h >> 16;
  return h;
}

@parrt
Copy link
Member

parrt commented Oct 21, 2017

hi gang. Are we ready to merge this one?

@parrt
Copy link
Member

parrt commented Oct 27, 2017

@milanaleksic @davesisson @neatnerd Are we ready to merge this one?

@davesisson
Copy link
Contributor

Yes, I think this one is good to go.

@parrt parrt added this to the 4.7.1 milestone Oct 27, 2017
@parrt parrt merged commit 089550d into antlr:master Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants