Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(577)

Side by Side Diff: src/code-factory.cc

Issue 2187603004: [stubs] Using template magic to get the call interface descriptor type from callable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@code-factory-cleanup
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-factory.h ('k') | src/compiler/js-generic-lowering.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/ic/ic.h" 8 #include "src/ic/ic.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 namespace { 13 namespace {
14 14
15 // TODO(ishell): make it (const Stub& stub) once CodeStub::GetCode() is const. 15 // TODO(ishell): make it (const Stub& stub) once CodeStub::GetCode() is const.
16 template <typename Stub> 16 template <typename Stub>
17 Callable make_callable(Stub& stub) { 17 Callable make_callable(Stub& stub) {
18 typedef typename Stub::Descriptor Descriptor; 18 typedef typename Stub::Descriptor Descriptor;
19 return Callable(stub.GetCode(), Descriptor(stub.isolate())); 19 return Callable(stub.GetCode(), Descriptor(stub.isolate()));
20 } 20 }
21 21
22 // TODO(ishell): make it (const Stub& stub) once CodeStub::GetCode() is const.
23 template <typename Stub>
24 CallableD<typename Stub::Descriptor> make_callableD(Stub& stub) {
25 typedef typename Stub::Descriptor Descriptor;
26 return CallableD<Descriptor>(stub.GetCode(), stub.isolate());
27 }
28
22 } // namespace 29 } // namespace
23 30
24 // static 31 // static
25 Callable CodeFactory::LoadIC(Isolate* isolate) { 32 Callable CodeFactory::LoadIC(Isolate* isolate) {
26 if (FLAG_tf_load_ic_stub) { 33 if (FLAG_tf_load_ic_stub) {
27 LoadICTrampolineTFStub stub(isolate); 34 LoadICTrampolineTFStub stub(isolate);
28 return make_callable(stub); 35 return make_callable(stub);
29 } 36 }
30 LoadICTrampolineStub stub(isolate); 37 LoadICTrampolineStub stub(isolate);
31 return make_callable(stub); 38 return make_callable(stub);
32 } 39 }
33 40
34 // static 41 // static
35 Callable CodeFactory::ApiGetter(Isolate* isolate) { 42 Callable CodeFactory::ApiGetter(Isolate* isolate) {
36 CallApiGetterStub stub(isolate); 43 CallApiGetterStub stub(isolate);
37 return make_callable(stub); 44 return make_callable(stub);
38 } 45 }
39 46
40 // static 47 // static
41 Callable CodeFactory::LoadICInOptimizedCode(Isolate* isolate) { 48 CallableD<LoadWithVectorDescriptor> CodeFactory::LoadICInOptimizedCode(
49 Isolate* isolate) {
42 if (FLAG_tf_load_ic_stub) { 50 if (FLAG_tf_load_ic_stub) {
43 LoadICTFStub stub(isolate); 51 LoadICTFStub stub(isolate);
44 return make_callable(stub); 52 return make_callableD(stub);
45 } 53 }
46 LoadICStub stub(isolate); 54 LoadICStub stub(isolate);
47 return make_callable(stub); 55 return make_callableD(stub);
48 } 56 }
49 57
50 // static 58 // static
51 Callable CodeFactory::LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode) { 59 Callable CodeFactory::LoadGlobalIC(Isolate* isolate, TypeofMode typeof_mode) {
52 LoadGlobalICTrampolineStub stub(isolate, LoadGlobalICState(typeof_mode)); 60 LoadGlobalICTrampolineStub stub(isolate, LoadGlobalICState(typeof_mode));
53 return make_callable(stub); 61 return make_callable(stub);
54 } 62 }
55 63
56 // static 64 // static
57 Callable CodeFactory::LoadGlobalICInOptimizedCode(Isolate* isolate, 65 CallableD<LoadGlobalWithVectorDescriptor>
58 TypeofMode typeof_mode) { 66 CodeFactory::LoadGlobalICInOptimizedCode(Isolate* isolate,
67 TypeofMode typeof_mode) {
59 LoadGlobalICStub stub(isolate, LoadGlobalICState(typeof_mode)); 68 LoadGlobalICStub stub(isolate, LoadGlobalICState(typeof_mode));
60 return make_callable(stub); 69 return make_callableD(stub);
61 } 70 }
62 71
63 // static 72 // static
64 Callable CodeFactory::KeyedLoadIC(Isolate* isolate) { 73 Callable CodeFactory::KeyedLoadIC(Isolate* isolate) {
65 if (FLAG_tf_load_ic_stub) { 74 if (FLAG_tf_load_ic_stub) {
66 KeyedLoadICTrampolineTFStub stub(isolate); 75 KeyedLoadICTrampolineTFStub stub(isolate);
67 return make_callable(stub); 76 return make_callable(stub);
68 } 77 }
69 KeyedLoadICTrampolineStub stub(isolate); 78 KeyedLoadICTrampolineStub stub(isolate);
70 return make_callable(stub); 79 return make_callable(stub);
71 } 80 }
72 81
73 // static 82 // static
74 Callable CodeFactory::KeyedLoadICInOptimizedCode(Isolate* isolate) { 83 CallableD<LoadWithVectorDescriptor> CodeFactory::KeyedLoadICInOptimizedCode(
84 Isolate* isolate) {
75 if (FLAG_tf_load_ic_stub) { 85 if (FLAG_tf_load_ic_stub) {
76 KeyedLoadICTFStub stub(isolate); 86 KeyedLoadICTFStub stub(isolate);
77 return make_callable(stub); 87 return make_callableD(stub);
78 } 88 }
79 KeyedLoadICStub stub(isolate); 89 KeyedLoadICStub stub(isolate);
80 return make_callable(stub); 90 return make_callableD(stub);
81 } 91 }
82 92
83 // static 93 // static
84 Callable CodeFactory::KeyedLoadIC_Megamorphic(Isolate* isolate) { 94 Callable CodeFactory::KeyedLoadIC_Megamorphic(Isolate* isolate) {
85 return Callable(isolate->builtins()->KeyedLoadIC_Megamorphic(), 95 return Callable(isolate->builtins()->KeyedLoadIC_Megamorphic(),
86 LoadWithVectorDescriptor(isolate)); 96 LoadWithVectorDescriptor(isolate));
87 } 97 }
88 98
89 // static 99 // static
90 Callable CodeFactory::CallIC(Isolate* isolate, int argc, 100 Callable CodeFactory::CallIC(Isolate* isolate, int argc,
(...skipping 11 matching lines...) Expand all
102 return make_callable(stub); 112 return make_callable(stub);
103 } 113 }
104 114
105 // static 115 // static
106 Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) { 116 Callable CodeFactory::StoreIC(Isolate* isolate, LanguageMode language_mode) {
107 StoreICTrampolineStub stub(isolate, StoreICState(language_mode)); 117 StoreICTrampolineStub stub(isolate, StoreICState(language_mode));
108 return make_callable(stub); 118 return make_callable(stub);
109 } 119 }
110 120
111 // static 121 // static
112 Callable CodeFactory::StoreICInOptimizedCode(Isolate* isolate, 122 CallableD<StoreWithVectorDescriptor> CodeFactory::StoreICInOptimizedCode(
113 LanguageMode language_mode) { 123 Isolate* isolate, LanguageMode language_mode) {
114 StoreICStub stub(isolate, StoreICState(language_mode)); 124 StoreICStub stub(isolate, StoreICState(language_mode));
115 return make_callable(stub); 125 return make_callableD(stub);
116 } 126 }
117 127
118 // static 128 // static
119 Callable CodeFactory::KeyedStoreIC(Isolate* isolate, 129 Callable CodeFactory::KeyedStoreIC(Isolate* isolate,
120 LanguageMode language_mode) { 130 LanguageMode language_mode) {
121 KeyedStoreICTrampolineStub stub(isolate, StoreICState(language_mode)); 131 KeyedStoreICTrampolineStub stub(isolate, StoreICState(language_mode));
122 return make_callable(stub); 132 return make_callable(stub);
123 } 133 }
124 134
125 // static 135 // static
126 Callable CodeFactory::KeyedStoreICInOptimizedCode(Isolate* isolate, 136 CallableD<StoreWithVectorDescriptor> CodeFactory::KeyedStoreICInOptimizedCode(
127 LanguageMode language_mode) { 137 Isolate* isolate, LanguageMode language_mode) {
128 KeyedStoreICStub stub(isolate, StoreICState(language_mode)); 138 KeyedStoreICStub stub(isolate, StoreICState(language_mode));
129 return make_callable(stub); 139 return make_callableD(stub);
130 } 140 }
131 141
132 // static 142 // static
133 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) { 143 Callable CodeFactory::CompareIC(Isolate* isolate, Token::Value op) {
134 CompareICStub stub(isolate, op); 144 CompareICStub stub(isolate, op);
135 return make_callable(stub); 145 return make_callable(stub);
136 } 146 }
137 147
138 // static 148 // static
139 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) { 149 Callable CodeFactory::BinaryOpIC(Isolate* isolate, Token::Value op) {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 600 }
591 601
592 // static 602 // static
593 Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) { 603 Callable CodeFactory::InterpreterOnStackReplacement(Isolate* isolate) {
594 return Callable(isolate->builtins()->InterpreterOnStackReplacement(), 604 return Callable(isolate->builtins()->InterpreterOnStackReplacement(),
595 ContextOnlyDescriptor(isolate)); 605 ContextOnlyDescriptor(isolate));
596 } 606 }
597 607
598 } // namespace internal 608 } // namespace internal
599 } // namespace v8 609 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-factory.h ('k') | src/compiler/js-generic-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698