Commit cd4b7228 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: Fix undefined behaviour on CommentOperator

Port 19953355

Original Commit Message:

    The {CommentOperator}, used for implementing the --code-comments flag,
    is not UBSan-safe. This CL fixes this and adds a test which uses code
    comments.

R=clemensh@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ia7976ec9a726fdeb7d8bfbb99c8a16d473aa0da4
Reviewed-on: https://chromium-review.googlesource.com/1157230Reviewed-by: 's avatarMuntasir Mallick <mmallick@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#54828}
parent f95b2632
......@@ -1057,11 +1057,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchPrepareTailCall:
AssemblePrepareTailCall();
break;
case kArchComment: {
Address comment_string = i.InputExternalReference(0).address();
__ RecordComment(reinterpret_cast<const char*>(comment_string));
case kArchComment:
#ifdef V8_TARGET_ARCH_PPC64
__ RecordComment(reinterpret_cast<const char*>(i.InputInt64(0)));
#else
__ RecordComment(reinterpret_cast<const char*>(i.InputInt32(0)));
#endif
break;
}
case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode());
if (instr->InputAt(0)->IsImmediate()) {
......
......@@ -1348,11 +1348,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode());
switch (opcode) {
case kArchComment: {
Address comment_string = i.InputExternalReference(0).address();
__ RecordComment(reinterpret_cast<const char*>(comment_string));
case kArchComment:
#ifdef V8_TARGET_ARCH_S390X
__ RecordComment(reinterpret_cast<const char*>(i.InputInt64(0)));
#else
__ RecordComment(reinterpret_cast<const char*>(i.InputInt32(0)));
#endif
break;
}
case kArchCallCodeObject: {
if (HasRegisterInput(instr, 0)) {
Register reg = i.InputRegister(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment