Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/Common/ConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ PHASE(All)
#define DEFAULT_CONFIG_ES7TrailingComma (true)
#define DEFAULT_CONFIG_ES7ValuesEntries (true)
#define DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors (true)
#define DEFAULT_CONFIG_ESSharedArrayBuffer (false)
#define DEFAULT_CONFIG_ES6Verbose (false)
#define DEFAULT_CONFIG_ES6All (false)
// ES6 DEFAULT BEHAVIOR
Expand Down Expand Up @@ -784,6 +785,14 @@ PHASE(All)
#define FLAGPR(Type, ParentName, Name, String, Default) FLAG(Type, Name, String, Default, ParentName, FALSE)
#define FLAGR(Type, Name, String, Default) FLAG(Type, Name, String, Default, NoParent, FALSE)

// Release flags with parent and acronym
#ifndef FLAGPRA
#define FLAGPRA(Type, ParentName, Name, Acronym, String, Default) \
FLAGPR(Type, ParentName, Name, String, Default) \
FLAGNR(Type, Acronym, String, Default)
#endif


// RELEASE FLAGS WITH REGISTRY OVERRIDE
#define FLAGPR_REGOVR_ASMJS(Type, ParentName, Name, String, Default) FLAG_REGOVR_ASMJS(Type, Name, String, Default, ParentName, FALSE)
#define FLAGPR_REGOVR_EXP(Type, ParentName, Name, String, Default) FLAG_REGOVR_EXP(Type, Name, String, Default, ParentName, FALSE)
Expand Down Expand Up @@ -1013,7 +1022,8 @@ FLAGPR (Boolean, ES6, ES6Verbose , "Enable ES6 verbose tra
#endif
FLAGPR_REGOVR_EXP(Boolean, ES6, ArrayBufferTransfer , "Enable ArrayBuffer.transfer" , DEFAULT_CONFIG_ArrayBufferTransfer)

FLAGPR (Boolean, ES6, ESObjectGetOwnPropertyDescriptors, "Enable Object.getOwnPropertyDescriptors" , DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors)
FLAGPR (Boolean, ES6, ESObjectGetOwnPropertyDescriptors, "Enable Object.getOwnPropertyDescriptors" , DEFAULT_CONFIG_ESObjectGetOwnPropertyDescriptors)
FLAGPRA (Boolean, ES6, ESSharedArrayBuffer , sab , "Enable SharedArrayBuffer" , DEFAULT_CONFIG_ESSharedArrayBuffer)
Copy link
Collaborator

@agarwal-sandeep agarwal-sandeep Sep 2, 2016

Choose a reason for hiding this comment

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

FLAGPRA [](start = 0, length = 7)

Will we be able to disable this using COMPILE_DISABLE_ macro similar to other release ES6 options above? #Closed

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 believe this is not even as experimental phase. None of ES7(ESNext) are having the COMPILE_DISABLE macro. So I put that as is.


In reply to: 77396110 [](ancestors = 77396110)


// /ES6 (BLUE+1) features/flags

Expand Down Expand Up @@ -1474,5 +1484,6 @@ FLAGNR(Boolean, CFG, "Force enable CFG on jshost. version in the jshost's manife
#undef FLAGNR
#undef FLAGNRA
#undef FLAGPNR
#undef FLAGPRA

#endif
6 changes: 6 additions & 0 deletions lib/Common/Core/ConfigFlagsTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,12 @@ namespace Js
Name = Acronym; \
}
#if ENABLE_DEBUG_CONFIG_OPTIONS
#define FLAGPRA(Type, ParentName, Name, Acronym, ...) \
if(!IsEnabled(Name##Flag) && IsEnabled(Acronym##Flag)) \
{ \
Enable(Name##Flag); \
Name = Acronym; \
}
#define FLAGRA(Type, Name, Acronym, ...) FLAGNRA(Type, Name, Acronym, __VA_ARGS__)
#endif
#include "ConfigFlagsList.h"
Expand Down
2 changes: 1 addition & 1 deletion lib/Jsrt/Jsrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ Js::ArrayObject* CreateTypedArray(Js::ScriptContext *scriptContext, void* data,
{
Js::JavascriptLibrary* library = scriptContext->GetLibrary();

Js::ArrayBuffer* arrayBuffer = RecyclerNew(
Js::ArrayBufferBase* arrayBuffer = RecyclerNew(
scriptContext->GetRecycler(),
Js::ExternalArrayBuffer,
reinterpret_cast<BYTE*>(data),
Expand Down
5 changes: 5 additions & 0 deletions lib/Parser/rterrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,8 @@ RT_ERROR_MSG(JSERR_InvalidHint, 5658, "%s: invalid hint", "invalid hint", kjstTy

RT_ERROR_MSG(JSERR_This_NeedNamespace, 5659, "%s: 'this' is not a Module Namespace object", "Module Namespace object expected", kjstTypeError, JSERR_This_NeedNamespace) // {Locked="\'this\'"}
RT_ERROR_MSG(JSERR_This_NeedListIterator, 5660, "%s: 'this' is not a List Iterator object", "List Iterator expected", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_NeedSharedArrayBufferObject, 5661, "%s is not a SharedArrayBuffer", "SharedArrayBuffer object expected", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_NeedTypedArrayObject, 5662, "", "Atomics function called with invalid typed array object", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_InvalidTypedArrayIndex, 5663, "", "Access index is out of range", kjstRangeError, 0)
RT_ERROR_MSG(JSERR_InvalidOperationOnTypedArray, 5664, "", "The operation is not supported on this typed array type", kjstRangeError, 0)
RT_ERROR_MSG(JSERR_CannotSuspendBuffer, 5665, "", "Current agent cannot be suspended", kjstRangeError, 0)
1 change: 1 addition & 0 deletions lib/Runtime/Base/FunctionBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace Js
class AmsJsModuleInfo;
#endif
class ArrayBuffer;
class SharedArrayBuffer;
class FunctionCodeGenRuntimeData;
#pragma endregion

Expand Down
8 changes: 8 additions & 0 deletions lib/Runtime/Base/JnDirectFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,14 @@ ENTRY(screen)
ENTRY(padStart)
ENTRY(padEnd)

ENTRY(SharedArrayBuffer)
ENTRY(Atomics)
ENTRY(compareExchange)
ENTRY(exchange)
ENTRY(isLockFree)
ENTRY(wait)
ENTRY(wake)

// Note: Do not add fields for conditionally-compiled PropertyIds into this file.
// The bytecode for internal javascript libraries is built on chk but re-used in fre builds.
// Having a mismatch in the number of PropertyIds will cause a failure loading bytecode.
Expand Down
1 change: 1 addition & 0 deletions lib/Runtime/Base/ThreadConfigFlagsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ FLAG_RELEASE(SkipSplitOnNoResult, SkipSplitOnNoResult)
FLAG_RELEASE(IsES7AsyncAndAwaitEnabled, ES7AsyncAwait)
FLAG_RELEASE(IsArrayBufferTransferEnabled, ArrayBufferTransfer)
FLAG_RELEASE(IsESObjectGetOwnPropertyDescriptorsEnabled, ESObjectGetOwnPropertyDescriptors)
FLAG_RELEASE(IsESSharedArrayBufferEnabled, ESSharedArrayBuffer)
#ifdef ENABLE_PROJECTION
FLAG(AreWinRTDelegatesInterfaces, WinRTDelegateInterfaces)
FLAG_RELEASE(IsWinRTAdaptiveAppsEnabled, WinRTAdaptiveApps)
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Language/JavascriptOperators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5330,9 +5330,10 @@ namespace Js
{
switch (state->GetTypeId())
{
case TypeIds_SharedArrayBuffer:
return Js::SharedArrayBuffer::NewFromSharedState(state, library);
case TypeIds_ArrayBuffer:
return Js::ArrayBuffer::NewFromDetachedState(state, library);
break;
default:
AssertMsg(false, "We should explicitly have a case statement for each object which has detached state.");
return nullptr;
Expand Down
15 changes: 13 additions & 2 deletions lib/Runtime/Library/ArrayBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@

namespace Js
{
bool ArrayBufferBase::Is(Var value)
{
return ArrayBuffer::Is(value) || SharedArrayBuffer::Is(value);
}

ArrayBufferBase* ArrayBufferBase::FromVar(Var value)
{
Assert(ArrayBufferBase::Is(value));
return static_cast<ArrayBuffer *> (value);
}

ArrayBuffer* ArrayBuffer::NewFromDetachedState(DetachedStateBase* state, JavascriptLibrary *library)
{
ArrayBufferDetachedStateBase* arrayBufferState = (ArrayBufferDetachedStateBase *)state;
Expand Down Expand Up @@ -426,7 +437,7 @@ namespace Js

template <class Allocator>
ArrayBuffer::ArrayBuffer(uint32 length, DynamicType * type, Allocator allocator) :
DynamicObject(type), mIsAsmJsBuffer(false), isBufferCleared(false),isDetached(false)
ArrayBufferBase(type), mIsAsmJsBuffer(false), isBufferCleared(false),isDetached(false)
{
buffer = nullptr;
bufferLength = 0;
Expand Down Expand Up @@ -473,7 +484,7 @@ namespace Js
}

ArrayBuffer::ArrayBuffer(byte* buffer, uint32 length, DynamicType * type) :
buffer(buffer), bufferLength(length), DynamicObject(type), mIsAsmJsBuffer(false), isDetached(false)
buffer(buffer), bufferLength(length), ArrayBufferBase(type), mIsAsmJsBuffer(false), isDetached(false)
{
if (length > MaxArrayBufferLength)
{
Expand Down
65 changes: 42 additions & 23 deletions lib/Runtime/Library/ArrayBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,38 @@
namespace Js
{
class ArrayBufferParent;
class ArrayBuffer : public DynamicObject
class ArrayBuffer;
class SharedArrayBuffer;
class ArrayBufferBase : public DynamicObject
{
public:
DEFINE_VTABLE_CTOR_ABSTRACT(ArrayBufferBase, DynamicObject);

virtual void MarshalToScriptContext(Js::ScriptContext * scriptContext) = 0;

ArrayBufferBase(DynamicType *type) : DynamicObject(type) { }

virtual bool IsArrayBuffer() = 0;
virtual bool IsSharedArrayBuffer() = 0;
virtual ArrayBuffer * GetAsArrayBuffer() = 0;
virtual SharedArrayBuffer * GetAsSharedArrayBuffer() { return nullptr; }
virtual void AddParent(ArrayBufferParent* parent) { }
virtual void RemoveParent(ArrayBufferParent* parent) { }
virtual bool IsDetached() { return false; }
virtual uint32 GetByteLength() const = 0;
virtual BYTE* GetBuffer() const = 0;
virtual bool IsValidVirtualBufferLength(uint length) { return false; }

static bool Is(Var value);
static ArrayBufferBase* FromVar(Var value);
};

class ArrayBuffer : public ArrayBufferBase
{
public:
// we need to install cross-site thunk on the nested array buffer when marshaling
// typed array.
DEFINE_VTABLE_CTOR_ABSTRACT(ArrayBuffer, DynamicObject);
virtual void MarshalToScriptContext(Js::ScriptContext * scriptContext) = 0;
DEFINE_VTABLE_CTOR_ABSTRACT(ArrayBuffer, ArrayBufferBase);
#define MAX_ASMJS_ARRAYBUFFER_LENGTH 0x100000000 //4GB
private:
void ClearParentsLength(ArrayBufferParent* parent);
Expand Down Expand Up @@ -84,17 +109,17 @@ namespace Js
virtual BOOL GetDiagValueString(StringBuilder<ArenaAllocator>* stringBuilder, ScriptContext* requestContext) override;

virtual ArrayBufferDetachedStateBase* DetachAndGetState();
bool IsDetached() { return this->isDetached; }
virtual bool IsDetached() override { return this->isDetached; }
void SetIsAsmJsBuffer(){ mIsAsmJsBuffer = true; }
uint32 GetByteLength() const { return bufferLength; }
BYTE* GetBuffer() const { return buffer; }
virtual uint32 GetByteLength() const override { return bufferLength; }
virtual BYTE* GetBuffer() const override { return buffer; }

static int GetByteLengthOffset() { return offsetof(ArrayBuffer, bufferLength); }
static int GetIsDetachedOffset() { return offsetof(ArrayBuffer, isDetached); }
static int GetBufferOffset() { return offsetof(ArrayBuffer, buffer); }

void AddParent(ArrayBufferParent* parent);
void RemoveParent(ArrayBufferParent* parent);
virtual void AddParent(ArrayBufferParent* parent) override;
virtual void RemoveParent(ArrayBufferParent* parent) override;
#if _WIN64
//maximum 2G -1 for amd64
static const uint32 MaxArrayBufferLength = 0x7FFFFFFF;
Expand All @@ -103,8 +128,12 @@ namespace Js
static const uint32 MaxArrayBufferLength = 1 << 30;
#endif
virtual bool IsValidAsmJsBufferLength(uint length, bool forceCheck = false) { return false; }
virtual bool IsValidVirtualBufferLength(uint length) { return false; }
virtual bool IsArrayBuffer() override { return true; }
virtual bool IsSharedArrayBuffer() override { return false; }
virtual ArrayBuffer * GetAsArrayBuffer() override { return ArrayBuffer::FromVar(this); }

protected:

typedef void __cdecl FreeFn(void* ptr);
virtual ArrayBufferDetachedStateBase* CreateDetachedState(BYTE* buffer, DECLSPEC_GUARD_OVERFLOW uint32 bufferLength) = 0;
virtual ArrayBuffer * TransferInternal(DECLSPEC_GUARD_OVERFLOW uint32 newBufferLength) = 0;
Expand All @@ -130,14 +159,15 @@ namespace Js
class ArrayBufferParent : public ArrayObject
{
friend ArrayBuffer;
friend ArrayBufferBase;

private:
ArrayBuffer* arrayBuffer;
ArrayBufferBase* arrayBuffer;

protected:
DEFINE_VTABLE_CTOR_ABSTRACT(ArrayBufferParent, ArrayObject);

ArrayBufferParent(DynamicType * type, uint32 length, ArrayBuffer* arrayBuffer)
ArrayBufferParent(DynamicType * type, uint32 length, ArrayBufferBase* arrayBuffer)
: ArrayObject(type, /*initSlots*/true, length),
arrayBuffer(arrayBuffer)
{
Expand All @@ -153,19 +183,8 @@ namespace Js
}
}

void SetArrayBuffer(ArrayBuffer* arrayBuffer)
{
this->ClearArrayBuffer();

if (arrayBuffer != nullptr)
{
this->arrayBuffer->AddParent(this);
this->arrayBuffer = arrayBuffer;
}
}

public:
ArrayBuffer* GetArrayBuffer() const
ArrayBufferBase* GetArrayBuffer() const
{
return this->arrayBuffer;
}
Expand Down
Loading