Title: [293265] trunk/Source/_javascript_Core
- Revision
- 293265
- Author
- [email protected]
- Date
- 2022-04-22 16:21:38 -0700 (Fri, 22 Apr 2022)
Log Message
[Refactoring] Reduce number of const and reinterpret casts
https://bugs.webkit.org/show_bug.cgi?id=239648
Reviewed by Yusuke Suzuki.
The statement
"reinterpret_cast<TypeDefinition*>(const_cast<char*>(functionType.m_payload)
- sizeof(TypeDefinition))"
is dangerous and it produces warning on some platfroms.
There is way to avoid it and this patch is doint that.
* wasm/WasmSlowPaths.cpp:
(JSC::LLInt::doWasmCallIndirect):
(JSC::LLInt::doWasmCallRef):
* wasm/WasmTypeDefinition.h:
(JSC::Wasm::FunctionSignature::operator== const):
* wasm/WasmTypeDefinitionInlines.h:
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (293264 => 293265)
--- trunk/Source/_javascript_Core/ChangeLog 2022-04-22 23:19:24 UTC (rev 293264)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-04-22 23:21:38 UTC (rev 293265)
@@ -1,3 +1,23 @@
+2022-04-22 Dmitry Bezhetskov <[email protected]>
+
+ [Refactoring] Reduce number of const and reinterpret casts
+ https://bugs.webkit.org/show_bug.cgi?id=239648
+
+ Reviewed by Yusuke Suzuki.
+
+ The statement
+ "reinterpret_cast<TypeDefinition*>(const_cast<char*>(functionType.m_payload)
+ - sizeof(TypeDefinition))"
+ is dangerous and it produces warning on some platfroms.
+ There is way to avoid it and this patch is doint that.
+
+ * wasm/WasmSlowPaths.cpp:
+ (JSC::LLInt::doWasmCallIndirect):
+ (JSC::LLInt::doWasmCallRef):
+ * wasm/WasmTypeDefinition.h:
+ (JSC::Wasm::FunctionSignature::operator== const):
+ * wasm/WasmTypeDefinitionInlines.h:
+
2022-04-22 Geza Lore <[email protected]>
[JSC]Throw consistent exceptions for memory.init and memory.copy
Modified: trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp (293264 => 293265)
--- trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2022-04-22 23:19:24 UTC (rev 293264)
+++ trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2022-04-22 23:21:38 UTC (rev 293265)
@@ -500,7 +500,7 @@
WASM_THROW(Wasm::ExceptionType::NullTableEntry);
const auto& callSignature = CALLEE()->signature(typeIndex);
- if (function.typeIndex != Wasm::TypeInformation::get(callSignature))
+ if (callSignature != Wasm::TypeInformation::getFunctionSignature(function.typeIndex))
WASM_THROW(Wasm::ExceptionType::BadSignature);
if (targetInstance != instance)
@@ -541,7 +541,7 @@
if (calleeInstance != callerInstance)
calleeInstance->setCachedStackLimit(callerInstance->cachedStackLimit());
- ASSERT(function.typeIndex == Wasm::TypeInformation::get(CALLEE()->signature(typeIndex)));
+ ASSERT(Wasm::TypeInformation::getFunctionSignature(function.typeIndex) == CALLEE()->signature(typeIndex));
UNUSED_PARAM(typeIndex);
WASM_CALL_RETURN(calleeInstance, function.entrypointLoadLocation->executableAddress(), WasmEntryPtrTag);
}
Modified: trunk/Source/_javascript_Core/wasm/WasmTypeDefinition.h (293264 => 293265)
--- trunk/Source/_javascript_Core/wasm/WasmTypeDefinition.h 2022-04-22 23:19:24 UTC (rev 293264)
+++ trunk/Source/_javascript_Core/wasm/WasmTypeDefinition.h 2022-04-22 23:21:38 UTC (rev 293265)
@@ -60,6 +60,14 @@
bool returnsVoid() const { return !returnCount(); }
Type argumentType(FunctionArgCount i) const { return const_cast<FunctionSignature*>(this)->getArgumentType(i); }
+ bool operator==(const FunctionSignature& other) const
+ {
+ // Function signatures are unique because it is just an view class over TypeDefinition and
+ // so, we can compare two signatures with just payload pointers comparision.
+ // Other checks probably aren't necessary but it's good to be paranoid.
+ return m_payload == other.m_payload && m_argCount == other.m_argCount && m_retCount == other.m_retCount;
+ }
+
WTF::String toString() const;
void dump(WTF::PrintStream& out) const;
@@ -217,7 +225,6 @@
static const TypeDefinition& get(TypeIndex);
static TypeIndex get(const TypeDefinition&);
- static TypeIndex get(const FunctionSignature&);
static const FunctionSignature& getFunctionSignature(TypeIndex);
static void tryCleanup();
Modified: trunk/Source/_javascript_Core/wasm/WasmTypeDefinitionInlines.h (293264 => 293265)
--- trunk/Source/_javascript_Core/wasm/WasmTypeDefinitionInlines.h 2022-04-22 23:19:24 UTC (rev 293264)
+++ trunk/Source/_javascript_Core/wasm/WasmTypeDefinitionInlines.h 2022-04-22 23:21:38 UTC (rev 293265)
@@ -64,11 +64,6 @@
return bitwise_cast<TypeIndex>(&type);
}
-inline TypeIndex TypeInformation::get(const FunctionSignature& functionType)
-{
- return get(*reinterpret_cast<TypeDefinition*>(const_cast<char*>(functionType.m_payload) - sizeof(TypeDefinition)));
-}
-
} } // namespace JSC::Wasm
#endif // ENABLE(WEBASSEMBLY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes