Skip to content

Connie/threading proposal#57

Merged
ErikMcClure merged 20 commits intoinnative-sdk:masterfrom
Connicpu:connie/threading-proposal
May 26, 2020
Merged

Connie/threading proposal#57
ErikMcClure merged 20 commits intoinnative-sdk:masterfrom
Connicpu:connie/threading-proposal

Conversation

@Connicpu
Copy link
Contributor

Implement #35

The implementation of wait/notify is far from optimized but it works for now. It can be greatly improved if the spec relaxes the requirement for no spurious failures.

imports.wast will not be able to pass until multi-memory is implemented

Copy link
Contributor

@ErikMcClure ErikMcClure left a comment

Choose a reason for hiding this comment

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

Please double check the types being parsed from the binary wasm file.

OP_i64_atomic_rmw16_cmpxchg_u = 0x4D,
OP_i64_atomic_rmw32_cmpxchg_u = 0x4E,

OP_atomic_end,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove OP_atomic_end and simply set OP_END equal to OP_i64_atomic_rmw32_cmpxchg_u because OP_START is kind of arbitrary as well, and that check only actually works if additional atomic instructions are contiguous, which might not be true, so there's no reason to introduce false assurance.


namespace innative::atomic_details {
constexpr auto OP_START = OP_i32_atomic_load;
constexpr auto OP_END = OP_atomic_end;
Copy link
Contributor

Choose a reason for hiding this comment

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

set this to OP_i64_atomic_rmw32_cmpxchg_u


#elif defined(POSIX)

static int64_t in_atomic_load64(int64_t* address) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

In order for linux to compile at all this function will at least return something, so maybe change this to return *address and put a // TODO comment here.

// Copyright (c)2020 Black Sphere Studios
// For conditions of distribution and use, see copyright notice in innative.h

#pragma once
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use #pragma once, because it won't work if the same header file is duplicated in two different locations (which can happen if a library depending on this library contains it's own set of headers since nobody can agree on how to properly deal with them). Also, GCC whines about it. Use include guards instead using the standard format.


IN_ERROR innative::ParseResizableLimits(Stream& s, ResizableLimits& limits)
{
// This will only actually read a single byte
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this using ParseVarUInt32 if it will only actually read a single byte? If there is only one byte it should be varuint7, unless the spec has done something very strange.

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'm actually not sure on this one tbh. Technically according to the spec the only valid values here are {0,1,3}, but it was already reading a varuint32. I can change it to varint7 if you'd prefer though

if(err < 0)
return err;

ins.immediates[0]._varuint32 = alignByte & 0b111;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we assigning a single byte to _varuint32?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just for symmetry with the existing load/store instructions. They also used the _varuint32 field even though the spec says they can't be bigger than 0x7

t.Push(WatToken{ WatTokens::INTEGER, 0, 0, 0, limits.maximum });
if(limits.flags & WASM_LIMIT_SHARED)
t.Push(WatToken{ WatTokens::SHARED });
// TODO: Should we serialize an UNSHARED token in the other case?
Copy link
Contributor

Choose a reason for hiding this comment

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

No, unless other wasm serializers decide to do this (but none of them support threads yet).

}

uint8_t GetInstruction(StringSpan ref)
uint16_t GetInstruction(StringSpan ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

Once again, if this is supposed to capture all instruction bytes in a single type, this type should be defined based off of the maximum number of instruction bytes.

@ErikMcClure ErikMcClure merged commit 6044353 into innative-sdk:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants