code-factory.h 4.56 KB
Newer Older
1 2 3 4
// Copyright 2012 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.

5 6
#ifndef V8_CODEGEN_CODE_FACTORY_H_
#define V8_CODEGEN_CODE_FACTORY_H_
7

8
#include "src/codegen/callable.h"
9
#include "src/codegen/interface-descriptors.h"
10 11
#include "src/common/globals.h"
#include "src/objects/type-hints.h"
12
#include "src/utils/allocation.h"
13 14 15 16

namespace v8 {
namespace internal {

17 18 19 20 21 22
// For ArrayNoArgumentConstructor and ArraySingleArgumentConstructor.
enum AllocationSiteOverrideMode {
  DONT_OVERRIDE,
  DISABLE_ALLOCATION_SITES,
};

23
class V8_EXPORT_PRIVATE CodeFactory final {
24
 public:
25
  // CEntry has var-args semantics (all the arguments are passed on the
26 27 28 29 30
  // stack and the arguments count is passed via register) which currently
  // can't be expressed in CallInterfaceDescriptor. Therefore only the code
  // is exported here.
  static Handle<Code> RuntimeCEntry(Isolate* isolate, int result_size = 1);

31 32 33 34 35
  static Handle<Code> CEntry(Isolate* isolate, int result_size = 1,
                             SaveFPRegsMode save_doubles = kDontSaveFPRegs,
                             ArgvMode argv_mode = kArgvOnStack,
                             bool builtin_exit_frame = false);

36
  // Initial states for ICs.
37 38 39
  static Callable LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode);
  static Callable LoadGlobalICInOptimizedCode(Isolate* isolate,
                                              TypeofMode typeof_mode);
40 41
  static Callable StoreOwnIC(Isolate* isolate);
  static Callable StoreOwnICInOptimizedCode(Isolate* isolate);
42

43 44
  static Callable KeyedStoreIC_SloppyArguments(Isolate* isolate,
                                               KeyedAccessStoreMode mode);
45 46 47 48
  static Callable ElementsTransitionAndStore(Isolate* isolate,
                                             KeyedAccessStoreMode mode);
  static Callable StoreFastElementIC(Isolate* isolate,
                                     KeyedAccessStoreMode mode);
49

50 51
  static Callable ResumeGenerator(Isolate* isolate);

52 53 54
  static Callable FrameDropperTrampoline(Isolate* isolate);
  static Callable HandleDebuggerStatement(Isolate* isolate);

55
  static Callable BinaryOperation(Isolate* isolate, Operation op);
56

57
  static Callable ApiGetter(Isolate* isolate);
58
  static Callable CallApiCallback(Isolate* isolate);
59

60 61 62 63
  static Callable NonPrimitiveToPrimitive(
      Isolate* isolate, ToPrimitiveHint hint = ToPrimitiveHint::kDefault);
  static Callable OrdinaryToPrimitive(Isolate* isolate,
                                      OrdinaryToPrimitiveHint hint);
64

65
  static Callable StringAdd(Isolate* isolate,
66
                            StringAddFlags flags = STRING_ADD_CHECK_NONE);
67

68 69
  static Callable FastNewFunctionContext(Isolate* isolate,
                                         ScopeType scope_type);
70

71
  static Callable ArgumentAdaptor(Isolate* isolate);
72
  static Callable Call(Isolate* isolate,
73
                       ConvertReceiverMode mode = ConvertReceiverMode::kAny);
74
  static Callable Call_WithFeedback(Isolate* isolate, ConvertReceiverMode mode);
75
  static Callable CallWithArrayLike(Isolate* isolate);
76
  static Callable CallWithSpread(Isolate* isolate);
77
  static Callable CallFunction(
78
      Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny);
79
  static Callable CallVarargs(Isolate* isolate);
80 81
  static Callable CallForwardVarargs(Isolate* isolate);
  static Callable CallFunctionForwardVarargs(Isolate* isolate);
82
  static Callable Construct(Isolate* isolate);
83
  static Callable ConstructWithSpread(Isolate* isolate);
84
  static Callable ConstructFunction(Isolate* isolate);
85
  static Callable ConstructVarargs(Isolate* isolate);
86 87
  static Callable ConstructForwardVarargs(Isolate* isolate);
  static Callable ConstructFunctionForwardVarargs(Isolate* isolate);
88

89 90 91 92 93
  static Callable InterpreterPushArgsThenCall(Isolate* isolate,
                                              ConvertReceiverMode receiver_mode,
                                              InterpreterPushArgsMode mode);
  static Callable InterpreterPushArgsThenConstruct(
      Isolate* isolate, InterpreterPushArgsMode mode);
94
  static Callable InterpreterCEntry(Isolate* isolate, int result_size = 1);
95
  static Callable InterpreterOnStackReplacement(Isolate* isolate);
96

97 98 99 100 101 102
  static Callable ArrayNoArgumentConstructor(
      Isolate* isolate, ElementsKind kind,
      AllocationSiteOverrideMode override_mode);
  static Callable ArraySingleArgumentConstructor(
      Isolate* isolate, ElementsKind kind,
      AllocationSiteOverrideMode override_mode);
103
};
104 105 106 107

}  // namespace internal
}  // namespace v8

108
#endif  // V8_CODEGEN_CODE_FACTORY_H_