| Ben Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 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 | |
| Ben Murdoch | 62ed631 | 2017-06-06 11:06:27 +0100 | [diff] [blame^] | 7 | #include "src/builtins/builtins-constructor.h" |
| Ben Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 8 | #include "src/code-stubs.h" |
| Ben Murdoch | 62ed631 | 2017-06-06 11:06:27 +0100 | [diff] [blame^] | 9 | #include "src/objects-inl.h" |
| Ben Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
| 13 | namespace interpreter { |
| 14 | |
| 15 | // static |
| Ben Murdoch | f3b273f | 2017-01-17 12:11:28 +0000 | [diff] [blame] | 16 | uint8_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 Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 24 | uint8_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 Murdoch | 62ed631 | 2017-06-06 11:06:27 +0100 | [diff] [blame^] | 30 | ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties <= |
| Ben Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 31 | 1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift); |
| Ben Murdoch | 62ed631 | 2017-06-06 11:06:27 +0100 | [diff] [blame^] | 32 | DCHECK_LE( |
| 33 | properties_count, |
| 34 | ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties); |
| Ben Murdoch | f91f061 | 2016-11-29 16:50:11 +0000 | [diff] [blame] | 35 | result |= CreateObjectLiteralFlags::FastClonePropertiesCountBits::encode( |
| 36 | properties_count); |
| 37 | } |
| 38 | return result; |
| 39 | } |
| 40 | |
| 41 | // static |
| 42 | uint8_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 |