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

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

Issue 1965293002: [turbofan] Unify function prototype constant folding. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months 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-native-context-specialization.cc ('k') | src/compiler/typer.cc » ('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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 Handle<Name> name = NamedAccessOf(node->op()).name(); 929 Handle<Name> name = NamedAccessOf(node->op()).name();
930 // Optimize "length" property of strings. 930 // Optimize "length" property of strings.
931 if (name.is_identical_to(factory()->length_string()) && 931 if (name.is_identical_to(factory()->length_string()) &&
932 receiver_type->Is(Type::String())) { 932 receiver_type->Is(Type::String())) {
933 Node* value = effect = graph()->NewNode( 933 Node* value = effect = graph()->NewNode(
934 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver, 934 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver,
935 effect, control); 935 effect, control);
936 ReplaceWithValue(node, value, effect); 936 ReplaceWithValue(node, value, effect);
937 return Replace(value); 937 return Replace(value);
938 } 938 }
939 // Optimize "prototype" property of functions.
940 if (name.is_identical_to(factory()->prototype_string()) &&
941 receiver_type->IsConstant() &&
942 receiver_type->AsConstant()->Value()->IsJSFunction()) {
943 // TODO(turbofan): This lowering might not kick in if we ever lower
944 // the C++ accessor for "prototype" in an earlier optimization pass.
945 Handle<JSFunction> function =
946 Handle<JSFunction>::cast(receiver_type->AsConstant()->Value());
947 if (function->has_initial_map()) {
948 // We need to add a code dependency on the initial map of the {function}
949 // in order to be notified about changes to the "prototype" of {function},
950 // so it doesn't make sense to continue unless deoptimization is enabled.
951 if (!(flags() & kDeoptimizationEnabled)) return NoChange();
952 Handle<Map> initial_map(function->initial_map(), isolate());
953 dependencies()->AssumeInitialMapCantChange(initial_map);
954 Node* value =
955 jsgraph()->Constant(handle(initial_map->prototype(), isolate()));
956 ReplaceWithValue(node, value);
957 return Replace(value);
958 }
959 }
960 return NoChange(); 939 return NoChange();
961 } 940 }
962 941
963 942
964 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { 943 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
965 Node* key = NodeProperties::GetValueInput(node, 1); 944 Node* key = NodeProperties::GetValueInput(node, 1);
966 Node* base = NodeProperties::GetValueInput(node, 0); 945 Node* base = NodeProperties::GetValueInput(node, 0);
967 Type* key_type = NodeProperties::GetType(key); 946 Type* key_type = NodeProperties::GetType(key);
968 HeapObjectMatcher mbase(base); 947 HeapObjectMatcher mbase(base);
969 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) { 948 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 } 1808 }
1830 1809
1831 1810
1832 CompilationDependencies* JSTypedLowering::dependencies() const { 1811 CompilationDependencies* JSTypedLowering::dependencies() const {
1833 return dependencies_; 1812 return dependencies_;
1834 } 1813 }
1835 1814
1836 } // namespace compiler 1815 } // namespace compiler
1837 } // namespace internal 1816 } // namespace internal
1838 } // namespace v8 1817 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-native-context-specialization.cc ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698