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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1466643002: [turbofan] Initial support for Array constructor specialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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
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 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 NodeProperties::GetValueInput(node, 0), effect, control)); 1225 NodeProperties::GetValueInput(node, 0), effect, control));
1226 } 1226 }
1227 node->RemoveInput(2); 1227 node->RemoveInput(2);
1228 NodeProperties::ChangeOp( 1228 NodeProperties::ChangeOp(
1229 node, 1229 node,
1230 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); 1230 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index())));
1231 return Changed(node); 1231 return Changed(node);
1232 } 1232 }
1233 1233
1234 1234
1235 Reduction JSTypedLowering::ReduceJSLoadNativeContext(Node* node) {
1236 DCHECK_EQ(IrOpcode::kJSLoadNativeContext, node->opcode());
1237 Node* const effect = NodeProperties::GetEffectInput(node);
1238 Node* const control = graph()->start();
1239 node->ReplaceInput(1, effect);
1240 node->ReplaceInput(2, control);
1241 NodeProperties::ChangeOp(
1242 node,
1243 simplified()->LoadField(AccessBuilder::ForJSGlobalObjectNativeContext()));
1244 return Changed(node);
1245 }
1246
1247
1235 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { 1248 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) {
1236 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); 1249 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode());
1237 ConvertReceiverMode mode = ConvertReceiverModeOf(node->op()); 1250 ConvertReceiverMode mode = ConvertReceiverModeOf(node->op());
1238 Node* receiver = NodeProperties::GetValueInput(node, 0); 1251 Node* receiver = NodeProperties::GetValueInput(node, 0);
1239 Type* receiver_type = NodeProperties::GetType(receiver); 1252 Type* receiver_type = NodeProperties::GetType(receiver);
1240 Node* context = NodeProperties::GetContextInput(node); 1253 Node* context = NodeProperties::GetContextInput(node);
1241 Type* context_type = NodeProperties::GetType(context); 1254 Type* context_type = NodeProperties::GetType(context);
1242 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0); 1255 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
1243 Node* effect = NodeProperties::GetEffectInput(node); 1256 Node* effect = NodeProperties::GetEffectInput(node);
1244 Node* control = NodeProperties::GetControlInput(node); 1257 Node* control = NodeProperties::GetControlInput(node);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
1537 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); 1550 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length));
1538 RelaxControls(node); 1551 RelaxControls(node);
1539 a.FinishAndChange(node); 1552 a.FinishAndChange(node);
1540 return Changed(node); 1553 return Changed(node);
1541 } 1554 }
1542 1555
1543 return NoChange(); 1556 return NoChange();
1544 } 1557 }
1545 1558
1546 1559
1560 Reduction JSTypedLowering::ReduceJSCreateArray(Node* node) {
1561 DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode());
1562 CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
1563 Node* const target = NodeProperties::GetValueInput(node, 0);
1564 Node* const new_target = NodeProperties::GetValueInput(node, 1);
1565
1566 // TODO(bmeurer): Optimize the subclassing case.
1567 if (target != new_target) return NoChange();
1568
1569 // Check if we have a feedback {site} on the {node}.
1570 Handle<AllocationSite> site;
1571 if (!p.site().ToHandle(&site)) return NoChange();
1572 ElementsKind const elements_kind = site->GetElementsKind();
1573 AllocationSiteOverrideMode override_mode =
1574 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE)
1575 ? DISABLE_ALLOCATION_SITES
1576 : DONT_OVERRIDE;
1577
1578 // Reduce {node} to the appropriate ArrayConstructorStub backend.
1579 // Note that these stubs "behave" like JSFunctions, which means they
1580 // expect a receiver on the stack, which they remove. We just push
1581 // undefined for the receiver.
1582 if (p.arity() == 0) {
1583 ArrayNoArgumentConstructorStub stub(isolate(), elements_kind,
1584 override_mode);
1585 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1586 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 1,
1587 CallDescriptor::kNeedsFrameState);
1588 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1589 node->InsertInput(graph()->zone(), 2, jsgraph()->UndefinedConstant());
1590 node->InsertInput(graph()->zone(), 3, jsgraph()->UndefinedConstant());
1591 NodeProperties::ChangeOp(node, common()->Call(desc));
1592 return Changed(node);
1593 } else if (p.arity() == 1) {
1594 // TODO(bmeurer): Optimize for the 0 length non-holey case?
1595 ArraySingleArgumentConstructorStub stub(
1596 isolate(), GetHoleyElementsKind(elements_kind), override_mode);
1597 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1598 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
1599 CallDescriptor::kNeedsFrameState);
1600 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1601 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
1602 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(1));
1603 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1604 NodeProperties::ChangeOp(node, common()->Call(desc));
1605 return Changed(node);
1606 } else {
1607 int const arity = static_cast<int>(p.arity());
1608 ArrayNArgumentsConstructorStub stub(isolate(), elements_kind,
1609 override_mode);
1610 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1611 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(),
1612 arity + 1, CallDescriptor::kNeedsFrameState);
1613 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1614 node->InsertInput(graph()->zone(), 2, jsgraph()->UndefinedConstant());
1615 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1616 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1617 NodeProperties::ChangeOp(node, common()->Call(desc));
1618 return Changed(node);
1619 }
1620 }
1621
1622
1547 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { 1623 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
1548 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); 1624 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
1549 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); 1625 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
1550 Handle<SharedFunctionInfo> shared = p.shared_info(); 1626 Handle<SharedFunctionInfo> shared = p.shared_info();
1551 1627
1552 // Use the FastNewClosureStub that allocates in new space only for nested 1628 // Use the FastNewClosureStub that allocates in new space only for nested
1553 // functions that don't need literals cloning. 1629 // functions that don't need literals cloning.
1554 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { 1630 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) {
1555 Isolate* isolate = jsgraph()->isolate(); 1631 Isolate* isolate = jsgraph()->isolate();
1556 Callable callable = CodeFactory::FastNewClosure( 1632 Callable callable = CodeFactory::FastNewClosure(
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 case IrOpcode::kJSLoadProperty: 2309 case IrOpcode::kJSLoadProperty:
2234 return ReduceJSLoadProperty(node); 2310 return ReduceJSLoadProperty(node);
2235 case IrOpcode::kJSStoreProperty: 2311 case IrOpcode::kJSStoreProperty:
2236 return ReduceJSStoreProperty(node); 2312 return ReduceJSStoreProperty(node);
2237 case IrOpcode::kJSInstanceOf: 2313 case IrOpcode::kJSInstanceOf:
2238 return ReduceJSInstanceOf(node); 2314 return ReduceJSInstanceOf(node);
2239 case IrOpcode::kJSLoadContext: 2315 case IrOpcode::kJSLoadContext:
2240 return ReduceJSLoadContext(node); 2316 return ReduceJSLoadContext(node);
2241 case IrOpcode::kJSStoreContext: 2317 case IrOpcode::kJSStoreContext:
2242 return ReduceJSStoreContext(node); 2318 return ReduceJSStoreContext(node);
2319 case IrOpcode::kJSLoadNativeContext:
2320 return ReduceJSLoadNativeContext(node);
2243 case IrOpcode::kJSConvertReceiver: 2321 case IrOpcode::kJSConvertReceiver:
2244 return ReduceJSConvertReceiver(node); 2322 return ReduceJSConvertReceiver(node);
2245 case IrOpcode::kJSCreate: 2323 case IrOpcode::kJSCreate:
2246 return ReduceJSCreate(node); 2324 return ReduceJSCreate(node);
2247 case IrOpcode::kJSCreateArguments: 2325 case IrOpcode::kJSCreateArguments:
2248 return ReduceJSCreateArguments(node); 2326 return ReduceJSCreateArguments(node);
2327 case IrOpcode::kJSCreateArray:
2328 return ReduceJSCreateArray(node);
2249 case IrOpcode::kJSCreateClosure: 2329 case IrOpcode::kJSCreateClosure:
2250 return ReduceJSCreateClosure(node); 2330 return ReduceJSCreateClosure(node);
2251 case IrOpcode::kJSCreateLiteralArray: 2331 case IrOpcode::kJSCreateLiteralArray:
2252 return ReduceJSCreateLiteralArray(node); 2332 return ReduceJSCreateLiteralArray(node);
2253 case IrOpcode::kJSCreateLiteralObject: 2333 case IrOpcode::kJSCreateLiteralObject:
2254 return ReduceJSCreateLiteralObject(node); 2334 return ReduceJSCreateLiteralObject(node);
2255 case IrOpcode::kJSCreateFunctionContext: 2335 case IrOpcode::kJSCreateFunctionContext:
2256 return ReduceJSCreateFunctionContext(node); 2336 return ReduceJSCreateFunctionContext(node);
2257 case IrOpcode::kJSCreateWithContext: 2337 case IrOpcode::kJSCreateWithContext:
2258 return ReduceJSCreateWithContext(node); 2338 return ReduceJSCreateWithContext(node);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2386 } 2466 }
2387 2467
2388 2468
2389 CompilationDependencies* JSTypedLowering::dependencies() const { 2469 CompilationDependencies* JSTypedLowering::dependencies() const {
2390 return dependencies_; 2470 return dependencies_;
2391 } 2471 }
2392 2472
2393 } // namespace compiler 2473 } // namespace compiler
2394 } // namespace internal 2474 } // namespace internal
2395 } // namespace v8 2475 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698