LCOV - code coverage report
Current view: top level - src/interpreter - bytecode-flags.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 27 27 100.0 %
Date: 2019-04-17 Functions: 8 8 100.0 %

          Line data    Source code
       1             : // Copyright 2016 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/interpreter/bytecode-flags.h"
       6             : 
       7             : #include "src/ast/ast-value-factory.h"
       8             : #include "src/ast/ast.h"
       9             : #include "src/builtins/builtins-constructor.h"
      10             : #include "src/objects-inl.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : namespace interpreter {
      15             : 
      16             : // static
      17      382100 : uint8_t CreateArrayLiteralFlags::Encode(bool use_fast_shallow_clone,
      18             :                                         int runtime_flags) {
      19             :   uint8_t result = FlagsBits::encode(runtime_flags);
      20      382100 :   result |= FastCloneSupportedBit::encode(use_fast_shallow_clone);
      21      382100 :   return result;
      22             : }
      23             : 
      24             : // static
      25      203291 : uint8_t CreateObjectLiteralFlags::Encode(int runtime_flags,
      26             :                                          bool fast_clone_supported) {
      27             :   uint8_t result = FlagsBits::encode(runtime_flags);
      28      203291 :   result |= FastCloneSupportedBit::encode(fast_clone_supported);
      29      203291 :   return result;
      30             : }
      31             : 
      32             : // static
      33     2709984 : uint8_t CreateClosureFlags::Encode(bool pretenure, bool is_function_scope,
      34             :                                    bool might_always_opt) {
      35             :   uint8_t result = PretenuredBit::encode(pretenure);
      36     2709984 :   if (!might_always_opt && !pretenure && is_function_scope) {
      37     1171280 :     result |= FastNewClosureBit::encode(true);
      38             :   }
      39     2709984 :   return result;
      40             : }
      41             : 
      42             : // static
      43      100066 : TestTypeOfFlags::LiteralFlag TestTypeOfFlags::GetFlagForLiteral(
      44             :     const AstStringConstants* ast_constants, Literal* literal) {
      45             :   const AstRawString* raw_literal = literal->AsRawString();
      46      100066 :   if (raw_literal == ast_constants->number_string()) {
      47             :     return LiteralFlag::kNumber;
      48       71416 :   } else if (raw_literal == ast_constants->string_string()) {
      49             :     return LiteralFlag::kString;
      50       60634 :   } else if (raw_literal == ast_constants->symbol_string()) {
      51             :     return LiteralFlag::kSymbol;
      52       60557 :   } else if (raw_literal == ast_constants->boolean_string()) {
      53             :     return LiteralFlag::kBoolean;
      54       60406 :   } else if (raw_literal == ast_constants->bigint_string()) {
      55             :     return LiteralFlag::kBigInt;
      56       60385 :   } else if (raw_literal == ast_constants->undefined_string()) {
      57             :     return LiteralFlag::kUndefined;
      58       55635 :   } else if (raw_literal == ast_constants->function_string()) {
      59             :     return LiteralFlag::kFunction;
      60       21914 :   } else if (raw_literal == ast_constants->object_string()) {
      61             :     return LiteralFlag::kObject;
      62             :   } else {
      63         243 :     return LiteralFlag::kOther;
      64             :   }
      65             : }
      66             : 
      67             : // static
      68      138044 : uint8_t TestTypeOfFlags::Encode(LiteralFlag literal_flag) {
      69      138044 :   return static_cast<uint8_t>(literal_flag);
      70             : }
      71             : 
      72             : // static
      73       40331 : TestTypeOfFlags::LiteralFlag TestTypeOfFlags::Decode(uint8_t raw_flag) {
      74             :   DCHECK_LE(raw_flag, static_cast<uint8_t>(LiteralFlag::kOther));
      75       40331 :   return static_cast<LiteralFlag>(raw_flag);
      76             : }
      77             : 
      78             : // static
      79       37378 : uint8_t StoreLookupSlotFlags::Encode(LanguageMode language_mode,
      80             :                                      LookupHoistingMode lookup_hoisting_mode) {
      81             :   DCHECK_IMPLIES(lookup_hoisting_mode == LookupHoistingMode::kLegacySloppy,
      82             :                  language_mode == LanguageMode::kSloppy);
      83             :   return LanguageModeBit::encode(language_mode) |
      84       74756 :          LookupHoistingModeBit::encode(static_cast<bool>(lookup_hoisting_mode));
      85             : }
      86             : 
      87             : }  // namespace interpreter
      88             : }  // namespace internal
      89      121996 : }  // namespace v8

Generated by: LCOV version 1.10