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

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

Issue 1482213002: [turbofan] Support for typed lowering of "prototype" load from functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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 | « no previous file | 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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 Handle<Name> name = NamedAccessOf(node->op()).name(); 968 Handle<Name> name = NamedAccessOf(node->op()).name();
969 // Optimize "length" property of strings. 969 // Optimize "length" property of strings.
970 if (name.is_identical_to(factory()->length_string()) && 970 if (name.is_identical_to(factory()->length_string()) &&
971 receiver_type->Is(Type::String())) { 971 receiver_type->Is(Type::String())) {
972 Node* value = effect = graph()->NewNode( 972 Node* value = effect = graph()->NewNode(
973 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver, 973 simplified()->LoadField(AccessBuilder::ForStringLength()), receiver,
974 effect, control); 974 effect, control);
975 ReplaceWithValue(node, value, effect); 975 ReplaceWithValue(node, value, effect);
976 return Replace(value); 976 return Replace(value);
977 } 977 }
978 // Optimize "prototype" property of functions.
979 if (name.is_identical_to(factory()->prototype_string()) &&
980 receiver_type->IsConstant() &&
981 receiver_type->AsConstant()->Value()->IsJSFunction()) {
982 // TODO(turbofan): This lowering might not kick in if we ever lower
983 // the C++ accessor for "prototype" in an earlier optimization pass.
984 Handle<JSFunction> function =
985 Handle<JSFunction>::cast(receiver_type->AsConstant()->Value());
986 if (function->has_initial_map()) {
987 // We need to add a code dependency on the initial map of the {function}
988 // in order to be notified about changes to the "prototype" of {function},
989 // so it doesn't make sense to continue unless deoptimization is enabled.
990 if (!(flags() & kDeoptimizationEnabled)) return NoChange();
991 Handle<Map> initial_map(function->initial_map(), isolate());
992 dependencies()->AssumeInitialMapCantChange(initial_map);
993 Node* value =
994 jsgraph()->Constant(handle(initial_map->prototype(), isolate()));
995 ReplaceWithValue(node, value);
996 return Replace(value);
997 }
998 }
978 return NoChange(); 999 return NoChange();
979 } 1000 }
980 1001
981 1002
982 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) { 1003 Reduction JSTypedLowering::ReduceJSLoadProperty(Node* node) {
983 Node* key = NodeProperties::GetValueInput(node, 1); 1004 Node* key = NodeProperties::GetValueInput(node, 1);
984 Node* base = NodeProperties::GetValueInput(node, 0); 1005 Node* base = NodeProperties::GetValueInput(node, 0);
985 Type* key_type = NodeProperties::GetType(key); 1006 Type* key_type = NodeProperties::GetType(key);
986 HeapObjectMatcher mbase(base); 1007 HeapObjectMatcher mbase(base);
987 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) { 1008 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 } 2589 }
2569 2590
2570 2591
2571 CompilationDependencies* JSTypedLowering::dependencies() const { 2592 CompilationDependencies* JSTypedLowering::dependencies() const {
2572 return dependencies_; 2593 return dependencies_;
2573 } 2594 }
2574 2595
2575 } // namespace compiler 2596 } // namespace compiler
2576 } // namespace internal 2597 } // namespace internal
2577 } // namespace v8 2598 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698