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

Side by Side Diff: src/compiler/js-native-context-specialization.cc

Issue 1413383004: [turbofan] Slightly refactor JSLoadGlobal specialization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-native-context-specialization.h" 5 #include "src/compiler/js-native-context-specialization.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/compilation-dependencies.h" 8 #include "src/compilation-dependencies.h"
9 #include "src/compiler/access-builder.h" 9 #include "src/compiler/access-builder.h"
10 #include "src/compiler/js-graph.h" 10 #include "src/compiler/js-graph.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 Handle<PropertyCell> property_cell = it.GetPropertyCell(); 80 Handle<PropertyCell> property_cell = it.GetPropertyCell();
81 PropertyDetails property_details = property_cell->property_details(); 81 PropertyDetails property_details = property_cell->property_details();
82 Handle<Object> property_cell_value(property_cell->value(), isolate()); 82 Handle<Object> property_cell_value(property_cell->value(), isolate());
83 83
84 // Load from non-configurable, read-only data property on the global 84 // Load from non-configurable, read-only data property on the global
85 // object can be constant-folded, even without deoptimization support. 85 // object can be constant-folded, even without deoptimization support.
86 if (!property_details.IsConfigurable() && property_details.IsReadOnly()) { 86 if (!property_details.IsConfigurable() && property_details.IsReadOnly()) {
87 return Replace(node, property_cell_value); 87 return Replace(node, property_cell_value);
88 } 88 }
89 89
90 // Load from constant/undefined global property can be constant-folded
91 // with deoptimization support, by adding a code dependency on the cell.
92 if ((property_details.cell_type() == PropertyCellType::kConstant ||
93 property_details.cell_type() == PropertyCellType::kUndefined) &&
94 (flags() & kDeoptimizationEnabled)) {
95 dependencies()->AssumePropertyCell(property_cell);
96 return Replace(node, property_cell_value);
97 }
98
99 // Load from constant type global property can benefit from representation
100 // (and map) feedback with deoptimization support (requires code dependency).
101 if (property_details.cell_type() == PropertyCellType::kConstantType &&
102 (flags() & kDeoptimizationEnabled)) {
103 dependencies()->AssumePropertyCell(property_cell);
104 // Compute proper type based on the current value in the cell.
105 Type* property_cell_value_type;
106 if (property_cell_value->IsSmi()) {
107 property_cell_value_type = Type::Intersect(
108 Type::SignedSmall(), Type::TaggedSigned(), graph()->zone());
109 } else if (property_cell_value->IsNumber()) {
110 property_cell_value_type = Type::Intersect(
111 Type::Number(), Type::TaggedPointer(), graph()->zone());
112 } else {
113 Handle<Map> property_cell_value_map(
114 Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
115 property_cell_value_type =
116 Type::Class(property_cell_value_map, graph()->zone());
117 }
118 Node* value = effect = graph()->NewNode(
119 simplified()->LoadField(
120 AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
121 jsgraph()->Constant(property_cell), effect, control);
122 return Replace(node, value, effect);
123 }
124
125 // Load from non-configurable, data property on the global can be lowered to 90 // Load from non-configurable, data property on the global can be lowered to
126 // a field load, even without deoptimization, because the property cannot be 91 // a field load, even without deoptimization, because the property cannot be
127 // deleted or reconfigured to an accessor/interceptor property. 92 // deleted or reconfigured to an accessor/interceptor property. Yet, if
128 if (property_details.IsConfigurable()) { 93 // deoptimization support is available, we can constant-fold certain global
129 // With deoptimization support, we can lower loads even from configurable 94 // properties or at least lower them to field loads annotated with more
130 // data properties on the global object, by adding a code dependency on 95 // precise type feedback.
131 // the cell. 96 Type* property_cell_value_type =
132 if (!(flags() & kDeoptimizationEnabled)) return NoChange(); 97 Type::Intersect(Type::Any(), Type::Tagged(), graph()->zone());
133 dependencies()->AssumePropertyCell(property_cell); 98 if (flags() & kDeoptimizationEnabled) {
99 // Record a code dependency on the cell if we can benefit from the
100 // additional feedback, or the global property is configurable (i.e.
101 // can be deleted or reconfigured to an accessor property).
102 if (property_details.cell_type() != PropertyCellType::kMutable ||
103 property_details.IsConfigurable()) {
104 dependencies()->AssumePropertyCell(property_cell);
105 }
106
107 // Load from constant/undefined global property can be constant-folded.
108 if ((property_details.cell_type() == PropertyCellType::kConstant ||
109 property_details.cell_type() == PropertyCellType::kUndefined)) {
110 return Replace(node, property_cell_value);
111 }
112
113 // Load from constant type cell can benefit from type feedback.
114 if (property_details.cell_type() == PropertyCellType::kConstantType) {
115 // Compute proper type based on the current value in the cell.
116 if (property_cell_value->IsSmi()) {
117 property_cell_value_type = Type::Intersect(
118 Type::SignedSmall(), Type::TaggedSigned(), graph()->zone());
119 } else if (property_cell_value->IsNumber()) {
120 property_cell_value_type = Type::Intersect(
121 Type::Number(), Type::TaggedPointer(), graph()->zone());
122 } else {
123 Handle<Map> property_cell_value_map(
124 Handle<HeapObject>::cast(property_cell_value)->map(), isolate());
125 property_cell_value_type =
126 Type::Class(property_cell_value_map, graph()->zone());
127 }
128 }
129 } else if (property_details.IsConfigurable()) {
130 // Access to configurable global properties requires deoptimization support.
131 return NoChange();
134 } 132 }
135 Node* value = effect = graph()->NewNode( 133 Node* value = effect = graph()->NewNode(
136 simplified()->LoadField(AccessBuilder::ForPropertyCellValue()), 134 simplified()->LoadField(
135 AccessBuilder::ForPropertyCellValue(property_cell_value_type)),
137 jsgraph()->Constant(property_cell), effect, control); 136 jsgraph()->Constant(property_cell), effect, control);
138 return Replace(node, value, effect); 137 return Replace(node, value, effect);
139 } 138 }
140 139
141 140
142 Reduction JSNativeContextSpecialization::ReduceJSStoreGlobal(Node* node) { 141 Reduction JSNativeContextSpecialization::ReduceJSStoreGlobal(Node* node) {
143 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode()); 142 DCHECK_EQ(IrOpcode::kJSStoreGlobal, node->opcode());
144 Handle<Name> name = StoreGlobalParametersOf(node->op()).name(); 143 Handle<Name> name = StoreGlobalParametersOf(node->op()).name();
145 Node* value = NodeProperties::GetValueInput(node, 0); 144 Node* value = NodeProperties::GetValueInput(node, 0);
146 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1); 145 Node* frame_state = NodeProperties::GetFrameStateInput(node, 1);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 954 }
956 955
957 956
958 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 957 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
959 return jsgraph()->simplified(); 958 return jsgraph()->simplified();
960 } 959 }
961 960
962 } // namespace compiler 961 } // namespace compiler
963 } // namespace internal 962 } // namespace internal
964 } // namespace v8 963 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698