Commit c961986e authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[bigint] Fix typeof.

The bytecode generator has special handling for comparing the result of
the typeof operator against a string literal. This needs to be adapted
for bigints.

R=jkummerow@chromium.org, mythrie@chromium.org

Bug: v8:6791
Change-Id: I42d6c9e9225ce05e19393f10e01ae496ecb70c9c
Reviewed-on: https://chromium-review.googlesource.com/753465
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49172}
parent 7a546525
......@@ -195,6 +195,7 @@ class AstBigInt {
F(arguments, "arguments") \
F(async, "async") \
F(await, "await") \
F(bigint, "bigint") \
F(boolean, "boolean") \
F(constructor, "constructor") \
F(default, "default") \
......
......@@ -2476,6 +2476,10 @@ void BytecodeGraphBuilder::VisitTestTypeOf() {
graph()->NewNode(simplified()->ReferenceEqual(), object,
jsgraph()->NullConstant()));
break;
case interpreter::TestTypeOfFlags::LiteralFlag::kBigInt:
// TODO(neis): Implement.
UNIMPLEMENTED();
break;
case interpreter::TestTypeOfFlags::LiteralFlag::kOther:
UNREACHABLE(); // Should never be emitted.
break;
......
......@@ -52,6 +52,8 @@ TestTypeOfFlags::LiteralFlag TestTypeOfFlags::GetFlagForLiteral(
return LiteralFlag::kSymbol;
} else if (raw_literal == ast_constants->boolean_string()) {
return LiteralFlag::kBoolean;
} else if (raw_literal == ast_constants->bigint_string()) {
return LiteralFlag::kBigInt;
} else if (raw_literal == ast_constants->undefined_string()) {
return LiteralFlag::kUndefined;
} else if (raw_literal == ast_constants->function_string()) {
......
......@@ -54,6 +54,7 @@ class CreateClosureFlags {
V(String, string) \
V(Symbol, symbol) \
V(Boolean, boolean) \
V(BigInt, bigint) \
V(Undefined, undefined) \
V(Function, function) \
V(Object, object) \
......
......@@ -2031,6 +2031,12 @@ IGNITION_HANDLER(TestTypeOf, InterpreterAssembler) {
GotoIf(WordEqual(object, TrueConstant()), &if_true);
Branch(WordEqual(object, FalseConstant()), &if_true, &if_false);
}
BIND(&if_bigint);
{
Comment("IfBigInt");
GotoIf(TaggedIsSmi(object), &if_false);
Branch(IsBigInt(object), &if_true, &if_false);
}
BIND(&if_undefined);
{
Comment("IfUndefined");
......
......@@ -425,7 +425,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(17),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......
......@@ -140,7 +140,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(21),
B(JumpIfFalse), U8(109),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -429,7 +429,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(21),
B(JumpIfFalse), U8(109),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -740,7 +740,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(23),
B(JumpIfFalse), U8(109),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -988,7 +988,7 @@ bytecodes: [
B(TestEqualStrict), R(4), U8(22),
B(JumpIfFalse), U8(61),
B(Ldar), R(6),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......
......@@ -83,7 +83,7 @@ bytecodes: [
B(TestEqualStrict), R(4), U8(17),
B(JumpIfFalse), U8(61),
B(Ldar), R(6),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -224,7 +224,7 @@ bytecodes: [
B(TestEqualStrict), R(5), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(7),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -377,7 +377,7 @@ bytecodes: [
B(TestEqualStrict), R(4), U8(19),
B(JumpIfFalse), U8(61),
B(Ldar), R(6),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -520,7 +520,7 @@ bytecodes: [
B(TestEqualStrict), R(3), U8(22),
B(JumpIfFalse), U8(61),
B(Ldar), R(5),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......
......@@ -87,7 +87,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -265,7 +265,7 @@ bytecodes: [
B(TestEqualStrict), R(3), U8(20),
B(JumpIfFalse), U8(61),
B(Ldar), R(5),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -419,7 +419,7 @@ bytecodes: [
B(TestEqualStrict), R(4), U8(19),
B(JumpIfFalse), U8(61),
B(Ldar), R(6),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -577,7 +577,7 @@ bytecodes: [
B(TestEqualStrict), R(9), U8(21),
B(JumpIfFalse), U8(61),
B(Ldar), R(11),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -751,7 +751,7 @@ bytecodes: [
B(TestEqualStrict), R(7), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(9),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -950,7 +950,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -1113,7 +1113,7 @@ bytecodes: [
B(TestEqualStrict), R(7), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(9),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......@@ -1355,7 +1355,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(16),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......
......@@ -254,7 +254,7 @@ bytecodes: [
B(TestEqualStrict), R(6), U8(17),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(TestTypeOf), U8(6),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(142),
......
......@@ -90,6 +90,10 @@ const six = BigInt(6);
}{
assertEquals(%Typeof(zero), "bigint");
assertEquals(%Typeof(one), "bigint");
}{
assertTrue(typeof 1n === "bigint");
assertFalse(typeof 1n === "BigInt");
assertFalse(typeof 1 === "bigint");
}{
// TODO(neis): Enable once --no-opt can be removed.
//
......
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