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

[torque] Add @relaxedRead annotation

When generating getters, Torque needs to decide whether to perform a
normal or relaxed load. Thus far, it has used the somewhat non-obvious
logic that any indexed field with tagged non-smi data gets relaxed
loads. This change adds a new annotation @relaxedRead to be consistent
with the existing @relaxedWrite annotation. I added @relaxedRead
annotations on any field that previously had this automatic behavior and
whose getter is called, except for those in ScopeInfo because I'm
relatively confident that it doesn't need relaxed access.

Bug: v8:7793
Change-Id: I9987eea13760b967f1b8a3189b69742e55140c30
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2600113
Commit-Queue: Seth Brenith <seth.brenith@microsoft.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72499}
parent b84baffb
...@@ -80,7 +80,7 @@ extern shape JSStrictArgumentsObject extends JSArgumentsObject { ...@@ -80,7 +80,7 @@ extern shape JSStrictArgumentsObject extends JSArgumentsObject {
class SloppyArgumentsElements extends FixedArrayBase { class SloppyArgumentsElements extends FixedArrayBase {
context: Context; context: Context;
arguments: FixedArray|NumberDictionary; arguments: FixedArray|NumberDictionary;
mapped_entries[length]: Smi|TheHole; @relaxedRead mapped_entries[length]: Smi|TheHole;
} }
macro NewSloppyArgumentsElements<Iterator: type>( macro NewSloppyArgumentsElements<Iterator: type>(
......
...@@ -13,7 +13,7 @@ class Context extends HeapObject { ...@@ -13,7 +13,7 @@ class Context extends HeapObject {
return *ContextSlot(this, ContextSlot::SCOPE_INFO_INDEX); return *ContextSlot(this, ContextSlot::SCOPE_INFO_INDEX);
} }
const length: Smi; const length: Smi;
@relaxedWrite elements[length]: Object; @relaxedRead @relaxedWrite elements[length]: Object;
} }
extern class AwaitContext extends Context generates 'TNode<Context>'; extern class AwaitContext extends Context generates 'TNode<Context>';
......
...@@ -24,7 +24,7 @@ extern class FeedbackVector extends HeapObject { ...@@ -24,7 +24,7 @@ extern class FeedbackVector extends HeapObject {
shared_function_info: SharedFunctionInfo; shared_function_info: SharedFunctionInfo;
maybe_optimized_code: Weak<Code>; maybe_optimized_code: Weak<Code>;
closure_feedback_cell_array: ClosureFeedbackCellArray; closure_feedback_cell_array: ClosureFeedbackCellArray;
raw_feedback_slots[length]: MaybeObject; @relaxedRead raw_feedback_slots[length]: MaybeObject;
} }
extern class FeedbackMetadata extends HeapObject; extern class FeedbackMetadata extends HeapObject;
...@@ -26,7 +26,7 @@ extern class FixedDoubleArray extends FixedArrayBase { ...@@ -26,7 +26,7 @@ extern class FixedDoubleArray extends FixedArrayBase {
@generateCppClass @generateCppClass
extern class WeakFixedArray extends HeapObject { extern class WeakFixedArray extends HeapObject {
const length: Smi; const length: Smi;
objects[length]: MaybeObject; @relaxedRead objects[length]: MaybeObject;
} }
@generateCppClass @generateCppClass
...@@ -51,7 +51,7 @@ extern class TemplateList extends FixedArray { ...@@ -51,7 +51,7 @@ extern class TemplateList extends FixedArray {
extern class WeakArrayList extends HeapObject { extern class WeakArrayList extends HeapObject {
const capacity: Smi; const capacity: Smi;
length: Smi; length: Smi;
objects[capacity]: MaybeObject; @relaxedRead objects[capacity]: MaybeObject;
} }
extern operator '.length_intptr' macro LoadAndUntagFixedArrayBaseLength( extern operator '.length_intptr' macro LoadAndUntagFixedArrayBaseLength(
......
...@@ -931,6 +931,7 @@ struct ClassFieldExpression { ...@@ -931,6 +931,7 @@ struct ClassFieldExpression {
bool weak; bool weak;
bool const_qualified; bool const_qualified;
bool generate_verify; bool generate_verify;
bool relaxed_read;
bool relaxed_write; bool relaxed_write;
}; };
......
...@@ -106,7 +106,10 @@ static const char* const ANNOTATION_DO_NOT_GENERATE_CAST = "@doNotGenerateCast"; ...@@ -106,7 +106,10 @@ static const char* const ANNOTATION_DO_NOT_GENERATE_CAST = "@doNotGenerateCast";
static const char* const ANNOTATION_USE_PARENT_TYPE_CHECKER = static const char* const ANNOTATION_USE_PARENT_TYPE_CHECKER =
"@useParentTypeChecker"; "@useParentTypeChecker";
// Generate C++ accessors with relaxed write semantics. // Generate C++ accessors with relaxed write semantics.
// Weak<T> and MaybeObject fields always use relaxed write.
static const char* const ANNOTATION_RELAXED_WRITE = "@relaxedWrite"; static const char* const ANNOTATION_RELAXED_WRITE = "@relaxedWrite";
// Generate C++ accessors with relaxed read semantics.
static const char* const ANNOTATION_RELAXED_READ = "@relaxedRead";
inline bool IsConstexprName(const std::string& name) { inline bool IsConstexprName(const std::string& name) {
return name.substr(0, std::strlen(CONSTEXPR_TYPE_PREFIX)) == return name.substr(0, std::strlen(CONSTEXPR_TYPE_PREFIX)) ==
......
This diff is collapsed.
...@@ -1945,10 +1945,12 @@ base::Optional<ParseResult> MakeAnnotation(ParseResultIterator* child_results) { ...@@ -1945,10 +1945,12 @@ base::Optional<ParseResult> MakeAnnotation(ParseResultIterator* child_results) {
base::Optional<ParseResult> MakeClassField(ParseResultIterator* child_results) { base::Optional<ParseResult> MakeClassField(ParseResultIterator* child_results) {
AnnotationSet annotations(child_results, AnnotationSet annotations(child_results,
{ANNOTATION_NO_VERIFIER, ANNOTATION_RELAXED_WRITE}, {ANNOTATION_NO_VERIFIER, ANNOTATION_RELAXED_WRITE,
ANNOTATION_RELAXED_READ},
{ANNOTATION_IF, ANNOTATION_IFNOT}); {ANNOTATION_IF, ANNOTATION_IFNOT});
bool generate_verify = !annotations.Contains(ANNOTATION_NO_VERIFIER); bool generate_verify = !annotations.Contains(ANNOTATION_NO_VERIFIER);
bool relaxed_write = annotations.Contains(ANNOTATION_RELAXED_WRITE); bool relaxed_write = annotations.Contains(ANNOTATION_RELAXED_WRITE);
bool relaxed_read = annotations.Contains(ANNOTATION_RELAXED_READ);
std::vector<ConditionalAnnotation> conditions; std::vector<ConditionalAnnotation> conditions;
base::Optional<std::string> if_condition = base::Optional<std::string> if_condition =
annotations.GetStringParam(ANNOTATION_IF); annotations.GetStringParam(ANNOTATION_IF);
...@@ -1972,6 +1974,7 @@ base::Optional<ParseResult> MakeClassField(ParseResultIterator* child_results) { ...@@ -1972,6 +1974,7 @@ base::Optional<ParseResult> MakeClassField(ParseResultIterator* child_results) {
weak, weak,
const_qualified, const_qualified,
generate_verify, generate_verify,
relaxed_read,
relaxed_write}}; relaxed_write}};
} }
......
...@@ -208,6 +208,7 @@ const StructType* TypeVisitor::ComputeType( ...@@ -208,6 +208,7 @@ const StructType* TypeVisitor::ComputeType(
false, false,
field.const_qualified, field.const_qualified,
false, false,
false,
false}; false};
auto optional_size = SizeOf(f.name_and_type.type); auto optional_size = SizeOf(f.name_and_type.type);
struct_type->RegisterField(f); struct_type->RegisterField(f);
...@@ -429,6 +430,7 @@ void TypeVisitor::VisitClassFieldsAndMethods( ...@@ -429,6 +430,7 @@ void TypeVisitor::VisitClassFieldsAndMethods(
field_expression.weak, field_expression.weak,
field_expression.const_qualified, field_expression.const_qualified,
field_expression.generate_verify, field_expression.generate_verify,
field_expression.relaxed_read,
field_expression.relaxed_write}); field_expression.relaxed_write});
ResidueClass field_size = std::get<0>(field.GetFieldSizeInformation()); ResidueClass field_size = std::get<0>(field.GetFieldSizeInformation());
if (field.index) { if (field.index) {
......
...@@ -229,6 +229,7 @@ struct Field { ...@@ -229,6 +229,7 @@ struct Field {
bool is_weak; bool is_weak;
bool const_qualified; bool const_qualified;
bool generate_verify; bool generate_verify;
bool relaxed_read;
bool relaxed_write; bool relaxed_write;
}; };
......
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