From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- js/src/jit/WarpBuilder.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'js/src/jit/WarpBuilder.cpp') diff --git a/js/src/jit/WarpBuilder.cpp b/js/src/jit/WarpBuilder.cpp index cad28fa535..4ca882c4b1 100644 --- a/js/src/jit/WarpBuilder.cpp +++ b/js/src/jit/WarpBuilder.cpp @@ -21,6 +21,7 @@ #include "vm/GeneratorObject.h" #include "vm/Interpreter.h" #include "vm/Opcodes.h" +#include "vm/TypeofEqOperand.h" // TypeofEqOperand #include "gc/ObjectKind-inl.h" #include "vm/BytecodeIterator-inl.h" @@ -1564,6 +1565,30 @@ bool WarpBuilder::build_TypeofExpr(BytecodeLocation loc) { return build_Typeof(loc); } +bool WarpBuilder::build_TypeofEq(BytecodeLocation loc) { + auto operand = loc.getTypeofEqOperand(); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + MDefinition* input = current->pop(); + + if (const auto* typesSnapshot = getOpSnapshot(loc)) { + auto* typeOf = MTypeOf::New(alloc(), input); + typeOf->setObservedTypes(typesSnapshot->list()); + current->add(typeOf); + + auto* typeInt = MConstant::New(alloc(), Int32Value(type)); + current->add(typeInt); + + auto* ins = MCompare::New(alloc(), typeOf, typeInt, compareOp, + MCompare::Compare_Int32); + current->add(ins); + current->push(ins); + return true; + } + + return buildIC(loc, CacheKind::TypeOfEq, {input}); +} + bool WarpBuilder::build_Arguments(BytecodeLocation loc) { auto* snapshot = getOpSnapshot(loc); MOZ_ASSERT(info().needsArgsObj()); @@ -3402,6 +3427,23 @@ bool WarpBuilder::buildIC(BytecodeLocation loc, CacheKind kind, current->push(ins); return true; } + case CacheKind::TypeOfEq: { + MOZ_ASSERT(numInputs == 1); + auto operand = loc.getTypeofEqOperand(); + JSType type = operand.type(); + JSOp compareOp = operand.compareOp(); + auto* typeOf = MTypeOf::New(alloc(), getInput(0)); + current->add(typeOf); + + auto* typeInt = MConstant::New(alloc(), Int32Value(type)); + current->add(typeInt); + + auto* ins = MCompare::New(alloc(), typeOf, typeInt, compareOp, + MCompare::Compare_Int32); + current->add(ins); + current->push(ins); + return true; + } case CacheKind::NewObject: { auto* templateConst = constant(NullValue()); MNewObject* ins = MNewObject::NewVM( @@ -3482,6 +3524,7 @@ bool WarpBuilder::buildBailoutForColdIC(BytecodeLocation loc, CacheKind kind) { case CacheKind::CheckPrivateField: case CacheKind::InstanceOf: case CacheKind::OptimizeGetIterator: + case CacheKind::TypeOfEq: resultType = MIRType::Boolean; break; case CacheKind::SetProp: -- cgit v1.2.3