Changeset 209880 in webkit for trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py
- Timestamp:
- Dec 15, 2016, 3:42:19 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wasm/generateWasmValidateInlinesHeader.py
r209630 r209880 61 61 op = opcodes[name] 62 62 return """ 63 template<> bool Validate::addOp<OpType::""" + toCpp(name) + """>(ExpressionType value, ExpressionType& result)63 template<> auto Validate::addOp<OpType::""" + toCpp(name) + """>(ExpressionType value, ExpressionType& result) -> Result 64 64 { 65 if (value != """ + cppType(op["parameter"][0]) + """) { 66 m_errorMessage = makeString(\"""" + name + """ expects the value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(value)); 67 return false; 68 } 65 if (UNLIKELY(value != """ + cppType(op["parameter"][0]) + """)) 66 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ value type mismatch"); 69 67 70 68 result = """ + cppType(op["return"][0]) + """; 71 return true;69 return { }; 72 70 } 73 71 """ … … 77 75 op = opcodes[name] 78 76 return """ 79 template<> bool Validate::addOp<OpType::""" + toCpp(name) + """>(ExpressionType left, ExpressionType right, ExpressionType& result)77 template<> auto Validate::addOp<OpType::""" + toCpp(name) + """>(ExpressionType left, ExpressionType right, ExpressionType& result) -> Result 80 78 { 81 if (left != """ + cppType(op["parameter"][0]) + """) { 82 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)); 83 return false; 84 } 79 if (UNLIKELY(left != """ + cppType(op["parameter"][0]) + """)) 80 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ left value type mismatch"); 85 81 86 if (right != """ + cppType(op["parameter"][1]) + """) { 87 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)); 88 return false; 89 } 82 if (UNLIKELY(right != """ + cppType(op["parameter"][1]) + """)) 83 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ right value type mismatch"); 90 84 91 85 result = """ + cppType(op["return"][0]) + """; 92 return true;86 return { }; 93 87 } 94 88 """ … … 98 92 return """ 99 93 case LoadOpType::""" + toCpp(name) + """: { 100 if (pointer != """ + cppType(op["parameter"][0]) + """) { 101 m_errorMessage = makeString(\"""" + name + """ expects the pointer to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(pointer)); 102 return false; 103 } 94 if (UNLIKELY(pointer != """ + cppType(op["parameter"][0]) + """)) 95 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ pointer type mismatch"); 104 96 105 97 result = """ + cppType(op["return"][0]) + """; 106 return true;98 return { }; 107 99 }""" 108 100 … … 112 104 return """ 113 105 case StoreOpType::""" + toCpp(name) + """: { 114 if (pointer != """ + cppType(op["parameter"][0]) + """) { 115 m_errorMessage = makeString(\"""" + name + """ expects the pointer to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(pointer)); 116 return false; 117 } 106 if (UNLIKELY(pointer != """ + cppType(op["parameter"][0]) + """)) 107 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ pointer type mismatch"); 118 108 119 if (value != """ + cppType(op["parameter"][1]) + """) { 120 m_errorMessage = makeString(\"""" + name + """ expects the value to be of type: ", toString(""" + cppType(op["parameter"][0]) + """), " but got a value with type: ", toString(value)); 121 return false; 122 } 109 if (UNLIKELY(value != """ + cppType(op["parameter"][1]) + """)) 110 return UnexpectedType<Result::ErrorType>("validation failed: """ + name + """ value type mismatch"); 123 111 124 return true;112 return { }; 125 113 }""" 126 114 … … 142 130 """ + unarySpecializations + binarySpecializations + """ 143 131 144 bool Validate::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t) 132 auto Validate::load(LoadOpType op, ExpressionType pointer, ExpressionType& result, uint32_t) -> Result 145 133 { 146 if ( !hasMemory())147 return false;134 if (UNLIKELY(!hasMemory())) 135 return UnexpectedType<Result::ErrorType>("validation failed: load instruction without memory"); 148 136 149 137 switch (op) { … … 152 140 } 153 141 154 bool Validate::store(StoreOpType op, ExpressionType pointer, ExpressionType value, uint32_t) 142 auto Validate::store(StoreOpType op, ExpressionType pointer, ExpressionType value, uint32_t) -> Result 155 143 { 156 if ( !hasMemory())157 return false;144 if (UNLIKELY(!hasMemory())) 145 return UnexpectedType<Result::ErrorType>("validation failed: store instruction without memory"); 158 146 159 147 switch (op) {
Note:
See TracChangeset
for help on using the changeset viewer.