Skip to content

Commit

Permalink
generated bit casts
Browse files Browse the repository at this point in the history
  • Loading branch information
dylan-conway committed Nov 22, 2024
1 parent 2c28d33 commit 3b86b8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/generator/Argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def setter(traits)
{
if (!#{Fits::check "size", "value", @type})
value = func();
auto* stream = std::bit_cast<typename TypeBySize<size>::unsignedType*>(reinterpret_cast<uint8_t*>(this) + #{@index} * size + PaddingBySize<size>::value + OpcodeIDWidthBySize<#{traits}, size>::opcodeIDSize);
auto* stream = __bit_cast<typename TypeBySize<size>::unsignedType*>(reinterpret_cast<uint8_t*>(this) + #{@index} * size + PaddingBySize<size>::value + OpcodeIDWidthBySize<#{traits}, size>::opcodeIDSize);
*stream = #{Fits::convert "size", "value", @type};
}
EOF
Expand Down
10 changes: 5 additions & 5 deletions Source/JavaScriptCore/generator/Opcode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,29 +290,29 @@ def constructors
#{capitalized_name}(const uint8_t* stream)
#{init.call("OpcodeSize::Narrow")}
{
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(std::bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Narrow>::opcodeType*>(stream)[-1]) == opcodeID);
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(__bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Narrow>::opcodeType*>(stream)[-1]) == opcodeID);
}
#{capitalized_name}(const uint16_t* stream)
#{init.call("OpcodeSize::Wide16")}
{
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(std::bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide16>::opcodeType*>(stream)[-1]) == opcodeID);
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(__bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide16>::opcodeType*>(stream)[-1]) == opcodeID);
}
#{capitalized_name}(const uint32_t* stream)
#{init.call("OpcodeSize::Wide32")}
{
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(std::bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide32>::opcodeType*>(stream)[-1]) == opcodeID);
ASSERT_UNUSED(stream, static_cast<#{opcodeIDType}>(__bit_cast<const typename OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide32>::opcodeType*>(stream)[-1]) == opcodeID);
}
static #{capitalized_name} decode(const uint8_t* stream)
{
// A pointer is pointing to the first operand (opcode and prefix are not included).
if (*stream == #{wide32})
return { std::bit_cast<const uint32_t*>(stream + /* prefix */ 1 + OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide32>::opcodeIDSize) };
return { __bit_cast<const uint32_t*>(stream + /* prefix */ 1 + OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide32>::opcodeIDSize) };
if (*stream == #{wide16})
return { std::bit_cast<const uint16_t*>(stream + /* prefix */ 1 + OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide16>::opcodeIDSize) };
return { __bit_cast<const uint16_t*>(stream + /* prefix */ 1 + OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Wide16>::opcodeIDSize) };
return { stream + OpcodeIDWidthBySize<#{type_prefix}OpcodeTraits, OpcodeSize::Narrow>::opcodeIDSize };
}
EOF
Expand Down

0 comments on commit 3b86b8c

Please sign in to comment.