Commit d1f42cce authored by Seth Brenith's avatar Seth Brenith Committed by Commit Bot

Use correctly sized offset in basic block instrumentation

The graph verifer caught this bug. The offset in a load instruction
should be pointer-sized.

Bug: v8:10605
Change-Id: I816165c9c9ef4f0d7fbdcaf9c70faf845dbbb9fd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2238016Reviewed-by: 's avatarGeorg Neis <neis@chromium.org>
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#68324}
parent a75c4be6
...@@ -37,13 +37,18 @@ static NodeVector::iterator FindInsertionPoint(BasicBlock* block) { ...@@ -37,13 +37,18 @@ static NodeVector::iterator FindInsertionPoint(BasicBlock* block) {
return i; return i;
} }
static const Operator* IntPtrConstant(CommonOperatorBuilder* common,
intptr_t value) {
return kSystemPointerSize == 8
? common->Int64Constant(value)
: common->Int32Constant(static_cast<int32_t>(value));
}
// TODO(dcarney): need to mark code as non-serializable. // TODO(dcarney): need to mark code as non-serializable.
static const Operator* PointerConstant(CommonOperatorBuilder* common, static const Operator* PointerConstant(CommonOperatorBuilder* common,
const void* ptr) { const void* ptr) {
intptr_t ptr_as_int = reinterpret_cast<intptr_t>(ptr); intptr_t ptr_as_int = reinterpret_cast<intptr_t>(ptr);
return kSystemPointerSize == 8 return IntPtrConstant(common, ptr_as_int);
? common->Int64Constant(ptr_as_int)
: common->Int32Constant(static_cast<int32_t>(ptr_as_int));
} }
BasicBlockProfilerData* BasicBlockInstrumentor::Instrument( BasicBlockProfilerData* BasicBlockInstrumentor::Instrument(
...@@ -102,7 +107,7 @@ BasicBlockProfilerData* BasicBlockInstrumentor::Instrument( ...@@ -102,7 +107,7 @@ BasicBlockProfilerData* BasicBlockInstrumentor::Instrument(
offset_to_counter_value += ByteArray::kHeaderSize - kHeapObjectTag; offset_to_counter_value += ByteArray::kHeaderSize - kHeapObjectTag;
} }
Node* offset_to_counter = Node* offset_to_counter =
graph->NewNode(common.Int32Constant(offset_to_counter_value)); graph->NewNode(IntPtrConstant(&common, offset_to_counter_value));
Node* load = Node* load =
graph->NewNode(machine.Load(MachineType::Uint32()), counters_array, graph->NewNode(machine.Load(MachineType::Uint32()), counters_array,
offset_to_counter, graph->start(), graph->start()); offset_to_counter, graph->start(), graph->start());
......
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