code-factory.h 4.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// 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.

#ifndef V8_CODE_FACTORY_H_
#define V8_CODE_FACTORY_H_

#include "src/allocation.h"
#include "src/assembler.h"
#include "src/codegen.h"
#include "src/globals.h"
#include "src/interface-descriptors.h"

namespace v8 {
namespace internal {

// Associates a body of code with an interface descriptor.
18
class Callable final BASE_EMBEDDED {
19 20 21 22 23 24 25 26 27 28 29 30 31
 public:
  Callable(Handle<Code> code, CallInterfaceDescriptor descriptor)
      : code_(code), descriptor_(descriptor) {}

  Handle<Code> code() const { return code_; }
  CallInterfaceDescriptor descriptor() const { return descriptor_; }

 private:
  const Handle<Code> code_;
  const CallInterfaceDescriptor descriptor_;
};


32
class CodeFactory final {
33 34
 public:
  // Initial states for ICs.
35
  static Callable LoadIC(Isolate* isolate, TypeofMode typeof_mode,
36
                         LanguageMode language_mode);
37 38
  static Callable LoadICInOptimizedCode(Isolate* isolate,
                                        TypeofMode typeof_mode,
39
                                        LanguageMode language_mode,
40
                                        InlineCacheState initialization_state);
41
  static Callable KeyedLoadIC(Isolate* isolate, LanguageMode language_mode);
42
  static Callable KeyedLoadICInOptimizedCode(
43 44
      Isolate* isolate, LanguageMode language_mode,
      InlineCacheState initialization_state);
45 46 47 48 49
  static Callable CallIC(Isolate* isolate, int argc,
                         ConvertReceiverMode mode = ConvertReceiverMode::kAny);
  static Callable CallICInOptimizedCode(
      Isolate* isolate, int argc,
      ConvertReceiverMode mode = ConvertReceiverMode::kAny);
50
  static Callable StoreIC(Isolate* isolate, LanguageMode mode);
51 52
  static Callable StoreICInOptimizedCode(Isolate* isolate, LanguageMode mode,
                                         InlineCacheState initialization_state);
53
  static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode);
54 55 56
  static Callable KeyedStoreICInOptimizedCode(
      Isolate* isolate, LanguageMode mode,
      InlineCacheState initialization_state);
57

58
  static Callable CompareIC(Isolate* isolate, Token::Value op,
59
                            Strength strength);
60
  static Callable CompareNilIC(Isolate* isolate, NilValue nil_value);
61

62
  static Callable BinaryOpIC(Isolate* isolate, Token::Value op,
63
                             Strength strength);
64 65 66

  // Code stubs. Add methods here as needed to reduce dependency on
  // code-stubs.h.
67
  static Callable InstanceOf(Isolate* isolate);
68

69
  static Callable ToBoolean(Isolate* isolate);
70 71

  static Callable ToNumber(Isolate* isolate);
72
  static Callable ToString(Isolate* isolate);
73
  static Callable ToLength(Isolate* isolate);
74
  static Callable ToObject(Isolate* isolate);
75 76 77
  static Callable NumberToString(Isolate* isolate);

  static Callable RegExpConstructResult(Isolate* isolate);
78 79 80

  static Callable StringAdd(Isolate* isolate, StringAddFlags flags,
                            PretenureFlag pretenure_flag);
81
  static Callable StringCompare(Isolate* isolate);
82

83 84
  static Callable Typeof(Isolate* isolate);

85
  static Callable FastCloneRegExp(Isolate* isolate);
86 87 88
  static Callable FastCloneShallowArray(Isolate* isolate);
  static Callable FastCloneShallowObject(Isolate* isolate, int length);

89
  static Callable FastNewContext(Isolate* isolate, int slot_count);
90 91 92
  static Callable FastNewClosure(Isolate* isolate, LanguageMode language_mode,
                                 FunctionKind kind);

93 94 95
  static Callable ArgumentsAccess(Isolate* isolate, bool is_unmapped_arguments,
                                  bool has_duplicate_parameters);

96
  static Callable AllocateHeapNumber(Isolate* isolate);
97
  static Callable AllocateMutableHeapNumber(Isolate* isolate);
98
  static Callable AllocateInNewSpace(Isolate* isolate);
99

100
  static Callable ArgumentAdaptor(Isolate* isolate);
101 102 103 104
  static Callable Call(Isolate* isolate,
                       ConvertReceiverMode mode = ConvertReceiverMode::kAny);
  static Callable CallFunction(
      Isolate* isolate, ConvertReceiverMode mode = ConvertReceiverMode::kAny);
105
  static Callable Construct(Isolate* isolate);
106

107
  static Callable InterpreterPushArgsAndCall(Isolate* isolate);
108
  static Callable InterpreterPushArgsAndConstruct(Isolate* isolate);
109
  static Callable InterpreterCEntry(Isolate* isolate);
110
};
111 112 113 114

}  // namespace internal
}  // namespace v8

115
#endif  // V8_CODE_FACTORY_H_