Commit 148e7076 authored by jkummerow's avatar jkummerow Committed by Commit bot

Turn on -Wmissing-field-initializers on Linux.

Because not initializing fields can be, you know, dangerous.

Review-Url: https://codereview.chromium.org/1952703002
Cr-Commit-Position: refs/heads/master@{#36071}
parent 1d941a44
......@@ -710,8 +710,7 @@
'-Wno-long-long',
'-pthread',
'-pedantic',
# Don't warn about the "struct foo f = {0};" initialization pattern.
'-Wno-missing-field-initializers',
'-Wmissing-field-initializers',
'-Wno-gnu-zero-variadic-macro-arguments',
],
'cflags_cc': [
......
......@@ -165,8 +165,19 @@ class ModuleDecoder : public Decoder {
uint32_t functions_count = consume_u32v(&length, "functions count");
module->functions.reserve(SafeReserve(functions_count));
for (uint32_t i = 0; i < functions_count; i++) {
module->functions.push_back(
{nullptr, i, 0, 0, 0, 0, 0, 0, false, false});
module->functions.push_back({nullptr, // sig
i, // func_index
0, // sig_index
0, // name_offset
0, // name_length
0, // code_start_offset
0, // code_end_offset
0, // local_i32_count
0, // local_i64_count
0, // local_f32_count
0, // local_f64_count
false, // exported
false}); // external
WasmFunction* function = &module->functions.back();
function->sig_index = consume_sig_index(module, &function->sig);
}
......@@ -213,8 +224,19 @@ class ModuleDecoder : public Decoder {
TRACE("DecodeFunction[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->functions.push_back(
{nullptr, i, 0, 0, 0, 0, 0, 0, false, false});
module->functions.push_back({nullptr, // sig
i, // func_index
0, // sig_index
0, // name_offset
0, // name_length
0, // code_start_offset
0, // code_end_offset
0, // local_i32_count
0, // local_i64_count
0, // local_f32_count
0, // local_f64_count
false, // exported
false}); // external
WasmFunction* function = &module->functions.back();
DecodeFunctionInModule(module, function, false);
}
......@@ -283,7 +305,10 @@ class ModuleDecoder : public Decoder {
if (failed()) break;
TRACE("DecodeDataSegment[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->data_segments.push_back({0, 0, 0});
module->data_segments.push_back({0, // dest_addr
0, // source_offset
0, // source_size
false}); // init
WasmDataSegment* segment = &module->data_segments.back();
DecodeDataSegmentInModule(module, segment);
}
......@@ -337,7 +362,12 @@ class ModuleDecoder : public Decoder {
TRACE("DecodeImportTable[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->import_table.push_back({nullptr, 0, 0});
module->import_table.push_back({nullptr, // sig
0, // sig_index
0, // module_name_offset
0, // module_name_length
0, // function_name_offset
0}); // function_name_length
WasmImport* import = &module->import_table.back();
import->sig_index = consume_sig_index(module, &import->sig);
......@@ -365,7 +395,9 @@ class ModuleDecoder : public Decoder {
TRACE("DecodeExportTable[%d] module+%d\n", i,
static_cast<int>(pc_ - start_));
module->export_table.push_back({0, 0});
module->export_table.push_back({0, // func_index
0, // name_offset
0}); // name_length
WasmExport* exp = &module->export_table.back();
WasmFunction* func;
......
......@@ -107,9 +107,9 @@ class ChangeLoweringCommonTest
};
TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) {
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(),
MachineType::AnyTagged()};
FieldAccess access = {
kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
Type::Any(), MachineType::AnyTagged(), kNoWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::TaggedSigned());
Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
......@@ -126,9 +126,9 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) {
TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) {
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(),
MachineType::AnyTagged()};
FieldAccess access = {
kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
Type::Any(), MachineType::AnyTagged(), kFullWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::Tagged());
Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
......@@ -145,9 +145,9 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) {
TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) {
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(),
MachineType::AnyTagged()};
FieldAccess access = {
kTaggedBase, FixedArrayBase::kHeaderSize, Handle<Name>::null(),
Type::Any(), MachineType::AnyTagged(), kNoWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* load = graph()->NewNode(simplified()->LoadField(access), p0,
graph()->start(), graph()->start());
......@@ -164,7 +164,7 @@ TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) {
TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) {
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
MachineType::AnyTagged()};
MachineType::AnyTagged(), kFullWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::Signed32());
Node* p2 = Parameter(Type::Tagged());
......@@ -191,7 +191,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) {
TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) {
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Type::Signed32(), MachineType::Uint8()};
Type::Signed32(), MachineType::Uint8(),
kNoWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::Signed32());
Node* p2 = Parameter(Type::Signed32());
......@@ -215,7 +216,7 @@ TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) {
TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) {
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
MachineType::AnyTagged()};
MachineType::AnyTagged(), kNoWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::Signed32());
Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
......@@ -239,7 +240,8 @@ TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) {
TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) {
ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Type::Signed32(), MachineType::Int8()};
Type::Signed32(), MachineType::Int8(),
kNoWriteBarrier};
Node* p0 = Parameter(Type::TaggedPointer());
Node* p1 = Parameter(Type::Signed32());
Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
......
......@@ -146,14 +146,18 @@ class EscapeAnalysisTest : public GraphTest {
}
FieldAccess FieldAccessAtIndex(int offset) {
FieldAccess access = {kTaggedBase, offset, MaybeHandle<Name>(), Type::Any(),
MachineType::AnyTagged()};
FieldAccess access = {kTaggedBase,
offset,
MaybeHandle<Name>(),
Type::Any(),
MachineType::AnyTagged(),
kFullWriteBarrier};
return access;
}
ElementAccess MakeElementAccess(int header_size) {
ElementAccess access = {kTaggedBase, header_size, Type::Any(),
MachineType::AnyTagged()};
MachineType::AnyTagged(), kFullWriteBarrier};
return access;
}
......
......@@ -203,39 +203,46 @@ namespace {
const ElementAccess kElementAccesses[] = {
{kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
MachineType::AnyTagged()},
{kUntaggedBase, 0, Type::Any(), MachineType::Int8()},
{kUntaggedBase, 0, Type::Any(), MachineType::Int16()},
{kUntaggedBase, 0, Type::Any(), MachineType::Int32()},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint8()},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint16()},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint32()},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int8()},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint8()},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int16()},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint16()},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int32()},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint32()},
MachineType::AnyTagged(), kFullWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Int8(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Int16(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Int32(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint8(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint16(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Any(), MachineType::Uint32(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int8(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint8(),
kNoWriteBarrier},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int16(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint16(),
kNoWriteBarrier},
{kUntaggedBase, 0, Type::Signed32(), MachineType::Int32(), kNoWriteBarrier},
{kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint32(),
kNoWriteBarrier},
{kUntaggedBase, 0, Type::Number(),
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)},
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
kNoWriteBarrier},
{kUntaggedBase, 0, Type::Number(),
MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone)},
MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone),
kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
MachineType::Int8()},
MachineType::Int8(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
MachineType::Uint8()},
MachineType::Uint8(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
MachineType::Int16()},
MachineType::Int16(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
MachineType::Uint16()},
MachineType::Uint16(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
MachineType::Int32()},
MachineType::Int32(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
MachineType::Uint32()},
MachineType::Uint32(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)},
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)}};
MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
kNoWriteBarrier}};
} // namespace
......
......@@ -1140,12 +1140,29 @@ class TestModuleEnv : public ModuleEnv {
return static_cast<byte>(mod.signatures.size() - 1);
}
byte AddFunction(FunctionSig* sig) {
mod.functions.push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false});
mod.functions.push_back({sig, // sig
0, // func_index
0, // sig_index
0, // name_offset
0, // name_length
0, // code_start_offset
0, // code_end_offset
0, // local_i32_count
0, // local_i64_count
0, // local_f32_count
0, // local_f64_count
false, // exported
false}); // external
CHECK(mod.functions.size() <= 127);
return static_cast<byte>(mod.functions.size() - 1);
}
byte AddImport(FunctionSig* sig) {
mod.import_table.push_back({sig, 0, 0});
mod.import_table.push_back({sig, // sig
0, // sig_index
0, // module_name_offset
0, // module_name_length
0, // function_name_offset
0}); // function_name_length
CHECK(mod.import_table.size() <= 127);
return static_cast<byte>(mod.import_table.size() - 1);
}
......
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