Skip to content

Commit

Permalink
CR Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cellule committed Mar 16, 2018
1 parent 06aa106 commit 6a13913
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion lib/Runtime/Library/JavascriptLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ namespace Js
class SourceTextModuleRecord;
class ArrayBufferBase;
class SharedContents;
class SharedContents;
typedef RecyclerFastAllocator<JavascriptNumber, LeafBit> RecyclerJavascriptNumberAllocator;
typedef JsUtil::List<Var, Recycler> ListForListIterator;

Expand Down
4 changes: 3 additions & 1 deletion lib/Runtime/Library/SharedArrayBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ namespace Js

BYTE* SharedArrayBuffer::AllocBuffer(uint32 length, uint32 maxLength)
{
Unused(maxLength); // WebAssembly only
#if ENABLE_FAST_ARRAYBUFFER
if (this->IsValidVirtualBufferLength(length))
{
Expand All @@ -262,6 +263,7 @@ namespace Js

void SharedArrayBuffer::FreeBuffer(BYTE* buffer, uint32 length, uint32 maxLength)
{
Unused(maxLength); // WebAssembly only
#if ENABLE_FAST_ARRAYBUFFER
//AsmJS Virtual Free
if (this->IsValidVirtualBufferLength(length))
Expand Down Expand Up @@ -585,7 +587,7 @@ namespace Js
return false;
}

__checkReturn bool WebAssemblySharedArrayBuffer::GrowMemory(uint32 newBufferLength)
_Must_inspect_result_ bool WebAssemblySharedArrayBuffer::GrowMemory(uint32 newBufferLength)
{
uint32 bufferLength = sharedContents->bufferLength;
BYTE* buffer = sharedContents->buffer;
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Library/SharedArrayBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ namespace Js
virtual bool IsValidVirtualBufferLength(uint length) const;

protected:
// maxLength is necessary only for WebAssemblySharedArrayBuffer to know how much it can grow
// Must call after constructor of child class is completed. Required to be able to make correct virtual calls
void Init(uint32 length, uint32 maxLength);
virtual BYTE* AllocBuffer(uint32 length, uint32 maxLength);
Expand Down Expand Up @@ -148,7 +149,7 @@ namespace Js

virtual bool IsValidVirtualBufferLength(uint length) const override;
virtual bool IsWebAssemblyArrayBuffer() override { return true; }
__checkReturn bool GrowMemory(uint32 newBufferLength);
_Must_inspect_result_ bool GrowMemory(uint32 newBufferLength);

protected:
virtual BYTE* AllocBuffer(uint32 length, uint32 maxLength) override;
Expand Down
9 changes: 5 additions & 4 deletions lib/Runtime/Library/WebAssemblyMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ WebAssemblyMemory::WebAssemblyMemory(ArrayBufferBase* buffer, uint32 initial, ui
m_initial(initial),
m_maximum(maximum)
{
Assert(buffer->IsWebAssemblyArrayBuffer());
Assert(m_buffer);
Assert(m_buffer->GetByteLength() >= UInt32Math::Mul<WebAssembly::PageSize>(initial));
}


__checkReturn bool WebAssemblyMemory::AreLimitsValid(uint32 initial, uint32 maximum)
_Must_inspect_result_ bool WebAssemblyMemory::AreLimitsValid(uint32 initial, uint32 maximum)
{
return initial <= maximum && initial <= Wasm::Limits::GetMaxMemoryInitialPages() && maximum <= Wasm::Limits::GetMaxMemoryMaximumPages();
}


__checkReturn bool WebAssemblyMemory::AreLimitsValid(uint32 initial, uint32 maximum, uint32 bufferLength)
_Must_inspect_result_ bool WebAssemblyMemory::AreLimitsValid(uint32 initial, uint32 maximum, uint32 bufferLength)
{
if (!AreLimitsValid(initial, maximum))
{
Expand Down Expand Up @@ -186,7 +187,7 @@ WebAssemblyMemory::GrowInternal(uint32 deltaPages)
if (m_buffer->IsSharedArrayBuffer())
{
AssertOrFailFast(Wasm::Threads::IsEnabled());
if (!((WebAssemblySharedArrayBuffer*)PointerValue(m_buffer))->GrowMemory(newBytes))
if (!((WebAssemblySharedArrayBuffer*)GetBuffer())->GrowMemory(newBytes))
{
return -1;
}
Expand All @@ -197,7 +198,7 @@ WebAssemblyMemory::GrowInternal(uint32 deltaPages)
JavascriptExceptionObject* caughtExceptionObject = nullptr;
try
{
WebAssemblyArrayBuffer* newBuffer = ((WebAssemblyArrayBuffer*)PointerValue(m_buffer))->GrowMemory(newBytes);
WebAssemblyArrayBuffer* newBuffer = ((WebAssemblyArrayBuffer*)GetBuffer())->GrowMemory(newBytes);
if (newBuffer == nullptr)
{
return -1;
Expand Down
5 changes: 2 additions & 3 deletions lib/Runtime/Library/WebAssemblyMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ namespace Js
#endif
private:
WebAssemblyMemory(ArrayBufferBase* buffer, uint32 initial, uint32 maximum, DynamicType * type);
static __checkReturn bool AreLimitsValid(uint32 initial, uint32 maximum);
static __checkReturn bool AreLimitsValid(uint32 initial, uint32 maximum, uint32 bufferLength);

static _Must_inspect_result_ bool AreLimitsValid(uint32 initial, uint32 maximum);
static _Must_inspect_result_ bool AreLimitsValid(uint32 initial, uint32 maximum, uint32 bufferLength);

Field(ArrayBufferBase*) m_buffer;

Expand Down
2 changes: 1 addition & 1 deletion lib/WasmReader/WasmParseTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool IsLocalType(WasmTypes::WasmType type)
return false;
}
#endif
return (uint32)(type - 1) < (WasmTypes::Limit - 1);
return type > WasmTypes::Void && type < WasmTypes::Limit;
}

uint32 GetTypeByteSize(WasmType type)
Expand Down

0 comments on commit 6a13913

Please sign in to comment.