mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 933001 - Part 2/5 - Make SharedArrayBuffer usable as an AsmJS heap. r=luke
This commit is contained in:
parent
f9325c702d
commit
ae8cbd7af4
@ -224,29 +224,8 @@ ValidateConstant(JSContext *cx, AsmJSModule::Global &global, HandleValue globalV
|
||||
}
|
||||
|
||||
static bool
|
||||
DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module)
|
||||
LinkModuleToHeap(JSContext *cx, AsmJSModule &module, Handle<ArrayBufferObject*> heap)
|
||||
{
|
||||
module.setIsDynamicallyLinked();
|
||||
|
||||
RootedValue globalVal(cx);
|
||||
if (args.length() > 0)
|
||||
globalVal = args[0];
|
||||
|
||||
RootedValue importVal(cx);
|
||||
if (args.length() > 1)
|
||||
importVal = args[1];
|
||||
|
||||
RootedValue bufferVal(cx);
|
||||
if (args.length() > 2)
|
||||
bufferVal = args[2];
|
||||
|
||||
Rooted<ArrayBufferObject*> heap(cx);
|
||||
if (module.hasArrayView()) {
|
||||
if (!IsTypedArrayBuffer(bufferVal))
|
||||
return LinkFail(cx, "bad ArrayBuffer argument");
|
||||
|
||||
heap = &bufferVal.toObject().as<ArrayBufferObject>();
|
||||
|
||||
if (!IsValidAsmJSHeapLength(heap->byteLength())) {
|
||||
ScopedJSFreePtr<char> msg(
|
||||
JS_smprintf("ArrayBuffer byteLength 0x%x is not a valid heap length. The next "
|
||||
@ -273,6 +252,34 @@ DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module)
|
||||
return LinkFail(cx, "Unable to prepare ArrayBuffer for asm.js use");
|
||||
|
||||
module.initHeap(heap, cx);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
DynamicallyLinkModule(JSContext *cx, CallArgs args, AsmJSModule &module)
|
||||
{
|
||||
module.setIsDynamicallyLinked();
|
||||
|
||||
RootedValue globalVal(cx);
|
||||
if (args.length() > 0)
|
||||
globalVal = args[0];
|
||||
|
||||
RootedValue importVal(cx);
|
||||
if (args.length() > 1)
|
||||
importVal = args[1];
|
||||
|
||||
RootedValue bufferVal(cx);
|
||||
if (args.length() > 2)
|
||||
bufferVal = args[2];
|
||||
|
||||
Rooted<ArrayBufferObject*> heap(cx);
|
||||
if (module.hasArrayView()) {
|
||||
if (!IsTypedArrayBuffer(bufferVal))
|
||||
return LinkFail(cx, "bad ArrayBuffer argument");
|
||||
|
||||
heap = &AsTypedArrayBuffer(bufferVal);
|
||||
if (!LinkModuleToHeap(cx, module, heap))
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoObjectVector ffis(cx);
|
||||
|
@ -533,6 +533,10 @@ ArrayBufferObject::prepareForAsmJS(JSContext *cx, Handle<ArrayBufferObject*> buf
|
||||
if (buffer->isAsmJSArrayBuffer())
|
||||
return true;
|
||||
|
||||
// SharedArrayBuffers are already created with AsmJS support in mind.
|
||||
if (buffer->isSharedArrayBuffer())
|
||||
return true;
|
||||
|
||||
// Get the entire reserved region (with all pages inaccessible).
|
||||
void *p;
|
||||
# ifdef XP_WIN
|
||||
@ -598,6 +602,9 @@ ArrayBufferObject::prepareForAsmJS(JSContext *cx, Handle<ArrayBufferObject*> buf
|
||||
if (buffer->isAsmJSArrayBuffer())
|
||||
return true;
|
||||
|
||||
if (buffer->isSharedArrayBuffer())
|
||||
return true;
|
||||
|
||||
if (!ensureNonInline(cx, buffer))
|
||||
return false;
|
||||
|
||||
@ -616,6 +623,7 @@ ArrayBufferObject::releaseAsmJSArrayBuffer(FreeOp *fop, JSObject *obj)
|
||||
bool
|
||||
ArrayBufferObject::neuterAsmJSArrayBuffer(JSContext *cx, ArrayBufferObject &buffer)
|
||||
{
|
||||
JS_ASSERT(!buffer.isSharedArrayBuffer());
|
||||
#ifdef JS_ION
|
||||
AsmJSActivation *act = cx->mainThread().asmJSActivationStackFromOwnerThread();
|
||||
for (; act; act = act->prev()) {
|
||||
|
@ -2768,7 +2768,18 @@ js::IsTypedArrayConstructor(HandleValue v, uint32_t type)
|
||||
bool
|
||||
js::IsTypedArrayBuffer(HandleValue v)
|
||||
{
|
||||
return v.isObject() && v.toObject().is<ArrayBufferObject>();
|
||||
return v.isObject() &&
|
||||
(v.toObject().is<ArrayBufferObject>() ||
|
||||
v.toObject().is<SharedArrayBufferObject>());
|
||||
}
|
||||
|
||||
ArrayBufferObject &
|
||||
js::AsTypedArrayBuffer(HandleValue v)
|
||||
{
|
||||
JS_ASSERT(IsTypedArrayBuffer(v));
|
||||
if (v.toObject().is<ArrayBufferObject>())
|
||||
return v.toObject().as<ArrayBufferObject>();
|
||||
return v.toObject().as<SharedArrayBufferObject>();
|
||||
}
|
||||
|
||||
/* JS Friend API */
|
||||
|
@ -150,6 +150,9 @@ IsTypedArrayConstructor(HandleValue v, uint32_t type);
|
||||
bool
|
||||
IsTypedArrayBuffer(HandleValue v);
|
||||
|
||||
ArrayBufferObject &
|
||||
AsTypedArrayBuffer(HandleValue v);
|
||||
|
||||
static inline unsigned
|
||||
TypedArrayShift(ArrayBufferView::ViewType viewType)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user