Skip to content

Commit cd4b722

Browse files
Junliang YanCommit Bot
authored andcommitted
PPC/s390: Fix undefined behaviour on CommentOperator
Port 1995335 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. [email protected], [email protected], [email protected] BUG= LOG=N Change-Id: Ia7976ec9a726fdeb7d8bfbb99c8a16d473aa0da4 Reviewed-on: https://chromium-review.googlesource.com/1157230 Reviewed-by: Muntasir Mallick <[email protected]> Commit-Queue: Junliang Yan <[email protected]> Cr-Commit-Position: refs/heads/master@{#54828}
1 parent f95b263 commit cd4b722

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/compiler/ppc/code-generator-ppc.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,11 +1057,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
10571057
case kArchPrepareTailCall:
10581058
AssemblePrepareTailCall();
10591059
break;
1060-
case kArchComment: {
1061-
Address comment_string = i.InputExternalReference(0).address();
1062-
__ RecordComment(reinterpret_cast<const char*>(comment_string));
1060+
case kArchComment:
1061+
#ifdef V8_TARGET_ARCH_PPC64
1062+
__ RecordComment(reinterpret_cast<const char*>(i.InputInt64(0)));
1063+
#else
1064+
__ RecordComment(reinterpret_cast<const char*>(i.InputInt32(0)));
1065+
#endif
10631066
break;
1064-
}
10651067
case kArchCallCFunction: {
10661068
int const num_parameters = MiscField::decode(instr->opcode());
10671069
if (instr->InputAt(0)->IsImmediate()) {

src/compiler/s390/code-generator-s390.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,11 +1348,13 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
13481348
ArchOpcode opcode = ArchOpcodeField::decode(instr->opcode());
13491349

13501350
switch (opcode) {
1351-
case kArchComment: {
1352-
Address comment_string = i.InputExternalReference(0).address();
1353-
__ RecordComment(reinterpret_cast<const char*>(comment_string));
1351+
case kArchComment:
1352+
#ifdef V8_TARGET_ARCH_S390X
1353+
__ RecordComment(reinterpret_cast<const char*>(i.InputInt64(0)));
1354+
#else
1355+
__ RecordComment(reinterpret_cast<const char*>(i.InputInt32(0)));
1356+
#endif
13541357
break;
1355-
}
13561358
case kArchCallCodeObject: {
13571359
if (HasRegisterInput(instr, 0)) {
13581360
Register reg = i.InputRegister(0);

0 commit comments

Comments
 (0)