Commit f9e5a7bb authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] avoid dangerous == overloads with WordEqual

Bug: v8:7793 v8:8737
Change-Id: I186cb33eb2e84a47fcb0897978bde9c6dffb9df3
Reviewed-on: https://chromium-review.googlesource.com/c/1456044
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59431}
parent cbcbb059
......@@ -382,6 +382,7 @@ type Null extends Oddball generates 'TNode<Oddball>';
type Undefined extends Oddball generates 'TNode<Oddball>';
type True extends Oddball generates 'TNode<Oddball>';
type False extends Oddball generates 'TNode<Oddball>';
type EmptyString extends String generates 'TNode<String>';
type Boolean = True | False;
type NumberOrUndefined = Number | Undefined;
......@@ -393,7 +394,7 @@ extern macro TrueConstant(): True;
extern macro FalseConstant(): False;
extern macro Int32TrueConstant(): bool;
extern macro Int32FalseConstant(): bool;
extern macro EmptyStringConstant(): String;
extern macro EmptyStringConstant(): EmptyString;
extern macro LengthStringConstant(): String;
const Hole: Hole = TheHoleConstant();
......@@ -401,7 +402,7 @@ const Null: Null = NullConstant();
const Undefined: Undefined = UndefinedConstant();
const True: True = TrueConstant();
const False: False = FalseConstant();
const kEmptyString: String = EmptyStringConstant();
const kEmptyString: EmptyString = EmptyStringConstant();
const kLengthString: String = LengthStringConstant();
const true: constexpr bool generates 'true';
......@@ -597,8 +598,22 @@ extern builtin Divide(implicit context: Context)(Object, Object): Numeric;
extern builtin Modulus(implicit context: Context)(Object, Object): Numeric;
extern builtin Subtract(implicit context: Context)(Object, Object): Numeric;
extern operator '==' macro WordEqual(Object, Object): bool;
extern operator '!=' macro WordNotEqual(Object, Object): bool;
// The type of all tagged values that can safely be compared with WordEqual.
type TaggedWithIdentity =
JSReceiver | FixedArrayBase | Oddball | Map | EmptyString;
extern operator '==' macro WordEqual(TaggedWithIdentity, Object): bool;
extern operator '==' macro WordEqual(Object, TaggedWithIdentity): bool;
extern operator '==' macro WordEqual(
TaggedWithIdentity, TaggedWithIdentity): bool;
extern operator '!=' macro WordNotEqual(TaggedWithIdentity, Object): bool;
extern operator '!=' macro WordNotEqual(Object, TaggedWithIdentity): bool;
extern operator '!=' macro WordNotEqual(
TaggedWithIdentity, TaggedWithIdentity): bool;
// Do not overload == and != if it is unclear if object identity is the right
// equality.
extern macro WordEqual(Object, Object): bool;
extern macro WordNotEqual(Object, Object): bool;
extern operator '+' macro SmiAdd(Smi, Smi): Smi;
extern operator '-' macro SmiSub(Smi, Smi): Smi;
......
......@@ -30,8 +30,8 @@ namespace test {
}
macro LabelTestHelper3(): never
labels Label3(String, Smi) {
goto Label3('foo', 7);
labels Label3(Oddball, Smi) {
goto Label3(Null, 7);
}
macro TestConstexpr1() {
......@@ -74,8 +74,8 @@ namespace test {
try {
LabelTestHelper3() otherwise Label3;
}
label Label3(str: String, smi: Smi) {
check(str == 'foo');
label Label3(o: Oddball, smi: Smi) {
check(o == Null);
check(smi == 7);
return True;
}
......@@ -156,7 +156,6 @@ namespace test {
check(GenericMacroTest<Object>(True) == True);
check((GenericMacroTestWithLabels<Smi>(0) otherwise Fail) == Undefined);
check((GenericMacroTestWithLabels<Smi>(0) otherwise Fail) == Undefined);
check((GenericMacroTestWithLabels<Object>(smi0) otherwise Fail) == smi0);
try {
GenericMacroTestWithLabels<Object>(False) otherwise Expected;
}
......
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