[torque] Fix and test broken non-tagged class fields stores

Bug: v8:7793
Change-Id: Iaf3941b76e261308f656fb92b3c53e6cab5ad350
Reviewed-on: https://chromium-review.googlesource.com/c/1454476
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59356}
This commit is contained in:
Daniel Clifford 2019-02-05 09:13:12 +01:00 committed by Commit Bot
parent 44ffcca488
commit dc15a1eefa
3 changed files with 45 additions and 5 deletions

View File

@ -708,12 +708,26 @@ void CSAGenerator::EmitInstruction(
stack->Push(value);
const Field& field =
instruction.class_type->LookupField(instruction.field_name);
if (field.offset == 0) {
out_ << " CodeStubAssembler(state_).StoreMap(" + object + ", " + value +
");\n";
if (field.name_and_type.type->IsSubtypeOf(TypeOracle::GetTaggedType())) {
if (field.offset == 0) {
out_ << " CodeStubAssembler(state_).StoreMap(" + object + ", " +
value + ");\n";
} else {
out_ << " CodeStubAssembler(state_).StoreObjectField(" + object +
", " + std::to_string(field.offset) + ", " + value + ");\n";
}
} else {
out_ << " CodeStubAssembler(state_).StoreObjectField(" + object + ", " +
std::to_string(field.offset) + ", " + value + ");\n";
size_t field_size;
std::string size_string;
std::string machine_type;
std::tie(field_size, size_string, machine_type) =
field.GetFieldSizeInformation();
if (field.offset == 0) {
ReportError("the first field in a class object must be a map");
}
out_ << " CodeStubAssembler(state_).StoreObjectFieldNoWriteBarrier("
<< object << ", " << std::to_string(field.offset) + ", " << value
<< ", " << machine_type << ".representation());\n";
}
}

View File

@ -160,6 +160,9 @@ struct NameAndType {
std::ostream& operator<<(std::ostream& os, const NameAndType& name_and_type);
struct Field {
// TODO(danno): This likely should be refactored, the handling of the types
// using the universal grab-bag utility with std::tie, as well as the
// reliance of string types is quite clunky.
std::tuple<size_t, std::string, std::string> GetFieldSizeInformation() const;
SourcePosition pos;

View File

@ -782,4 +782,27 @@ namespace test {
h: intptr;
i: uintptr;
}
macro TestClassWithAllTypesLoadsAndStores(
t: TestClassWithAllTypes, r: RawPtr, v1: int8, v2: uint8, v3: int16,
v4: uint16) {
t.a = v1;
t.b = v2;
t.c = v3;
t.d = v4;
t.e = 0;
t.f = 0;
t.g = r;
t.h = 0;
t.i = 0;
t.a = t.a;
t.b = t.b;
t.c = t.c;
t.d = t.d;
t.e = t.e;
t.f = t.f;
t.g = t.g;
t.h = t.h;
t.i = t.i;
}
}