| Differences between
and this patch
- a/JSTests/ChangeLog +12 lines
Lines 1-3 a/JSTests/ChangeLog_sec1
1
2017-05-08  JF Bastien  <jfbastien@apple.com>
2
3
        WebAssembly: support name section
4
        https://bugs.webkit.org/show_bug.cgi?id=171263
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * wasm/function-tests/nameSection.js: Added.
9
        (const.compile):
10
        * wasm/function-tests/nameSection.wasm: Added.
11
        * wasm/function-tests/stack-trace.js: Update format
12
1
2017-05-06  Oleksandr Skachkov  <gskachkov@gmail.com>
13
2017-05-06  Oleksandr Skachkov  <gskachkov@gmail.com>
2
14
3
        [ES6] Arrow function. Issue in access to this after eval('super()') within constructor
15
        [ES6] Arrow function. Issue in access to this after eval('super()') within constructor
- a/JSTests/wasm/function-tests/nameSection.js +72 lines
Line 0 a/JSTests/wasm/function-tests/nameSection.js_sec1
1
import * as assert from '../assert.js'
2
3
/*
4
This test loads a WebAssembly file compiled by Emscripten with:
5
  ./emsdk-portable/emscripten/incoming/em++ ./nameSection.cc -O2 -g4 -s WASM=1 -o nameSection.js -s EXPORTED_FUNCTIONS="['_parrot']"
6
7
From the following C++ source file:
8
  extern "C" {
9
  int silly(int);
10
  __attribute__((noinline)) int eggs(int i) { return silly(i); }
11
  __attribute__((noinline)) int bacon(int i) { return eggs(i); }
12
  __attribute__((noinline)) int spam(int i) { return bacon(i); }
13
  __attribute__((noinline)) int parrot(int i) { return spam(i); }
14
  }
15
*/
16
17
const verbose = false;
18
const wasmFile = 'nameSection.wasm';
19
20
const compile = (location, importObject = {}) => {
21
    if (verbose)
22
        print(`Processing ${location}`);
23
    let buf = typeof readbuffer !== "undefined"? readbuffer(location) : read(location, 'binary');
24
    if (verbose)
25
        print(`  Size: ${buf.byteLength}`);
26
27
    let t0 = Date.now();
28
    let module = new WebAssembly.Module(buf);
29
    let t1 = Date.now();
30
    if (verbose)
31
        print(`new WebAssembly.Module(buf) took ${t1-t0} ms.`);
32
33
    if (verbose)
34
        print(`Creating fake import object with ${WebAssembly.Module.imports(module).length} imports`);
35
    for (let imp of WebAssembly.Module.imports(module)) {
36
        if (typeof importObject[imp.module] === "undefined")
37
            importObject[imp.module] = {};
38
        if (typeof importObject[imp.module][imp.name] === "undefined") {
39
            switch (imp.kind) {
40
            case "function": importObject[imp.module][imp.name] = () => {}; break;
41
            case "table": importObject[imp.module][imp.name] = new WebAssembly.Table({ initial: 6, maximum: 6, element: "anyfunc" }); break;
42
            case "memory": importObject[imp.module][imp.name] = new WebAssembly.Memory({ initial: 16777216 / (64 * 1024), maximum: 16777216 / (64 * 1024) }); break;
43
            case "global": importObject[imp.module][imp.name] = 0; break;
44
            }
45
        }
46
47
    }
48
49
    let t2 = Date.now();
50
    let instance = new WebAssembly.Instance(module, importObject);
51
    let t3 = Date.now();
52
    if (verbose)
53
        print(`new WebAssembly.Module(buf) took ${t3-t2} ms.`);
54
55
    return instance;
56
};
57
58
let stacktrace;
59
const importObject = { env: { _silly: i => { stacktrace = (new Error).stack; return i + 42; } } };
60
const instance = compile(wasmFile, importObject);
61
const result = instance.exports._parrot(1);
62
assert.eq(result, 1 + 42);
63
64
assert.truthy(stacktrace);
65
stacktrace = stacktrace.split("\n");
66
assert.falsy(stacktrace[0].indexOf("_silly") === -1);
67
assert.eq(stacktrace[1], "wasm function@[wasm code]"); // the wasm->js stub
68
assert.eq(stacktrace[2], "wasm function: _eggs@[wasm code]");
69
assert.eq(stacktrace[3], "wasm function: _bacon@[wasm code]");
70
assert.eq(stacktrace[4], "wasm function: _spam@[wasm code]");
71
assert.eq(stacktrace[5], "wasm function: _parrot@[wasm code]");
72
assert.eq(stacktrace[6], "wasm function@[wasm code]"); // wasm entry
- a/JSTests/wasm/function-tests/stack-trace.js -4 / +4 lines
Lines 47-56 for (let i = 0; i < 10000; ++i) { a/JSTests/wasm/function-tests/stack-trace.js_sec1
47
    stacktrace = stacktrace.split("\n");
47
    stacktrace = stacktrace.split("\n");
48
    assert(stacktrace[0].indexOf("imp") !== -1); // the arrow function import named "imp".
48
    assert(stacktrace[0].indexOf("imp") !== -1); // the arrow function import named "imp".
49
    assert(stacktrace[1] === "wasm function@[wasm code]"); // the wasm->js stub
49
    assert(stacktrace[1] === "wasm function@[wasm code]"); // the wasm->js stub
50
    assert(stacktrace[2] === "wasm function index: 4@[wasm code]");
50
    assert(stacktrace[2] === "wasm function: 4@[wasm code]");
51
    assert(stacktrace[3] === "wasm function index: 2@[wasm code]");
51
    assert(stacktrace[3] === "wasm function: 2@[wasm code]");
52
    assert(stacktrace[4] === "wasm function index: 3@[wasm code]");
52
    assert(stacktrace[4] === "wasm function: 3@[wasm code]");
53
    assert(stacktrace[5] === "wasm function index: 1@[wasm code]");
53
    assert(stacktrace[5] === "wasm function: 1@[wasm code]");
54
    assert(stacktrace[6] === "wasm function@[wasm code]"); // wasm entry
54
    assert(stacktrace[6] === "wasm function@[wasm code]"); // wasm entry
55
55
56
    stacktrace = null;
56
    stacktrace = null;
- a/Source/JavaScriptCore/CMakeLists.txt -1 / +3 lines
Lines 941-946 set(JavaScriptCore_SOURCES a/Source/JavaScriptCore/CMakeLists.txt_sec1
941
    tools/SigillCrashAnalyzer.cpp
941
    tools/SigillCrashAnalyzer.cpp
942
    tools/VMInspector.cpp
942
    tools/VMInspector.cpp
943
943
944
944
    wasm/JSWebAssembly.cpp
945
    wasm/JSWebAssembly.cpp
945
    wasm/WasmB3IRGenerator.cpp
946
    wasm/WasmB3IRGenerator.cpp
946
    wasm/WasmBBQPlan.cpp
947
    wasm/WasmBBQPlan.cpp
Lines 951-962 set(JavaScriptCore_SOURCES a/Source/JavaScriptCore/CMakeLists.txt_sec2
951
    wasm/WasmContext.cpp
952
    wasm/WasmContext.cpp
952
    wasm/WasmFaultSignalHandler.cpp
953
    wasm/WasmFaultSignalHandler.cpp
953
    wasm/WasmFormat.cpp
954
    wasm/WasmFormat.cpp
955
    wasm/WasmIndexOrName.cpp
954
    wasm/WasmMachineThreads.cpp
956
    wasm/WasmMachineThreads.cpp
955
    wasm/WasmMemory.cpp
957
    wasm/WasmMemory.cpp
956
    wasm/WasmMemoryInformation.cpp
958
    wasm/WasmMemoryInformation.cpp
957
    wasm/WasmModule.cpp
959
    wasm/WasmModule.cpp
958
    wasm/WasmModuleInformation.cpp
960
    wasm/WasmModuleInformation.cpp
959
    wasm/WasmModuleParser.cpp
961
    wasm/WasmModuleParser.cpp
962
    wasm/WasmNameSectionParser.cpp
960
    wasm/WasmOMGPlan.cpp
963
    wasm/WasmOMGPlan.cpp
961
    wasm/WasmOpcodeOrigin.cpp
964
    wasm/WasmOpcodeOrigin.cpp
962
    wasm/WasmPageCount.cpp
965
    wasm/WasmPageCount.cpp
Lines 965-971 set(JavaScriptCore_SOURCES a/Source/JavaScriptCore/CMakeLists.txt_sec3
965
    wasm/WasmThunks.cpp
968
    wasm/WasmThunks.cpp
966
    wasm/WasmValidate.cpp
969
    wasm/WasmValidate.cpp
967
    wasm/WasmWorklist.cpp
970
    wasm/WasmWorklist.cpp
968
969
    wasm/js/JSWebAssemblyCodeBlock.cpp
971
    wasm/js/JSWebAssemblyCodeBlock.cpp
970
    wasm/js/JSWebAssemblyCompileError.cpp
972
    wasm/js/JSWebAssemblyCompileError.cpp
971
    wasm/js/JSWebAssemblyInstance.cpp
973
    wasm/js/JSWebAssemblyInstance.cpp
- a/Source/JavaScriptCore/ChangeLog +64 lines
Lines 1-3 a/Source/JavaScriptCore/ChangeLog_sec1
1
2017-05-08  JF Bastien  <jfbastien@apple.com>
2
3
        WebAssembly: support name section
4
5
        https://bugs.webkit.org/show_bug.cgi?id=171263
6
7
        Reviewed by NOBODY (OOPS!).
8
9
        The name section is an optional custom section in the WebAssembly
10
        spec. At least when debugging, developers expect to be able to use
11
        this section to obtain intelligible stack traces, otherwise we
12
        just number the wasm functions which is somewhat painful.
13
14
        This patch parses this section, dropping its content eagerly on
15
        error, and if there is a name section then backtraces use their
16
        value instead of numbers. Otherwise we stick to numbers as before.
17
18
        Note that the format of name sections changed in mid-February:
19
          https://github.com/WebAssembly/design/pull/984
20
        And binaryen was only updated in early March:
21
          https://github.com/WebAssembly/binaryen/pull/933
22
23
        * CMakeLists.txt:
24
        * JavaScriptCore.xcodeproj/project.pbxproj:
25
        * interpreter/Interpreter.cpp:
26
        (JSC::GetStackTraceFunctor::operator()):
27
        * interpreter/StackVisitor.cpp:
28
        (JSC::StackVisitor::readNonInlinedFrame):
29
        (JSC::StackVisitor::Frame::functionName):
30
        * interpreter/StackVisitor.h:
31
        (JSC::StackVisitor::Frame::wasmFunctionIndexOrName):
32
        * runtime/StackFrame.cpp:
33
        (JSC::StackFrame::functionName):
34
        * runtime/StackFrame.h:
35
        (JSC::StackFrame::StackFrame):
36
        (JSC::StackFrame::wasm):
37
        * wasm/WasmBBQPlanInlines.h:
38
        (JSC::Wasm::BBQPlan::initializeCallees):
39
        * wasm/WasmCallee.cpp:
40
        (JSC::Wasm::Callee::Callee):
41
        * wasm/WasmCallee.h:
42
        (JSC::Wasm::Callee::create):
43
        (JSC::Wasm::Callee::indexOrName):
44
        * wasm/WasmFormat.cpp:
45
        (JSC::Wasm::makeString):
46
        * wasm/WasmFormat.h:
47
        (JSC::Wasm::isValidExternalKind):
48
        (JSC::Wasm::isValidNameType):
49
        (JSC::Wasm::NameSection::get):
50
        * wasm/WasmIndexOrName.cpp: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp.
51
        (JSC::Wasm::IndexOrName::IndexOrName):
52
        (JSC::Wasm::makeString):
53
        * wasm/WasmIndexOrName.h: Copied from Source/JavaScriptCore/wasm/WasmFormat.cpp.
54
        * wasm/WasmModuleInformation.h:
55
        * wasm/WasmModuleParser.cpp:
56
        * wasm/WasmName.h: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp.
57
        * wasm/WasmNameSectionParser.cpp: Added.
58
        * wasm/WasmNameSectionParser.h: Copied from Source/JavaScriptCore/wasm/WasmCallee.cpp.
59
        (JSC::Wasm::NameSectionParser::NameSectionParser):
60
        * wasm/WasmOMGPlan.cpp:
61
        (JSC::Wasm::OMGPlan::work):
62
        * wasm/WasmParser.h:
63
        (JSC::Wasm::Parser<SuccessType>::consumeUTF8String):
64
1
2017-05-06  Bill Ming  <mbbill@gmail.com>
65
2017-05-06  Bill Ming  <mbbill@gmail.com>
2
66
3
        Fix 32bit Windows build by giving correct parameters to MASM
67
        Fix 32bit Windows build by giving correct parameters to MASM
- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj -5 / +25 lines
Lines 2142-2154 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec1
2142
		AD4937D41DDD27DE0077C807 /* WebAssemblyFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4937CA1DDD27340077C807 /* WebAssemblyFunction.h */; };
2142
		AD4937D41DDD27DE0077C807 /* WebAssemblyFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4937CA1DDD27340077C807 /* WebAssemblyFunction.h */; };
2143
		AD4B1DF91DF244E20071AE32 /* WasmBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */; };
2143
		AD4B1DF91DF244E20071AE32 /* WasmBinding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */; };
2144
		AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4B1DF81DF244D70071AE32 /* WasmBinding.h */; };
2144
		AD4B1DFA1DF244E20071AE32 /* WasmBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4B1DF81DF244D70071AE32 /* WasmBinding.h */; };
2145
		AD5B416F1EBAFB77008EFA43 /* WasmName.h in Headers */ = {isa = PBXBuildFile; fileRef = AD5B416E1EBAFB65008EFA43 /* WasmName.h */; };
2145
		AD7438C01E0457A400FD0C2A /* WasmSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7438BF1E04579200FD0C2A /* WasmSignature.h */; settings = {ATTRIBUTES = (Private, ); }; };
2146
		AD7438C01E0457A400FD0C2A /* WasmSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7438BF1E04579200FD0C2A /* WasmSignature.h */; settings = {ATTRIBUTES = (Private, ); }; };
2146
		AD7438C11E0457AA00FD0C2A /* WasmSignature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */; };
2147
		AD7438C11E0457AA00FD0C2A /* WasmSignature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */; };
2147
		AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
2148
		AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
2149
		AD8FF3971EB5BDA80087FF82 /* WasmIndexOrName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */; };
2150
		AD8FF3981EB5BDB20087FF82 /* WasmIndexOrName.h in Headers */ = {isa = PBXBuildFile; fileRef = AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */; };
2148
		AD9E852F1E8A0C7C008DE39E /* JSWebAssemblyCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
2151
		AD9E852F1E8A0C7C008DE39E /* JSWebAssemblyCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
2149
		ADB6F67D1E15D7600082F384 /* WasmPageCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */; };
2152
		ADB6F67D1E15D7600082F384 /* WasmPageCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */; };
2150
		ADBC54D41DF8EA2B005BF738 /* WebAssemblyToJSCallee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */; };
2153
		ADBC54D41DF8EA2B005BF738 /* WebAssemblyToJSCallee.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */; };
2151
		ADBC54D51DF8EA2B005BF738 /* WebAssemblyToJSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */; };
2154
		ADBC54D51DF8EA2B005BF738 /* WebAssemblyToJSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */; };
2155
		ADD8FA451EB3078E00DF542F /* WasmNameSectionParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */; };
2156
		ADD8FA461EB3079700DF542F /* WasmNameSectionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */; };
2152
		ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
2157
		ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
2153
		ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
2158
		ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
2154
		ADE802981E08F1DE0058DE78 /* JSWebAssemblyLinkError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADE802931E08F1C90058DE78 /* JSWebAssemblyLinkError.cpp */; };
2159
		ADE802981E08F1DE0058DE78 /* JSWebAssemblyLinkError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ADE802931E08F1C90058DE78 /* JSWebAssemblyLinkError.cpp */; };
Lines 4766-4778 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec2
4766
		AD4937CA1DDD27340077C807 /* WebAssemblyFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyFunction.h; path = js/WebAssemblyFunction.h; sourceTree = "<group>"; };
4771
		AD4937CA1DDD27340077C807 /* WebAssemblyFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyFunction.h; path = js/WebAssemblyFunction.h; sourceTree = "<group>"; };
4767
		AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmBinding.cpp; sourceTree = "<group>"; };
4772
		AD4B1DF71DF244D70071AE32 /* WasmBinding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmBinding.cpp; sourceTree = "<group>"; };
4768
		AD4B1DF81DF244D70071AE32 /* WasmBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmBinding.h; sourceTree = "<group>"; };
4773
		AD4B1DF81DF244D70071AE32 /* WasmBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmBinding.h; sourceTree = "<group>"; };
4774
		AD5B416E1EBAFB65008EFA43 /* WasmName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmName.h; sourceTree = "<group>"; };
4769
		AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmSignature.cpp; sourceTree = "<group>"; };
4775
		AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmSignature.cpp; sourceTree = "<group>"; };
4770
		AD7438BF1E04579200FD0C2A /* WasmSignature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSignature.h; sourceTree = "<group>"; };
4776
		AD7438BF1E04579200FD0C2A /* WasmSignature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSignature.h; sourceTree = "<group>"; };
4771
		AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
4777
		AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
4778
		AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmIndexOrName.h; sourceTree = "<group>"; };
4779
		AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmIndexOrName.cpp; sourceTree = "<group>"; };
4772
		AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyCodeBlock.h; path = js/JSWebAssemblyCodeBlock.h; sourceTree = "<group>"; };
4780
		AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyCodeBlock.h; path = js/JSWebAssemblyCodeBlock.h; sourceTree = "<group>"; };
4773
		ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPageCount.cpp; sourceTree = "<group>"; };
4781
		ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPageCount.cpp; sourceTree = "<group>"; };
4774
		ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyToJSCallee.cpp; path = js/WebAssemblyToJSCallee.cpp; sourceTree = "<group>"; };
4782
		ADBC54D21DF8EA00005BF738 /* WebAssemblyToJSCallee.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyToJSCallee.cpp; path = js/WebAssemblyToJSCallee.cpp; sourceTree = "<group>"; };
4775
		ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyToJSCallee.h; path = js/WebAssemblyToJSCallee.h; sourceTree = "<group>"; };
4783
		ADBC54D31DF8EA00005BF738 /* WebAssemblyToJSCallee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyToJSCallee.h; path = js/WebAssemblyToJSCallee.h; sourceTree = "<group>"; };
4784
		ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmNameSectionParser.h; sourceTree = "<group>"; };
4785
		ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmNameSectionParser.cpp; sourceTree = "<group>"; };
4776
		ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
4786
		ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
4777
		ADE802931E08F1C90058DE78 /* JSWebAssemblyLinkError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyLinkError.cpp; path = js/JSWebAssemblyLinkError.cpp; sourceTree = "<group>"; };
4787
		ADE802931E08F1C90058DE78 /* JSWebAssemblyLinkError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyLinkError.cpp; path = js/JSWebAssemblyLinkError.cpp; sourceTree = "<group>"; };
4778
		ADE802941E08F1C90058DE78 /* JSWebAssemblyLinkError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyLinkError.h; path = js/JSWebAssemblyLinkError.h; sourceTree = "<group>"; };
4788
		ADE802941E08F1C90058DE78 /* JSWebAssemblyLinkError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyLinkError.h; path = js/JSWebAssemblyLinkError.h; sourceTree = "<group>"; };
Lines 6400-6427 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec3
6400
				AD412B311E7B2E8A008AF157 /* WasmContext.cpp */,
6410
				AD412B311E7B2E8A008AF157 /* WasmContext.cpp */,
6401
				AD412B321E7B2E8A008AF157 /* WasmContext.h */,
6411
				AD412B321E7B2E8A008AF157 /* WasmContext.h */,
6402
				79DAE2791E03C82200B526AA /* WasmExceptionType.h */,
6412
				79DAE2791E03C82200B526AA /* WasmExceptionType.h */,
6413
				5381B9361E60E9660090F794 /* WasmFaultSignalHandler.cpp */,
6414
				5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */,
6403
				AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */,
6415
				AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */,
6404
				7BC547D21B69599B00959B58 /* WasmFormat.h */,
6416
				7BC547D21B69599B00959B58 /* WasmFormat.h */,
6405
				53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
6417
				53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
6418
				AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */,
6419
				AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */,
6406
				53E9E0A91EAE83DE00FEE251 /* WasmMachineThreads.cpp */,
6420
				53E9E0A91EAE83DE00FEE251 /* WasmMachineThreads.cpp */,
6407
				53E9E0AA1EAE83DE00FEE251 /* WasmMachineThreads.h */,
6421
				53E9E0AA1EAE83DE00FEE251 /* WasmMachineThreads.h */,
6408
				790081361E95A8EC0052D7CD /* WasmModule.cpp */,
6409
				790081371E95A8EC0052D7CD /* WasmModule.h */,
6410
				535557151D9DFA32006D583B /* WasmMemory.cpp */,
6422
				535557151D9DFA32006D583B /* WasmMemory.cpp */,
6411
				535557131D9D9EA5006D583B /* WasmMemory.h */,
6423
				535557131D9D9EA5006D583B /* WasmMemory.h */,
6412
				79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */,
6424
				79B759711DFA4C600052174C /* WasmMemoryInformation.cpp */,
6413
				79B759721DFA4C600052174C /* WasmMemoryInformation.h */,
6425
				79B759721DFA4C600052174C /* WasmMemoryInformation.h */,
6426
				790081361E95A8EC0052D7CD /* WasmModule.cpp */,
6427
				790081371E95A8EC0052D7CD /* WasmModule.h */,
6414
				53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */,
6428
				53E777E11E92E265007CBEC4 /* WasmModuleInformation.cpp */,
6415
				53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */,
6429
				53E777E21E92E265007CBEC4 /* WasmModuleInformation.h */,
6416
				53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */,
6430
				53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */,
6417
				53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */,
6431
				53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */,
6432
				AD5B416E1EBAFB65008EFA43 /* WasmName.h */,
6433
				ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */,
6434
				ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */,
6418
				5311BD481EA581E500525281 /* WasmOMGPlan.cpp */,
6435
				5311BD481EA581E500525281 /* WasmOMGPlan.cpp */,
6419
				5311BD491EA581E500525281 /* WasmOMGPlan.h */,
6436
				5311BD491EA581E500525281 /* WasmOMGPlan.h */,
6420
				ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */,
6421
				5381B9361E60E9660090F794 /* WasmFaultSignalHandler.cpp */,
6422
				5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */,
6423
				53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */,
6437
				53C6FEF01E8AFE0C00B18425 /* WasmOpcodeOrigin.cpp */,
6424
				53C6FEEE1E8ADFA900B18425 /* WasmOpcodeOrigin.h */,
6438
				53C6FEEE1E8ADFA900B18425 /* WasmOpcodeOrigin.h */,
6439
				ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */,
6425
				79B759731DFA4C600052174C /* WasmPageCount.h */,
6440
				79B759731DFA4C600052174C /* WasmPageCount.h */,
6426
				53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
6441
				53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
6427
				531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */,
6442
				531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */,
Lines 8206-8211 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec4
8206
				0F6183311C45BF070072450B /* AirLowerMacros.h in Headers */,
8221
				0F6183311C45BF070072450B /* AirLowerMacros.h in Headers */,
8207
				0F40E4A71C497F7400A577FA /* AirOpcode.h in Headers */,
8222
				0F40E4A71C497F7400A577FA /* AirOpcode.h in Headers */,
8208
				0F40E4A81C497F7400A577FA /* AirOpcodeGenerated.h in Headers */,
8223
				0F40E4A81C497F7400A577FA /* AirOpcodeGenerated.h in Headers */,
8224
				AD8FF3981EB5BDB20087FF82 /* WasmIndexOrName.h in Headers */,
8209
				0F40E4A91C497F7400A577FA /* AirOpcodeUtils.h in Headers */,
8225
				0F40E4A91C497F7400A577FA /* AirOpcodeUtils.h in Headers */,
8210
				0FB387901BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h in Headers */,
8226
				0FB387901BFBC44D00E3AB1E /* AirOptimizeBlockOrder.h in Headers */,
8211
				0F9CABC91DB54A7A0008E83B /* AirPadInterference.h in Headers */,
8227
				0F9CABC91DB54A7A0008E83B /* AirPadInterference.h in Headers */,
Lines 8324-8329 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec5
8324
				0FEC85241BDACDAC0080FF74 /* B3Origin.h in Headers */,
8340
				0FEC85241BDACDAC0080FF74 /* B3Origin.h in Headers */,
8325
				0F4C91661C29F4F2004341A6 /* B3OriginDump.h in Headers */,
8341
				0F4C91661C29F4F2004341A6 /* B3OriginDump.h in Headers */,
8326
				0FEC85261BDACDAC0080FF74 /* B3PatchpointSpecial.h in Headers */,
8342
				0FEC85261BDACDAC0080FF74 /* B3PatchpointSpecial.h in Headers */,
8343
				ADD8FA461EB3079700DF542F /* WasmNameSectionParser.h in Headers */,
8327
				0FEC85281BDACDAC0080FF74 /* B3PatchpointValue.h in Headers */,
8344
				0FEC85281BDACDAC0080FF74 /* B3PatchpointValue.h in Headers */,
8328
				799EF7C41C56ED96002B0534 /* B3PCToOriginMap.h in Headers */,
8345
				799EF7C41C56ED96002B0534 /* B3PCToOriginMap.h in Headers */,
8329
				0FEC852A1BDACDAC0080FF74 /* B3PhaseScope.h in Headers */,
8346
				0FEC852A1BDACDAC0080FF74 /* B3PhaseScope.h in Headers */,
Lines 8643-8648 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec6
8643
				86EC9DD11328DF82002B2AD7 /* DFGRegisterBank.h in Headers */,
8660
				86EC9DD11328DF82002B2AD7 /* DFGRegisterBank.h in Headers */,
8644
				79FC8A081E32E9F000D88F0E /* DFGRegisteredStructure.h in Headers */,
8661
				79FC8A081E32E9F000D88F0E /* DFGRegisteredStructure.h in Headers */,
8645
				7980C16D1E3A940E00B71615 /* DFGRegisteredStructureSet.h in Headers */,
8662
				7980C16D1E3A940E00B71615 /* DFGRegisteredStructureSet.h in Headers */,
8663
				AD5B416F1EBAFB77008EFA43 /* WasmName.h in Headers */,
8646
				0F2FCCFC18A60070001A27F8 /* DFGSafepoint.h in Headers */,
8664
				0F2FCCFC18A60070001A27F8 /* DFGSafepoint.h in Headers */,
8647
				A77A424317A0BBFD00A8DB81 /* DFGSafeToExecute.h in Headers */,
8665
				A77A424317A0BBFD00A8DB81 /* DFGSafeToExecute.h in Headers */,
8648
				A741017F179DAF80002EB8BA /* DFGSaneStringGetByValSlowPathGenerator.h in Headers */,
8666
				A741017F179DAF80002EB8BA /* DFGSaneStringGetByValSlowPathGenerator.h in Headers */,
Lines 10969-10974 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec7
10969
				0F6C73501AC9F99F00BE1682 /* VariableWriteFireDetail.cpp in Sources */,
10987
				0F6C73501AC9F99F00BE1682 /* VariableWriteFireDetail.cpp in Sources */,
10970
				0FE0502C1AA9095600D33B33 /* VarOffset.cpp in Sources */,
10988
				0FE0502C1AA9095600D33B33 /* VarOffset.cpp in Sources */,
10971
				0F20C2591A8013AB00DA3229 /* VirtualRegister.cpp in Sources */,
10989
				0F20C2591A8013AB00DA3229 /* VirtualRegister.cpp in Sources */,
10990
				AD8FF3971EB5BDA80087FF82 /* WasmIndexOrName.cpp in Sources */,
10972
				0F952AA21DF7860D00E06FBD /* VisitRaceKey.cpp in Sources */,
10991
				0F952AA21DF7860D00E06FBD /* VisitRaceKey.cpp in Sources */,
10973
				E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
10992
				E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
10974
				FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
10993
				FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
Lines 11025-11030 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec8
11025
				86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
11044
				86704B8612DBA33700A9FE7B /* YarrJIT.cpp in Sources */,
11026
				86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
11045
				86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
11027
				86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
11046
				86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
11047
				ADD8FA451EB3078E00DF542F /* WasmNameSectionParser.cpp in Sources */,
11028
				321D9E4CFB67423A97F191A7 /* ModuleNamespaceAccessCase.cpp in Sources */,
11048
				321D9E4CFB67423A97F191A7 /* ModuleNamespaceAccessCase.cpp in Sources */,
11029
			);
11049
			);
11030
			runOnlyForDeploymentPostprocessing = 0;
11050
			runOnlyForDeploymentPostprocessing = 0;
- a/Source/JavaScriptCore/interpreter/Interpreter.cpp -2 / +1 lines
Lines 480-487 public: a/Source/JavaScriptCore/interpreter/Interpreter.cpp_sec1
480
480
481
        if (m_remainingCapacityForFrameCapture) {
481
        if (m_remainingCapacityForFrameCapture) {
482
            if (visitor->isWasmFrame()) {
482
            if (visitor->isWasmFrame()) {
483
                std::optional<unsigned> wasmFunctionIndex = visitor->wasmFunctionIndex();
483
                m_results.append(StackFrame::wasm(visitor->wasmFunctionIndexOrName()));
484
                m_results.append(StackFrame::wasm(wasmFunctionIndex ? *wasmFunctionIndex : StackFrame::invalidWasmIndex));
485
            } else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
484
            } else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
486
                m_results.append(
485
                m_results.append(
487
                    StackFrame(m_vm, visitor->callee().asCell(), visitor->codeBlock(), visitor->bytecodeOffset()));
486
                    StackFrame(m_vm, visitor->callee().asCell(), visitor->codeBlock(), visitor->bytecodeOffset()));
- a/Source/JavaScriptCore/interpreter/StackVisitor.cpp -4 / +5 lines
Lines 32-37 a/Source/JavaScriptCore/interpreter/StackVisitor.cpp_sec1
32
#include "Interpreter.h"
32
#include "Interpreter.h"
33
#include "JSCInlines.h"
33
#include "JSCInlines.h"
34
#include "WasmCallee.h"
34
#include "WasmCallee.h"
35
#include "WasmIndexOrName.h"
35
#include <wtf/text/StringBuilder.h>
36
#include <wtf/text/StringBuilder.h>
36
37
37
namespace JSC {
38
namespace JSC {
Lines 166-172 void StackVisitor::readNonInlinedFrame(CallFrame* callFrame, CodeOrigin* codeOri a/Source/JavaScriptCore/interpreter/StackVisitor.cpp_sec2
166
#if ENABLE(WEBASSEMBLY)
167
#if ENABLE(WEBASSEMBLY)
167
        CalleeBits bits = callFrame->callee();
168
        CalleeBits bits = callFrame->callee();
168
        if (bits.isWasm())
169
        if (bits.isWasm())
169
            m_frame.m_wasmFunctionIndex = bits.asWasmCallee()->index();
170
            m_frame.m_wasmFunctionIndexOrName = bits.asWasmCallee()->indexOrName();
170
#endif
171
#endif
171
    } else {
172
    } else {
172
        m_frame.m_codeBlock = callFrame->codeBlock();
173
        m_frame.m_codeBlock = callFrame->codeBlock();
Lines 283-292 String StackVisitor::Frame::functionName() const a/Source/JavaScriptCore/interpreter/StackVisitor.cpp_sec3
283
284
284
    switch (codeType()) {
285
    switch (codeType()) {
285
    case CodeType::Wasm:
286
    case CodeType::Wasm:
286
        if (m_wasmFunctionIndex)
287
        if (m_wasmFunctionIndexOrName.isEmpty())
287
            traceLine = makeString("wasm function index: ", String::number(*m_wasmFunctionIndex));
288
            traceLine = makeString("wasm function");
288
        else
289
        else
289
            traceLine = ASCIILiteral("wasm function");
290
            traceLine = makeString("wasm function: ", makeString(m_wasmFunctionIndexOrName));
290
        break;
291
        break;
291
    case CodeType::Eval:
292
    case CodeType::Eval:
292
        traceLine = ASCIILiteral("eval code");
293
        traceLine = ASCIILiteral("eval code");
- a/Source/JavaScriptCore/interpreter/StackVisitor.h -3 / +4 lines
Lines 27-32 a/Source/JavaScriptCore/interpreter/StackVisitor.h_sec1
27
27
28
#include "CalleeBits.h"
28
#include "CalleeBits.h"
29
#include "VMEntryRecord.h"
29
#include "VMEntryRecord.h"
30
#include "WasmIndexOrName.h"
30
#include <functional>
31
#include <functional>
31
#include <wtf/Indenter.h>
32
#include <wtf/Indenter.h>
32
#include <wtf/text/WTFString.h>
33
#include <wtf/text/WTFString.h>
Lines 77-86 public: a/Source/JavaScriptCore/interpreter/StackVisitor.h_sec2
77
        bool isNativeFrame() const { return !codeBlock() && !isWasmFrame(); }
78
        bool isNativeFrame() const { return !codeBlock() && !isWasmFrame(); }
78
        bool isInlinedFrame() const { return !!inlineCallFrame(); }
79
        bool isInlinedFrame() const { return !!inlineCallFrame(); }
79
        bool isWasmFrame() const;
80
        bool isWasmFrame() const;
80
        std::optional<unsigned> const wasmFunctionIndex()
81
        Wasm::IndexOrName const wasmFunctionIndexOrName()
81
        {
82
        {
82
            ASSERT(isWasmFrame());
83
            ASSERT(isWasmFrame());
83
            return m_wasmFunctionIndex;
84
            return m_wasmFunctionIndexOrName;
84
        }
85
        }
85
86
86
        JS_EXPORT_PRIVATE String functionName() const;
87
        JS_EXPORT_PRIVATE String functionName() const;
Lines 121-127 public: a/Source/JavaScriptCore/interpreter/StackVisitor.h_sec3
121
        size_t m_index;
122
        size_t m_index;
122
        size_t m_argumentCountIncludingThis;
123
        size_t m_argumentCountIncludingThis;
123
        unsigned m_bytecodeOffset;
124
        unsigned m_bytecodeOffset;
124
        std::optional<unsigned> m_wasmFunctionIndex;
125
        Wasm::IndexOrName m_wasmFunctionIndexOrName;
125
        bool m_callerIsVMEntryFrame : 1;
126
        bool m_callerIsVMEntryFrame : 1;
126
        bool m_isWasmFrame : 1;
127
        bool m_isWasmFrame : 1;
127
128
- a/Source/JavaScriptCore/runtime/StackFrame.cpp -3 / +3 lines
Lines 1-5 a/Source/JavaScriptCore/runtime/StackFrame.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 58-66 String StackFrame::sourceURL() const a/Source/JavaScriptCore/runtime/StackFrame.cpp_sec2
58
String StackFrame::functionName(VM& vm) const
58
String StackFrame::functionName(VM& vm) const
59
{
59
{
60
    if (m_isWasmFrame) {
60
    if (m_isWasmFrame) {
61
        if (m_wasmFunctionIndex == invalidWasmIndex)
61
        if (m_wasmFunctionIndexOrName.isEmpty())
62
            return ASCIILiteral("wasm function");
62
            return ASCIILiteral("wasm function");
63
        return makeString("wasm function index: ", String::number(m_wasmFunctionIndex));
63
        return makeString("wasm function: ", makeString(m_wasmFunctionIndexOrName));
64
    }
64
    }
65
65
66
    if (m_codeBlock) {
66
    if (m_codeBlock) {
- a/Source/JavaScriptCore/runtime/StackFrame.h -6 / +8 lines
Lines 1-5 a/Source/JavaScriptCore/runtime/StackFrame.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 26-31 a/Source/JavaScriptCore/runtime/StackFrame.h_sec2
26
#pragma once
26
#pragma once
27
27
28
#include "Strong.h"
28
#include "Strong.h"
29
#include "WasmIndexOrName.h"
29
#include <limits.h>
30
#include <limits.h>
30
31
31
namespace JSC {
32
namespace JSC {
Lines 35-41 class JSObject; a/Source/JavaScriptCore/runtime/StackFrame.h_sec3
35
36
36
class StackFrame {
37
class StackFrame {
37
public:
38
public:
38
    StackFrame() = default;
39
    StackFrame()
40
        : m_bytecodeOffset(UINT_MAX)
41
    { }
39
42
40
    StackFrame(VM& vm, JSCell* callee)
43
    StackFrame(VM& vm, JSCell* callee)
41
        : m_callee(vm, callee)
44
        : m_callee(vm, callee)
Lines 48-59 public: a/Source/JavaScriptCore/runtime/StackFrame.h_sec4
48
        , m_bytecodeOffset(bytecodeOffset)
51
        , m_bytecodeOffset(bytecodeOffset)
49
    { }
52
    { }
50
53
51
    static constexpr unsigned invalidWasmIndex = UINT_MAX;
54
    static StackFrame wasm(Wasm::IndexOrName indexOrName)
52
    static StackFrame wasm(unsigned index)
53
    {
55
    {
54
        StackFrame result;
56
        StackFrame result;
55
        result.m_isWasmFrame = true;
57
        result.m_isWasmFrame = true;
56
        result.m_wasmFunctionIndex = index;
58
        result.m_wasmFunctionIndexOrName = indexOrName;
57
        return result;
59
        return result;
58
    }
60
    }
59
61
Lines 78-84 private: a/Source/JavaScriptCore/runtime/StackFrame.h_sec5
78
    Strong<CodeBlock> m_codeBlock { };
80
    Strong<CodeBlock> m_codeBlock { };
79
    union {
81
    union {
80
        unsigned m_bytecodeOffset;
82
        unsigned m_bytecodeOffset;
81
        unsigned m_wasmFunctionIndex;
83
        Wasm::IndexOrName m_wasmFunctionIndexOrName;
82
    };
84
    };
83
    bool m_isWasmFrame { false };
85
    bool m_isWasmFrame { false };
84
};
86
};
- a/Source/JavaScriptCore/wasm/WasmBBQPlanInlines.h -1 / +2 lines
Lines 43-49 void BBQPlan::initializeCallees(const Functor& callback) a/Source/JavaScriptCore/wasm/WasmBBQPlanInlines.h_sec1
43
        Ref<Wasm::Callee> jsEntrypointCallee = Wasm::Callee::create(WTFMove(function->jsToWasmEntrypoint));
43
        Ref<Wasm::Callee> jsEntrypointCallee = Wasm::Callee::create(WTFMove(function->jsToWasmEntrypoint));
44
        MacroAssembler::repatchPointer(function->jsToWasmCalleeMoveLocation, CalleeBits::boxWasm(jsEntrypointCallee.ptr()));
44
        MacroAssembler::repatchPointer(function->jsToWasmCalleeMoveLocation, CalleeBits::boxWasm(jsEntrypointCallee.ptr()));
45
45
46
        Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->wasmEntrypoint), internalFunctionIndex + m_moduleInformation->importFunctionCount());
46
        size_t functionIndexSpace = internalFunctionIndex + m_moduleInformation->importFunctionCount();
47
        Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->wasmEntrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace));
47
        MacroAssembler::repatchPointer(function->wasmCalleeMoveLocation, CalleeBits::boxWasm(wasmEntrypointCallee.ptr()));
48
        MacroAssembler::repatchPointer(function->wasmCalleeMoveLocation, CalleeBits::boxWasm(wasmEntrypointCallee.ptr()));
48
49
49
        callback(internalFunctionIndex, WTFMove(jsEntrypointCallee), WTFMove(wasmEntrypointCallee));
50
        callback(internalFunctionIndex, WTFMove(jsEntrypointCallee), WTFMove(wasmEntrypointCallee));
- a/Source/JavaScriptCore/wasm/WasmCallee.cpp -2 / +8 lines
Lines 32-40 a/Source/JavaScriptCore/wasm/WasmCallee.cpp_sec1
32
32
33
namespace JSC { namespace Wasm {
33
namespace JSC { namespace Wasm {
34
34
35
Callee::Callee(Entrypoint&& entrypoint, unsigned index)
35
Callee::Callee(Entrypoint&& entrypoint)
36
    : m_entrypoint(WTFMove(entrypoint))
36
    : m_entrypoint(WTFMove(entrypoint))
37
    , m_index(index)
37
{
38
    registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end());
39
}
40
41
Callee::Callee(Entrypoint&& entrypoint, size_t index, const Name* name)
42
    : m_entrypoint(WTFMove(entrypoint))
43
    , m_indexOrName(index, name)
38
{
44
{
39
    registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end());
45
    registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end());
40
}
46
}
- a/Source/JavaScriptCore/wasm/WasmCallee.h -13 / +12 lines
Lines 30-35 a/Source/JavaScriptCore/wasm/WasmCallee.h_sec1
30
#include "B3Compilation.h"
30
#include "B3Compilation.h"
31
#include "RegisterAtOffsetList.h"
31
#include "RegisterAtOffsetList.h"
32
#include "WasmFormat.h"
32
#include "WasmFormat.h"
33
#include "WasmIndexOrName.h"
33
#include <wtf/ThreadSafeRefCounted.h>
34
#include <wtf/ThreadSafeRefCounted.h>
34
35
35
namespace JSC { namespace Wasm {
36
namespace JSC { namespace Wasm {
Lines 37-67 namespace JSC { namespace Wasm { a/Source/JavaScriptCore/wasm/WasmCallee.h_sec2
37
class Callee : public ThreadSafeRefCounted<Callee> {
38
class Callee : public ThreadSafeRefCounted<Callee> {
38
    WTF_MAKE_FAST_ALLOCATED;
39
    WTF_MAKE_FAST_ALLOCATED;
39
public:
40
public:
41
    static Ref<Callee> create(Wasm::Entrypoint&& entrypoint)
42
    {
43
        Callee* callee = new Callee(WTFMove(entrypoint));
44
        return adoptRef(*callee);
45
    }
40
46
41
    // We use this when we're the JS entrypoint, we don't ascribe an index to those.
47
    static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, size_t index, const Name* name)
42
    static constexpr unsigned invalidCalleeIndex = UINT_MAX;
43
44
    static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, unsigned index = invalidCalleeIndex)
45
    {
48
    {
46
        Callee* callee = new Callee(WTFMove(entrypoint), index);
49
        Callee* callee = new Callee(WTFMove(entrypoint), index, name);
47
        return adoptRef(*callee);
50
        return adoptRef(*callee);
48
    }
51
    }
49
52
50
    void* entrypoint() const { return m_entrypoint.compilation->code().executableAddress(); }
53
    void* entrypoint() const { return m_entrypoint.compilation->code().executableAddress(); }
51
54
52
    RegisterAtOffsetList* calleeSaveRegisters() { return &m_entrypoint.calleeSaveRegisters; }
55
    RegisterAtOffsetList* calleeSaveRegisters() { return &m_entrypoint.calleeSaveRegisters; }
53
    std::optional<unsigned> index() const
56
    IndexOrName indexOrName() const { return m_indexOrName; }
54
    {
55
        if (m_index == invalidCalleeIndex)
56
            return std::nullopt;
57
        return m_index;
58
    }
59
57
60
private:
58
private:
61
    JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, unsigned index);
59
    JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&);
60
    JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, size_t, const Name*);
62
61
63
    Wasm::Entrypoint m_entrypoint;
62
    Wasm::Entrypoint m_entrypoint;
64
    unsigned m_index;
63
    IndexOrName m_indexOrName;
65
};
64
};
66
65
67
} } // namespace JSC::Wasm
66
} } // namespace JSC::Wasm
- a/Source/JavaScriptCore/wasm/WasmFormat.cpp -2 / +2 lines
Lines 1-5 a/Source/JavaScriptCore/wasm/WasmFormat.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 55-61 Segment::Ptr Segment::adoptPtr(Segment* segment) a/Source/JavaScriptCore/wasm/WasmFormat.cpp_sec2
55
    return Ptr(segment, &Segment::destroy);
55
    return Ptr(segment, &Segment::destroy);
56
}
56
}
57
57
58
String makeString(const Vector<LChar>& characters)
58
String makeString(const Name& characters)
59
{
59
{
60
    String result = String::fromUTF8(characters);
60
    String result = String::fromUTF8(characters);
61
    ASSERT(result);
61
    ASSERT(result);
- a/Source/JavaScriptCore/wasm/WasmFormat.h -7 / +31 lines
Lines 33-38 a/Source/JavaScriptCore/wasm/WasmFormat.h_sec1
33
#include "MacroAssemblerCodeRef.h"
33
#include "MacroAssemblerCodeRef.h"
34
#include "RegisterAtOffsetList.h"
34
#include "RegisterAtOffsetList.h"
35
#include "WasmMemoryInformation.h"
35
#include "WasmMemoryInformation.h"
36
#include "WasmName.h"
36
#include "WasmOps.h"
37
#include "WasmOps.h"
37
#include "WasmPageCount.h"
38
#include "WasmPageCount.h"
38
#include "WasmSignature.h"
39
#include "WasmSignature.h"
Lines 82-90 static bool isValidExternalKind(Int val) a/Source/JavaScriptCore/wasm/WasmFormat.h_sec2
82
    case static_cast<Int>(ExternalKind::Memory):
83
    case static_cast<Int>(ExternalKind::Memory):
83
    case static_cast<Int>(ExternalKind::Global):
84
    case static_cast<Int>(ExternalKind::Global):
84
        return true;
85
        return true;
85
    default:
86
        return false;
87
    }
86
    }
87
    return false;
88
}
88
}
89
89
90
static_assert(static_cast<int>(ExternalKind::Function) == 0, "Wasm needs Function to have the value 0");
90
static_assert(static_cast<int>(ExternalKind::Function) == 0, "Wasm needs Function to have the value 0");
Lines 105-123 inline const char* makeString(ExternalKind kind) a/Source/JavaScriptCore/wasm/WasmFormat.h_sec3
105
}
105
}
106
106
107
struct Import {
107
struct Import {
108
    const Vector<LChar> module;
108
    const Name module;
109
    const Vector<LChar> field;
109
    const Name field;
110
    ExternalKind kind;
110
    ExternalKind kind;
111
    unsigned kindIndex; // Index in the vector of the corresponding kind.
111
    unsigned kindIndex; // Index in the vector of the corresponding kind.
112
};
112
};
113
113
114
struct Export {
114
struct Export {
115
    const Vector<LChar> field;
115
    const Name field;
116
    ExternalKind kind;
116
    ExternalKind kind;
117
    unsigned kindIndex; // Index in the vector of the corresponding kind.
117
    unsigned kindIndex; // Index in the vector of the corresponding kind.
118
};
118
};
119
119
120
String makeString(const Vector<LChar>& characters);
120
String makeString(const Name& characters);
121
121
122
struct Global {
122
struct Global {
123
    enum Mutability : uint8_t {
123
    enum Mutability : uint8_t {
Lines 231-240 private: a/Source/JavaScriptCore/wasm/WasmFormat.h_sec4
231
};
231
};
232
    
232
    
233
struct CustomSection {
233
struct CustomSection {
234
    Vector<LChar> name;
234
    Name name;
235
    Vector<uint8_t> payload;
235
    Vector<uint8_t> payload;
236
};
236
};
237
237
238
enum class NameType : uint8_t {
239
    Function = 1,
240
    Local = 2,
241
};
242
    
243
template<typename Int>
244
static bool isValidNameType(Int val)
245
{
246
    switch (val) {
247
    case static_cast<Int>(NameType::Function):
248
    case static_cast<Int>(NameType::Local):
249
        return true;
250
    }
251
    return false;
252
}
253
    
254
struct NameSection {
255
    Vector<Name> functionNames;
256
    const Name* get(size_t functionIndexSpace)
257
    {
258
        return functionIndexSpace < functionNames.size() ? &functionNames[functionIndexSpace] : nullptr;
259
    }
260
};
261
238
struct UnlinkedWasmToWasmCall {
262
struct UnlinkedWasmToWasmCall {
239
    CodeLocationNearCall callLocation;
263
    CodeLocationNearCall callLocation;
240
    size_t functionIndexSpace;
264
    size_t functionIndexSpace;
- a/Source/JavaScriptCore/wasm/WasmIndexOrName.cpp +50 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmIndexOrName.cpp_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WasmIndexOrName.h"
28
29
namespace JSC { namespace Wasm {
30
31
IndexOrName::IndexOrName(unsigned index, const Name* name)
32
{
33
    if ((index & allTags) || (bitwise_cast<size_t>(name) & allTags))
34
        *this = IndexOrName();
35
    else if (name)
36
        m_name = name;
37
    else
38
        m_index = indexTag | index;
39
}
40
41
String makeString(const IndexOrName& ion)
42
{
43
    if (ion.isEmpty())
44
        return String();
45
    if (ion.isIndex())
46
        return String::number(ion.m_index & ~IndexOrName::indexTag);
47
    return String(ion.m_name->data(), ion.m_name->size());
48
};
49
50
} } // namespace JSC::Wasm
- a/Source/JavaScriptCore/wasm/WasmIndexOrName.h +58 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmIndexOrName.h_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "WasmName.h"
29
#include <wtf/StdLibExtras.h>
30
#include <wtf/text/WTFString.h>
31
32
namespace JSC { namespace Wasm {
33
34
union IndexOrName {
35
    IndexOrName()
36
        : m_index(emptyTag)
37
    { }
38
    IndexOrName(unsigned index, const Name*);
39
    bool isEmpty() const { return bitwise_cast<size_t>(*this) & emptyTag; }
40
    bool isIndex() const { return bitwise_cast<size_t>(*this) & indexTag; }
41
    bool isName() const { return !(isEmpty() || isName()); }
42
43
    friend String makeString(const IndexOrName&);
44
45
private:
46
    size_t m_index;
47
    const Name* m_name;
48
    static_assert(sizeof(m_index) == sizeof(m_name), "bit-tagging depends on sizes being equal");
49
50
    // Use the top bits as tags. Neither pointers nor the function index space should use them.
51
    static constexpr size_t indexTag = 1ull << 63;
52
    static constexpr size_t emptyTag = 1ull << 62;
53
    static constexpr size_t allTags = indexTag | emptyTag;
54
};
55
56
String makeString(const IndexOrName&);
57
58
} } // namespace JSC::Wasm
- a/Source/JavaScriptCore/wasm/WasmModuleInformation.h -1 / +1 lines
Lines 74-80 struct ModuleInformation : public ThreadSafeRefCounted<ModuleInformation> { a/Source/JavaScriptCore/wasm/WasmModuleInformation.h_sec1
74
    Vector<Global> globals;
74
    Vector<Global> globals;
75
    unsigned firstInternalGlobal { 0 };
75
    unsigned firstInternalGlobal { 0 };
76
    Vector<CustomSection> customSections;
76
    Vector<CustomSection> customSections;
77
77
    NameSection nameSection;
78
};
78
};
79
79
80
    
80
    
- a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp -8 / +13 lines
Lines 1-5 a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp_sec1
1
/*
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 30-42 a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp_sec2
30
30
31
#include "IdentifierInlines.h"
31
#include "IdentifierInlines.h"
32
#include "JSWebAssemblyTable.h"
32
#include "JSWebAssemblyTable.h"
33
#include "WasmFormat.h"
34
#include "WasmMemoryInformation.h"
33
#include "WasmMemoryInformation.h"
34
#include "WasmNameSectionParser.h"
35
#include "WasmOps.h"
35
#include "WasmOps.h"
36
#include "WasmSections.h"
36
#include "WasmSections.h"
37
37
38
#include <sys/mman.h>
39
40
namespace JSC { namespace Wasm {
38
namespace JSC { namespace Wasm {
41
39
42
ALWAYS_INLINE I32InitExpr makeI32InitExpr(uint8_t opcode, uint32_t bits)
40
ALWAYS_INLINE I32InitExpr makeI32InitExpr(uint8_t opcode, uint32_t bits)
Lines 156-163 auto ModuleParser::parseImport() -> PartialResult a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp_sec3
156
    for (uint32_t importNumber = 0; importNumber < importCount; ++importNumber) {
154
    for (uint32_t importNumber = 0; importNumber < importCount; ++importNumber) {
157
        uint32_t moduleLen;
155
        uint32_t moduleLen;
158
        uint32_t fieldLen;
156
        uint32_t fieldLen;
159
        Vector<LChar> moduleString;
157
        Name moduleString;
160
        Vector<LChar> fieldString;
158
        Name fieldString;
161
        ExternalKind kind;
159
        ExternalKind kind;
162
        unsigned kindIndex { 0 };
160
        unsigned kindIndex { 0 };
163
161
Lines 368-374 auto ModuleParser::parseExport() -> PartialResult a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp_sec4
368
    HashSet<String> exportNames;
366
    HashSet<String> exportNames;
369
    for (uint32_t exportNumber = 0; exportNumber < exportCount; ++exportNumber) {
367
    for (uint32_t exportNumber = 0; exportNumber < exportCount; ++exportNumber) {
370
        uint32_t fieldLen;
368
        uint32_t fieldLen;
371
        Vector<LChar> fieldString;
369
        Name fieldString;
372
        ExternalKind kind;
370
        ExternalKind kind;
373
        unsigned kindIndex;
371
        unsigned kindIndex;
374
372
Lines 605-611 auto ModuleParser::parseCustom(uint32_t sectionLength) -> PartialResult a/Source/JavaScriptCore/wasm/WasmModuleParser.cpp_sec5
605
        WASM_PARSER_FAIL_IF(!parseUInt8(byte), "can't get ", byteNumber, "th data byte from ", customSectionNumber, "th custom section");
603
        WASM_PARSER_FAIL_IF(!parseUInt8(byte), "can't get ", byteNumber, "th data byte from ", customSectionNumber, "th custom section");
606
        section.payload.uncheckedAppend(byte);
604
        section.payload.uncheckedAppend(byte);
607
    }
605
    }
608
    
606
607
    Name nameName = { 'n', 'a', 'm', 'e' };
608
    if (section.name == nameName) {
609
        NameSectionParser nameSectionParser(section.payload.begin(), section.payload.size(), m_info);
610
        if (auto nameSection = nameSectionParser.parse())
611
            m_info->nameSection = WTFMove(*nameSection);
612
    }
613
609
    m_info->customSections.uncheckedAppend(WTFMove(section));
614
    m_info->customSections.uncheckedAppend(WTFMove(section));
610
615
611
    return { };
616
    return { };
- a/Source/JavaScriptCore/wasm/WasmName.h +41 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmName.h_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBASSEMBLY)
29
30
#include <wtf/Vector.h>
31
#include <wtf/text/LChar.h>
32
33
namespace JSC {
34
35
namespace Wasm {
36
37
typedef Vector<LChar> Name;
38
39
} } // namespace JSC::Wasm
40
41
#endif // ENABLE(WEBASSEMBLY)
- a/Source/JavaScriptCore/wasm/WasmNameSectionParser.cpp +90 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmNameSectionParser.cpp_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "WasmNameSectionParser.h"
28
29
#if ENABLE(WEBASSEMBLY)
30
31
#include "IdentifierInlines.h"
32
33
namespace JSC { namespace Wasm {
34
35
auto NameSectionParser::parse() -> Result
36
{
37
    NameSection nameSection;
38
    WASM_PARSER_FAIL_IF(!nameSection.functionNames.tryReserveCapacity(m_info.functionIndexSpaceSize()), "can't allocate enough memory for function names");
39
    nameSection.functionNames.resize(m_info.functionIndexSpaceSize());
40
41
    for (size_t payloadNumber = 0; m_offset < length(); ++payloadNumber) {
42
        uint8_t nameType;
43
        uint32_t payloadLength;
44
        WASM_PARSER_FAIL_IF(!parseUInt7(nameType), "can't get name type for payload ", payloadNumber);
45
        WASM_PARSER_FAIL_IF(!isValidNameType(nameType), "name type ", nameType, " is invalid for payload ", payloadNumber);
46
        WASM_PARSER_FAIL_IF(!parseVarUInt32(payloadLength), "can't get payload length for payload ", payloadNumber);
47
        WASM_PARSER_FAIL_IF(payloadLength > length() - m_offset, "payload length is too big for payload ", payloadNumber);
48
        const auto payloadStart = m_offset;
49
50
        switch (static_cast<NameType>(nameType)) {
51
        case NameType::Function: {
52
            uint32_t count;
53
            WASM_PARSER_FAIL_IF(!parseVarUInt32(count), "can't get function count for payload ", payloadNumber);
54
            for (uint32_t function = 0; function < count; ++function) {
55
                uint32_t index;
56
                uint32_t nameLen;
57
                Name nameString;
58
                WASM_PARSER_FAIL_IF(!parseVarUInt32(index), "can't get function ", function, " index for payload ", payloadNumber);
59
                WASM_PARSER_FAIL_IF(m_info.functionIndexSpaceSize() <= index, "function ", function, " index ", index, " is larger than function index space ", m_info.functionIndexSpaceSize(), " for payload ", payloadNumber);
60
                WASM_PARSER_FAIL_IF(!parseVarUInt32(nameLen), "can't get ", function, "th function's name length for payload ", payloadNumber);
61
                WASM_PARSER_FAIL_IF(!consumeUTF8String(nameString, nameLen), "can't get ", function, "th function's name of length ", nameLen, " for payload ", payloadNumber);
62
                nameSection.functionNames[index] = WTFMove(nameString);
63
            }
64
            break;
65
        }
66
        case NameType::Local: {
67
            // Ignore local names for now, we don't do anything with them but we still need to parse them in order to properly ignore them.
68
            uint32_t functionIndex;
69
            uint32_t count;
70
            WASM_PARSER_FAIL_IF(!parseVarUInt32(functionIndex), "can't get local's function index for payload ", payloadNumber);
71
            WASM_PARSER_FAIL_IF(!parseVarUInt32(count), "can't get local count for payload ", payloadNumber);
72
            for (uint32_t local = 0; local < count; ++local) {
73
                uint32_t index;
74
                uint32_t nameLen;
75
                Name nameString;
76
                WASM_PARSER_FAIL_IF(!parseVarUInt32(index), "can't get local ", local, " index for payload ", payloadNumber);
77
                WASM_PARSER_FAIL_IF(!parseVarUInt32(nameLen), "can't get ", local, "th local's name length for payload ", payloadNumber);
78
                WASM_PARSER_FAIL_IF(!consumeUTF8String(nameString, nameLen), "can't get ", local, "th local's name of length ", nameLen, " for payload ", payloadNumber);
79
            }
80
            break;
81
        }
82
        }
83
        WASM_PARSER_FAIL_IF(payloadStart + payloadLength != m_offset);
84
    }
85
    return nameSection;
86
}
87
88
} } // namespace JSC::Wasm
89
90
#endif // ENABLE(WEBASSEMBLY)
- a/Source/JavaScriptCore/wasm/WasmNameSectionParser.h +51 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmNameSectionParser.h_sec1
1
/*
2
 * Copyright (C) 2017 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if ENABLE(WEBASSEMBLY)
29
30
#include "WasmFormat.h"
31
#include "WasmParser.h"
32
33
namespace JSC { namespace Wasm {
34
35
class NameSectionParser : public Parser<NameSection> {
36
public:
37
    NameSectionParser(const uint8_t* sourceBuffer, size_t sourceLength, const ModuleInformation& info)
38
        : Parser(sourceBuffer, sourceLength)
39
        , m_info(info)
40
    {
41
    }
42
43
    Result WARN_UNUSED_RETURN parse();
44
    
45
private:
46
    const ModuleInformation& m_info;
47
};
48
49
} } // namespace JSC::Wasm
50
51
#endif // ENABLE(WEBASSEMBLY)
- a/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp -1 / +1 lines
Lines 98-104 void OMGPlan::work(CompilationEffort) a/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp_sec1
98
    void* entrypoint;
98
    void* entrypoint;
99
    {
99
    {
100
        ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(mode()));
100
        ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(mode()));
101
        Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace);
101
        Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace));
102
        MacroAssembler::repatchPointer(parseAndCompileResult.value()->wasmCalleeMoveLocation, CalleeBits::boxWasm(callee.ptr()));
102
        MacroAssembler::repatchPointer(parseAndCompileResult.value()->wasmCalleeMoveLocation, CalleeBits::boxWasm(callee.ptr()));
103
        ASSERT(!m_codeBlock->m_optimizedCallees[m_functionIndex]);
103
        ASSERT(!m_codeBlock->m_optimizedCallees[m_functionIndex]);
104
        entrypoint = callee->entrypoint();
104
        entrypoint = callee->entrypoint();
- a/Source/JavaScriptCore/wasm/WasmParser.h -4 / +3 lines
Lines 1-5 a/Source/JavaScriptCore/wasm/WasmParser.h_sec1
1
/*
1
/*
2
 * Copyright (C) 2016 Apple Inc. All rights reserved.
2
 * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
3
 *
3
 *
4
 * Redistribution and use in source and binary forms, with or without
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
5
 * modification, are permitted provided that the following conditions
Lines 62-68 protected: a/Source/JavaScriptCore/wasm/WasmParser.h_sec2
62
62
63
    bool WARN_UNUSED_RETURN consumeCharacter(char);
63
    bool WARN_UNUSED_RETURN consumeCharacter(char);
64
    bool WARN_UNUSED_RETURN consumeString(const char*);
64
    bool WARN_UNUSED_RETURN consumeString(const char*);
65
    bool WARN_UNUSED_RETURN consumeUTF8String(Vector<LChar>&, size_t);
65
    bool WARN_UNUSED_RETURN consumeUTF8String(Name&, size_t);
66
66
67
    bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t&);
67
    bool WARN_UNUSED_RETURN parseVarUInt1(uint8_t&);
68
    bool WARN_UNUSED_RETURN parseInt7(int8_t&);
68
    bool WARN_UNUSED_RETURN parseInt7(int8_t&);
Lines 142-148 ALWAYS_INLINE bool Parser<SuccessType>::consumeString(const char* str) a/Source/JavaScriptCore/wasm/WasmParser.h_sec3
142
}
142
}
143
143
144
template<typename SuccessType>
144
template<typename SuccessType>
145
ALWAYS_INLINE bool Parser<SuccessType>::consumeUTF8String(Vector<LChar>& result, size_t stringLength)
145
ALWAYS_INLINE bool Parser<SuccessType>::consumeUTF8String(Name& result, size_t stringLength)
146
{
146
{
147
    if (length() < stringLength || m_offset > length() - stringLength)
147
    if (length() < stringLength || m_offset > length() - stringLength)
148
        return false;
148
        return false;
149
- 

Return to Bug 171263