Commit 017faaf4 authored by bmeurer's avatar bmeurer Committed by Commit bot

[turbofan] First steps towards optimizing for-in loops.

This is basically a port of the majority of optimizations that are
applied to for-in in full codegen. But it is not done during graph
building, but instead during typed lowering, which way less adhoc than
what the other compilers do.

Review URL: https://codereview.chromium.org/1155313008

Cr-Commit-Position: refs/heads/master@{#28726}
parent 7a709875
......@@ -58,6 +58,34 @@ FieldAccess AccessBuilder::ForExternalArrayPointer() {
}
// static
FieldAccess AccessBuilder::ForDescriptorArrayEnumCache() {
return {kTaggedBase, DescriptorArray::kEnumCacheOffset, Handle<Name>(),
Type::TaggedPointer(), kMachAnyTagged};
}
// static
FieldAccess AccessBuilder::ForDescriptorArrayEnumCacheBridgeCache() {
return {kTaggedBase, DescriptorArray::kEnumCacheBridgeCacheOffset,
Handle<Name>(), Type::TaggedPointer(), kMachAnyTagged};
}
// static
FieldAccess AccessBuilder::ForMapBitField3() {
return {kTaggedBase, Map::kBitField3Offset, Handle<Name>(),
Type::UntaggedUnsigned32(), kMachUint32};
}
// static
FieldAccess AccessBuilder::ForMapDescriptors() {
return {kTaggedBase, Map::kDescriptorsOffset, Handle<Name>(),
Type::TaggedPointer(), kMachAnyTagged};
}
// static
FieldAccess AccessBuilder::ForMapInstanceType() {
return {kTaggedBase, Map::kInstanceTypeOffset, Handle<Name>(),
......
......@@ -37,6 +37,18 @@ class AccessBuilder final : public AllStatic {
// Provides access to ExternalArray::external_pointer() field.
static FieldAccess ForExternalArrayPointer();
// Provides access to DescriptorArray::enum_cache() field.
static FieldAccess ForDescriptorArrayEnumCache();
// Provides access to DescriptorArray::enum_cache_bridge_cache() field.
static FieldAccess ForDescriptorArrayEnumCacheBridgeCache();
// Provides access to Map::bit_field3() field.
static FieldAccess ForMapBitField3();
// Provides access to Map::descriptors() field.
static FieldAccess ForMapDescriptors();
// Provides access to Map::instance_type() field.
static FieldAccess ForMapInstanceType();
......
......@@ -74,6 +74,11 @@ class Graph : public ZoneObject {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8};
return NewNode(op, arraysize(nodes), nodes);
}
Node* NewNode(const Operator* op, Node* n1, Node* n2, Node* n3, Node* n4,
Node* n5, Node* n6, Node* n7, Node* n8, Node* n9) {
Node* nodes[] = {n1, n2, n3, n4, n5, n6, n7, n8, n9};
return NewNode(op, arraysize(nodes), nodes);
}
template <class Visitor>
inline void VisitNodeInputsFromEnd(Visitor* visitor);
......
......@@ -606,8 +606,7 @@ void JSGenericLowering::LowerJSForInPrepare(Node* node) {
Node* cache_type = effect = graph()->NewNode(
common()->Call(descriptor),
jsgraph()->CEntryStubConstant(function->result_size), object,
jsgraph()->ExternalConstant(
ExternalReference(function->function_id, isolate())),
jsgraph()->ExternalConstant(function->function_id),
jsgraph()->Int32Constant(1), context, frame_state, effect, control);
control = graph()->NewNode(common()->IfSuccess(), cache_type);
......
......@@ -183,6 +183,11 @@ Node* JSGraph::ExternalConstant(ExternalReference reference) {
}
Node* JSGraph::ExternalConstant(Runtime::FunctionId function_id) {
return ExternalConstant(ExternalReference(function_id, isolate()));
}
Node* JSGraph::EmptyFrameState() {
Node* empty_frame_state = cached_nodes_[kEmptyFrameState];
if (!empty_frame_state || empty_frame_state->IsDead()) {
......
......@@ -102,6 +102,7 @@ class JSGraph : public ZoneObject {
// Creates an ExternalConstant node, usually canonicalized.
Node* ExternalConstant(ExternalReference ref);
Node* ExternalConstant(Runtime::FunctionId function_id);
Node* SmiConstant(int32_t immediate) {
DCHECK(Smi::IsValid(immediate));
......
This diff is collapsed.
......@@ -58,6 +58,10 @@ class JSTypedLowering final : public AdvancedReducer {
Reduction ReduceJSCreateLiteralObject(Node* node);
Reduction ReduceJSCreateWithContext(Node* node);
Reduction ReduceJSCreateBlockContext(Node* node);
Reduction ReduceJSForInDone(Node* node);
Reduction ReduceJSForInNext(Node* node);
Reduction ReduceJSForInPrepare(Node* node);
Reduction ReduceJSForInStep(Node* node);
Reduction ReduceNumberBinop(Node* node, const Operator* numberOp);
Reduction ReduceInt32Binop(Node* node, const Operator* intOp);
Reduction ReduceUI32Shift(Node* node, Signedness left_signedness,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment