Changeset 214438 in webkit


Ignore:
Timestamp:
Mar 27, 2017 4:24:31 PM (7 years ago)
Author:
jfbastien@apple.com
Message:

WebAssembly: misc memory testing
https://bugs.webkit.org/show_bug.cgi?id=170137

Reviewed by Keith Miller.

JSTests:

  • wasm/assert.js: handle newlines in code we print out, avoid regex
  • wasm/function-tests/memory-import-and-grow.js: Added.

(const.instantiate):
(const.test):

  • wasm/function-tests/memory-section-and-import.js: Added.

(const.instantiate):

Source/JavaScriptCore:

  • wasm/js/WebAssemblyInstanceConstructor.cpp:

(JSC::WebAssemblyInstanceConstructor::createInstance): improve error messages

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r214345 r214438  
     12017-03-27  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly: misc memory testing
     4        https://bugs.webkit.org/show_bug.cgi?id=170137
     5
     6        Reviewed by Keith Miller.
     7
     8        * wasm/assert.js: handle newlines in code we print out, avoid regex
     9        * wasm/function-tests/memory-import-and-grow.js: Added.
     10        (const.instantiate):
     11        (const.test):
     12        * wasm/function-tests/memory-section-and-import.js: Added.
     13        (const.instantiate):
     14
    1152017-03-23  Yusuke Suzuki  <utatane.tea@gmail.com>
    216
  • trunk/JSTests/wasm/assert.js

    r213465 r214438  
    112112};
    113113
    114 // Ignore source information at the end of the error message if the expected message didn't specify that information. Sometimes it changes, or it's tricky to get just right.
    115 const _sourceRe = new RegExp(/( \(evaluating '.*'\))|( \(In .*\))/);
    116 
    117114const _throws = (func, type, message, ...args) => {
    118115    try {
     
    122119            if (e.message === message)
    123120                return e;
    124             const cleanMessage = e.message.replace(_sourceRe, '');
    125             if (cleanMessage === message)
    126                 return e;
     121            // Ignore source information at the end of the error message if the
     122            // expected message didn't specify that information. Sometimes it
     123            // changes, or it's tricky to get just right.
     124            const evaluatingIndex = e.message.indexOf(" (evaluating '");
     125            if (evaluatingIndex !== -1) {
     126                const cleanMessage = e.message.substring(0, evaluatingIndex);
     127                if (cleanMessage === message)
     128                    return e;
     129            }
     130            return e;
    127131        }
    128132        _fail(`Expected to throw a ${type.name} with message "${message}", got ${e.name} with message "${e.message}"`);
  • trunk/Source/JavaScriptCore/ChangeLog

    r214416 r214438  
     12017-03-27  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly: misc memory testing
     4        https://bugs.webkit.org/show_bug.cgi?id=170137
     5
     6        Reviewed by Keith Miller.
     7
     8        * wasm/js/WebAssemblyInstanceConstructor.cpp:
     9        (JSC::WebAssemblyInstanceConstructor::createInstance): improve error messages
     10
    1112017-03-27  Michael Saboff  <msaboff@apple.com>
    212
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp

    r214261 r214438  
    169169                return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Table import is not an instance of WebAssembly.Table")));
    170170
    171             uint32_t expectedInitial = moduleInformation.tableInformation.initial();
    172             uint32_t actualInitial = table->size();
    173             if (actualInitial < expectedInitial)
     171            uint32_t declaredInitial = moduleInformation.tableInformation.initial();
     172            uint32_t importedInitial = table->size();
     173            if (importedInitial < declaredInitial)
    174174                return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Table import provided an 'initial' that is too small")));
    175175
    176             if (std::optional<uint32_t> expectedMaximum = moduleInformation.tableInformation.maximum()) {
    177                 std::optional<uint32_t> actualMaximum = table->maximum();
    178                 if (!actualMaximum)
     176            if (std::optional<uint32_t> declaredMaximum = moduleInformation.tableInformation.maximum()) {
     177                std::optional<uint32_t> importedMaximum = table->maximum();
     178                if (!importedMaximum)
    179179                    return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Table import does not have a 'maximum' but the module requires that it does")));
    180                 if (*actualMaximum > *expectedMaximum)
     180                if (*importedMaximum > *declaredMaximum)
    181181                    return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Imported Table's 'maximum' is larger than the module's expected 'maximum'")));
    182182            }
     
    197197                return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory import is not an instance of WebAssembly.Memory")));
    198198
    199             Wasm::PageCount expectedInitial = moduleInformation.memory.initial();
    200             Wasm::PageCount actualInitial = memory->memory().initial();
    201             if (actualInitial < expectedInitial)
    202                 return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory import provided an 'initial' that is too small")));
    203 
    204             if (Wasm::PageCount expectedMaximum = moduleInformation.memory.maximum()) {
    205                 Wasm::PageCount actualMaximum = memory->memory().maximum();
    206                 if (!actualMaximum)
     199            Wasm::PageCount declaredInitial = moduleInformation.memory.initial();
     200            Wasm::PageCount importedInitial = memory->memory().initial();
     201            if (importedInitial < declaredInitial)
     202                return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory import provided an 'initial' that is smaller than the module's declared 'initial' import memory size")));
     203
     204            if (Wasm::PageCount declaredMaximum = moduleInformation.memory.maximum()) {
     205                Wasm::PageCount importedMaximum = memory->memory().maximum();
     206                if (!importedMaximum)
    207207                    return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory import did not have a 'maximum' but the module requires that it does")));
    208208
    209                 if (actualMaximum > expectedMaximum)
    210                     return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory imports 'maximum' is larger than the module's expected 'maximum'")));
     209                if (importedMaximum > declaredMaximum)
     210                    return exception(createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("Memory import provided a 'maximum' that is larger than the module's declared 'maximum' import memory size")));
    211211            }
    212212
Note: See TracChangeset for help on using the changeset viewer.