blob: e68d539207b2b32300a3b1e947e6e26be5cf8221 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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
11namespace v8 {
12namespace internal {
13
14// static
15Callable 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
Emily Bernierd0a1eb72015-03-24 16:35:39 -040023Callable 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
Ben Murdochb8a8cc12014-11-26 15:28:44 +000035Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040036 return Callable(KeyedLoadIC::initialize_stub(isolate),
Ben Murdochb8a8cc12014-11-26 15:28:44 +000037 LoadDescriptor(isolate));
38}
39
40
41// static
Emily Bernierd0a1eb72015-03-24 16:35:39 -040042Callable 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
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052Callable CodeFactory::StoreIC(Isolate* isolate, StrictMode mode) {
53 return Callable(StoreIC::initialize_stub(isolate, mode),
54 StoreDescriptor(isolate));
55}
56
57
58// static
59Callable CodeFactory::KeyedStoreIC(Isolate* isolate, StrictMode mode) {
60 Handle<Code> ic = mode == SLOPPY
61 ? isolate->builtins()->KeyedStoreIC_Initialize()
62 : isolate->builtins()->KeyedStoreIC_Initialize_Strict();
63 return Callable(ic, StoreDescriptor(isolate));
64}
65
66
67// static
68Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
69 Handle<Code> code = CompareIC::GetUninitialized(isolate, op);
70 return Callable(code, BinaryOpDescriptor(isolate));
71}
72
73
74// static
75Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op,
76 OverwriteMode mode) {
77 BinaryOpICStub stub(isolate, op, mode);
78 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
79}
80
81
82// static
83Callable CodeFactory::ToBoolean(Isolate* isolate,
84 ToBooleanStub::ResultMode mode,
85 ToBooleanStub::Types types) {
86 ToBooleanStub stub(isolate, mode, types);
87 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
88}
89
90
91// static
92Callable CodeFactory::ToNumber(Isolate* isolate) {
93 ToNumberStub stub(isolate);
94 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
95}
96
97
98// static
99Callable CodeFactory::StringAdd(Isolate* isolate, StringAddFlags flags,
100 PretenureFlag pretenure_flag) {
101 StringAddStub stub(isolate, flags, pretenure_flag);
102 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
103}
104
105
106// static
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400107Callable CodeFactory::AllocateHeapNumber(Isolate* isolate) {
108 AllocateHeapNumberStub stub(isolate);
109 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
110}
111
112
113// static
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000114Callable CodeFactory::CallFunction(Isolate* isolate, int argc,
115 CallFunctionFlags flags) {
116 CallFunctionStub stub(isolate, argc, flags);
117 return Callable(stub.GetCode(), stub.GetCallInterfaceDescriptor());
118}
119
120} // namespace internal
121} // namespace v8