deps: update v8 to 4.3.61.21
[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::LoadGlobalIC(Isolate* isolate,
16                                    Handle<GlobalObject> global,
17                                    Handle<String> name) {
18   return Callable(LoadIC::load_global(isolate, global, name),
19                   LoadDescriptor(isolate));
20 }
21
22
23 // static
24 Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) {
25   return Callable(
26       LoadIC::initialize_stub(isolate, LoadICState(mode).GetExtraICState()),
27       LoadDescriptor(isolate));
28 }
29
30
31 // static
32 Callable CodeFactory::LoadICInOptimizedCode(
33     Isolate* isolate, ContextualMode mode,
34     InlineCacheState initialization_state) {
35   auto code = LoadIC::initialize_stub_in_optimized_code(
36       isolate, LoadICState(mode).GetExtraICState(), initialization_state);
37   if (FLAG_vector_ics) {
38     return Callable(code, VectorLoadICDescriptor(isolate));
39   }
40   return Callable(code, LoadDescriptor(isolate));
41 }
42
43
44 // static
45 Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
46   return Callable(KeyedLoadIC::initialize_stub(isolate),
47                   LoadDescriptor(isolate));
48 }
49
50
51 // static
52 Callable CodeFactory::KeyedLoadICInOptimizedCode(
53     Isolate* isolate, InlineCacheState initialization_state) {
54   auto code = KeyedLoadIC::initialize_stub_in_optimized_code(
55       isolate, initialization_state);
56   if (FLAG_vector_ics) {
57     return Callable(code, VectorLoadICDescriptor(isolate));
58   }
59   return Callable(code, LoadDescriptor(isolate));
60 }
61
62
63 // static
64 Callable CodeFactory::CallIC(Isolate* isolate, int argc,
65                              CallICState::CallType call_type) {
66   return Callable(CallIC::initialize_stub(isolate, argc, call_type),
67                   CallFunctionWithFeedbackDescriptor(isolate));
68 }
69
70
71 // static
72 Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, int argc,
73                                             CallICState::CallType call_type) {
74   return Callable(
75       CallIC::initialize_stub_in_optimized_code(isolate, argc, call_type),
76       CallFunctionWithFeedbackAndVectorDescriptor(isolate));
77 }
78
79
80 // static
81 Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
82   return Callable(
83       StoreIC::initialize_stub(isolate, language_mode, UNINITIALIZED),
84       StoreDescriptor(isolate));
85 }
86
87
88 // static
89 Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
90                                    LanguageMode language_mode) {
91   return Callable(
92       KeyedStoreIC::initialize_stub(isolate, language_mode, UNINITIALIZED),
93       StoreDescriptor(isolate));
94 }
95
96
97 // static
98 Callable CodeFactory::KeyedStoreICInOptimizedCode(
99     Isolate* isolate, LanguageMode language_mode,
100     InlineCacheState initialization_state) {
101   return Callable(KeyedStoreIC::initialize_stub(isolate, language_mode,
102                                                 initialization_state),
103                   StoreDescriptor(isolate));
104 }
105
106
107 // static
108 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
109   Handle<Code> code = CompareIC::GetUninitialized(isolate, op);
110   return Callable(code, CompareDescriptor(isolate));
111 }
112
113
114 // static
115 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
116   BinaryOpICStub stub(isolate, op);
117   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
118 }
119
120
121 // static
122 Callable CodeFactory::ToBoolean(Isolate* isolate,
123                                 ToBooleanStub::ResultMode mode,
124                                 ToBooleanStub::Types types) {
125   ToBooleanStub stub(isolate, mode, types);
126   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
127 }
128
129
130 // static
131 Callable CodeFactory::ToNumber(Isolate* isolate) {
132   ToNumberStub stub(isolate);
133   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
134 }
135
136
137 // static
138 Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
139                                 PretenureFlag pretenure_flag) {
140   StringAddStub stub(isolate, flags, pretenure_flag);
141   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
142 }
143
144
145 // static
146 Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
147   AllocateHeapNumberStub stub(isolate);
148   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
149 }
150
151
152 // static
153 Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
154                                    CallFunctionFlags flags) {
155   CallFunctionStub stub(isolate, argc, flags);
156   return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
157 }
158
159 }  // namespace internal
160 }  // namespace v8