Changeset 214547 in webkit
- Timestamp:
- Mar 29, 2017 10:44:59 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r214504 r214547 1 2017-03-29 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: add shell-only Memory mode helper 4 https://bugs.webkit.org/show_bug.cgi?id=170227 5 6 Reviewed by Mark Lam. 7 8 * wasm/assert.js: fix a prior debug thing I forgot to remove 9 * wasm/function-tests/memory-section-and-import.js: the assert 10 issue was hiding a failure in error message here 11 * wasm/js-api/element.js: the assert issue was hiding a failure in 12 error message here 13 (badInstantiation.test): 14 (badInstantiation): 15 * wasm/js-api/extension-MemoryMode.js: Added. 16 (const.validateMode.what.switch): 17 (testMemoryNoMax): 18 (testMemory): 19 (testInstanceNoMemory): 20 (testInstanceNoMax): 21 (testInstance): 22 * wasm/js-api/test_memory.js: the assert issue was hiding a 23 failure in error message here 24 (test): 25 1 26 2017-03-28 Keith Miller <keith_miller@apple.com> 2 27 -
trunk/JSTests/wasm/assert.js
r214504 r214547 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 46 46 export const notNumber = (v, msg) => isNotA(v, "number", msg); 47 47 export const isNumber = (v, msg) => isA(v, "number", msg); 48 export const notFunction = (v, msg) => isNotA(v, "function", msg); 49 export const isFunction = (v, msg) => isA(v, "function", msg); 48 50 49 51 export const hasObjectProperty = (o, p, msg) => { … … 128 130 return e; 129 131 } 130 return e;131 132 } 132 133 _fail(`Expected to throw a ${type.name} with message "${message}", got ${e.name} with message "${e.message}"`); -
trunk/JSTests/wasm/function-tests/memory-section-and-import.js
r214438 r214547 29 29 30 30 const i0 = instantiate(builder0); 31 assert.throws(() => instantiate(builder1, { imp: { memory: i0.exports.memory } }), WebAssembly.CompileError, `WebAssembly.Module doesn't parse at byte 3 4 / 40: Memory section cannot exist if an Import has a memory`);31 assert.throws(() => instantiate(builder1, { imp: { memory: i0.exports.memory } }), WebAssembly.CompileError, `WebAssembly.Module doesn't parse at byte 35 / 41: Memory section cannot exist if an Import has a memory`); -
trunk/JSTests/wasm/js-api/element.js
r213484 r214547 182 182 assert.eq(table.get(j)(i*2), i*2 + 42); 183 183 else 184 assert.throws(() => table.get(j)(i*2), TypeError, "table.get(j) is not a function. ");184 assert.throws(() => table.get(j)(i*2), TypeError, "table.get(j) is not a function. (In 'table.get(j)(i*2)', 'table.get(j)' is null)"); 185 185 } 186 186 } -
trunk/JSTests/wasm/js-api/test_memory.js
r210201 r214547 318 318 const module = new WebAssembly.Module(bin); 319 319 320 assert.throws(() => new WebAssembly.Instance(module, 20), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object (evaluating 'new WebAssembly.Instance(module, 20)')`);321 assert.throws(() => new WebAssembly.Instance(module, {}), TypeError, `import must be an object (evaluating 'new WebAssembly.Instance(module, {})')`);322 assert.throws(() => new WebAssembly.Instance(module, {imp: { } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { } })')`);323 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: 20 } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { memory: 20 } })')`);324 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: [] } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory (evaluating 'new WebAssembly.Instance(module, {imp: { memory: [] } })')`);325 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }), WebAssembly.LinkError, `Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } })')`);326 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } }), WebAssembly.LinkError, `Memory import did not have a 'maximum' but the module requires that it does (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } })')`);327 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } }), WebAssembly.LinkError, `Memory import s 'maximum' is larger than the module's expected 'maximum' (evaluating 'new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } })')`);320 assert.throws(() => new WebAssembly.Instance(module, 20), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object`); 321 assert.throws(() => new WebAssembly.Instance(module, {}), TypeError, `import must be an object`); 322 assert.throws(() => new WebAssembly.Instance(module, {imp: { } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`); 323 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: 20 } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`); 324 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: [] } }), WebAssembly.LinkError, `Memory import is not an instance of WebAssembly.Memory`); 325 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }), WebAssembly.LinkError, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`); 326 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20}) } }), WebAssembly.LinkError, `Memory import did not have a 'maximum' but the module requires that it does`); 327 assert.throws(() => new WebAssembly.Instance(module, {imp: { memory: new WebAssembly.Memory({initial: 20, maximum: 26}) } }), WebAssembly.LinkError, `Memory import provided a 'maximum' that is larger than the module's declared 'maximum' import memory size`); 328 328 }); 329 329 … … 355 355 } 356 356 357 testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, "Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, instanceObj)')");358 testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19}) } }, "Memory import provided an 'initial' that is too small (evaluating 'new WebAssembly.Instance(module, instanceObj)')");357 testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19, maximum: 25}) } }, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`); 358 testMemImportError({imp: { memory: new WebAssembly.Memory({initial: 19}) } }, `Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size`); 359 359 360 360 // This should not throw. -
trunk/Source/JavaScriptCore/ChangeLog
r214544 r214547 1 2017-03-29 JF Bastien <jfbastien@apple.com> 2 3 WebAssembly: add shell-only Memory mode helper 4 https://bugs.webkit.org/show_bug.cgi?id=170227 5 6 Reviewed by Mark Lam. 7 8 * jsc.cpp: 9 (GlobalObject::finishCreation): 10 (functionWebAssemblyMemoryMode): 11 * wasm/WasmMemory.h: 12 * wasm/js/JSWebAssemblyInstance.h: 13 * wasm/js/JSWebAssemblyMemory.h: 14 1 15 2017-03-29 Keith Miller <keith_miller@apple.com> 2 16 -
trunk/Source/JavaScriptCore/jsc.cpp
r214504 r214547 58 58 #include "JSTypedArrays.h" 59 59 #include "JSWebAssemblyCallee.h" 60 #include "JSWebAssemblyInstance.h" 61 #include "JSWebAssemblyMemory.h" 60 62 #include "LLIntData.h" 61 63 #include "LLIntThunks.h" … … 1085 1087 #if ENABLE(WEBASSEMBLY) 1086 1088 static EncodedJSValue JSC_HOST_CALL functionTestWasmModuleFunctions(ExecState*); 1089 static EncodedJSValue JSC_HOST_CALL functionWebAssemblyMemoryMode(ExecState*); 1087 1090 #endif 1088 1091 … … 1359 1362 #if ENABLE(WEBASSEMBLY) 1360 1363 addFunction(vm, "testWasmModuleFunctions", functionTestWasmModuleFunctions, 0); 1364 addFunction(vm, "WebAssemblyMemoryMode", functionWebAssemblyMemoryMode, 1); 1361 1365 #endif 1362 1366 … … 3247 3251 } 3248 3252 3253 static 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 3249 3271 #endif // ENABLE(WEBASSEBLY) 3250 3272 -
trunk/Source/JavaScriptCore/wasm/WasmMemory.h
r214504 r214547 52 52 }; 53 53 static constexpr size_t NumberOfMemoryModes = static_cast<size_t>(MemoryMode::NumberOfMemoryModes); 54 const char* makeString(MemoryMode);54 JS_EXPORT_PRIVATE const char* makeString(MemoryMode); 55 55 56 56 class Memory : public RefCounted<Memory> { -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
r214504 r214547 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 52 52 static Structure* createStructure(VM&, JSGlobalObject*, JSValue); 53 53 54 DECLARE_ INFO;54 DECLARE_EXPORT_INFO; 55 55 56 56 JSWebAssemblyCodeBlock* codeBlock() const { return m_codeBlock.get(); } -
trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h
r213386 r214547 45 45 static Structure* createStructure(VM&, JSGlobalObject*, JSValue); 46 46 47 DECLARE_ INFO;47 DECLARE_EXPORT_INFO; 48 48 49 49 Wasm::Memory& memory() { return m_memory.get(); }
Note: See TracChangeset
for help on using the changeset viewer.