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.
7 #include "src/bootstrapper.h"
8 #include "src/code-factory.h"
15 Callable CodeFactory::LoadIC(Isolate* isolate, ContextualMode mode) {
17 LoadIC::initialize_stub(isolate, LoadICState(mode).GetExtraICState()),
18 LoadDescriptor(isolate));
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));
30 return CodeFactory::LoadIC(isolate, mode);
35 Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
36 return Callable(KeyedLoadIC::initialize_stub(isolate),
37 LoadDescriptor(isolate));
42 Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) {
43 if (FLAG_vector_ics) {
44 return Callable(KeyedLoadIC::initialize_stub_in_optimized_code(isolate),
45 VectorLoadICDescriptor(isolate));
47 return CodeFactory::KeyedLoadIC(isolate);
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));
60 Callable CodeFactory::CallICInOptimizedCode(Isolate* isolate, int argc,
61 CallICState::CallType call_type) {
63 CallIC::initialize_stub_in_optimized_code(isolate, argc, call_type),
64 CallFunctionWithFeedbackAndVectorDescriptor(isolate));
69 Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
70 return Callable(StoreIC::initialize_stub(isolate, language_mode),
71 StoreDescriptor(isolate));
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));
86 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
87 Handle<Code> code = CompareIC::GetUninitialized(isolate, op);
88 return Callable(code, BinaryOpDescriptor(isolate));
93 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
94 BinaryOpICStub stub(isolate, op);
95 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
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());
109 Callable CodeFactory::ToNumber(Isolate* isolate) {
110 ToNumberStub stub(isolate);
111 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
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());
124 Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
125 AllocateHeapNumberStub stub(isolate);
126 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
131 Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
132 CallFunctionFlags flags) {
133 CallFunctionStub stub(isolate, argc, flags);
134 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
137 } // namespace internal