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

Unified Diff: src/compiler/js-native-context-specialization.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-native-context-specialization.cc
diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc
index 374f7b9702319a47e4630cb4de14705e36f4b8db..69f864909c7f1f8a4ab8fb06e7fe85beca10ac4f 100644
--- a/src/compiler/js-native-context-specialization.cc
+++ b/src/compiler/js-native-context-specialization.cc
@@ -457,8 +457,33 @@ Reduction JSNativeContextSpecialization::ReduceNamedAccess(
Reduction JSNativeContextSpecialization::ReduceJSLoadNamed(Node* node) {
DCHECK_EQ(IrOpcode::kJSLoadNamed, node->opcode());
NamedAccess const& p = NamedAccessOf(node->op());
+ Node* const receiver = NodeProperties::GetValueInput(node, 0);
Node* const value = jsgraph()->Dead();
+ // Check if we have a constant receiver.
+ HeapObjectMatcher m(receiver);
+ if (m.HasValue()) {
+ // Optimize "prototype" property of functions.
+ if (m.Value()->IsJSFunction() &&
+ p.name().is_identical_to(factory()->prototype_string())) {
+ Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
+ if (function->has_initial_map()) {
+ // We need to add a code dependency on the initial map of the
+ // {function} in order to be notified about changes to the
+ // "prototype" of {function}, so it doesn't make sense to
+ // continue unless deoptimization is enabled.
+ if ((flags() & kDeoptimizationEnabled)) {
+ Handle<Map> initial_map(function->initial_map(), isolate());
+ dependencies()->AssumeInitialMapCantChange(initial_map);
+ Handle<Object> prototype(initial_map->prototype(), isolate());
+ Node* value = jsgraph()->Constant(prototype);
+ ReplaceWithValue(node, value);
+ return Replace(value);
+ }
+ }
+ }
+ }
+
// Extract receiver maps from the LOAD_IC using the LoadICNexus.
if (!p.feedback().IsValid()) return NoChange();
LoadICNexus nexus(p.feedback().vector(), p.feedback().slot());
« no previous file with comments | « no previous file | src/compiler/js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698