LCOV - code coverage report
Current view: top level - src/builtins - builtins.h (source / functions) Hit Total Coverage
Test: app.info Lines: 3 3 100.0 %
Date: 2017-04-26 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2011 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             : #ifndef V8_BUILTINS_BUILTINS_H_
       6             : #define V8_BUILTINS_BUILTINS_H_
       7             : 
       8             : #include "src/base/flags.h"
       9             : #include "src/builtins/builtins-definitions.h"
      10             : #include "src/globals.h"
      11             : 
      12             : namespace v8 {
      13             : namespace internal {
      14             : 
      15             : class Callable;
      16             : template <typename T>
      17             : class Handle;
      18             : class Isolate;
      19             : 
      20             : // Forward declarations.
      21             : class RootVisitor;
      22             : enum class InterpreterPushArgsMode : unsigned;
      23             : namespace compiler {
      24             : class CodeAssemblerState;
      25             : }
      26             : 
      27             : class Builtins {
      28             :  public:
      29             :   ~Builtins();
      30             : 
      31             :   void TearDown();
      32             : 
      33             :   // Garbage collection support.
      34             :   void IterateBuiltins(RootVisitor* v);
      35             : 
      36             :   // Disassembler support.
      37             :   const char* Lookup(byte* pc);
      38             : 
      39             :   enum Name : int32_t {
      40             : #define DEF_ENUM(Name, ...) k##Name,
      41             :     BUILTIN_LIST_ALL(DEF_ENUM)
      42             : #undef DEF_ENUM
      43             :         builtin_count
      44             :   };
      45             : 
      46             : #define DECLARE_BUILTIN_ACCESSOR(Name, ...) \
      47             :   V8_EXPORT_PRIVATE Handle<Code> Name();
      48             :   BUILTIN_LIST_ALL(DECLARE_BUILTIN_ACCESSOR)
      49             : #undef DECLARE_BUILTIN_ACCESSOR
      50             : 
      51             :   // Convenience wrappers.
      52             :   Handle<Code> CallFunction(
      53             :       ConvertReceiverMode = ConvertReceiverMode::kAny,
      54             :       TailCallMode tail_call_mode = TailCallMode::kDisallow);
      55             :   Handle<Code> Call(ConvertReceiverMode = ConvertReceiverMode::kAny,
      56             :                     TailCallMode tail_call_mode = TailCallMode::kDisallow);
      57             :   Handle<Code> CallBoundFunction(TailCallMode tail_call_mode);
      58             :   Handle<Code> NonPrimitiveToPrimitive(
      59             :       ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
      60             :   Handle<Code> OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint);
      61             :   Handle<Code> InterpreterPushArgsThenCall(ConvertReceiverMode receiver_mode,
      62             :                                            TailCallMode tail_call_mode,
      63             :                                            InterpreterPushArgsMode mode);
      64             :   Handle<Code> InterpreterPushArgsThenConstruct(InterpreterPushArgsMode mode);
      65             :   Handle<Code> NewFunctionContext(ScopeType scope_type);
      66             :   Handle<Code> NewCloneShallowArray(AllocationSiteMode allocation_mode);
      67             :   Handle<Code> NewCloneShallowObject(int length);
      68             : 
      69        9216 :   Code* builtin(Name name) {
      70             :     // Code::cast cannot be used here since we access builtins
      71             :     // during the marking phase of mark sweep. See IC::Clear.
      72    42582998 :     return reinterpret_cast<Code*>(builtins_[name]);
      73             :   }
      74             : 
      75             :   Address builtin_address(Name name) {
      76             :     return reinterpret_cast<Address>(&builtins_[name]);
      77             :   }
      78             : 
      79             :   static Callable CallableFor(Isolate* isolate, Name name);
      80             : 
      81             :   static const char* name(int index);
      82             : 
      83             :   // Returns the C++ entry point for builtins implemented in C++, and the null
      84             :   // Address otherwise.
      85             :   static Address CppEntryOf(int index);
      86             : 
      87             :   static bool IsCpp(int index);
      88             :   static bool IsApi(int index);
      89             :   static bool HasCppImplementation(int index);
      90             : 
      91             :   bool is_initialized() const { return initialized_; }
      92             : 
      93             :   // Used by SetupIsolateDelegate and Deserializer.
      94             :   void MarkInitialized() {
      95             :     DCHECK(!initialized_);
      96       60782 :     initialized_ = true;
      97             :   }
      98             : 
      99             :   MUST_USE_RESULT static MaybeHandle<Object> InvokeApiFunction(
     100             :       Isolate* isolate, bool is_construct, Handle<HeapObject> function,
     101             :       Handle<Object> receiver, int argc, Handle<Object> args[],
     102             :       Handle<HeapObject> new_target);
     103             : 
     104             :   enum ExitFrameType { EXIT, BUILTIN_EXIT };
     105             : 
     106             :   static void Generate_Adaptor(MacroAssembler* masm, Address builtin_address,
     107             :                                ExitFrameType exit_frame_type);
     108             : 
     109             :   static bool AllowDynamicFunction(Isolate* isolate, Handle<JSFunction> target,
     110             :                                    Handle<JSObject> target_global_proxy);
     111             : 
     112             :  private:
     113             :   Builtins();
     114             : 
     115             :   static void Generate_CallFunction(MacroAssembler* masm,
     116             :                                     ConvertReceiverMode mode,
     117             :                                     TailCallMode tail_call_mode);
     118             : 
     119             :   static void Generate_CallBoundFunctionImpl(MacroAssembler* masm,
     120             :                                              TailCallMode tail_call_mode);
     121             : 
     122             :   static void Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode,
     123             :                             TailCallMode tail_call_mode);
     124             :   static void Generate_CallForwardVarargs(MacroAssembler* masm,
     125             :                                           Handle<Code> code);
     126             : 
     127             :   static void Generate_InterpreterPushArgsThenCallImpl(
     128             :       MacroAssembler* masm, ConvertReceiverMode receiver_mode,
     129             :       TailCallMode tail_call_mode, InterpreterPushArgsMode mode);
     130             : 
     131             :   static void Generate_InterpreterPushArgsThenConstructImpl(
     132             :       MacroAssembler* masm, InterpreterPushArgsMode mode);
     133             : 
     134             : #define DECLARE_ASM(Name, ...) \
     135             :   static void Generate_##Name(MacroAssembler* masm);
     136             : #define DECLARE_TF(Name, ...) \
     137             :   static void Generate_##Name(compiler::CodeAssemblerState* state);
     138             : 
     139             :   BUILTIN_LIST(IGNORE_BUILTIN, IGNORE_BUILTIN, DECLARE_TF, DECLARE_TF,
     140             :                DECLARE_TF, DECLARE_TF, DECLARE_ASM, DECLARE_ASM)
     141             : 
     142             : #undef DECLARE_ASM
     143             : #undef DECLARE_TF
     144             : 
     145             :   // Note: These are always Code objects, but to conform with
     146             :   // IterateBuiltins() above which assumes Object**'s for the callback
     147             :   // function f, we use an Object* array here.
     148             :   Object* builtins_[builtin_count];
     149             :   bool initialized_;
     150             : 
     151             :   friend class Isolate;
     152             :   friend class SetupIsolateDelegate;
     153             : 
     154             :   DISALLOW_COPY_AND_ASSIGN(Builtins);
     155             : };
     156             : 
     157             : }  // namespace internal
     158             : }  // namespace v8
     159             : 
     160             : #endif  // V8_BUILTINS_BUILTINS_H_

Generated by: LCOV version 1.10