Commit e67f5cf4 authored by pcc's avatar pcc Committed by Commit bot

Read all integer op parameters using a signed integer type.

The code was previously reading unsigned integers by performing an invalid cast
of Operator1<intNN_t> objects to Operator1<uintNN_t> and reading the integer
directly. To fix the invalid cast, we cast to the correct type and static_cast
the integer to uintNN_t, which is a no-op on every reasonable target.

Cleanup for cfi_vptr=1; see https://www.chromium.org/developers/testing/control-flow-integrity

BUG=chromium:457523
R=bmeurer@chromium.org
LOG=N

Review URL: https://codereview.chromium.org/1310633004

Cr-Commit-Position: refs/heads/master@{#30499}
parent 8937bfc1
......@@ -68,6 +68,18 @@ struct ValueMatcher : public NodeMatcher {
};
template <>
inline ValueMatcher<uint32_t, IrOpcode::kInt32Constant>::ValueMatcher(
Node* node)
: NodeMatcher(node),
value_(),
has_value_(opcode() == IrOpcode::kInt32Constant) {
if (has_value_) {
value_ = static_cast<uint32_t>(OpParameter<int32_t>(node));
}
}
template <>
inline ValueMatcher<int64_t, IrOpcode::kInt64Constant>::ValueMatcher(Node* node)
: NodeMatcher(node), value_(), has_value_(false) {
......@@ -86,10 +98,10 @@ inline ValueMatcher<uint64_t, IrOpcode::kInt64Constant>::ValueMatcher(
Node* node)
: NodeMatcher(node), value_(), has_value_(false) {
if (opcode() == IrOpcode::kInt32Constant) {
value_ = OpParameter<uint32_t>(node);
value_ = static_cast<uint32_t>(OpParameter<int32_t>(node));
has_value_ = true;
} else if (opcode() == IrOpcode::kInt64Constant) {
value_ = OpParameter<uint64_t>(node);
value_ = static_cast<uint64_t>(OpParameter<int64_t>(node));
has_value_ = true;
}
}
......
......@@ -75,7 +75,7 @@ class RepresentationChanger {
return node; // No change necessary.
case IrOpcode::kInt32Constant:
if (output_type & kTypeUint32) {
uint32_t value = OpParameter<uint32_t>(node);
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Constant(static_cast<double>(value));
} else if (output_type & kTypeInt32) {
int32_t value = OpParameter<int32_t>(node);
......@@ -125,7 +125,7 @@ class RepresentationChanger {
DoubleToFloat32(OpParameter<double>(node)));
case IrOpcode::kInt32Constant:
if (output_type & kTypeUint32) {
uint32_t value = OpParameter<uint32_t>(node);
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Float32Constant(static_cast<float>(value));
} else {
int32_t value = OpParameter<int32_t>(node);
......@@ -169,7 +169,7 @@ class RepresentationChanger {
return jsgraph()->Float64Constant(OpParameter<double>(node));
case IrOpcode::kInt32Constant:
if (output_type & kTypeUint32) {
uint32_t value = OpParameter<uint32_t>(node);
uint32_t value = static_cast<uint32_t>(OpParameter<int32_t>(node));
return jsgraph()->Float64Constant(static_cast<double>(value));
} else {
int32_t value = OpParameter<int32_t>(node);
......
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