590dbbb027c789670cd565f13f58d0de6e4fd3eb
[platform/upstream/nodejs.git] / deps / v8 / src / code-factory.cc
1 // Copyright 2014 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/v8.h"
6
7 #include "src/bootstrapper.h"
8 #include "src/code-factory.h"
9 #include "src/ic/ic.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // static
15 Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) {
16   return Callable(
17       LoadIC::initialize_stub(isolate, LoadICState(mode).GetExtraICState()),
18       LoadDescriptor(isolate));
19 }
20
21
22 // static
23 Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate,
24                                             ContextualMode mode) {
25   if (FLAG_vector_ics) {
26     return Callable(LoadIC::initialize_stub_in_optimized_code(
27                         isolate, LoadICState(mode).GetExtraICState()),
28                     VectorLoadICDescriptor(isolate));
29   }
30   return CodeFactory::LoadIC(isolate, mode);
31 }
32
33
34 // static
35 Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
36   return Callable(KeyedLoadIC::initialize_stub(isolate),
37                   LoadDescriptor(isolate));
38 }
39
40
41 // static
42 Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) {
43   if (FLAG_vector_ics) {
44     return Callable(KeyedLoadIC::initialize_stub_in_optimized_code(isolate),
45                     VectorLoadICDescriptor(isolate));
46   }
47   return CodeFactory::KeyedLoadIC(isolate);
48 }
49
50
51 // static
52 Callable CodeFactory::CallIC(Isolate* isolate, int argc,
53                              CallICState::CallType call_type) {
54   return Callable(CallIC::initialize_stub(isolate, argc, call_type),
55                   CallFunctionWithFeedbackDescriptor(isolate));
56 }
57
58
59 // static
60 Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, int argc,
61                                             CallICState::CallType call_type) {
62   return Callable(
63       CallIC::initialize_stub_in_optimized_code(isolate, argc, call_type),
64       CallFunctionWithFeedbackAndVectorDescriptor(isolate));
65 }
66
67
68 // static
69 Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
70   return Callable(StoreIC::initialize_stub(isolate, language_mode),
71                   StoreDescriptor(isolate));
72 }
73
74
75 // static
76 Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
77                                    LanguageMode language_mode) {
78   Handle<Code> ic = is_strict(language_mode)
79                         ? isolate->builtins()->KeyedStoreIC_Initialize_Strict()
80                         : isolate->builtins()->KeyedStoreIC_Initialize();
81   return Callable(ic, StoreDescriptor(isolate));
82 }
83
84
85 // static
86 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
87   Handle<Code> code = CompareIC::GetUninitialized(isolate, op);
88   return Callable(code, BinaryOpDescriptor(isolate));
89 }
90
91
92 // static
93 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
94   BinaryOpICStub stub(isolate, op);
95   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
96 }
97
98
99 // static
100 Callable CodeFactory::ToBoolean(Isolate* isolate,
101                                 ToBooleanStub::ResultMode mode,
102                                 ToBooleanStub::Types types) {
103   ToBooleanStub stub(isolate, mode, types);
104   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
105 }
106
107
108 // static
109 Callable CodeFactory::ToNumber(Isolate* isolate) {
110   ToNumberStub stub(isolate);
111   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
112 }
113
114
115 // static
116 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
117                                 PretenureFlag pretenure_flag) {
118   StringAddStub stub(isolate, flags, pretenure_flag);
119   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
120 }
121
122
123 // static
124 Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
125   AllocateHeapNumberStub stub(isolate);
126   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
127 }
128
129
130 // static
131 Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
132                                    CallFunctionFlags flags) {
133   CallFunctionStub stub(isolate, argc, flags);
134   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
135 }
136
137 }  // namespace internal
138 }  // namespace v8