aboutsummaryrefslogtreecommitdiff
path: root/src/interpreter/bytecode-flags.cc
blob: 158af13ea73edd39372cfcecef332e29628112da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/interpreter/bytecode-flags.h"

#include "src/code-stubs.h"

namespace v8 {
namespace internal {
namespace interpreter {

// static
uint8_t CreateArrayLiteralFlags::Encode(bool use_fast_shallow_clone,
                                        int runtime_flags) {
  uint8_t result = FlagsBits::encode(runtime_flags);
  result |= FastShallowCloneBit::encode(use_fast_shallow_clone);
  return result;
}

// static
uint8_t CreateObjectLiteralFlags::Encode(bool fast_clone_supported,
                                         int properties_count,
                                         int runtime_flags) {
  uint8_t result = FlagsBits::encode(runtime_flags);
  if (fast_clone_supported) {
    STATIC_ASSERT(
        FastCloneShallowObjectStub::kMaximumClonedProperties <=
        1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift);
    DCHECK_LE(properties_count,
              FastCloneShallowObjectStub::kMaximumClonedProperties);
    result |= CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode(
        properties_count);
  }
  return result;
}

// static
uint8_t CreateClosureFlags::Encode(bool pretenure, bool is_function_scope) {
  uint8_t result = PretenuredBit::encode(pretenure);
  if (!FLAG_always_opt && !FLAG_prepare_always_opt &&
      pretenure == NOT_TENURED && is_function_scope) {
    result |= FastNewClosureBit::encode(true);
  }
  return result;
}

}  // namespace interpreter
}  // namespace internal
}  // namespace v8