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

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: Addressed Michi's comments. 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
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/node-properties.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 #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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length)); 1554 a.Store(AccessBuilder::ForArgumentsLength(), jsgraph()->Constant(length));
1542 RelaxControls(node); 1555 RelaxControls(node);
1543 a.FinishAndChange(node); 1556 a.FinishAndChange(node);
1544 return Changed(node); 1557 return Changed(node);
1545 } 1558 }
1546 1559
1547 return NoChange(); 1560 return NoChange();
1548 } 1561 }
1549 1562
1550 1563
1564 Reduction JSTypedLowering::ReduceJSCreateArray(Node* node) {
1565 DCHECK_EQ(IrOpcode::kJSCreateArray, node->opcode());
1566 CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
1567 Node* const target = NodeProperties::GetValueInput(node, 0);
1568 Node* const new_target = NodeProperties::GetValueInput(node, 1);
1569
1570 // TODO(bmeurer): Optimize the subclassing case.
1571 if (target != new_target) return NoChange();
1572
1573 // Check if we have a feedback {site} on the {node}.
1574 Handle<AllocationSite> site = p.site();
1575 if (p.site().is_null()) return NoChange();
1576 ElementsKind const elements_kind = site->GetElementsKind();
1577 AllocationSiteOverrideMode override_mode =
1578 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE)
1579 ? DISABLE_ALLOCATION_SITES
1580 : DONT_OVERRIDE;
1581
1582 // Reduce {node} to the appropriate ArrayConstructorStub backend.
1583 // Note that these stubs "behave" like JSFunctions, which means they
1584 // expect a receiver on the stack, which they remove. We just push
1585 // undefined for the receiver.
1586 if (p.arity() == 0) {
1587 ArrayNoArgumentConstructorStub stub(isolate(), elements_kind,
1588 override_mode);
1589 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1590 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 1,
1591 CallDescriptor::kNeedsFrameState);
1592 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1593 node->InsertInput(graph()->zone(), 2, jsgraph()->UndefinedConstant());
1594 node->InsertInput(graph()->zone(), 3, jsgraph()->UndefinedConstant());
1595 NodeProperties::ChangeOp(node, common()->Call(desc));
1596 return Changed(node);
1597 } else if (p.arity() == 1) {
1598 // TODO(bmeurer): Optimize for the 0 length non-holey case?
1599 ArraySingleArgumentConstructorStub stub(
1600 isolate(), GetHoleyElementsKind(elements_kind), override_mode);
1601 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1602 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
1603 CallDescriptor::kNeedsFrameState);
1604 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1605 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
1606 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(1));
1607 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1608 NodeProperties::ChangeOp(node, common()->Call(desc));
1609 return Changed(node);
1610 } else {
1611 int const arity = static_cast<int>(p.arity());
1612 ArrayNArgumentsConstructorStub stub(isolate(), elements_kind,
1613 override_mode);
1614 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
1615 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(),
1616 arity + 1, CallDescriptor::kNeedsFrameState);
1617 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
1618 node->InsertInput(graph()->zone(), 2, jsgraph()->UndefinedConstant());
1619 node->InsertInput(graph()->zone(), 3, jsgraph()->Int32Constant(arity));
1620 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
1621 NodeProperties::ChangeOp(node, common()->Call(desc));
1622 return Changed(node);
1623 }
1624 }
1625
1626
1551 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { 1627 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
1552 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); 1628 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
1553 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); 1629 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
1554 Handle<SharedFunctionInfo> shared = p.shared_info(); 1630 Handle<SharedFunctionInfo> shared = p.shared_info();
1555 1631
1556 // Use the FastNewClosureStub that allocates in new space only for nested 1632 // Use the FastNewClosureStub that allocates in new space only for nested
1557 // functions that don't need literals cloning. 1633 // functions that don't need literals cloning.
1558 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { 1634 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) {
1559 Isolate* isolate = jsgraph()->isolate(); 1635 Isolate* isolate = jsgraph()->isolate();
1560 Callable callable = CodeFactory::FastNewClosure( 1636 Callable callable = CodeFactory::FastNewClosure(
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 case IrOpcode::kJSLoadProperty: 2313 case IrOpcode::kJSLoadProperty:
2238 return ReduceJSLoadProperty(node); 2314 return ReduceJSLoadProperty(node);
2239 case IrOpcode::kJSStoreProperty: 2315 case IrOpcode::kJSStoreProperty:
2240 return ReduceJSStoreProperty(node); 2316 return ReduceJSStoreProperty(node);
2241 case IrOpcode::kJSInstanceOf: 2317 case IrOpcode::kJSInstanceOf:
2242 return ReduceJSInstanceOf(node); 2318 return ReduceJSInstanceOf(node);
2243 case IrOpcode::kJSLoadContext: 2319 case IrOpcode::kJSLoadContext:
2244 return ReduceJSLoadContext(node); 2320 return ReduceJSLoadContext(node);
2245 case IrOpcode::kJSStoreContext: 2321 case IrOpcode::kJSStoreContext:
2246 return ReduceJSStoreContext(node); 2322 return ReduceJSStoreContext(node);
2323 case IrOpcode::kJSLoadNativeContext:
2324 return ReduceJSLoadNativeContext(node);
2247 case IrOpcode::kJSConvertReceiver: 2325 case IrOpcode::kJSConvertReceiver:
2248 return ReduceJSConvertReceiver(node); 2326 return ReduceJSConvertReceiver(node);
2249 case IrOpcode::kJSCreate: 2327 case IrOpcode::kJSCreate:
2250 return ReduceJSCreate(node); 2328 return ReduceJSCreate(node);
2251 case IrOpcode::kJSCreateArguments: 2329 case IrOpcode::kJSCreateArguments:
2252 return ReduceJSCreateArguments(node); 2330 return ReduceJSCreateArguments(node);
2331 case IrOpcode::kJSCreateArray:
2332 return ReduceJSCreateArray(node);
2253 case IrOpcode::kJSCreateClosure: 2333 case IrOpcode::kJSCreateClosure:
2254 return ReduceJSCreateClosure(node); 2334 return ReduceJSCreateClosure(node);
2255 case IrOpcode::kJSCreateLiteralArray: 2335 case IrOpcode::kJSCreateLiteralArray:
2256 return ReduceJSCreateLiteralArray(node); 2336 return ReduceJSCreateLiteralArray(node);
2257 case IrOpcode::kJSCreateLiteralObject: 2337 case IrOpcode::kJSCreateLiteralObject:
2258 return ReduceJSCreateLiteralObject(node); 2338 return ReduceJSCreateLiteralObject(node);
2259 case IrOpcode::kJSCreateFunctionContext: 2339 case IrOpcode::kJSCreateFunctionContext:
2260 return ReduceJSCreateFunctionContext(node); 2340 return ReduceJSCreateFunctionContext(node);
2261 case IrOpcode::kJSCreateWithContext: 2341 case IrOpcode::kJSCreateWithContext:
2262 return ReduceJSCreateWithContext(node); 2342 return ReduceJSCreateWithContext(node);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 } 2470 }
2391 2471
2392 2472
2393 CompilationDependencies* JSTypedLowering::dependencies() const { 2473 CompilationDependencies* JSTypedLowering::dependencies() const {
2394 return dependencies_; 2474 return dependencies_;
2395 } 2475 }
2396 2476
2397 } // namespace compiler 2477 } // namespace compiler
2398 } // namespace internal 2478 } // namespace internal
2399 } // namespace v8 2479 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/node-properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698