11cb0ef41Sopenharmony_ci// Copyright 2015 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#include "src/interpreter/bytecodes.h"
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include <iomanip>
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ci#include "src/base/bits.h"
101cb0ef41Sopenharmony_ci#include "src/interpreter/bytecode-traits.h"
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_cinamespace v8 {
131cb0ef41Sopenharmony_cinamespace internal {
141cb0ef41Sopenharmony_cinamespace interpreter {
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci// clang-format off
171cb0ef41Sopenharmony_ciconst OperandType* const Bytecodes::kOperandTypes[] = {
181cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kOperandTypes,
191cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
201cb0ef41Sopenharmony_ci#undef ENTRY
211cb0ef41Sopenharmony_ci};
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciconst OperandTypeInfo* const Bytecodes::kOperandTypeInfos[] = {
241cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kOperandTypeInfos,
251cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
261cb0ef41Sopenharmony_ci#undef ENTRY
271cb0ef41Sopenharmony_ci};
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ciconst int Bytecodes::kOperandCount[] = {
301cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kOperandCount,
311cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
321cb0ef41Sopenharmony_ci#undef ENTRY
331cb0ef41Sopenharmony_ci};
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciconst ImplicitRegisterUse Bytecodes::kImplicitRegisterUse[] = {
361cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kImplicitRegisterUse,
371cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
381cb0ef41Sopenharmony_ci#undef ENTRY
391cb0ef41Sopenharmony_ci};
401cb0ef41Sopenharmony_ci
411cb0ef41Sopenharmony_ciconst uint8_t Bytecodes::kBytecodeSizes[3][kBytecodeCount] = {
421cb0ef41Sopenharmony_ci  {
431cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kSingleScaleSize,
441cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
451cb0ef41Sopenharmony_ci#undef ENTRY
461cb0ef41Sopenharmony_ci  }, {
471cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kDoubleScaleSize,
481cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
491cb0ef41Sopenharmony_ci#undef ENTRY
501cb0ef41Sopenharmony_ci  }, {
511cb0ef41Sopenharmony_ci#define ENTRY(Name, ...) BytecodeTraits<__VA_ARGS__>::kQuadrupleScaleSize,
521cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
531cb0ef41Sopenharmony_ci#undef ENTRY
541cb0ef41Sopenharmony_ci  }
551cb0ef41Sopenharmony_ci};
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ciconst OperandSize* const Bytecodes::kOperandSizes[3][kBytecodeCount] = {
581cb0ef41Sopenharmony_ci  {
591cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
601cb0ef41Sopenharmony_ci    BytecodeTraits<__VA_ARGS__>::kSingleScaleOperandSizes,
611cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
621cb0ef41Sopenharmony_ci#undef ENTRY
631cb0ef41Sopenharmony_ci  }, {
641cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
651cb0ef41Sopenharmony_ci    BytecodeTraits<__VA_ARGS__>::kDoubleScaleOperandSizes,
661cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
671cb0ef41Sopenharmony_ci#undef ENTRY
681cb0ef41Sopenharmony_ci  }, {
691cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
701cb0ef41Sopenharmony_ci    BytecodeTraits<__VA_ARGS__>::kQuadrupleScaleOperandSizes,
711cb0ef41Sopenharmony_ci  BYTECODE_LIST(ENTRY)
721cb0ef41Sopenharmony_ci#undef ENTRY
731cb0ef41Sopenharmony_ci  }
741cb0ef41Sopenharmony_ci};
751cb0ef41Sopenharmony_ci
761cb0ef41Sopenharmony_ciconst OperandSize
771cb0ef41Sopenharmony_ciBytecodes::kOperandKindSizes[3][BytecodeOperands::kOperandTypeCount] = {
781cb0ef41Sopenharmony_ci  {
791cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
801cb0ef41Sopenharmony_ci    OperandScaler<OperandType::k##Name, OperandScale::kSingle>::kOperandSize,
811cb0ef41Sopenharmony_ci  OPERAND_TYPE_LIST(ENTRY)
821cb0ef41Sopenharmony_ci#undef ENTRY
831cb0ef41Sopenharmony_ci  }, {
841cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
851cb0ef41Sopenharmony_ci    OperandScaler<OperandType::k##Name, OperandScale::kDouble>::kOperandSize,
861cb0ef41Sopenharmony_ci  OPERAND_TYPE_LIST(ENTRY)
871cb0ef41Sopenharmony_ci#undef ENTRY
881cb0ef41Sopenharmony_ci  }, {
891cb0ef41Sopenharmony_ci#define ENTRY(Name, ...)  \
901cb0ef41Sopenharmony_ci    OperandScaler<OperandType::k##Name, OperandScale::kQuadruple>::kOperandSize,
911cb0ef41Sopenharmony_ci  OPERAND_TYPE_LIST(ENTRY)
921cb0ef41Sopenharmony_ci#undef ENTRY
931cb0ef41Sopenharmony_ci  }
941cb0ef41Sopenharmony_ci};
951cb0ef41Sopenharmony_ci// clang-format on
961cb0ef41Sopenharmony_ci
971cb0ef41Sopenharmony_ci// Make sure kFirstShortStar and kLastShortStar are set correctly.
981cb0ef41Sopenharmony_ci#define ASSERT_SHORT_STAR_RANGE(Name, ...)                        \
991cb0ef41Sopenharmony_ci  STATIC_ASSERT(Bytecode::k##Name >= Bytecode::kFirstShortStar && \
1001cb0ef41Sopenharmony_ci                Bytecode::k##Name <= Bytecode::kLastShortStar);
1011cb0ef41Sopenharmony_ciSHORT_STAR_BYTECODE_LIST(ASSERT_SHORT_STAR_RANGE)
1021cb0ef41Sopenharmony_ci#undef ASSERT_SHORT_STAR_RANGE
1031cb0ef41Sopenharmony_ci
1041cb0ef41Sopenharmony_ci// static
1051cb0ef41Sopenharmony_ciconst char* Bytecodes::ToString(Bytecode bytecode) {
1061cb0ef41Sopenharmony_ci  switch (bytecode) {
1071cb0ef41Sopenharmony_ci#define CASE(Name, ...)   \
1081cb0ef41Sopenharmony_ci  case Bytecode::k##Name: \
1091cb0ef41Sopenharmony_ci    return #Name;
1101cb0ef41Sopenharmony_ci    BYTECODE_LIST(CASE)
1111cb0ef41Sopenharmony_ci#undef CASE
1121cb0ef41Sopenharmony_ci  }
1131cb0ef41Sopenharmony_ci  UNREACHABLE();
1141cb0ef41Sopenharmony_ci}
1151cb0ef41Sopenharmony_ci
1161cb0ef41Sopenharmony_ci// static
1171cb0ef41Sopenharmony_cistd::string Bytecodes::ToString(Bytecode bytecode, OperandScale operand_scale,
1181cb0ef41Sopenharmony_ci                                const char* separator) {
1191cb0ef41Sopenharmony_ci  std::string value(ToString(bytecode));
1201cb0ef41Sopenharmony_ci  if (operand_scale > OperandScale::kSingle) {
1211cb0ef41Sopenharmony_ci    Bytecode prefix_bytecode = OperandScaleToPrefixBytecode(operand_scale);
1221cb0ef41Sopenharmony_ci    std::string suffix = ToString(prefix_bytecode);
1231cb0ef41Sopenharmony_ci    return value.append(separator).append(suffix);
1241cb0ef41Sopenharmony_ci  } else {
1251cb0ef41Sopenharmony_ci    return value;
1261cb0ef41Sopenharmony_ci  }
1271cb0ef41Sopenharmony_ci}
1281cb0ef41Sopenharmony_ci
1291cb0ef41Sopenharmony_ci// static
1301cb0ef41Sopenharmony_ciBytecode Bytecodes::GetDebugBreak(Bytecode bytecode) {
1311cb0ef41Sopenharmony_ci  DCHECK(!IsDebugBreak(bytecode));
1321cb0ef41Sopenharmony_ci  if (bytecode == Bytecode::kWide) {
1331cb0ef41Sopenharmony_ci    return Bytecode::kDebugBreakWide;
1341cb0ef41Sopenharmony_ci  }
1351cb0ef41Sopenharmony_ci  if (bytecode == Bytecode::kExtraWide) {
1361cb0ef41Sopenharmony_ci    return Bytecode::kDebugBreakExtraWide;
1371cb0ef41Sopenharmony_ci  }
1381cb0ef41Sopenharmony_ci  int bytecode_size = Size(bytecode, OperandScale::kSingle);
1391cb0ef41Sopenharmony_ci#define RETURN_IF_DEBUG_BREAK_SIZE_MATCHES(Name)                         \
1401cb0ef41Sopenharmony_ci  if (bytecode_size == Size(Bytecode::k##Name, OperandScale::kSingle)) { \
1411cb0ef41Sopenharmony_ci    return Bytecode::k##Name;                                            \
1421cb0ef41Sopenharmony_ci  }
1431cb0ef41Sopenharmony_ci  DEBUG_BREAK_PLAIN_BYTECODE_LIST(RETURN_IF_DEBUG_BREAK_SIZE_MATCHES)
1441cb0ef41Sopenharmony_ci#undef RETURN_IF_DEBUG_BREAK_SIZE_MATCHES
1451cb0ef41Sopenharmony_ci  UNREACHABLE();
1461cb0ef41Sopenharmony_ci}
1471cb0ef41Sopenharmony_ci
1481cb0ef41Sopenharmony_ci// static
1491cb0ef41Sopenharmony_ciint Bytecodes::GetOperandOffset(Bytecode bytecode, int i,
1501cb0ef41Sopenharmony_ci                                OperandScale operand_scale) {
1511cb0ef41Sopenharmony_ci  DCHECK_LT(i, Bytecodes::NumberOfOperands(bytecode));
1521cb0ef41Sopenharmony_ci  // TODO(oth): restore this to a statically determined constant.
1531cb0ef41Sopenharmony_ci  int offset = 1;
1541cb0ef41Sopenharmony_ci  for (int operand_index = 0; operand_index < i; ++operand_index) {
1551cb0ef41Sopenharmony_ci    OperandSize operand_size =
1561cb0ef41Sopenharmony_ci        GetOperandSize(bytecode, operand_index, operand_scale);
1571cb0ef41Sopenharmony_ci    offset += static_cast<int>(operand_size);
1581cb0ef41Sopenharmony_ci  }
1591cb0ef41Sopenharmony_ci  return offset;
1601cb0ef41Sopenharmony_ci}
1611cb0ef41Sopenharmony_ci
1621cb0ef41Sopenharmony_ci// static
1631cb0ef41Sopenharmony_ciBytecode Bytecodes::GetJumpWithoutToBoolean(Bytecode bytecode) {
1641cb0ef41Sopenharmony_ci  switch (bytecode) {
1651cb0ef41Sopenharmony_ci    case Bytecode::kJumpIfToBooleanTrue:
1661cb0ef41Sopenharmony_ci      return Bytecode::kJumpIfTrue;
1671cb0ef41Sopenharmony_ci    case Bytecode::kJumpIfToBooleanFalse:
1681cb0ef41Sopenharmony_ci      return Bytecode::kJumpIfFalse;
1691cb0ef41Sopenharmony_ci    case Bytecode::kJumpIfToBooleanTrueConstant:
1701cb0ef41Sopenharmony_ci      return Bytecode::kJumpIfTrueConstant;
1711cb0ef41Sopenharmony_ci    case Bytecode::kJumpIfToBooleanFalseConstant:
1721cb0ef41Sopenharmony_ci      return Bytecode::kJumpIfFalseConstant;
1731cb0ef41Sopenharmony_ci    default:
1741cb0ef41Sopenharmony_ci      break;
1751cb0ef41Sopenharmony_ci  }
1761cb0ef41Sopenharmony_ci  UNREACHABLE();
1771cb0ef41Sopenharmony_ci}
1781cb0ef41Sopenharmony_ci
1791cb0ef41Sopenharmony_ci// static
1801cb0ef41Sopenharmony_cibool Bytecodes::IsDebugBreak(Bytecode bytecode) {
1811cb0ef41Sopenharmony_ci  switch (bytecode) {
1821cb0ef41Sopenharmony_ci#define CASE(Name, ...) case Bytecode::k##Name:
1831cb0ef41Sopenharmony_ci    DEBUG_BREAK_BYTECODE_LIST(CASE);
1841cb0ef41Sopenharmony_ci#undef CASE
1851cb0ef41Sopenharmony_ci    return true;
1861cb0ef41Sopenharmony_ci    default:
1871cb0ef41Sopenharmony_ci      break;
1881cb0ef41Sopenharmony_ci  }
1891cb0ef41Sopenharmony_ci  return false;
1901cb0ef41Sopenharmony_ci}
1911cb0ef41Sopenharmony_ci
1921cb0ef41Sopenharmony_ci// static
1931cb0ef41Sopenharmony_cibool Bytecodes::IsRegisterOperandType(OperandType operand_type) {
1941cb0ef41Sopenharmony_ci  switch (operand_type) {
1951cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
1961cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
1971cb0ef41Sopenharmony_ci    return true;
1981cb0ef41Sopenharmony_ci    REGISTER_OPERAND_TYPE_LIST(CASE)
1991cb0ef41Sopenharmony_ci#undef CASE
2001cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
2011cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
2021cb0ef41Sopenharmony_ci    break;
2031cb0ef41Sopenharmony_ci    NON_REGISTER_OPERAND_TYPE_LIST(CASE)
2041cb0ef41Sopenharmony_ci#undef CASE
2051cb0ef41Sopenharmony_ci  }
2061cb0ef41Sopenharmony_ci  return false;
2071cb0ef41Sopenharmony_ci}
2081cb0ef41Sopenharmony_ci
2091cb0ef41Sopenharmony_ci// static
2101cb0ef41Sopenharmony_cibool Bytecodes::IsRegisterListOperandType(OperandType operand_type) {
2111cb0ef41Sopenharmony_ci  switch (operand_type) {
2121cb0ef41Sopenharmony_ci    case OperandType::kRegList:
2131cb0ef41Sopenharmony_ci    case OperandType::kRegOutList:
2141cb0ef41Sopenharmony_ci      return true;
2151cb0ef41Sopenharmony_ci    default:
2161cb0ef41Sopenharmony_ci      return false;
2171cb0ef41Sopenharmony_ci  }
2181cb0ef41Sopenharmony_ci}
2191cb0ef41Sopenharmony_ci
2201cb0ef41Sopenharmony_cibool Bytecodes::MakesCallAlongCriticalPath(Bytecode bytecode) {
2211cb0ef41Sopenharmony_ci  if (IsCallOrConstruct(bytecode) || IsCallRuntime(bytecode)) return true;
2221cb0ef41Sopenharmony_ci  switch (bytecode) {
2231cb0ef41Sopenharmony_ci    case Bytecode::kCreateWithContext:
2241cb0ef41Sopenharmony_ci    case Bytecode::kCreateBlockContext:
2251cb0ef41Sopenharmony_ci    case Bytecode::kCreateCatchContext:
2261cb0ef41Sopenharmony_ci    case Bytecode::kCreateRegExpLiteral:
2271cb0ef41Sopenharmony_ci    case Bytecode::kGetIterator:
2281cb0ef41Sopenharmony_ci      return true;
2291cb0ef41Sopenharmony_ci    default:
2301cb0ef41Sopenharmony_ci      return false;
2311cb0ef41Sopenharmony_ci  }
2321cb0ef41Sopenharmony_ci}
2331cb0ef41Sopenharmony_ci
2341cb0ef41Sopenharmony_ci// static
2351cb0ef41Sopenharmony_cibool Bytecodes::IsRegisterInputOperandType(OperandType operand_type) {
2361cb0ef41Sopenharmony_ci  switch (operand_type) {
2371cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
2381cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
2391cb0ef41Sopenharmony_ci    return true;
2401cb0ef41Sopenharmony_ci    REGISTER_INPUT_OPERAND_TYPE_LIST(CASE)
2411cb0ef41Sopenharmony_ci#undef CASE
2421cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
2431cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
2441cb0ef41Sopenharmony_ci    break;
2451cb0ef41Sopenharmony_ci    NON_REGISTER_OPERAND_TYPE_LIST(CASE)
2461cb0ef41Sopenharmony_ci    REGISTER_OUTPUT_OPERAND_TYPE_LIST(CASE)
2471cb0ef41Sopenharmony_ci#undef CASE
2481cb0ef41Sopenharmony_ci  }
2491cb0ef41Sopenharmony_ci  return false;
2501cb0ef41Sopenharmony_ci}
2511cb0ef41Sopenharmony_ci
2521cb0ef41Sopenharmony_ci// static
2531cb0ef41Sopenharmony_cibool Bytecodes::IsRegisterOutputOperandType(OperandType operand_type) {
2541cb0ef41Sopenharmony_ci  switch (operand_type) {
2551cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
2561cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
2571cb0ef41Sopenharmony_ci    return true;
2581cb0ef41Sopenharmony_ci    REGISTER_OUTPUT_OPERAND_TYPE_LIST(CASE)
2591cb0ef41Sopenharmony_ci#undef CASE
2601cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
2611cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
2621cb0ef41Sopenharmony_ci    break;
2631cb0ef41Sopenharmony_ci    NON_REGISTER_OPERAND_TYPE_LIST(CASE)
2641cb0ef41Sopenharmony_ci    REGISTER_INPUT_OPERAND_TYPE_LIST(CASE)
2651cb0ef41Sopenharmony_ci#undef CASE
2661cb0ef41Sopenharmony_ci  }
2671cb0ef41Sopenharmony_ci  return false;
2681cb0ef41Sopenharmony_ci}
2691cb0ef41Sopenharmony_ci
2701cb0ef41Sopenharmony_ci// static
2711cb0ef41Sopenharmony_cibool Bytecodes::IsStarLookahead(Bytecode bytecode, OperandScale operand_scale) {
2721cb0ef41Sopenharmony_ci  if (operand_scale == OperandScale::kSingle) {
2731cb0ef41Sopenharmony_ci    switch (bytecode) {
2741cb0ef41Sopenharmony_ci      // Short-star lookahead is required for correctness on kDebugBreak0. The
2751cb0ef41Sopenharmony_ci      // handler for all short-star codes re-reads the opcode from the bytecode
2761cb0ef41Sopenharmony_ci      // array and would not work correctly if it instead read kDebugBreak0.
2771cb0ef41Sopenharmony_ci      case Bytecode::kDebugBreak0:
2781cb0ef41Sopenharmony_ci
2791cb0ef41Sopenharmony_ci      case Bytecode::kLdaZero:
2801cb0ef41Sopenharmony_ci      case Bytecode::kLdaSmi:
2811cb0ef41Sopenharmony_ci      case Bytecode::kLdaNull:
2821cb0ef41Sopenharmony_ci      case Bytecode::kLdaTheHole:
2831cb0ef41Sopenharmony_ci      case Bytecode::kLdaConstant:
2841cb0ef41Sopenharmony_ci      case Bytecode::kLdaUndefined:
2851cb0ef41Sopenharmony_ci      case Bytecode::kLdaGlobal:
2861cb0ef41Sopenharmony_ci      case Bytecode::kGetNamedProperty:
2871cb0ef41Sopenharmony_ci      case Bytecode::kGetKeyedProperty:
2881cb0ef41Sopenharmony_ci      case Bytecode::kLdaContextSlot:
2891cb0ef41Sopenharmony_ci      case Bytecode::kLdaImmutableContextSlot:
2901cb0ef41Sopenharmony_ci      case Bytecode::kLdaCurrentContextSlot:
2911cb0ef41Sopenharmony_ci      case Bytecode::kLdaImmutableCurrentContextSlot:
2921cb0ef41Sopenharmony_ci      case Bytecode::kAdd:
2931cb0ef41Sopenharmony_ci      case Bytecode::kSub:
2941cb0ef41Sopenharmony_ci      case Bytecode::kMul:
2951cb0ef41Sopenharmony_ci      case Bytecode::kAddSmi:
2961cb0ef41Sopenharmony_ci      case Bytecode::kSubSmi:
2971cb0ef41Sopenharmony_ci      case Bytecode::kInc:
2981cb0ef41Sopenharmony_ci      case Bytecode::kDec:
2991cb0ef41Sopenharmony_ci      case Bytecode::kTypeOf:
3001cb0ef41Sopenharmony_ci      case Bytecode::kCallAnyReceiver:
3011cb0ef41Sopenharmony_ci      case Bytecode::kCallProperty:
3021cb0ef41Sopenharmony_ci      case Bytecode::kCallProperty0:
3031cb0ef41Sopenharmony_ci      case Bytecode::kCallProperty1:
3041cb0ef41Sopenharmony_ci      case Bytecode::kCallProperty2:
3051cb0ef41Sopenharmony_ci      case Bytecode::kCallUndefinedReceiver:
3061cb0ef41Sopenharmony_ci      case Bytecode::kCallUndefinedReceiver0:
3071cb0ef41Sopenharmony_ci      case Bytecode::kCallUndefinedReceiver1:
3081cb0ef41Sopenharmony_ci      case Bytecode::kCallUndefinedReceiver2:
3091cb0ef41Sopenharmony_ci      case Bytecode::kConstruct:
3101cb0ef41Sopenharmony_ci      case Bytecode::kConstructWithSpread:
3111cb0ef41Sopenharmony_ci      case Bytecode::kCreateObjectLiteral:
3121cb0ef41Sopenharmony_ci      case Bytecode::kCreateArrayLiteral:
3131cb0ef41Sopenharmony_ci      case Bytecode::kThrowReferenceErrorIfHole:
3141cb0ef41Sopenharmony_ci      case Bytecode::kGetTemplateObject:
3151cb0ef41Sopenharmony_ci        return true;
3161cb0ef41Sopenharmony_ci      default:
3171cb0ef41Sopenharmony_ci        return false;
3181cb0ef41Sopenharmony_ci    }
3191cb0ef41Sopenharmony_ci  }
3201cb0ef41Sopenharmony_ci  return false;
3211cb0ef41Sopenharmony_ci}
3221cb0ef41Sopenharmony_ci
3231cb0ef41Sopenharmony_ci// static
3241cb0ef41Sopenharmony_cibool Bytecodes::IsBytecodeWithScalableOperands(Bytecode bytecode) {
3251cb0ef41Sopenharmony_ci  for (int i = 0; i < NumberOfOperands(bytecode); i++) {
3261cb0ef41Sopenharmony_ci    if (OperandIsScalable(bytecode, i)) return true;
3271cb0ef41Sopenharmony_ci  }
3281cb0ef41Sopenharmony_ci  return false;
3291cb0ef41Sopenharmony_ci}
3301cb0ef41Sopenharmony_ci
3311cb0ef41Sopenharmony_ci// static
3321cb0ef41Sopenharmony_cibool Bytecodes::IsUnsignedOperandType(OperandType operand_type) {
3331cb0ef41Sopenharmony_ci  switch (operand_type) {
3341cb0ef41Sopenharmony_ci#define CASE(Name, _)        \
3351cb0ef41Sopenharmony_ci  case OperandType::k##Name: \
3361cb0ef41Sopenharmony_ci    return OperandTraits<OperandType::k##Name>::TypeInfoTraits::kIsUnsigned;
3371cb0ef41Sopenharmony_ci    OPERAND_TYPE_LIST(CASE)
3381cb0ef41Sopenharmony_ci#undef CASE
3391cb0ef41Sopenharmony_ci  }
3401cb0ef41Sopenharmony_ci  UNREACHABLE();
3411cb0ef41Sopenharmony_ci}
3421cb0ef41Sopenharmony_ci
3431cb0ef41Sopenharmony_ci// static
3441cb0ef41Sopenharmony_cibool Bytecodes::BytecodeHasHandler(Bytecode bytecode,
3451cb0ef41Sopenharmony_ci                                   OperandScale operand_scale) {
3461cb0ef41Sopenharmony_ci  return (operand_scale == OperandScale::kSingle &&
3471cb0ef41Sopenharmony_ci          (!IsShortStar(bytecode) || bytecode == Bytecode::kStar0)) ||
3481cb0ef41Sopenharmony_ci         Bytecodes::IsBytecodeWithScalableOperands(bytecode);
3491cb0ef41Sopenharmony_ci}
3501cb0ef41Sopenharmony_ci
3511cb0ef41Sopenharmony_cistd::ostream& operator<<(std::ostream& os, const Bytecode& bytecode) {
3521cb0ef41Sopenharmony_ci  return os << Bytecodes::ToString(bytecode);
3531cb0ef41Sopenharmony_ci}
3541cb0ef41Sopenharmony_ci
3551cb0ef41Sopenharmony_ci}  // namespace interpreter
3561cb0ef41Sopenharmony_ci}  // namespace internal
3571cb0ef41Sopenharmony_ci}  // namespace v8
358