OLD | NEW |
| (Empty) |
1 // Copyright 2016 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/builtins/builtins-utils.h" | |
6 #include "src/builtins/builtins.h" | |
7 #include "src/code-stub-assembler.h" | |
8 #include "src/ic/handler-compiler.h" | |
9 #include "src/ic/ic.h" | |
10 #include "src/ic/keyed-store-generic.h" | |
11 #include "src/objects-inl.h" | |
12 | |
13 namespace v8 { | |
14 namespace internal { | |
15 | |
16 TF_BUILTIN(KeyedLoadIC_IndexedString, CodeStubAssembler) { | |
17 typedef LoadWithVectorDescriptor Descriptor; | |
18 | |
19 Node* receiver = Parameter(Descriptor::kReceiver); | |
20 Node* index = Parameter(Descriptor::kName); | |
21 Node* slot = Parameter(Descriptor::kSlot); | |
22 Node* vector = Parameter(Descriptor::kVector); | |
23 Node* context = Parameter(Descriptor::kContext); | |
24 | |
25 Label miss(this); | |
26 | |
27 Node* index_intptr = TryToIntptr(index, &miss); | |
28 Node* length = SmiUntag(LoadStringLength(receiver)); | |
29 GotoIf(UintPtrGreaterThanOrEqual(index_intptr, length), &miss); | |
30 | |
31 Node* code = StringCharCodeAt(receiver, index_intptr, INTPTR_PARAMETERS); | |
32 Node* result = StringFromCharCode(code); | |
33 Return(result); | |
34 | |
35 Bind(&miss); | |
36 TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, index, slot, | |
37 vector); | |
38 } | |
39 | |
40 TF_BUILTIN(KeyedLoadIC_Miss, CodeStubAssembler) { | |
41 typedef LoadWithVectorDescriptor Descriptor; | |
42 | |
43 Node* receiver = Parameter(Descriptor::kReceiver); | |
44 Node* name = Parameter(Descriptor::kName); | |
45 Node* slot = Parameter(Descriptor::kSlot); | |
46 Node* vector = Parameter(Descriptor::kVector); | |
47 Node* context = Parameter(Descriptor::kContext); | |
48 | |
49 TailCallRuntime(Runtime::kKeyedLoadIC_Miss, context, receiver, name, slot, | |
50 vector); | |
51 } | |
52 | |
53 TF_BUILTIN(KeyedLoadIC_Slow, CodeStubAssembler) { | |
54 typedef LoadWithVectorDescriptor Descriptor; | |
55 | |
56 Node* receiver = Parameter(Descriptor::kReceiver); | |
57 Node* name = Parameter(Descriptor::kName); | |
58 Node* context = Parameter(Descriptor::kContext); | |
59 | |
60 TailCallRuntime(Runtime::kKeyedGetProperty, context, receiver, name); | |
61 } | |
62 | |
63 void Builtins::Generate_KeyedStoreIC_Megamorphic( | |
64 compiler::CodeAssemblerState* state) { | |
65 KeyedStoreGenericGenerator::Generate(state, SLOPPY); | |
66 } | |
67 | |
68 void Builtins::Generate_KeyedStoreIC_Megamorphic_Strict( | |
69 compiler::CodeAssemblerState* state) { | |
70 KeyedStoreGenericGenerator::Generate(state, STRICT); | |
71 } | |
72 | |
73 void Builtins::Generate_StoreIC_Uninitialized( | |
74 compiler::CodeAssemblerState* state) { | |
75 StoreICUninitializedGenerator::Generate(state, SLOPPY); | |
76 } | |
77 | |
78 void Builtins::Generate_StoreICStrict_Uninitialized( | |
79 compiler::CodeAssemblerState* state) { | |
80 StoreICUninitializedGenerator::Generate(state, STRICT); | |
81 } | |
82 | |
83 TF_BUILTIN(KeyedStoreIC_Miss, CodeStubAssembler) { | |
84 typedef StoreWithVectorDescriptor Descriptor; | |
85 | |
86 Node* receiver = Parameter(Descriptor::kReceiver); | |
87 Node* name = Parameter(Descriptor::kName); | |
88 Node* value = Parameter(Descriptor::kValue); | |
89 Node* slot = Parameter(Descriptor::kSlot); | |
90 Node* vector = Parameter(Descriptor::kVector); | |
91 Node* context = Parameter(Descriptor::kContext); | |
92 | |
93 TailCallRuntime(Runtime::kKeyedStoreIC_Miss, context, value, slot, vector, | |
94 receiver, name); | |
95 } | |
96 | |
97 TF_BUILTIN(KeyedStoreIC_Slow, CodeStubAssembler) { | |
98 typedef StoreWithVectorDescriptor Descriptor; | |
99 | |
100 Node* receiver = Parameter(Descriptor::kReceiver); | |
101 Node* name = Parameter(Descriptor::kName); | |
102 Node* value = Parameter(Descriptor::kValue); | |
103 Node* slot = Parameter(Descriptor::kSlot); | |
104 Node* vector = Parameter(Descriptor::kVector); | |
105 Node* context = Parameter(Descriptor::kContext); | |
106 | |
107 // The slow case calls into the runtime to complete the store without causing | |
108 // an IC miss that would otherwise cause a transition to the generic stub. | |
109 TailCallRuntime(Runtime::kKeyedStoreIC_Slow, context, value, slot, vector, | |
110 receiver, name); | |
111 } | |
112 | |
113 TF_BUILTIN(LoadGlobalIC_Miss, CodeStubAssembler) { | |
114 typedef LoadGlobalWithVectorDescriptor Descriptor; | |
115 | |
116 Node* name = Parameter(Descriptor::kName); | |
117 Node* slot = Parameter(Descriptor::kSlot); | |
118 Node* vector = Parameter(Descriptor::kVector); | |
119 Node* context = Parameter(Descriptor::kContext); | |
120 | |
121 TailCallRuntime(Runtime::kLoadGlobalIC_Miss, context, name, slot, vector); | |
122 } | |
123 | |
124 TF_BUILTIN(LoadGlobalIC_Slow, CodeStubAssembler) { | |
125 typedef LoadGlobalWithVectorDescriptor Descriptor; | |
126 | |
127 Node* name = Parameter(Descriptor::kName); | |
128 Node* slot = Parameter(Descriptor::kSlot); | |
129 Node* vector = Parameter(Descriptor::kVector); | |
130 Node* context = Parameter(Descriptor::kContext); | |
131 | |
132 TailCallRuntime(Runtime::kLoadGlobalIC_Slow, context, name, slot, vector); | |
133 } | |
134 | |
135 void Builtins::Generate_LoadIC_Getter_ForDeopt(MacroAssembler* masm) { | |
136 NamedLoadHandlerCompiler::GenerateLoadViaGetterForDeopt(masm); | |
137 } | |
138 | |
139 TF_BUILTIN(LoadIC_FunctionPrototype, CodeStubAssembler) { | |
140 typedef LoadWithVectorDescriptor Descriptor; | |
141 | |
142 Node* receiver = Parameter(Descriptor::kReceiver); | |
143 Node* name = Parameter(Descriptor::kName); | |
144 Node* slot = Parameter(Descriptor::kSlot); | |
145 Node* vector = Parameter(Descriptor::kVector); | |
146 Node* context = Parameter(Descriptor::kContext); | |
147 | |
148 Label miss(this); | |
149 | |
150 Node* proto_or_map = | |
151 LoadObjectField(receiver, JSFunction::kPrototypeOrInitialMapOffset); | |
152 GotoIf(IsTheHole(proto_or_map), &miss); | |
153 | |
154 Variable var_result(this, MachineRepresentation::kTagged, proto_or_map); | |
155 Label done(this, &var_result); | |
156 GotoIfNot(IsMap(proto_or_map), &done); | |
157 | |
158 var_result.Bind(LoadMapPrototype(proto_or_map)); | |
159 Goto(&done); | |
160 | |
161 Bind(&done); | |
162 Return(var_result.value()); | |
163 | |
164 Bind(&miss); | |
165 TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name, slot, vector); | |
166 } | |
167 | |
168 TF_BUILTIN(LoadIC_Miss, CodeStubAssembler) { | |
169 typedef LoadWithVectorDescriptor Descriptor; | |
170 | |
171 Node* receiver = Parameter(Descriptor::kReceiver); | |
172 Node* name = Parameter(Descriptor::kName); | |
173 Node* slot = Parameter(Descriptor::kSlot); | |
174 Node* vector = Parameter(Descriptor::kVector); | |
175 Node* context = Parameter(Descriptor::kContext); | |
176 | |
177 TailCallRuntime(Runtime::kLoadIC_Miss, context, receiver, name, slot, vector); | |
178 } | |
179 | |
180 TF_BUILTIN(LoadIC_Slow, CodeStubAssembler) { | |
181 typedef LoadWithVectorDescriptor Descriptor; | |
182 | |
183 Node* receiver = Parameter(Descriptor::kReceiver); | |
184 Node* name = Parameter(Descriptor::kName); | |
185 Node* context = Parameter(Descriptor::kContext); | |
186 | |
187 TailCallRuntime(Runtime::kGetProperty, context, receiver, name); | |
188 } | |
189 | |
190 TF_BUILTIN(StoreIC_Miss, CodeStubAssembler) { | |
191 typedef StoreWithVectorDescriptor Descriptor; | |
192 | |
193 Node* receiver = Parameter(Descriptor::kReceiver); | |
194 Node* name = Parameter(Descriptor::kName); | |
195 Node* value = Parameter(Descriptor::kValue); | |
196 Node* slot = Parameter(Descriptor::kSlot); | |
197 Node* vector = Parameter(Descriptor::kVector); | |
198 Node* context = Parameter(Descriptor::kContext); | |
199 | |
200 TailCallRuntime(Runtime::kStoreIC_Miss, context, value, slot, vector, | |
201 receiver, name); | |
202 } | |
203 | |
204 void Builtins::Generate_StoreIC_Setter_ForDeopt(MacroAssembler* masm) { | |
205 NamedStoreHandlerCompiler::GenerateStoreViaSetterForDeopt(masm); | |
206 } | |
207 | |
208 } // namespace internal | |
209 } // namespace v8 | |
OLD | NEW |