OLD | NEW |
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/compiler/js-generic-lowering.h" | 5 #include "src/compiler/js-generic-lowering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // The typeof operator doesn't need the current context. | 146 // The typeof operator doesn't need the current context. |
147 NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant()); | 147 NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant()); |
148 Callable callable = CodeFactory::Typeof(isolate()); | 148 Callable callable = CodeFactory::Typeof(isolate()); |
149 node->AppendInput(zone(), graph()->start()); | 149 node->AppendInput(zone(), graph()->start()); |
150 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate, | 150 ReplaceWithStubCall(node, callable, CallDescriptor::kNoAllocate, |
151 Operator::kEliminatable); | 151 Operator::kEliminatable); |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 void JSGenericLowering::LowerJSLoadProperty(Node* node) { | 155 void JSGenericLowering::LowerJSLoadProperty(Node* node) { |
156 Node* closure = NodeProperties::GetValueInput(node, 2); | |
157 Node* effect = NodeProperties::GetEffectInput(node); | |
158 Node* control = NodeProperties::GetControlInput(node); | |
159 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 156 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
160 const PropertyAccess& p = PropertyAccessOf(node->op()); | 157 const PropertyAccess& p = PropertyAccessOf(node->op()); |
161 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); | 158 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); |
162 // Load the type feedback vector from the closure. | 159 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
163 Node* literals = effect = graph()->NewNode( | |
164 machine()->Load(MachineType::AnyTagged()), closure, | |
165 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
166 effect, control); | |
167 Node* vector = effect = graph()->NewNode( | |
168 machine()->Load(MachineType::AnyTagged()), literals, | |
169 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
170 kHeapObjectTag), | |
171 effect, control); | |
172 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 160 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
173 node->ReplaceInput(3, vector); | 161 node->InsertInput(zone(), 3, vector); |
174 node->ReplaceInput(6, effect); | |
175 ReplaceWithStubCall(node, callable, flags); | 162 ReplaceWithStubCall(node, callable, flags); |
176 } | 163 } |
177 | 164 |
178 | 165 |
179 void JSGenericLowering::LowerJSLoadNamed(Node* node) { | 166 void JSGenericLowering::LowerJSLoadNamed(Node* node) { |
180 Node* closure = NodeProperties::GetValueInput(node, 1); | |
181 Node* effect = NodeProperties::GetEffectInput(node); | |
182 Node* control = NodeProperties::GetControlInput(node); | |
183 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 167 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
184 NamedAccess const& p = NamedAccessOf(node->op()); | 168 NamedAccess const& p = NamedAccessOf(node->op()); |
185 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); | 169 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); |
186 // Load the type feedback vector from the closure. | 170 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
187 Node* literals = effect = graph()->NewNode( | |
188 machine()->Load(MachineType::AnyTagged()), closure, | |
189 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
190 effect, control); | |
191 Node* vector = effect = graph()->NewNode( | |
192 machine()->Load(MachineType::AnyTagged()), literals, | |
193 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
194 kHeapObjectTag), | |
195 effect, control); | |
196 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); | 171 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name())); |
197 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); | 172 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index())); |
198 node->ReplaceInput(3, vector); | 173 node->InsertInput(zone(), 3, vector); |
199 node->ReplaceInput(6, effect); | |
200 ReplaceWithStubCall(node, callable, flags); | 174 ReplaceWithStubCall(node, callable, flags); |
201 } | 175 } |
202 | 176 |
203 | 177 |
204 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { | 178 void JSGenericLowering::LowerJSLoadGlobal(Node* node) { |
205 Node* closure = NodeProperties::GetValueInput(node, 0); | |
206 Node* effect = NodeProperties::GetEffectInput(node); | |
207 Node* control = NodeProperties::GetControlInput(node); | |
208 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 179 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
209 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); | 180 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op()); |
210 Callable callable = | 181 Callable callable = |
211 CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode()); | 182 CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode()); |
212 // Load the type feedback vector from the closure. | 183 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
213 Node* literals = effect = graph()->NewNode( | |
214 machine()->Load(MachineType::AnyTagged()), closure, | |
215 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
216 effect, control); | |
217 Node* vector = effect = graph()->NewNode( | |
218 machine()->Load(MachineType::AnyTagged()), literals, | |
219 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
220 kHeapObjectTag), | |
221 effect, control); | |
222 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name())); | 184 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name())); |
223 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index())); | 185 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index())); |
224 node->ReplaceInput(2, vector); | 186 node->InsertInput(zone(), 2, vector); |
225 node->ReplaceInput(5, effect); | |
226 ReplaceWithStubCall(node, callable, flags); | 187 ReplaceWithStubCall(node, callable, flags); |
227 } | 188 } |
228 | 189 |
229 | 190 |
230 void JSGenericLowering::LowerJSStoreProperty(Node* node) { | 191 void JSGenericLowering::LowerJSStoreProperty(Node* node) { |
231 Node* receiver = NodeProperties::GetValueInput(node, 0); | 192 Node* receiver = NodeProperties::GetValueInput(node, 0); |
232 Node* key = NodeProperties::GetValueInput(node, 1); | 193 Node* key = NodeProperties::GetValueInput(node, 1); |
233 Node* value = NodeProperties::GetValueInput(node, 2); | 194 Node* value = NodeProperties::GetValueInput(node, 2); |
234 Node* closure = NodeProperties::GetValueInput(node, 3); | |
235 Node* effect = NodeProperties::GetEffectInput(node); | |
236 Node* control = NodeProperties::GetControlInput(node); | |
237 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 195 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
238 PropertyAccess const& p = PropertyAccessOf(node->op()); | 196 PropertyAccess const& p = PropertyAccessOf(node->op()); |
239 LanguageMode language_mode = p.language_mode(); | 197 LanguageMode language_mode = p.language_mode(); |
240 Callable callable = | 198 Callable callable = |
241 CodeFactory::KeyedStoreICInOptimizedCode(isolate(), language_mode); | 199 CodeFactory::KeyedStoreICInOptimizedCode(isolate(), language_mode); |
242 // Load the type feedback vector from the closure. | 200 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
243 Node* literals = effect = graph()->NewNode( | |
244 machine()->Load(MachineType::AnyTagged()), closure, | |
245 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
246 effect, control); | |
247 Node* vector = effect = graph()->NewNode( | |
248 machine()->Load(MachineType::AnyTagged()), literals, | |
249 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
250 kHeapObjectTag), | |
251 effect, control); | |
252 typedef StoreWithVectorDescriptor Descriptor; | 201 typedef StoreWithVectorDescriptor Descriptor; |
253 node->InsertInputs(zone(), 0, 1); | 202 node->InsertInputs(zone(), 0, 2); |
254 node->ReplaceInput(Descriptor::kReceiver, receiver); | 203 node->ReplaceInput(Descriptor::kReceiver, receiver); |
255 node->ReplaceInput(Descriptor::kName, key); | 204 node->ReplaceInput(Descriptor::kName, key); |
256 node->ReplaceInput(Descriptor::kValue, value); | 205 node->ReplaceInput(Descriptor::kValue, value); |
257 node->ReplaceInput(Descriptor::kSlot, | 206 node->ReplaceInput(Descriptor::kSlot, |
258 jsgraph()->SmiConstant(p.feedback().index())); | 207 jsgraph()->SmiConstant(p.feedback().index())); |
259 node->ReplaceInput(Descriptor::kVector, vector); | 208 node->ReplaceInput(Descriptor::kVector, vector); |
260 node->ReplaceInput(7, effect); | |
261 ReplaceWithStubCall(node, callable, flags); | 209 ReplaceWithStubCall(node, callable, flags); |
262 } | 210 } |
263 | 211 |
264 | 212 |
265 void JSGenericLowering::LowerJSStoreNamed(Node* node) { | 213 void JSGenericLowering::LowerJSStoreNamed(Node* node) { |
266 Node* receiver = NodeProperties::GetValueInput(node, 0); | 214 Node* receiver = NodeProperties::GetValueInput(node, 0); |
267 Node* value = NodeProperties::GetValueInput(node, 1); | 215 Node* value = NodeProperties::GetValueInput(node, 1); |
268 Node* closure = NodeProperties::GetValueInput(node, 2); | |
269 Node* effect = NodeProperties::GetEffectInput(node); | |
270 Node* control = NodeProperties::GetControlInput(node); | |
271 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 216 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
272 NamedAccess const& p = NamedAccessOf(node->op()); | 217 NamedAccess const& p = NamedAccessOf(node->op()); |
273 Callable callable = | 218 Callable callable = |
274 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); | 219 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); |
275 // Load the type feedback vector from the closure. | 220 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
276 Node* literals = effect = graph()->NewNode( | |
277 machine()->Load(MachineType::AnyTagged()), closure, | |
278 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
279 effect, control); | |
280 Node* vector = effect = graph()->NewNode( | |
281 machine()->Load(MachineType::AnyTagged()), literals, | |
282 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
283 kHeapObjectTag), | |
284 effect, control); | |
285 typedef StoreWithVectorDescriptor Descriptor; | 221 typedef StoreWithVectorDescriptor Descriptor; |
286 node->InsertInputs(zone(), 0, 2); | 222 node->InsertInputs(zone(), 0, 3); |
287 node->ReplaceInput(Descriptor::kReceiver, receiver); | 223 node->ReplaceInput(Descriptor::kReceiver, receiver); |
288 node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name())); | 224 node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name())); |
289 node->ReplaceInput(Descriptor::kValue, value); | 225 node->ReplaceInput(Descriptor::kValue, value); |
290 node->ReplaceInput(Descriptor::kSlot, | 226 node->ReplaceInput(Descriptor::kSlot, |
291 jsgraph()->SmiConstant(p.feedback().index())); | 227 jsgraph()->SmiConstant(p.feedback().index())); |
292 node->ReplaceInput(Descriptor::kVector, vector); | 228 node->ReplaceInput(Descriptor::kVector, vector); |
293 node->ReplaceInput(7, effect); | |
294 ReplaceWithStubCall(node, callable, flags); | 229 ReplaceWithStubCall(node, callable, flags); |
295 } | 230 } |
296 | 231 |
297 | 232 |
298 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { | 233 void JSGenericLowering::LowerJSStoreGlobal(Node* node) { |
299 Node* value = NodeProperties::GetValueInput(node, 0); | 234 Node* value = NodeProperties::GetValueInput(node, 0); |
300 Node* closure = NodeProperties::GetValueInput(node, 1); | |
301 Node* context = NodeProperties::GetContextInput(node); | 235 Node* context = NodeProperties::GetContextInput(node); |
302 Node* effect = NodeProperties::GetEffectInput(node); | 236 Node* effect = NodeProperties::GetEffectInput(node); |
303 Node* control = NodeProperties::GetControlInput(node); | 237 Node* control = NodeProperties::GetControlInput(node); |
304 CallDescriptor::Flags flags = FrameStateFlagForCall(node); | 238 CallDescriptor::Flags flags = FrameStateFlagForCall(node); |
305 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); | 239 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op()); |
306 Callable callable = | 240 Callable callable = |
307 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); | 241 CodeFactory::StoreICInOptimizedCode(isolate(), p.language_mode()); |
308 // Load the type feedback vector from the closure. | 242 Node* vector = jsgraph()->HeapConstant(p.feedback().vector()); |
309 Node* literals = effect = graph()->NewNode( | |
310 machine()->Load(MachineType::AnyTagged()), closure, | |
311 jsgraph()->IntPtrConstant(JSFunction::kLiteralsOffset - kHeapObjectTag), | |
312 effect, control); | |
313 Node* vector = effect = graph()->NewNode( | |
314 machine()->Load(MachineType::AnyTagged()), literals, | |
315 jsgraph()->IntPtrConstant(LiteralsArray::kFeedbackVectorOffset - | |
316 kHeapObjectTag), | |
317 effect, control); | |
318 // Load global object from the context. | 243 // Load global object from the context. |
319 Node* native_context = effect = | 244 Node* native_context = effect = |
320 graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context, | 245 graph()->NewNode(machine()->Load(MachineType::AnyTagged()), context, |
321 jsgraph()->IntPtrConstant( | 246 jsgraph()->IntPtrConstant( |
322 Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)), | 247 Context::SlotOffset(Context::NATIVE_CONTEXT_INDEX)), |
323 effect, control); | 248 effect, control); |
324 Node* global = effect = graph()->NewNode( | 249 Node* global = effect = graph()->NewNode( |
325 machine()->Load(MachineType::AnyTagged()), native_context, | 250 machine()->Load(MachineType::AnyTagged()), native_context, |
326 jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)), | 251 jsgraph()->IntPtrConstant(Context::SlotOffset(Context::EXTENSION_INDEX)), |
327 effect, control); | 252 effect, control); |
328 typedef StoreWithVectorDescriptor Descriptor; | 253 typedef StoreWithVectorDescriptor Descriptor; |
329 node->InsertInputs(zone(), 0, 3); | 254 node->InsertInputs(zone(), 0, 4); |
330 node->ReplaceInput(Descriptor::kReceiver, global); | 255 node->ReplaceInput(Descriptor::kReceiver, global); |
331 node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name())); | 256 node->ReplaceInput(Descriptor::kName, jsgraph()->HeapConstant(p.name())); |
332 node->ReplaceInput(Descriptor::kValue, value); | 257 node->ReplaceInput(Descriptor::kValue, value); |
333 node->ReplaceInput(Descriptor::kSlot, | 258 node->ReplaceInput(Descriptor::kSlot, |
334 jsgraph()->SmiConstant(p.feedback().index())); | 259 jsgraph()->SmiConstant(p.feedback().index())); |
335 node->ReplaceInput(Descriptor::kVector, vector); | 260 node->ReplaceInput(Descriptor::kVector, vector); |
336 node->ReplaceInput(7, effect); | 261 node->ReplaceInput(7, effect); |
337 ReplaceWithStubCall(node, callable, flags); | 262 ReplaceWithStubCall(node, callable, flags); |
338 } | 263 } |
339 | 264 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 638 } |
714 | 639 |
715 | 640 |
716 MachineOperatorBuilder* JSGenericLowering::machine() const { | 641 MachineOperatorBuilder* JSGenericLowering::machine() const { |
717 return jsgraph()->machine(); | 642 return jsgraph()->machine(); |
718 } | 643 } |
719 | 644 |
720 } // namespace compiler | 645 } // namespace compiler |
721 } // namespace internal | 646 } // namespace internal |
722 } // namespace v8 | 647 } // namespace v8 |
OLD | NEW |