Home | History | Annotate | Download | only in interpreter
      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/builtins/builtins-constructor.h"
      8 #include "src/code-stubs.h"
      9 #include "src/objects-inl.h"
     10 
     11 namespace v8 {
     12 namespace internal {
     13 namespace interpreter {
     14 
     15 // static
     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
     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(
     30         ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties <=
     31         1 << CreateObjectLiteralFlags::FastClonePropertiesCountBits::kShift);
     32     DCHECK_LE(
     33         properties_count,
     34         ConstructorBuiltinsAssembler::kMaximumClonedShallowObjectProperties);
     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
     54