| Differences between
and this patch
- a/Source/JavaScriptCore/ChangeLog +65 lines
Lines 1-5 a/Source/JavaScriptCore/ChangeLog_sec1
1
2016-10-31  Keith Miller  <keith_miller@apple.com>
1
2016-10-31  Keith Miller  <keith_miller@apple.com>
2
2
3
        Add a WASM function validator.
4
        https://bugs.webkit.org/show_bug.cgi?id=161707
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        This is a new template specialization of the Wasm FunctionParser class.  Instead of having
9
        the FunctionParser track what B3 values each stack entry refers to the validator has each
10
        entry refer to the type of the stack entry. Additionally, the control stack tracks what type
11
        of block the object is and what the result type of the block is. The validation functions
12
        for unary, binary, and memory operations are autogenerated by the
13
        generateWasmValidateInlinesHeader.py script.
14
15
        There are still a couple issue with validating that will be addressed in follow-up patches.
16
        1) We need to handle result types from basic blocks.
17
        2) We need to handle popping things from stacks when they don't exist.
18
19
        * CMakeLists.txt:
20
        * DerivedSources.make:
21
        * JavaScriptCore.xcodeproj/project.pbxproj:
22
        * testWasm.cpp:
23
        (runWasmTests):
24
        * wasm/WasmB3IRGenerator.cpp:
25
        * wasm/WasmFormat.cpp: Added.
26
        (JSC::Wasm::toString):
27
        * wasm/WasmFormat.h:
28
        * wasm/WasmFunctionParser.h:
29
        (JSC::Wasm::FunctionParser<Context>::parseExpression):
30
        (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):
31
        * wasm/WasmPlan.cpp:
32
        (JSC::Wasm::Plan::Plan):
33
        * wasm/WasmValidate.cpp: Added.
34
        (JSC::Wasm::Validate::ControlData::ControlData):
35
        (JSC::Wasm::Validate::ControlData::dump):
36
        (JSC::Wasm::Validate::ControlData::type):
37
        (JSC::Wasm::Validate::ControlData::signature):
38
        (JSC::Wasm::Validate::addConstant):
39
        (JSC::Wasm::Validate::isContinuationReachable):
40
        (JSC::Wasm::Validate::errorMessage):
41
        (JSC::Wasm::Validate::Validate):
42
        (JSC::Wasm::Validate::addArguments):
43
        (JSC::Wasm::Validate::addLocal):
44
        (JSC::Wasm::Validate::getLocal):
45
        (JSC::Wasm::Validate::setLocal):
46
        (JSC::Wasm::Validate::addBlock):
47
        (JSC::Wasm::Validate::addLoop):
48
        (JSC::Wasm::Validate::addIf):
49
        (JSC::Wasm::Validate::addElse):
50
        (JSC::Wasm::Validate::addReturn):
51
        (JSC::Wasm::Validate::addBranch):
52
        (JSC::Wasm::Validate::endBlock):
53
        (JSC::Wasm::Validate::addCall):
54
        (JSC::Wasm::Validate::unify):
55
        (JSC::Wasm::Validate::dump):
56
        (JSC::Wasm::validateFunction):
57
        * wasm/WasmValidate.h: Added.
58
        * wasm/generateWasmValidateInlinesHeader.py: Added.
59
        (cppType):
60
        (toCpp):
61
        (unaryMacro):
62
        (binaryMacro):
63
        (loadMacro):
64
        (storeMacro):
65
66
2016-10-31  Keith Miller  <keith_miller@apple.com>
67
3
        autogenerated files from wasm.json should be in derived sources.
68
        autogenerated files from wasm.json should be in derived sources.
4
        https://bugs.webkit.org/show_bug.cgi?id=164152
69
        https://bugs.webkit.org/show_bug.cgi?id=164152
5
70
- a/Source/JavaScriptCore/CMakeLists.txt +2 lines
Lines 878-886 set(JavaScriptCore_SOURCES a/Source/JavaScriptCore/CMakeLists.txt_sec1
878
    wasm/JSWebAssembly.cpp
878
    wasm/JSWebAssembly.cpp
879
    wasm/WasmB3IRGenerator.cpp
879
    wasm/WasmB3IRGenerator.cpp
880
    wasm/WasmCallingConvention.cpp
880
    wasm/WasmCallingConvention.cpp
881
    wasm/WasmFormat.cpp
881
    wasm/WasmMemory.cpp
882
    wasm/WasmMemory.cpp
882
    wasm/WasmModuleParser.cpp
883
    wasm/WasmModuleParser.cpp
883
    wasm/WasmPlan.cpp
884
    wasm/WasmPlan.cpp
885
    wasm/WasmValidate.cpp
884
886
885
    wasm/js/JSWebAssemblyCompileError.cpp
887
    wasm/js/JSWebAssemblyCompileError.cpp
886
    wasm/js/JSWebAssemblyInstance.cpp
888
    wasm/js/JSWebAssemblyInstance.cpp
- a/Source/JavaScriptCore/DerivedSources.make +4 lines
Lines 64-69 all : \ a/Source/JavaScriptCore/DerivedSources.make_sec1
64
    AirOpcode.h \
64
    AirOpcode.h \
65
    YarrCanonicalizeUnicode.cpp \
65
    YarrCanonicalizeUnicode.cpp \
66
    WasmOps.h \
66
    WasmOps.h \
67
    WasmValidateInlines.h \
67
#
68
#
68
69
69
# JavaScript builtins.
70
# JavaScript builtins.
Lines 301-306 YarrCanonicalizeUnicode.cpp: $(JavaScriptCore)/generateYarrCanonicalizeUnicode $ a/Source/JavaScriptCore/DerivedSources.make_sec2
301
WasmOps.h: $(JavaScriptCore)/wasm/generateWasmOpsHeader.py $(JavaScriptCore)/wasm/generateWasm.py $(JavaScriptCore)/wasm/wasm.json
302
WasmOps.h: $(JavaScriptCore)/wasm/generateWasmOpsHeader.py $(JavaScriptCore)/wasm/generateWasm.py $(JavaScriptCore)/wasm/wasm.json
302
	$(PYTHON) $(JavaScriptCore)/wasm/generateWasmOpsHeader.py $(JavaScriptCore)/wasm/wasm.json ./WasmOps.h
303
	$(PYTHON) $(JavaScriptCore)/wasm/generateWasmOpsHeader.py $(JavaScriptCore)/wasm/wasm.json ./WasmOps.h
303
304
305
WasmValidateInlines.h: $(JavaScriptCore)/wasm/generateWasmValidateInlinesHeader.py $(JavaScriptCore)/wasm/generateWasm.py $(JavaScriptCore)/wasm/wasm.json
306
	$(PYTHON) $(JavaScriptCore)/wasm/generateWasmValidateInlinesHeader.py $(JavaScriptCore)/wasm/wasm.json ./WasmValidateInlines.h
307
304
# Dynamically-defined targets are listed below. Static targets belong up top.
308
# Dynamically-defined targets are listed below. Static targets belong up top.
305
309
306
all : \
310
all : \
- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj -7 / +19 lines
Lines 1227-1232 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec1
1227
		52C952B919A28A1C0069B386 /* TypeProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */; };
1227
		52C952B919A28A1C0069B386 /* TypeProfiler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 52C952B819A28A1C0069B386 /* TypeProfiler.cpp */; };
1228
		531374BD1D5CE67600AF7A0B /* WasmPlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 531374BC1D5CE67600AF7A0B /* WasmPlan.h */; };
1228
		531374BD1D5CE67600AF7A0B /* WasmPlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 531374BC1D5CE67600AF7A0B /* WasmPlan.h */; };
1229
		531374BF1D5CE95000AF7A0B /* WasmPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */; };
1229
		531374BF1D5CE95000AF7A0B /* WasmPlan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */; };
1230
		533B15DF1DC7F463004D500A /* WasmOps.h in Headers */ = {isa = PBXBuildFile; fileRef = 533B15DE1DC7F463004D500A /* WasmOps.h */; };
1230
		5341FC701DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5341FC6F1DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp */; };
1231
		5341FC701DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5341FC6F1DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp */; };
1231
		5341FC721DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 5341FC711DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h */; };
1232
		5341FC721DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 5341FC711DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h */; };
1232
		53486BB71C1795C300F6F3AF /* JSTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 53486BB61C1795C300F6F3AF /* JSTypedArray.h */; settings = {ATTRIBUTES = (Public, ); }; };
1233
		53486BB71C1795C300F6F3AF /* JSTypedArray.h in Headers */ = {isa = PBXBuildFile; fileRef = 53486BB61C1795C300F6F3AF /* JSTypedArray.h */; settings = {ATTRIBUTES = (Public, ); }; };
Lines 1250-1256 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec2
1250
		53F40E8B1D5901BB0099A1B6 /* WasmFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */; };
1251
		53F40E8B1D5901BB0099A1B6 /* WasmFunctionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */; };
1251
		53F40E8D1D5901F20099A1B6 /* WasmParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8C1D5901F20099A1B6 /* WasmParser.h */; };
1252
		53F40E8D1D5901F20099A1B6 /* WasmParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E8C1D5901F20099A1B6 /* WasmParser.h */; };
1252
		53F40E8F1D5902820099A1B6 /* WasmB3IRGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E8E1D5902820099A1B6 /* WasmB3IRGenerator.cpp */; };
1253
		53F40E8F1D5902820099A1B6 /* WasmB3IRGenerator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E8E1D5902820099A1B6 /* WasmB3IRGenerator.cpp */; };
1253
		53F40E911D5903020099A1B6 /* WasmOps.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E901D5903020099A1B6 /* WasmOps.h */; };
1254
		53F40E931D5A4AB30099A1B6 /* WasmB3IRGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */; };
1254
		53F40E931D5A4AB30099A1B6 /* WasmB3IRGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */; };
1255
		53F40E951D5A7AEF0099A1B6 /* WasmModuleParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */; };
1255
		53F40E951D5A7AEF0099A1B6 /* WasmModuleParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */; };
1256
		53F40E971D5A7BEC0099A1B6 /* WasmModuleParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */; };
1256
		53F40E971D5A7BEC0099A1B6 /* WasmModuleParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */; };
Lines 1259-1271 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec3
1259
		53FA2AE31CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FA2AE21CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp */; };
1259
		53FA2AE31CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FA2AE21CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp */; };
1260
		53FD04D31D7AB277003287D3 /* WasmCallingConvention.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */; };
1260
		53FD04D31D7AB277003287D3 /* WasmCallingConvention.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */; };
1261
		53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */; };
1261
		53FD04D41D7AB291003287D3 /* WasmCallingConvention.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */; };
1262
		5C4E8E961DBEBE620036F1FC /* JSONParseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */; };
1262
		53FF7F991DBFCD9000A26CCC /* WasmValidate.h in Headers */ = {isa = PBXBuildFile; fileRef = 53FF7F981DBFCD9000A26CCC /* WasmValidate.h */; };
1263
		53FF7F9B1DBFD2B900A26CCC /* WasmValidate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */; };
1264
		53FF7F9D1DC00DB100A26CCC /* WasmFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 53FF7F9C1DC00DB100A26CCC /* WasmFormat.cpp */; };
1263
		5B70CFDE1DB69E6600EC23F9 /* JSAsyncFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */; };
1265
		5B70CFDE1DB69E6600EC23F9 /* JSAsyncFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */; };
1264
		5B70CFDF1DB69E6600EC23F9 /* JSAsyncFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFD91DB69E5C00EC23F9 /* JSAsyncFunction.cpp */; };
1266
		5B70CFDF1DB69E6600EC23F9 /* JSAsyncFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFD91DB69E5C00EC23F9 /* JSAsyncFunction.cpp */; };
1265
		5B70CFE01DB69E6600EC23F9 /* AsyncFunctionPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFDA1DB69E5C00EC23F9 /* AsyncFunctionPrototype.h */; };
1267
		5B70CFE01DB69E6600EC23F9 /* AsyncFunctionPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFDA1DB69E5C00EC23F9 /* AsyncFunctionPrototype.h */; };
1266
		5B70CFE11DB69E6600EC23F9 /* AsyncFunctionPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFDB1DB69E5C00EC23F9 /* AsyncFunctionPrototype.cpp */; };
1268
		5B70CFE11DB69E6600EC23F9 /* AsyncFunctionPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFDB1DB69E5C00EC23F9 /* AsyncFunctionPrototype.cpp */; };
1267
		5B70CFE21DB69E6600EC23F9 /* AsyncFunctionConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFDC1DB69E5C00EC23F9 /* AsyncFunctionConstructor.h */; };
1269
		5B70CFE21DB69E6600EC23F9 /* AsyncFunctionConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = 5B70CFDC1DB69E5C00EC23F9 /* AsyncFunctionConstructor.h */; };
1268
		5B70CFE31DB69E6600EC23F9 /* AsyncFunctionConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFDD1DB69E5C00EC23F9 /* AsyncFunctionConstructor.cpp */; };
1270
		5B70CFE31DB69E6600EC23F9 /* AsyncFunctionConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5B70CFDD1DB69E5C00EC23F9 /* AsyncFunctionConstructor.cpp */; };
1271
		5C4E8E961DBEBE620036F1FC /* JSONParseTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */; };
1269
		5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
1272
		5D5D8AD10E0D0EBE00F9C692 /* libedit.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */; };
1270
		5DBB151B131D0B310056AD36 /* testapi.js in Copy Support Script */ = {isa = PBXBuildFile; fileRef = 14D857740A4696C80032146C /* testapi.js */; };
1273
		5DBB151B131D0B310056AD36 /* testapi.js in Copy Support Script */ = {isa = PBXBuildFile; fileRef = 14D857740A4696C80032146C /* testapi.js */; };
1271
		5DBB1525131D0BD70056AD36 /* minidom.js in Copy Support Script */ = {isa = PBXBuildFile; fileRef = 1412110D0A48788700480255 /* minidom.js */; };
1274
		5DBB1525131D0BD70056AD36 /* minidom.js in Copy Support Script */ = {isa = PBXBuildFile; fileRef = 1412110D0A48788700480255 /* minidom.js */; };
Lines 3552-3557 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec4
3552
		52C952B819A28A1C0069B386 /* TypeProfiler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypeProfiler.cpp; sourceTree = "<group>"; };
3555
		52C952B819A28A1C0069B386 /* TypeProfiler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TypeProfiler.cpp; sourceTree = "<group>"; };
3553
		531374BC1D5CE67600AF7A0B /* WasmPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmPlan.h; sourceTree = "<group>"; };
3556
		531374BC1D5CE67600AF7A0B /* WasmPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmPlan.h; sourceTree = "<group>"; };
3554
		531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPlan.cpp; sourceTree = "<group>"; };
3557
		531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPlan.cpp; sourceTree = "<group>"; };
3558
		533B15DE1DC7F463004D500A /* WasmOps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmOps.h; sourceTree = "<group>"; };
3555
		5341FC6F1DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3WasmBoundsCheckValue.cpp; path = b3/B3WasmBoundsCheckValue.cpp; sourceTree = "<group>"; };
3559
		5341FC6F1DAC33E500E7E4D7 /* B3WasmBoundsCheckValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3WasmBoundsCheckValue.cpp; path = b3/B3WasmBoundsCheckValue.cpp; sourceTree = "<group>"; };
3556
		5341FC711DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3WasmBoundsCheckValue.h; path = b3/B3WasmBoundsCheckValue.h; sourceTree = "<group>"; };
3560
		5341FC711DAC343C00E7E4D7 /* B3WasmBoundsCheckValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3WasmBoundsCheckValue.h; path = b3/B3WasmBoundsCheckValue.h; sourceTree = "<group>"; };
3557
		53486BB61C1795C300F6F3AF /* JSTypedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArray.h; sourceTree = "<group>"; };
3561
		53486BB61C1795C300F6F3AF /* JSTypedArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSTypedArray.h; sourceTree = "<group>"; };
Lines 3579-3585 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec5
3579
		53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmFunctionParser.h; sourceTree = "<group>"; };
3583
		53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmFunctionParser.h; sourceTree = "<group>"; };
3580
		53F40E8C1D5901F20099A1B6 /* WasmParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmParser.h; sourceTree = "<group>"; };
3584
		53F40E8C1D5901F20099A1B6 /* WasmParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmParser.h; sourceTree = "<group>"; };
3581
		53F40E8E1D5902820099A1B6 /* WasmB3IRGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmB3IRGenerator.cpp; sourceTree = "<group>"; };
3585
		53F40E8E1D5902820099A1B6 /* WasmB3IRGenerator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmB3IRGenerator.cpp; sourceTree = "<group>"; };
3582
		53F40E901D5903020099A1B6 /* WasmOps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmOps.h; sourceTree = "<group>"; };
3583
		53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmB3IRGenerator.h; sourceTree = "<group>"; };
3586
		53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmB3IRGenerator.h; sourceTree = "<group>"; };
3584
		53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmModuleParser.h; sourceTree = "<group>"; };
3587
		53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmModuleParser.h; sourceTree = "<group>"; };
3585
		53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmModuleParser.cpp; sourceTree = "<group>"; };
3588
		53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmModuleParser.cpp; sourceTree = "<group>"; };
Lines 3588-3595 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec6
3588
		53FA2AE21CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp; sourceTree = "<group>"; };
3591
		53FA2AE21CF380390022711D /* LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LLIntPrototypeLoadAdaptiveStructureWatchpoint.cpp; sourceTree = "<group>"; };
3589
		53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmCallingConvention.cpp; sourceTree = "<group>"; };
3592
		53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmCallingConvention.cpp; sourceTree = "<group>"; };
3590
		53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmCallingConvention.h; sourceTree = "<group>"; };
3593
		53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmCallingConvention.h; sourceTree = "<group>"; };
3591
		5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSONParseTest.cpp; path = API/tests/JSONParseTest.cpp; sourceTree = "<group>"; };
3594
		53FF7F981DBFCD9000A26CCC /* WasmValidate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmValidate.h; sourceTree = "<group>"; };
3592
		5C4E8E951DBEBDA20036F1FC /* JSONParseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSONParseTest.h; path = API/tests/JSONParseTest.h; sourceTree = "<group>"; };
3595
		53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmValidate.cpp; sourceTree = "<group>"; };
3596
		53FF7F9C1DC00DB100A26CCC /* WasmFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFormat.cpp; sourceTree = "<group>"; };
3593
		5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAsyncFunction.h; sourceTree = "<group>"; };
3597
		5B70CFD81DB69E5C00EC23F9 /* JSAsyncFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAsyncFunction.h; sourceTree = "<group>"; };
3594
		5B70CFD91DB69E5C00EC23F9 /* JSAsyncFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAsyncFunction.cpp; sourceTree = "<group>"; };
3598
		5B70CFD91DB69E5C00EC23F9 /* JSAsyncFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAsyncFunction.cpp; sourceTree = "<group>"; };
3595
		5B70CFDA1DB69E5C00EC23F9 /* AsyncFunctionPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFunctionPrototype.h; sourceTree = "<group>"; };
3599
		5B70CFDA1DB69E5C00EC23F9 /* AsyncFunctionPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFunctionPrototype.h; sourceTree = "<group>"; };
Lines 3597-3602 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec7
3597
		5B70CFDC1DB69E5C00EC23F9 /* AsyncFunctionConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFunctionConstructor.h; sourceTree = "<group>"; };
3601
		5B70CFDC1DB69E5C00EC23F9 /* AsyncFunctionConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncFunctionConstructor.h; sourceTree = "<group>"; };
3598
		5B70CFDD1DB69E5C00EC23F9 /* AsyncFunctionConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncFunctionConstructor.cpp; sourceTree = "<group>"; };
3602
		5B70CFDD1DB69E5C00EC23F9 /* AsyncFunctionConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncFunctionConstructor.cpp; sourceTree = "<group>"; };
3599
		5B8243041DB7AA4900EA6384 /* AsyncFunctionPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = AsyncFunctionPrototype.js; sourceTree = "<group>"; };
3603
		5B8243041DB7AA4900EA6384 /* AsyncFunctionPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = AsyncFunctionPrototype.js; sourceTree = "<group>"; };
3604
		5C4E8E941DBEBDA20036F1FC /* JSONParseTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSONParseTest.cpp; path = API/tests/JSONParseTest.cpp; sourceTree = "<group>"; };
3605
		5C4E8E951DBEBDA20036F1FC /* JSONParseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSONParseTest.h; path = API/tests/JSONParseTest.h; sourceTree = "<group>"; };
3600
		5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.dylib; sourceTree = "<absolute>"; };
3606
		5D5D8AD00E0D0EBE00F9C692 /* libedit.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libedit.dylib; path = /usr/lib/libedit.dylib; sourceTree = "<absolute>"; };
3601
		5DAFD6CB146B686300FBEFB4 /* JSC.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = JSC.xcconfig; sourceTree = "<group>"; };
3607
		5DAFD6CB146B686300FBEFB4 /* JSC.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = JSC.xcconfig; sourceTree = "<group>"; };
3602
		5DDDF44614FEE72200B4FB4D /* LLIntDesiredOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntDesiredOffsets.h; path = LLIntOffsets/LLIntDesiredOffsets.h; sourceTree = BUILT_PRODUCTS_DIR; };
3608
		5DDDF44614FEE72200B4FB4D /* LLIntDesiredOffsets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntDesiredOffsets.h; path = LLIntOffsets/LLIntDesiredOffsets.h; sourceTree = BUILT_PRODUCTS_DIR; };
Lines 5839-5844 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec8
5839
				996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */,
5845
				996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */,
5840
				996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */,
5846
				996B73141BD9FA2C00331B84 /* SymbolPrototype.lut.h */,
5841
				65A946141C8E9F6F00A7209A /* YarrCanonicalizeUnicode.cpp */,
5847
				65A946141C8E9F6F00A7209A /* YarrCanonicalizeUnicode.cpp */,
5848
				533B15DE1DC7F463004D500A /* WasmOps.h */,
5842
			);
5849
			);
5843
			name = "Derived Sources";
5850
			name = "Derived Sources";
5844
			path = DerivedSources/JavaScriptCore;
5851
			path = DerivedSources/JavaScriptCore;
Lines 5875-5881 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec9
5875
				53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */,
5882
				53F40E921D5A4AB30099A1B6 /* WasmB3IRGenerator.h */,
5876
				53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */,
5883
				53FD04D11D7AB187003287D3 /* WasmCallingConvention.cpp */,
5877
				53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
5884
				53FD04D21D7AB187003287D3 /* WasmCallingConvention.h */,
5878
				53F40E901D5903020099A1B6 /* WasmOps.h */,
5885
				53FF7F9C1DC00DB100A26CCC /* WasmFormat.cpp */,
5879
				7BC547D21B69599B00959B58 /* WasmFormat.h */,
5886
				7BC547D21B69599B00959B58 /* WasmFormat.h */,
5880
				53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
5887
				53F40E8A1D5901BB0099A1B6 /* WasmFunctionParser.h */,
5881
				535557151D9DFA32006D583B /* WasmMemory.cpp */,
5888
				535557151D9DFA32006D583B /* WasmMemory.cpp */,
Lines 5886-5891 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec10
5886
				531374BC1D5CE67600AF7A0B /* WasmPlan.h */,
5893
				531374BC1D5CE67600AF7A0B /* WasmPlan.h */,
5887
				53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
5894
				53F40E8C1D5901F20099A1B6 /* WasmParser.h */,
5888
				53F40E841D58F9770099A1B6 /* WasmSections.h */,
5895
				53F40E841D58F9770099A1B6 /* WasmSections.h */,
5896
				53FF7F9A1DBFD2B900A26CCC /* WasmValidate.cpp */,
5897
				53FF7F981DBFCD9000A26CCC /* WasmValidate.h */,
5889
			);
5898
			);
5890
			path = wasm;
5899
			path = wasm;
5891
			sourceTree = "<group>";
5900
			sourceTree = "<group>";
Lines 7986-7991 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec11
7986
				0F2BDC491522809600CD8910 /* DFGVariableEvent.h in Headers */,
7995
				0F2BDC491522809600CD8910 /* DFGVariableEvent.h in Headers */,
7987
				0F2BDC4B1522809D00CD8910 /* DFGVariableEventStream.h in Headers */,
7996
				0F2BDC4B1522809D00CD8910 /* DFGVariableEventStream.h in Headers */,
7988
				0FFFC96014EF90BD00C72532 /* DFGVirtualRegisterAllocationPhase.h in Headers */,
7997
				0FFFC96014EF90BD00C72532 /* DFGVirtualRegisterAllocationPhase.h in Headers */,
7998
				53FF7F991DBFCD9000A26CCC /* WasmValidate.h in Headers */,
7989
				0FC97F4218202119002C9B26 /* DFGWatchpointCollectionPhase.h in Headers */,
7999
				0FC97F4218202119002C9B26 /* DFGWatchpointCollectionPhase.h in Headers */,
7990
				0FDB2CE8174830A2007B3C1B /* DFGWorklist.h in Headers */,
8000
				0FDB2CE8174830A2007B3C1B /* DFGWorklist.h in Headers */,
7991
				147341DA1DC0300100AA29BA /* WebAssemblyExecutable.h in Headers */,
8001
				147341DA1DC0300100AA29BA /* WebAssemblyExecutable.h in Headers */,
Lines 8389-8395 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec12
8389
				A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */,
8399
				A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */,
8390
				FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */,
8400
				FE1220271BE7F58C0039E6F2 /* JITAddGenerator.h in Headers */,
8391
				0F919D11157F332C004A4E7D /* JSSegmentedVariableObject.h in Headers */,
8401
				0F919D11157F332C004A4E7D /* JSSegmentedVariableObject.h in Headers */,
8392
				53F40E911D5903020099A1B6 /* WasmOps.h in Headers */,
8393
				A7299D9E17D12837005F5FF9 /* JSSet.h in Headers */,
8402
				A7299D9E17D12837005F5FF9 /* JSSet.h in Headers */,
8394
				A790DD70182F499700588807 /* JSSetIterator.h in Headers */,
8403
				A790DD70182F499700588807 /* JSSetIterator.h in Headers */,
8395
				BC18C45E0E16F5CD00B34460 /* CLoopStack.h in Headers */,
8404
				BC18C45E0E16F5CD00B34460 /* CLoopStack.h in Headers */,
Lines 8769-8774 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec13
8769
				14F7256614EE265E00B1652B /* WeakHandleOwner.h in Headers */,
8778
				14F7256614EE265E00B1652B /* WeakHandleOwner.h in Headers */,
8770
				14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */,
8779
				14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */,
8771
				14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */,
8780
				14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */,
8781
				533B15DF1DC7F463004D500A /* WasmOps.h in Headers */,
8772
				A7CA3AE417DA41AE006538AF /* WeakMapConstructor.h in Headers */,
8782
				A7CA3AE417DA41AE006538AF /* WeakMapConstructor.h in Headers */,
8773
				A7CA3AEC17DA5168006538AF /* WeakMapData.h in Headers */,
8783
				A7CA3AEC17DA5168006538AF /* WeakMapData.h in Headers */,
8774
				A7CA3AE617DA41AE006538AF /* WeakMapPrototype.h in Headers */,
8784
				A7CA3AE617DA41AE006538AF /* WeakMapPrototype.h in Headers */,
Lines 9930-9935 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec14
9930
				0FF4275715914A20004CB9FF /* LinkBuffer.cpp in Sources */,
9940
				0FF4275715914A20004CB9FF /* LinkBuffer.cpp in Sources */,
9931
				A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */,
9941
				A7E2EA6C0FB460CF00601F06 /* LiteralParser.cpp in Sources */,
9932
				A5A1A0951D8CB341004C2EB8 /* DebuggerParseData.cpp in Sources */,
9942
				A5A1A0951D8CB341004C2EB8 /* DebuggerParseData.cpp in Sources */,
9943
				53FF7F9D1DC00DB100A26CCC /* WasmFormat.cpp in Sources */,
9933
				FE3913541B794F6E00EDAF71 /* LiveObjectList.cpp in Sources */,
9944
				FE3913541B794F6E00EDAF71 /* LiveObjectList.cpp in Sources */,
9934
				FE20CE9D15F04A9500DF3430 /* LLIntCLoop.cpp in Sources */,
9945
				FE20CE9D15F04A9500DF3430 /* LLIntCLoop.cpp in Sources */,
9935
				0F4680D214BBD16500BFE272 /* LLIntData.cpp in Sources */,
9946
				0F4680D214BBD16500BFE272 /* LLIntData.cpp in Sources */,
Lines 10088-10093 a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj_sec15
10088
				14469DEB107EC7E700650446 /* StringConstructor.cpp in Sources */,
10099
				14469DEB107EC7E700650446 /* StringConstructor.cpp in Sources */,
10089
				70EC0EC61AA0D7DA00B6AAFA /* StringIteratorPrototype.cpp in Sources */,
10100
				70EC0EC61AA0D7DA00B6AAFA /* StringIteratorPrototype.cpp in Sources */,
10090
				14469DEC107EC7E700650446 /* StringObject.cpp in Sources */,
10101
				14469DEC107EC7E700650446 /* StringObject.cpp in Sources */,
10102
				53FF7F9B1DBFD2B900A26CCC /* WasmValidate.cpp in Sources */,
10091
				14469DED107EC7E700650446 /* StringPrototype.cpp in Sources */,
10103
				14469DED107EC7E700650446 /* StringPrototype.cpp in Sources */,
10092
				9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */,
10104
				9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */,
10093
				BCDE3B430E6C832D001453A7 /* Structure.cpp in Sources */,
10105
				BCDE3B430E6C832D001453A7 /* Structure.cpp in Sources */,
- a/Source/JavaScriptCore/testWasm.cpp -39 / +178 lines
Lines 290-296 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec1
290
        };
290
        };
291
291
292
        Plan plan(*vm, vector);
292
        Plan plan(*vm, vector);
293
        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
293
        if (plan.failed()) {
294
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
295
            CRASH();
296
        }
297
298
        if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
294
            dataLogLn("Module failed to compile correctly.");
299
            dataLogLn("Module failed to compile correctly.");
295
            CRASH();
300
            CRASH();
296
        }
301
        }
Lines 319-325 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec2
319
        };
324
        };
320
325
321
        Plan plan(*vm, vector);
326
        Plan plan(*vm, vector);
322
        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
327
        if (plan.failed()) {
328
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
329
            CRASH();
330
        }
331
332
        if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
323
            dataLogLn("Module failed to compile correctly.");
333
            dataLogLn("Module failed to compile correctly.");
324
            CRASH();
334
            CRASH();
325
        }
335
        }
Lines 353-359 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec3
353
        };
363
        };
354
364
355
        Plan plan(*vm, vector);
365
        Plan plan(*vm, vector);
356
        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
366
        if (plan.failed()) {
367
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
368
            CRASH();
369
        }
370
371
        if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
357
            dataLogLn("Module failed to compile correctly.");
372
            dataLogLn("Module failed to compile correctly.");
358
            CRASH();
373
            CRASH();
359
        }
374
        }
Lines 387-393 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec4
387
        };
402
        };
388
403
389
        Plan plan(*vm, vector);
404
        Plan plan(*vm, vector);
390
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
405
        if (plan.failed()) {
406
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
407
            CRASH();
408
        }
409
410
        if (plan.resultSize() != 1 || !plan.result(0)) {
391
            dataLogLn("Module failed to compile correctly.");
411
            dataLogLn("Module failed to compile correctly.");
392
            CRASH();
412
            CRASH();
393
        }
413
        }
Lines 447-453 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec5
447
        };
467
        };
448
468
449
        Plan plan(*vm, vector);
469
        Plan plan(*vm, vector);
450
        if (plan.failed() || plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
470
        if (plan.failed()) {
471
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
472
            CRASH();
473
        }
474
475
        if (plan.resultSize() != 2 || !plan.result(0) || !plan.result(1)) {
451
            dataLogLn("Module failed to compile correctly.");
476
            dataLogLn("Module failed to compile correctly.");
452
            CRASH();
477
            CRASH();
453
        }
478
        }
Lines 463-486 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec6
463
488
464
    {
489
    {
465
        // Generated from:
490
        // Generated from:
466
        // (module
491
        //    (module
467
        //  (memory 1)
492
        //     (memory 1)
468
        //  (func (export "i32_load8_s") (param $i i32) (param $ptr i32) (result i32)
493
        //     (func (export "i64") (param $i i64) (param $ptr i32) (result i64)
469
        //   (i64.store (get_local $ptr) (get_local $i))
494
        //      (i64.store (get_local $ptr) (get_local $i))
470
        //   (return (i64.load (get_local $ptr)))
495
        //      (return (i64.load (get_local $ptr)))
471
        //   )
496
        //      )
472
        //  )
497
        //     )
473
        Vector<uint8_t> vector = {
498
        Vector<uint8_t> vector = {
474
            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
499
            0x00, 0x61, 0x73, 0x6d, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x40,
475
            0x02, 0x02, 0x01, 0x01, 0x02, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
500
            0x02, 0x02, 0x01, 0x01, 0x02, 0x03, 0x82, 0x80, 0x80, 0x80, 0x00, 0x01, 0x00, 0x05, 0x83, 0x80,
476
            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x01, 0x0b, 0x69, 0x33,
501
            0x80, 0x80, 0x00, 0x01, 0x01, 0x01, 0x07, 0x87, 0x80, 0x80, 0x80, 0x00, 0x01, 0x03, 0x69, 0x36,
477
            0x32, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x38, 0x5f, 0x73, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80,
502
            0x34, 0x00, 0x00, 0x0a, 0x95, 0x80, 0x80, 0x80, 0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00,
478
            0x00, 0x01, 0x8f, 0x80, 0x80, 0x80, 0x00, 0x00, 0x14, 0x01, 0x14, 0x00, 0x34, 0x03, 0x00, 0x14,
503
            0x14, 0x01, 0x14, 0x00, 0x34, 0x03, 0x00, 0x14, 0x01, 0x2b, 0x03, 0x00, 0x09, 0x0f
479
            0x01, 0x2b, 0x03, 0x00, 0x09, 0x0f
480
        };
504
        };
481
505
482
        Plan plan(*vm, vector);
506
        Plan plan(*vm, vector);
483
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
507
        if (plan.failed()) {
508
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
509
            CRASH();
510
        }
511
512
        if (plan.resultSize() != 1 || !plan.result(0)) {
484
            dataLogLn("Module failed to compile correctly.");
513
            dataLogLn("Module failed to compile correctly.");
485
            CRASH();
514
            CRASH();
486
        }
515
        }
Lines 510-516 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec7
510
        };
539
        };
511
540
512
        Plan plan(*vm, vector);
541
        Plan plan(*vm, vector);
513
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
542
        if (plan.failed()) {
543
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
544
            CRASH();
545
        }
546
547
        if (plan.resultSize() != 1 || !plan.result(0)) {
514
            dataLogLn("Module failed to compile correctly.");
548
            dataLogLn("Module failed to compile correctly.");
515
            CRASH();
549
            CRASH();
516
        }
550
        }
Lines 550-556 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec8
550
        };
584
        };
551
585
552
        Plan plan(*vm, vector);
586
        Plan plan(*vm, vector);
553
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
587
        if (plan.failed()) {
588
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
589
            CRASH();
590
        }
591
592
        if (plan.resultSize() != 1 || !plan.result(0)) {
554
            dataLogLn("Module failed to compile correctly.");
593
            dataLogLn("Module failed to compile correctly.");
555
            CRASH();
594
            CRASH();
556
        }
595
        }
Lines 605-611 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec9
605
        };
644
        };
606
645
607
        Plan plan(*vm, vector);
646
        Plan plan(*vm, vector);
608
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
647
        if (plan.failed()) {
648
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
649
            CRASH();
650
        }
651
652
        if (plan.resultSize() != 1 || !plan.result(0)) {
609
            dataLogLn("Module failed to compile correctly.");
653
            dataLogLn("Module failed to compile correctly.");
610
            CRASH();
654
            CRASH();
611
        }
655
        }
Lines 649-655 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec10
649
        };
693
        };
650
694
651
        Plan plan(*vm, vector);
695
        Plan plan(*vm, vector);
652
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
696
        if (plan.failed()) {
697
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
698
            CRASH();
699
        }
700
701
        if (plan.resultSize() != 1 || !plan.result(0)) {
653
            dataLogLn("Module failed to compile correctly.");
702
            dataLogLn("Module failed to compile correctly.");
654
            CRASH();
703
            CRASH();
655
        }
704
        }
Lines 680-686 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec11
680
        };
729
        };
681
730
682
        Plan plan(*vm, vector);
731
        Plan plan(*vm, vector);
683
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
732
        if (plan.failed()) {
733
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
734
            CRASH();
735
        }
736
737
        if (plan.resultSize() != 1 || !plan.result(0)) {
684
            dataLogLn("Module failed to compile correctly.");
738
            dataLogLn("Module failed to compile correctly.");
685
            CRASH();
739
            CRASH();
686
        }
740
        }
Lines 710-716 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec12
710
        };
764
        };
711
765
712
        Plan plan(*vm, vector);
766
        Plan plan(*vm, vector);
713
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
767
        if (plan.failed()) {
768
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
769
            CRASH();
770
        }
771
772
        if (plan.resultSize() != 1 || !plan.result(0)) {
714
            dataLogLn("Module failed to compile correctly.");
773
            dataLogLn("Module failed to compile correctly.");
715
            CRASH();
774
            CRASH();
716
        }
775
        }
Lines 741-747 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec13
741
        };
800
        };
742
801
743
        Plan plan(*vm, vector);
802
        Plan plan(*vm, vector);
744
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
803
        if (plan.failed()) {
804
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
805
            CRASH();
806
        }
807
808
        if (plan.resultSize() != 1 || !plan.result(0)) {
745
            dataLogLn("Module failed to compile correctly.");
809
            dataLogLn("Module failed to compile correctly.");
746
            CRASH();
810
            CRASH();
747
        }
811
        }
Lines 781-787 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec14
781
        };
845
        };
782
846
783
        Plan plan(*vm, vector);
847
        Plan plan(*vm, vector);
784
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
848
        if (plan.failed()) {
849
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
850
            CRASH();
851
        }
852
853
        if (plan.resultSize() != 1 || !plan.result(0)) {
785
            dataLogLn("Module failed to compile correctly.");
854
            dataLogLn("Module failed to compile correctly.");
786
            CRASH();
855
            CRASH();
787
        }
856
        }
Lines 836-842 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec15
836
        };
905
        };
837
906
838
        Plan plan(*vm, vector);
907
        Plan plan(*vm, vector);
839
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
908
        if (plan.failed()) {
909
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
910
            CRASH();
911
        }
912
913
        if (plan.resultSize() != 1 || !plan.result(0)) {
840
            dataLogLn("Module failed to compile correctly.");
914
            dataLogLn("Module failed to compile correctly.");
841
            CRASH();
915
            CRASH();
842
        }
916
        }
Lines 880-886 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec16
880
        };
954
        };
881
955
882
        Plan plan(*vm, vector);
956
        Plan plan(*vm, vector);
883
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
957
        if (plan.failed()) {
958
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
959
            CRASH();
960
        }
961
962
        if (plan.resultSize() != 1 || !plan.result(0)) {
884
            dataLogLn("Module failed to compile correctly.");
963
            dataLogLn("Module failed to compile correctly.");
885
            CRASH();
964
            CRASH();
886
        }
965
        }
Lines 911-917 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec17
911
        };
990
        };
912
991
913
        Plan plan(*vm, vector);
992
        Plan plan(*vm, vector);
914
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
993
        if (plan.failed()) {
994
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
995
            CRASH();
996
        }
997
998
        if (plan.resultSize() != 1 || !plan.result(0)) {
915
            dataLogLn("Module failed to compile correctly.");
999
            dataLogLn("Module failed to compile correctly.");
916
            CRASH();
1000
            CRASH();
917
        }
1001
        }
Lines 941-947 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec18
941
        };
1025
        };
942
1026
943
        Plan plan(*vm, vector);
1027
        Plan plan(*vm, vector);
944
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1028
        if (plan.failed()) {
1029
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1030
            CRASH();
1031
        }
1032
1033
        if (plan.resultSize() != 1 || !plan.result(0)) {
945
            dataLogLn("Module failed to compile correctly.");
1034
            dataLogLn("Module failed to compile correctly.");
946
            CRASH();
1035
            CRASH();
947
        }
1036
        }
Lines 982-988 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec19
982
        };
1071
        };
983
1072
984
        Plan plan(*vm, vector);
1073
        Plan plan(*vm, vector);
985
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1074
        if (plan.failed()) {
1075
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1076
            CRASH();
1077
        }
1078
1079
        if (plan.resultSize() != 1 || !plan.result(0)) {
986
            dataLogLn("Module failed to compile correctly.");
1080
            dataLogLn("Module failed to compile correctly.");
987
            CRASH();
1081
            CRASH();
988
        }
1082
        }
Lines 1009-1015 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec20
1009
        };
1103
        };
1010
1104
1011
        Plan plan(*vm, vector);
1105
        Plan plan(*vm, vector);
1012
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1106
        if (plan.failed()) {
1107
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1108
            CRASH();
1109
        }
1110
1111
        if (plan.resultSize() != 1 || !plan.result(0)) {
1013
            dataLogLn("Module failed to compile correctly.");
1112
            dataLogLn("Module failed to compile correctly.");
1014
            CRASH();
1113
            CRASH();
1015
        }
1114
        }
Lines 1030-1036 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec21
1030
        };
1129
        };
1031
1130
1032
        Plan plan(*vm, vector);
1131
        Plan plan(*vm, vector);
1033
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1132
        if (plan.failed()) {
1133
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1134
            CRASH();
1135
        }
1136
1137
        if (plan.resultSize() != 1 || !plan.result(0)) {
1034
            dataLogLn("Module failed to compile correctly.");
1138
            dataLogLn("Module failed to compile correctly.");
1035
            CRASH();
1139
            CRASH();
1036
        }
1140
        }
Lines 1050-1056 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec22
1050
        };
1154
        };
1051
1155
1052
        Plan plan(*vm, vector);
1156
        Plan plan(*vm, vector);
1053
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1157
        if (plan.failed()) {
1158
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1159
            CRASH();
1160
        }
1161
1162
        if (plan.resultSize() != 1 || !plan.result(0)) {
1054
            dataLogLn("Module failed to compile correctly.");
1163
            dataLogLn("Module failed to compile correctly.");
1055
            CRASH();
1164
            CRASH();
1056
        }
1165
        }
Lines 1070-1076 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec23
1070
        };
1179
        };
1071
1180
1072
        Plan plan(*vm, vector);
1181
        Plan plan(*vm, vector);
1073
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1182
        if (plan.failed()) {
1183
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1184
            CRASH();
1185
        }
1186
1187
        if (plan.resultSize() != 1 || !plan.result(0)) {
1074
            dataLogLn("Module failed to compile correctly.");
1188
            dataLogLn("Module failed to compile correctly.");
1075
            CRASH();
1189
            CRASH();
1076
        }
1190
        }
Lines 1089-1095 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec24
1089
        };
1203
        };
1090
1204
1091
        Plan plan(*vm, vector);
1205
        Plan plan(*vm, vector);
1092
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1206
        if (plan.failed()) {
1207
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1208
            CRASH();
1209
        }
1210
1211
        if (plan.resultSize() != 1 || !plan.result(0)) {
1093
            dataLogLn("Module failed to compile correctly.");
1212
            dataLogLn("Module failed to compile correctly.");
1094
            CRASH();
1213
            CRASH();
1095
        }
1214
        }
Lines 1118-1124 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec25
1118
        };
1237
        };
1119
1238
1120
        Plan plan(*vm, vector);
1239
        Plan plan(*vm, vector);
1121
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1240
        if (plan.failed()) {
1241
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1242
            CRASH();
1243
        }
1244
1245
        if (plan.resultSize() != 1 || !plan.result(0)) {
1122
            dataLogLn("Module failed to compile correctly.");
1246
            dataLogLn("Module failed to compile correctly.");
1123
            CRASH();
1247
            CRASH();
1124
        }
1248
        }
Lines 1154-1160 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec26
1154
        };
1278
        };
1155
1279
1156
        Plan plan(*vm, vector);
1280
        Plan plan(*vm, vector);
1157
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1281
        if (plan.failed()) {
1282
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1283
            CRASH();
1284
        }
1285
1286
        if (plan.resultSize() != 1 || !plan.result(0)) {
1158
            dataLogLn("Module failed to compile correctly.");
1287
            dataLogLn("Module failed to compile correctly.");
1159
            CRASH();
1288
            CRASH();
1160
        }
1289
        }
Lines 1198-1204 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec27
1198
        };
1327
        };
1199
1328
1200
        Plan plan(*vm, vector);
1329
        Plan plan(*vm, vector);
1201
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1330
        if (plan.failed()) {
1331
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1332
            CRASH();
1333
        }
1334
1335
        if (plan.resultSize() != 1 || !plan.result(0)) {
1202
            dataLogLn("Module failed to compile correctly.");
1336
            dataLogLn("Module failed to compile correctly.");
1203
            CRASH();
1337
            CRASH();
1204
        }
1338
        }
Lines 1251-1257 static void runWasmTests() a/Source/JavaScriptCore/testWasm.cpp_sec28
1251
        };
1385
        };
1252
1386
1253
        Plan plan(*vm, vector);
1387
        Plan plan(*vm, vector);
1254
        if (plan.failed() || plan.resultSize() != 1 || !plan.result(0)) {
1388
        if (plan.failed()) {
1389
            dataLogLn("Module failed to compile with error: ", plan.errorMessage());
1390
            CRASH();
1391
        }
1392
1393
        if (plan.resultSize() != 1 || !plan.result(0)) {
1255
            dataLogLn("Module failed to compile correctly.");
1394
            dataLogLn("Module failed to compile correctly.");
1256
            CRASH();
1395
            CRASH();
1257
        }
1396
        }
- a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp -5 / +14 lines
Lines 87-92 private: a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp_sec1
87
        {
87
        {
88
        }
88
        }
89
89
90
        LazyBlock()
91
        {
92
        }
93
90
        explicit operator bool() const { return !!m_block; }
94
        explicit operator bool() const { return !!m_block; }
91
95
92
        BasicBlock* get(Procedure& proc)
96
        BasicBlock* get(Procedure& proc)
Lines 118-123 public: a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp_sec2
118
                result.append(proc.addVariable(toB3Type(signature)));
122
                result.append(proc.addVariable(toB3Type(signature)));
119
        }
123
        }
120
124
125
        ControlData()
126
        {
127
        }
128
121
        void dump(PrintStream& out) const
129
        void dump(PrintStream& out) const
122
        {
130
        {
123
            switch (type()) {
131
            switch (type()) {
Lines 191-198 public: a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp_sec3
191
    // Control flow
199
    // Control flow
192
    ControlData WARN_UNUSED_RETURN addBlock(Type signature);
200
    ControlData WARN_UNUSED_RETURN addBlock(Type signature);
193
    ControlData WARN_UNUSED_RETURN addLoop(Type signature);
201
    ControlData WARN_UNUSED_RETURN addLoop(Type signature);
194
    ControlData WARN_UNUSED_RETURN addIf(ExpressionType condition, Type signature);
202
    bool WARN_UNUSED_RETURN addIf(ExpressionType condition, Type signature, ControlData& result);
195
    bool WARN_UNUSED_RETURN addElse(ControlData&);
203
    bool WARN_UNUSED_RETURN addElse(ControlData&, const ExpressionList&);
196
204
197
    bool WARN_UNUSED_RETURN addReturn(const ExpressionList& returnValues);
205
    bool WARN_UNUSED_RETURN addReturn(const ExpressionList& returnValues);
198
    bool WARN_UNUSED_RETURN addBranch(ControlData&, ExpressionType condition, const ExpressionList& returnValues);
206
    bool WARN_UNUSED_RETURN addBranch(ControlData&, ExpressionType condition, const ExpressionList& returnValues);
Lines 493-499 B3IRGenerator::ControlData B3IRGenerator::addLoop(Type signature) a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp_sec4
493
    return ControlData(m_proc, signature, body);
501
    return ControlData(m_proc, signature, body);
494
}
502
}
495
503
496
B3IRGenerator::ControlData B3IRGenerator::addIf(ExpressionType condition, Type signature)
504
bool B3IRGenerator::addIf(ExpressionType condition, Type signature, ControlType& result)
497
{
505
{
498
    // FIXME: This needs to do some kind of stack passing.
506
    // FIXME: This needs to do some kind of stack passing.
499
507
Lines 507-516 B3IRGenerator::ControlData B3IRGenerator::addIf(ExpressionType condition, Type s a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp_sec5
507
    notTaken->addPredecessor(m_currentBlock);
515
    notTaken->addPredecessor(m_currentBlock);
508
516
509
    m_currentBlock = taken;
517
    m_currentBlock = taken;
510
    return ControlData(m_proc, signature, notTaken, continuation);
518
    result = ControlData(m_proc, signature, notTaken, continuation);
519
    return true;
511
}
520
}
512
521
513
bool B3IRGenerator::addElse(ControlData& data)
522
bool B3IRGenerator::addElse(ControlData& data, const ExpressionList&)
514
{
523
{
515
    ASSERT(data.continuation);
524
    ASSERT(data.continuation);
516
    m_currentBlock = data.special;
525
    m_currentBlock = data.special;
- a/Source/JavaScriptCore/wasm/WasmFormat.cpp +51 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmFormat.cpp_sec1
1
/*
2
 * Copyright (C) 2016 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 "WasmFormat.h"
28
29
#if ENABLE(WEBASSEMBLY)
30
31
namespace JSC { namespace Wasm {
32
33
const char* toString(Type type)
34
{
35
    switch (type) {
36
    case Void:
37
        return "void";
38
    case I32:
39
        return "i32";
40
    case I64:
41
        return "i64";
42
    case F32:
43
        return "f32";
44
    case F64:
45
        return "f64";
46
    }
47
}
48
49
} } // namespace JSC::Wasm
50
51
#endif // ENABLE(B3_JIT)
- a/Source/JavaScriptCore/wasm/WasmFormat.h +1 lines
Lines 97-102 inline bool isValueType(Type type) a/Source/JavaScriptCore/wasm/WasmFormat.h_sec1
97
    return false;
97
    return false;
98
}
98
}
99
99
100
const char* toString(Type);
100
101
101
struct Signature {
102
struct Signature {
102
    Type returnType;
103
    Type returnType;
- a/Source/JavaScriptCore/wasm/WasmFunctionParser.h -3 / +7 lines
Lines 282-293 bool FunctionParser<Context>::parseExpression(OpType op) a/Source/JavaScriptCore/wasm/WasmFunctionParser.h_sec1
282
            return false;
282
            return false;
283
283
284
        ExpressionType condition = m_expressionStack.takeLast();
284
        ExpressionType condition = m_expressionStack.takeLast();
285
        m_controlStack.append(m_context.addIf(condition, inlineSignature));
285
        ControlType control;
286
        if (!m_context.addIf(condition, inlineSignature, control))
287
            return false;
288
289
        m_controlStack.append(control);
286
        return true;
290
        return true;
287
    }
291
    }
288
292
289
    case OpType::Else: {
293
    case OpType::Else: {
290
        return m_context.addElse(m_controlStack.last());
294
        return m_context.addElse(m_controlStack.last(), m_expressionStack);
291
    }
295
    }
292
296
293
    case OpType::Br:
297
    case OpType::Br:
Lines 349-355 bool FunctionParser<Context>::parseUnreachableExpression(OpType op) a/Source/JavaScriptCore/wasm/WasmFunctionParser.h_sec2
349
        ControlType& data = m_controlStack.last();
353
        ControlType& data = m_controlStack.last();
350
        ASSERT(data.type() == BlockType::If);
354
        ASSERT(data.type() == BlockType::If);
351
        m_unreachableBlocks = 0;
355
        m_unreachableBlocks = 0;
352
        return m_context.addElse(data);
356
        return m_context.addElse(data, m_expressionStack);
353
    }
357
    }
354
358
355
    case OpType::End: {
359
    case OpType::End: {
- a/Source/JavaScriptCore/wasm/WasmPlan.cpp +8 lines
Lines 32-37 a/Source/JavaScriptCore/wasm/WasmPlan.cpp_sec1
32
#include "WasmB3IRGenerator.h"
32
#include "WasmB3IRGenerator.h"
33
#include "WasmCallingConvention.h"
33
#include "WasmCallingConvention.h"
34
#include "WasmModuleParser.h"
34
#include "WasmModuleParser.h"
35
#include "WasmValidate.h"
35
#include <wtf/DataLog.h>
36
#include <wtf/DataLog.h>
36
37
37
namespace JSC { namespace Wasm {
38
namespace JSC { namespace Wasm {
Lines 63-68 Plan::Plan(VM& vm, const uint8_t* source, size_t sourceLength) a/Source/JavaScriptCore/wasm/WasmPlan.cpp_sec2
63
        const uint8_t* functionStart = source + info.start;
64
        const uint8_t* functionStart = source + info.start;
64
        size_t functionLength = info.end - info.start;
65
        size_t functionLength = info.end - info.start;
65
        ASSERT(functionLength <= sourceLength);
66
        ASSERT(functionLength <= sourceLength);
67
68
        String error = validateFunction(functionStart, functionLength, info.signature, moduleParser.functionInformation());
69
        if (!error.isNull()) {
70
            m_errorMessage = error;
71
            return;
72
        }
73
66
        m_result.append(parseAndCompile(vm, functionStart, functionLength, moduleParser.memory().get(), info.signature, moduleParser.functionInformation()));
74
        m_result.append(parseAndCompile(vm, functionStart, functionLength, moduleParser.memory().get(), info.signature, moduleParser.functionInformation()));
67
    }
75
    }
68
76
- a/Source/JavaScriptCore/wasm/WasmValidate.cpp +299 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmValidate.cpp_sec1
1
/*
2
 * Copyright (C) 2016 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 "WasmValidate.h"
28
29
#if ENABLE(WEBASSEMBLY)
30
31
#include "WasmFunctionParser.h"
32
33
namespace JSC { namespace Wasm {
34
35
class Validate {
36
public:
37
    class ControlData {
38
    public:
39
        ControlData(BlockType type, Type signature)
40
            : m_blockType(type)
41
            , m_signature(signature)
42
        {
43
        }
44
45
        ControlData()
46
        {
47
        }
48
49
        void dump(PrintStream& out) const
50
        {
51
            switch (type()) {
52
            case BlockType::If:
53
                out.print("If:    ");
54
                break;
55
            case BlockType::Block:
56
                out.print("Block: ");
57
                break;
58
            case BlockType::Loop:
59
                out.print("Loop:  ");
60
                break;
61
            }
62
        }
63
64
        BlockType type() const { return m_blockType; }
65
        Type signature() const { return m_signature; }
66
    private:
67
        BlockType m_blockType;
68
        Type m_signature;
69
    };
70
    typedef Type ExpressionType;
71
    typedef ControlData ControlType;
72
    typedef Vector<ExpressionType, 1> ExpressionList;
73
    static const ExpressionType emptyExpression = Void;
74
75
    void addArguments(const Vector<Type>&);
76
    void addLocal(Type, uint32_t);
77
    ExpressionType addConstant(Type type, uint64_t) { return type; }
78
79
    // Locals
80
    bool WARN_UNUSED_RETURN getLocal(uint32_t index, ExpressionType& result);
81
    bool WARN_UNUSED_RETURN setLocal(uint32_t index, ExpressionType value);
82
83
    // Memory
84
    bool WARN_UNUSED_RETURN load(LoadOpType, ExpressionType pointer, ExpressionType& result, uint32_t offset);
85
    bool WARN_UNUSED_RETURN store(StoreOpType, ExpressionType pointer, ExpressionType value, uint32_t offset);
86
87
    // Basic operators
88
    bool WARN_UNUSED_RETURN binaryOp(BinaryOpType, ExpressionType left, ExpressionType right, ExpressionType& result);
89
    bool WARN_UNUSED_RETURN unaryOp(UnaryOpType, ExpressionType arg, ExpressionType& result);
90
91
    // Control flow
92
    ControlData WARN_UNUSED_RETURN addBlock(Type signature);
93
    ControlData WARN_UNUSED_RETURN addLoop(Type signature);
94
    bool WARN_UNUSED_RETURN addIf(ExpressionType condition, Type signature, ControlData& result);
95
    bool WARN_UNUSED_RETURN addElse(ControlData&, const ExpressionList&);
96
97
    bool WARN_UNUSED_RETURN addReturn(const ExpressionList& returnValues);
98
    bool WARN_UNUSED_RETURN addBranch(ControlData&, ExpressionType condition, const ExpressionList& returnValues);
99
    bool WARN_UNUSED_RETURN endBlock(ControlData&, ExpressionList& expressionStack);
100
101
    bool WARN_UNUSED_RETURN addCall(unsigned calleeIndex, const FunctionInformation&, const Vector<ExpressionType>& args, ExpressionType& result);
102
    bool WARN_UNUSED_RETURN isContinuationReachable(ControlData&) { return true; }
103
104
    void dump(const Vector<ControlType>& controlStack, const ExpressionList& expressionStack);
105
106
    String errorMessage() const { return m_errorMessage; }
107
    Validate(ExpressionType returnType)
108
        : m_returnType(returnType)
109
    {
110
    }
111
112
private:
113
    bool unify(Type, Type);
114
    bool unify(const ExpressionList&, const ControlData&);
115
116
    ExpressionType m_returnType;
117
    Vector<Type> m_locals;
118
    String m_errorMessage;
119
};
120
121
void Validate::addArguments(const Vector<Type>& args)
122
{
123
    for (Type arg : args)
124
        addLocal(arg, 1);
125
}
126
127
void Validate::addLocal(Type type, uint32_t count)
128
{
129
    m_locals.reserveCapacity(m_locals.size() + count);
130
    for (uint32_t i = 0; i < count; ++i)
131
        m_locals.append(type);
132
}
133
134
bool Validate::getLocal(uint32_t index, ExpressionType& result)
135
{
136
    if (index < m_locals.size()) {
137
        result = m_locals[index];
138
        return true;
139
    }
140
    m_errorMessage = ASCIILiteral("Attempt to use unknown local.");
141
    return false;
142
}
143
144
bool Validate::setLocal(uint32_t index, ExpressionType value)
145
{
146
    ExpressionType localType;
147
    if (!getLocal(index, localType))
148
        return false;
149
150
    if (localType == value)
151
        return true;
152
153
    m_errorMessage = makeString("Attempt to set local with type: ", toString(localType), " with a variable of type: ", toString(value));
154
    return false;
155
}
156
157
Validate::ControlType Validate::addBlock(Type signature)
158
{
159
    return ControlData(BlockType::Block, signature);
160
}
161
162
Validate::ControlType Validate::addLoop(Type signature)
163
{
164
    return ControlData(BlockType::Loop, signature);
165
}
166
167
bool Validate::addIf(ExpressionType condition, Type signature, ControlType& result)
168
{
169
    if (condition != I32) {
170
        m_errorMessage = makeString("Attempting to use ", toString(condition), " as the condition for an if block");
171
        return false;
172
    }
173
    result = ControlData(BlockType::If, signature);
174
    return true;
175
}
176
177
bool Validate::addElse(ControlType& current, const ExpressionList& values)
178
{
179
    if (current.type() != BlockType::If) {
180
        m_errorMessage = makeString("Attempting to add else block to something other than an if");
181
        return false;
182
    }
183
184
    if (!unify(values, current)) {
185
        ASSERT(errorMessage());
186
        return false;
187
    }
188
189
    current = ControlData(BlockType::Block, current.signature());
190
    return true;
191
}
192
193
bool Validate::addReturn(const ExpressionList& returnValues)
194
{
195
    if (m_returnType == Void)
196
        return true;
197
    ASSERT(returnValues.size() == 1);
198
199
    if (m_returnType == returnValues[0])
200
        return true;
201
202
    m_errorMessage = makeString("Attempting to add return with type: ", toString(returnValues[0]), " but function expects return with type: ", toString(m_returnType));
203
    return false;
204
}
205
206
bool Validate::addBranch(ControlType& target, ExpressionType condition, const ExpressionList& stack)
207
{
208
    // Void means this is not a conditional branch.
209
    if (condition != Void && condition != I32) {
210
        m_errorMessage = makeString("Attempting to add a conditional branch with condition type: ", toString(condition), " but expected i32.");
211
        return false;
212
    }
213
214
    if (target.type() == BlockType::If)
215
        return true;
216
217
    if (target.signature() == Void)
218
        return true;
219
220
    ASSERT(stack.size() == 1);
221
    if (target.signature() == stack[0])
222
        return true;
223
224
    m_errorMessage = makeString("Attempting to branch to block with expected type: ", toString(target.signature()), " but branching with type: ", toString(target.signature()));
225
    return false;
226
}
227
228
bool Validate::endBlock(ControlType& block, ExpressionList& stack)
229
{
230
    if (block.signature() == Void)
231
        return true;
232
233
234
    ASSERT(stack.size() == 1);
235
    if (block.signature() == stack[0])
236
        return true;
237
238
    m_errorMessage = makeString("Block fallthrough has expected type: ", toString(block.signature()), " but produced type: ", toString(block.signature()));
239
    return false;
240
}
241
242
bool Validate::addCall(unsigned, const FunctionInformation& info, const Vector<ExpressionType>& args, ExpressionType& result)
243
{
244
    if (info.signature->arguments.size() != args.size()) {
245
        m_errorMessage = makeString("Arity mismatch in call");
246
        return false;
247
    }
248
249
    for (unsigned i = 0; i < args.size(); ++i) {
250
        if (args[i] != info.signature->arguments[i]) {
251
            m_errorMessage = makeString("Expected argument type: ", toString(info.signature->arguments[i]), " does not match passed argument type: ", toString(args[i]));
252
            return false;
253
        }
254
    }
255
256
    result = info.signature->returnType;
257
    return true;
258
}
259
260
bool Validate::unify(const ExpressionList& values, const ControlType& block)
261
{
262
    ASSERT(values.size() <= 1);
263
    if (block.signature() == Void)
264
        return true;
265
266
    if (!values.size()) {
267
        m_errorMessage = makeString("Block has non-void signature but has no stack entries on exit");
268
        return false;
269
    }
270
271
    if (values[0] == block.signature())
272
        return true;
273
274
    m_errorMessage = makeString("Expected control flow to return value with type: ", toString(block.signature()), " but got value with type: ", toString(values[0]));
275
    return false;
276
}
277
278
void Validate::dump(const Vector<ControlType>&, const ExpressionList&)
279
{
280
    dataLogLn("Validating");
281
}
282
283
String validateFunction(const uint8_t* source, size_t length, const Signature* signature, const Vector<FunctionInformation>& functions)
284
{
285
    Validate context(signature->returnType);
286
    FunctionParser<Validate> validator(context, source, length, signature, functions);
287
    if (!validator.parse()) {
288
        // FIXME: add better location information here.
289
        return context.errorMessage();
290
    }
291
292
    return String();
293
}
294
295
} } // namespace JSC::Wasm
296
297
#include "WasmValidateInlines.h"
298
299
#endif // ENABLE(WEBASSEMBLY)
- a/Source/JavaScriptCore/wasm/WasmValidate.h +38 lines
Line 0 a/Source/JavaScriptCore/wasm/WasmValidate.h_sec1
1
/*
2
 * Copyright (C) 2016 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
32
namespace JSC { namespace Wasm {
33
34
String validateFunction(const uint8_t*, size_t, const Signature*, const Vector<FunctionInformation>&);
35
36
} } // namespace JSC::Wasm
37
38
#endif // ENABLE(WEBASSEMBLY)
- a/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py +174 lines
Line 0 a/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py_sec1
1
#! /usr/bin/python
2
3
# Copyright (C) 2016 Apple Inc. All rights reserved.
4
#
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# are met:
8
#
9
# 1.  Redistributions of source code must retain the above copyright
10
#     notice, this list of conditions and the following disclaimer.
11
# 2.  Redistributions in binary form must reproduce the above copyright
12
#     notice, this list of conditions and the following disclaimer in the
13
#     documentation and/or other materials provided with the distribution.
14
#
15
# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18
# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26
# This tool has a couple of helpful macros to process Wasm files from the wasm.json.
27
28
from generateWasm import *
29
import optparse
30
import sys
31
32
parser = optparse.OptionParser(usage="usage: %prog <wasm.json> <WasmOps.h>")
33
(options, args) = parser.parse_args(sys.argv[0:])
34
if len(args) != 3:
35
    parser.error(parser.usage)
36
37
wasm = Wasm(args[0], args[1])
38
opcodes = wasm.opcodes
39
wasmValidateInlinesHFile = open(args[2], "w")
40
41
42
def cppType(name):
43
    result = {
44
        "bool": "I32",
45
        "addr": "I32",
46
        "i32": "I32",
47
        "i64": "I64",
48
        "f32": "F32",
49
        "f64": "F64",
50
    }.get(name, None)
51
    if result == None:
52
        raise ValueError("Unknown type name: " + name)
53
    return result
54
55
56
def toCpp(name):
57
    return wasm.toCpp(name)
58
59
60
def unaryMacro(name):
61
    op = opcodes[name]
62
    return """
63
    case UnaryOpType::""" + toCpp(name) + """: {
64
        if (value != """ + cppType(op["parameter"][0]) + """) {
65
            m_errorMessage = makeString(\"""" + name + """ expects the value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(value));
66
            return false;
67
        }
68
69
        result = """ + cppType(op["return"][0]) + """;
70
        return true;
71
    }"""
72
73
74
def binaryMacro(name):
75
    op = opcodes[name]
76
    return """
77
    case BinaryOpType::""" + toCpp(name) + """: {
78
        if (left != """ + cppType(op["parameter"][0]) + """) {
79
            m_errorMessage = makeString(\"""" + name + """ expects the left value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(left));
80
            return false;
81
        }
82
83
        if (right != """ + cppType(op["parameter"][1]) + """) {
84
            m_errorMessage = makeString(\"""" + name + """ expects the right value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(right));
85
            return false;
86
        }
87
88
        result = """ + cppType(op["return"][0]) + """;
89
        return true;
90
    }"""
91
92
93
def loadMacro(name):
94
    op = opcodes[name]
95
    return """
96
    case LoadOpType::""" + toCpp(name) + """: {
97
        if (pointer != """ + cppType(op["parameter"][0]) + """) {
98
            m_errorMessage = makeString(\"""" + name + """ expects the pointer to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(pointer));
99
            return false;
100
        }
101
102
        result = """ + cppType(op["return"][0]) + """;
103
        return true;
104
    }"""
105
106
107
def storeMacro(name):
108
    op = opcodes[name]
109
    return """
110
    case StoreOpType::""" + toCpp(name) + """: {
111
        if (pointer != """ + cppType(op["parameter"][0]) + """) {
112
            m_errorMessage = makeString(\"""" + name + """ expects the pointer to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(pointer));
113
            return false;
114
        }
115
116
        if (value != """ + cppType(op["parameter"][1]) + """) {
117
            m_errorMessage = makeString(\"""" + name + """ expects the value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(value));
118
            return false;
119
        }
120
121
        return true;
122
    }"""
123
124
125
unaryCases = "".join([op for op in wasm.opcodeIterator(isUnary, unaryMacro)])
126
binaryCases = "".join([op for op in wasm.opcodeIterator(isBinary, binaryMacro)])
127
loadCases = "".join([op for op in wasm.opcodeIterator(lambda op: op["category"] == "memory" and len(op["return"]) == 1, loadMacro)])
128
storeCases = "".join([op for op in wasm.opcodeIterator(lambda op: op["category"] == "memory" and len(op["return"]) == 0, storeMacro)])
129
130
contents = wasm.header + """
131
// This file is intended to be inlined by WasmValidate.cpp only! It should not be included elsewhere.
132
133
#pragma once
134
135
#if ENABLE(WEBASSEMBLY)
136
137
namespace JSC { namespace Wasm {
138
139
bool Validate::unaryOp(UnaryOpType op, ExpressionType value, ExpressionType& result)
140
{
141
    switch (op) {
142
""" + unaryCases + """
143
    }
144
}
145
146
bool Validate::binaryOp(BinaryOpType op, ExpressionType left, ExpressionType right, ExpressionType& result)
147
{
148
    switch (op) {
149
""" + binaryCases + """
150
    }
151
}
152
153
bool Validate::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t)
154
{
155
    switch (op) {
156
""" + loadCases + """
157
    }
158
}
159
160
bool Validate::store(StoreOpType op, ExpressionType pointer, ExpressionType value, uint32_t)
161
{
162
    switch (op) {
163
""" + storeCases + """
164
    }
165
}
166
167
} } // namespace JSC::Wasm
168
169
#endif // ENABLE(WEBASSEMBLY)
170
171
"""
172
173
wasmValidateInlinesHFile.write(contents)
174
wasmValidateInlinesHFile.close()

Return to Bug 161707