blob: 57277c8a33657727197a391e41ff5b9bc1f3f44c [file] [log] [blame]
Ben Murdochf91f0612016-11-29 16:50:11 +00001// 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
Ben Murdoch62ed6312017-06-06 11:06:27 +01007#include "src/builtins/builtins-constructor.h"
Ben Murdochf91f0612016-11-29 16:50:11 +00008#include "src/code-stubs.h"
Ben Murdoch62ed6312017-06-06 11:06:27 +01009#include "src/objects-inl.h"
Ben Murdochf91f0612016-11-29 16:50:11 +000010
11namespace v8 {
12namespace internal {
13namespace interpreter {
14
15// static
Ben Murdochf3b273f2017-01-17 12:11:28 +000016uint8_t CreateArrayLiteralFlags::Encode(bool use_fast_shallow_clone,
17 int runtime_flags) {
18 uint8_t result = FlagsBits::encode(runtime_flags);
19 result |= FastShallowCloneBit::encode(use_fast_shallow_clone);
20 return result;
21}
22
23// static
Ben Murdochf91f0612016-11-29 16:50:11 +000024uint8_t CreateObjectLiteralFlags::Encode(bool fast_clone_supported,
25 int properties_count,
26 int runtime_flags) {
27 uint8_t result = FlagsBits::encode(runtime_flags);
28 if (fast_clone_supported) {
29 STATIC_ASSERT(
Ben Murdoch62ed6312017-06-06 11:06:27 +010030 ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties <=
Ben Murdochf91f0612016-11-29 16:50:11 +000031 1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift);
Ben Murdoch62ed6312017-06-06 11:06:27 +010032 DCHECK_LE(
33 properties_count,
34 ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties);
Ben Murdochf91f0612016-11-29 16:50:11 +000035 result |= CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode(
36 properties_count);
37 }
38 return result;
39}
40
41// static
42uint8_t CreateClosureFlags::Encode(bool pretenure, bool is_function_scope) {
43 uint8_t result = PretenuredBit::encode(pretenure);
44 if (!FLAG_always_opt && !FLAG_prepare_always_opt &&
45 pretenure == NOT_TENURED && is_function_scope) {
46 result |= FastNewClosureBit::encode(true);
47 }
48 return result;
49}
50
51} // namespace interpreter
52} // namespace internal
53} // namespace v8