Commit dc0a6365 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by V8 LUCI CQ

[torque] add WasmInternalFunction to TaggedWithIdentity

Change-Id: I92479fe32ff4f55a0cf33c1d0898740e3f3cd5ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3406752Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarNico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78723}
parent 77be1c60
......@@ -897,8 +897,12 @@ macro Float64IsNaN(n: float64): bool {
}
// The type of all tagged values that can safely be compared with TaggedEqual.
type TaggedWithIdentity =
JSReceiver|FixedArrayBase|Oddball|Map|WeakCell|Context|EmptyString;
@if(V8_ENABLE_WEBASSEMBLY)
type TaggedWithIdentity = JSReceiver | FixedArrayBase | Oddball | Map |
WeakCell | Context | EmptyString | WasmInternalFunction;
@ifnot(V8_ENABLE_WEBASSEMBLY)
type TaggedWithIdentity = JSReceiver | FixedArrayBase | Oddball | Map |
WeakCell | Context | EmptyString;
extern operator '==' macro TaggedEqual(TaggedWithIdentity, Object): bool;
extern operator '==' macro TaggedEqual(Object, TaggedWithIdentity): bool;
......
......@@ -275,6 +275,8 @@ V8_EXPORT_PRIVATE const ParseResultTypeId
namespace {
bool ProcessIfAnnotation(ParseResultIterator* child_results);
base::Optional<ParseResult> AddGlobalDeclarations(
ParseResultIterator* child_results) {
auto declarations = child_results->NextAs<std::vector<Declaration*>>();
......@@ -702,9 +704,11 @@ base::Optional<ParseResult> MakeExternConstDeclaration(
base::Optional<ParseResult> MakeTypeAliasDeclaration(
ParseResultIterator* child_results) {
bool enabled = ProcessIfAnnotation(child_results);
auto name = child_results->NextAs<Identifier*>();
auto type = child_results->NextAs<TypeExpression*>();
Declaration* result = MakeNode<TypeAliasDeclaration>(name, type);
std::vector<Declaration*> result = {};
if (enabled) result = {MakeNode<TypeAliasDeclaration>(name, type)};
return ParseResult{result};
}
......@@ -847,6 +851,20 @@ class AnnotationSet {
std::map<std::string, std::pair<AnnotationParameter, SourcePosition>> map_;
};
bool ProcessIfAnnotation(ParseResultIterator* child_results) {
AnnotationSet annotations(child_results, {},
{ANNOTATION_IF, ANNOTATION_IFNOT});
if (base::Optional<std::string> condition =
annotations.GetStringParam(ANNOTATION_IF)) {
if (!BuildFlags::GetFlag(*condition, ANNOTATION_IF)) return false;
}
if (base::Optional<std::string> condition =
annotations.GetStringParam(ANNOTATION_IFNOT)) {
if (BuildFlags::GetFlag(*condition, ANNOTATION_IFNOT)) return false;
}
return true;
}
base::Optional<ParseResult> MakeInt32(ParseResultIterator* child_results) {
std::string value = child_results->NextAs<std::string>();
size_t num_chars_converted = 0;
......@@ -2212,21 +2230,10 @@ struct TorqueGrammar : Grammar {
ParseResultIterator* child_results) {
std::vector<T> l = {};
if (!first) l = child_results->NextAs<std::vector<T>>();
AnnotationSet annotations(child_results, {},
{ANNOTATION_IF, ANNOTATION_IFNOT});
bool skipped = false;
if (base::Optional<std::string> condition =
annotations.GetStringParam(ANNOTATION_IF)) {
if (!BuildFlags::GetFlag(*condition, ANNOTATION_IF)) skipped = true;
}
if (base::Optional<std::string> condition =
annotations.GetStringParam(ANNOTATION_IFNOT)) {
if (BuildFlags::GetFlag(*condition, ANNOTATION_IFNOT)) skipped = true;
}
bool enabled = ProcessIfAnnotation(child_results);
T x = child_results->NextAs<T>();
if (skipped) return ParseResult{std::move(l)};
l.push_back(std::move(x));
if (enabled) l.push_back(std::move(x));
return ParseResult{std::move(l)};
}
......@@ -2728,8 +2735,8 @@ struct TorqueGrammar : Grammar {
Sequence({Token("constexpr"), &externalString})),
Token(";")},
MakeAbstractTypeDeclaration),
Rule({Token("type"), &name, Token("="), &type, Token(";")},
AsSingletonVector<Declaration*, MakeTypeAliasDeclaration>()),
Rule({annotations, Token("type"), &name, Token("="), &type, Token(";")},
MakeTypeAliasDeclaration),
Rule({Token("intrinsic"), &intrinsicName,
TryOrDefault<GenericParameters>(&genericParameters),
&parameterListNoVararg, &returnType, &optionalBody},
......
......@@ -42,9 +42,6 @@ extern class WasmInternalFunction extends Foreign {
@if(V8_EXTERNAL_CODE_SPACE) code: CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) code: Code;
}
// WasmInternalFunction is safely comparable for pointer equality.
extern operator '==' macro TaggedEqual(WasmInternalFunction, Object): bool;
extern operator '==' macro TaggedEqual(Object, WasmInternalFunction): bool;
extern class WasmFunctionData extends HeapObject {
// The wasm-internal representation of this function object.
......
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