Ignore:
Timestamp:
Mar 29, 2017, 10:44:59 AM (8 years ago)
Author:
[email protected]
Message:

WebAssembly: add shell-only Memory mode helper
https://bugs.webkit.org/show_bug.cgi?id=170227

Reviewed by Mark Lam.

JSTests:

  • wasm/assert.js: fix a prior debug thing I forgot to remove
  • wasm/function-tests/memory-section-and-import.js: the assert

issue was hiding a failure in error message here

  • wasm/js-api/element.js: the assert issue was hiding a failure in

error message here
(badInstantiation.test):
(badInstantiation):

  • wasm/js-api/extension-MemoryMode.js: Added.

(const.validateMode.what.switch):
(testMemoryNoMax):
(testMemory):
(testInstanceNoMemory):
(testInstanceNoMax):
(testInstance):

  • wasm/js-api/test_memory.js: the assert issue was hiding a

failure in error message here
(test):

Source/JavaScriptCore:

  • jsc.cpp:

(GlobalObject::finishCreation):
(functionWebAssemblyMemoryMode):

  • wasm/WasmMemory.h:
  • wasm/js/JSWebAssemblyInstance.h:
  • wasm/js/JSWebAssemblyMemory.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r214504 r214547  
    5858#include "JSTypedArrays.h"
    5959#include "JSWebAssemblyCallee.h"
     60#include "JSWebAssemblyInstance.h"
     61#include "JSWebAssemblyMemory.h"
    6062#include "LLIntData.h"
    6163#include "LLIntThunks.h"
     
    10851087#if ENABLE(WEBASSEMBLY)
    10861088static EncodedJSValue JSC_HOST_CALL functionTestWasmModuleFunctions(ExecState*);
     1089static EncodedJSValue JSC_HOST_CALL functionWebAssemblyMemoryMode(ExecState*);
    10871090#endif
    10881091
     
    13591362#if ENABLE(WEBASSEMBLY)
    13601363        addFunction(vm, "testWasmModuleFunctions", functionTestWasmModuleFunctions, 0);
     1364        addFunction(vm, "WebAssemblyMemoryMode", functionWebAssemblyMemoryMode, 1);
    13611365#endif
    13621366
     
    32473251}
    32483252
     3253static EncodedJSValue JSC_HOST_CALL functionWebAssemblyMemoryMode(ExecState* exec)
     3254{
     3255    VM& vm = exec->vm();
     3256    auto scope = DECLARE_THROW_SCOPE(vm);
     3257   
     3258    if (!Options::useWebAssembly())
     3259        return throwVMTypeError(exec, scope, ASCIILiteral("WebAssemblyMemoryMode should only be called if the useWebAssembly option is set"));
     3260
     3261    if (JSObject* object = exec->argument(0).getObject()) {
     3262        if (auto* memory = jsDynamicCast<JSWebAssemblyMemory*>(vm, object))
     3263            return JSValue::encode(jsString(&vm, makeString(memory->memory().mode())));
     3264        if (auto* instance = jsDynamicCast<JSWebAssemblyInstance*>(vm, object))
     3265            return JSValue::encode(jsString(&vm, makeString(instance->memoryMode())));
     3266    }
     3267
     3268    return throwVMTypeError(exec, scope, ASCIILiteral("WebAssemblyMemoryMode expects either a WebAssembly.Memory or WebAssembly.Instance"));
     3269}
     3270
    32493271#endif // ENABLE(WEBASSEBLY)
    32503272
Note: See TracChangeset for help on using the changeset viewer.