1 // Copyright 2012 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.
5 #ifndef V8_CODE_FACTORY_H_
6 #define V8_CODE_FACTORY_H_
8 #include "src/allocation.h"
9 #include "src/assembler.h"
10 #include "src/codegen.h"
11 #include "src/globals.h"
12 #include "src/interface-descriptors.h"
17 // Associates a body of code with an interface descriptor.
18 class Callable FINAL BASE_EMBEDDED {
20 Callable(Handle<Code> code, CallInterfaceDescriptor descriptor)
21 : code_(code), descriptor_(descriptor) {}
23 Handle<Code> code() const { return code_; }
24 CallInterfaceDescriptor descriptor() const { return descriptor_; }
27 const Handle<Code> code_;
28 const CallInterfaceDescriptor descriptor_;
32 class CodeFactory FINAL {
34 // Initial states for ICs.
35 static Callable LoadGlobalIC(Isolate* isolate, Handle<GlobalObject> global,
37 static Callable LoadIC(Isolate* isolate, ContextualMode mode);
38 static Callable LoadICInOptimizedCode(Isolate* isolate, ContextualMode mode,
39 InlineCacheState initialization_state);
40 static Callable KeyedLoadIC(Isolate* isolate);
41 static Callable KeyedLoadICInOptimizedCode(
42 Isolate* isolate, InlineCacheState initialization_state);
43 static Callable CallIC(Isolate* isolate, int argc,
44 CallICState::CallType call_type);
45 static Callable CallICInOptimizedCode(Isolate* isolate, int argc,
46 CallICState::CallType call_type);
47 static Callable StoreIC(Isolate* isolate, LanguageMode mode);
48 static Callable KeyedStoreIC(Isolate* isolate, LanguageMode mode);
49 static Callable KeyedStoreICInOptimizedCode(
50 Isolate* isolate, LanguageMode mode,
51 InlineCacheState initialization_state);
53 static Callable CompareIC(Isolate* isolate, Token::Value op);
55 static Callable BinaryOpIC(Isolate* isolate, Token::Value op);
57 // Code stubs. Add methods here as needed to reduce dependency on
59 static Callable ToBoolean(
60 Isolate* isolate, ToBooleanStub::ResultMode mode,
61 ToBooleanStub::Types types = ToBooleanStub::Types());
63 static Callable ToNumber(Isolate* isolate);
65 static Callable StringAdd(Isolate* isolate, StringAddFlags flags,
66 PretenureFlag pretenure_flag);
68 static Callable AllocateHeapNumber(Isolate* isolate);
70 static Callable CallFunction(Isolate* isolate, int argc,
71 CallFunctionFlags flags);
74 } // namespace internal
77 #endif // V8_CODE_FACTORY_H_