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

Side by Side Diff: src/compiler/js-type-feedback.cc

Issue 1038953002: [turbofan] Reduce JSLoadProperty and JSStoreProperty of strings to JSLoadNamed and JSStoreNamed. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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-type-feedback.h ('k') | 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-type-feedback.h" 5 #include "src/compiler/js-type-feedback.h"
6 6
7 #include "src/property-details.h" 7 #include "src/property-details.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast.h" 10 #include "src/ast.h"
11 #include "src/type-info.h" 11 #include "src/type-info.h"
12 12
13 #include "src/compiler/access-builder.h" 13 #include "src/compiler/access-builder.h"
14 #include "src/compiler/common-operator.h" 14 #include "src/compiler/common-operator.h"
15 #include "src/compiler/node-aux-data.h" 15 #include "src/compiler/node-aux-data.h"
16 #include "src/compiler/node-matchers.h"
16 #include "src/compiler/simplified-operator.h" 17 #include "src/compiler/simplified-operator.h"
17 18
18 namespace v8 { 19 namespace v8 {
19 namespace internal { 20 namespace internal {
20 namespace compiler { 21 namespace compiler {
21 22
22 enum LoadOrStore { LOAD, STORE }; 23 enum LoadOrStore { LOAD, STORE };
23 24
24 JSTypeFeedbackTable::JSTypeFeedbackTable(Zone* zone) 25 JSTypeFeedbackTable::JSTypeFeedbackTable(Zone* zone)
25 : map_(TypeFeedbackIdMap::key_compare(), 26 : map_(TypeFeedbackIdMap::key_compare(),
26 TypeFeedbackIdMap::allocator_type(zone)) {} 27 TypeFeedbackIdMap::allocator_type(zone)) {}
27 28
28 29
29 void JSTypeFeedbackTable::Record(Node* node, TypeFeedbackId id) { 30 void JSTypeFeedbackTable::Record(Node* node, TypeFeedbackId id) {
30 map_.insert(std::make_pair(node->id(), id)); 31 map_.insert(std::make_pair(node->id(), id));
31 } 32 }
32 33
33 34
34 Reduction JSTypeFeedbackSpecializer::Reduce(Node* node) { 35 Reduction JSTypeFeedbackSpecializer::Reduce(Node* node) {
35 // TODO(turbofan): type feedback currently requires deoptimization.
36 if (!FLAG_turbo_deoptimization) return NoChange();
37 switch (node->opcode()) { 36 switch (node->opcode()) {
38 case IrOpcode::kJSLoadProperty: 37 case IrOpcode::kJSLoadProperty: {
38 HeapObjectMatcher<Name> match(node->InputAt(1));
39 if (match.HasValue() && match.Value().handle()->IsName()) {
40 // LoadProperty(o, "constant") => LoadNamed["constant"](o).
41 Unique<Name> name = match.Value();
42 const VectorSlotPair& feedback =
43 LoadPropertyParametersOf(node->op()).feedback();
44 node->set_op(jsgraph()->javascript()->LoadNamed(name, feedback));
45 node->RemoveInput(1);
46 return ReduceJSLoadNamed(node);
47 }
39 return ReduceJSLoadProperty(node); 48 return ReduceJSLoadProperty(node);
49 }
40 case IrOpcode::kJSLoadNamed: 50 case IrOpcode::kJSLoadNamed:
41 return ReduceJSLoadNamed(node); 51 return ReduceJSLoadNamed(node);
42 case IrOpcode::kJSStoreNamed: 52 case IrOpcode::kJSStoreNamed:
43 return ReduceJSStoreNamed(node); 53 return ReduceJSStoreNamed(node);
44 case IrOpcode::kJSStoreProperty: 54 case IrOpcode::kJSStoreProperty: {
55 HeapObjectMatcher<Name> match(node->InputAt(1));
56 if (match.HasValue() && match.Value().handle()->IsName()) {
57 // StoreProperty(o, "constant", v) => StoreNamed["constant"](o, v).
58 Unique<Name> name = match.Value();
59 LanguageMode language_mode = OpParameter<LanguageMode>(node);
60 node->set_op(jsgraph()->javascript()->StoreNamed(language_mode, name));
61 node->RemoveInput(1);
62 return ReduceJSStoreNamed(node);
63 }
45 return ReduceJSStoreProperty(node); 64 return ReduceJSStoreProperty(node);
65 }
46 default: 66 default:
47 break; 67 break;
48 } 68 }
49 return NoChange(); 69 return NoChange();
50 } 70 }
51 71
52 72
53 static bool GetInObjectFieldAccess(LoadOrStore mode, Handle<Map> map, 73 static bool GetInObjectFieldAccess(LoadOrStore mode, Handle<Map> map,
54 Handle<Name> name, FieldAccess* access) { 74 Handle<Name> name, FieldAccess* access) {
55 access->base_is_tagged = kTaggedBase; 75 access->base_is_tagged = kTaggedBase;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return true; 131 return true;
112 } 132 }
113 133
114 // TODO(turbofan): handle out of object properties. 134 // TODO(turbofan): handle out of object properties.
115 return false; 135 return false;
116 } 136 }
117 137
118 138
119 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) { 139 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadNamed(Node* node) {
120 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed); 140 DCHECK(node->opcode() == IrOpcode::kJSLoadNamed);
141 // TODO(turbofan): type feedback currently requires deoptimization.
142 if (!FLAG_turbo_deoptimization) return NoChange();
143
121 TypeFeedbackId id = js_type_feedback_->find(node); 144 TypeFeedbackId id = js_type_feedback_->find(node);
122 if (id.IsNone() || oracle()->LoadIsUninitialized(id)) return NoChange(); 145 if (id.IsNone() || oracle()->LoadIsUninitialized(id)) return NoChange();
123 146
124 const LoadNamedParameters& p = LoadNamedParametersOf(node->op()); 147 const LoadNamedParameters& p = LoadNamedParametersOf(node->op());
125 SmallMapList maps; 148 SmallMapList maps;
126 Handle<Name> name = p.name().handle(); 149 Handle<Name> name = p.name().handle();
127 Node* receiver = node->InputAt(0); 150 Node* receiver = node->InputAt(0);
128 Node* effect = NodeProperties::GetEffectInput(node); 151 Node* effect = NodeProperties::GetEffectInput(node);
129 GatherReceiverTypes(receiver, effect, id, name, &maps); 152 GatherReceiverTypes(receiver, effect, id, name, &maps);
130 153
(...skipping 26 matching lines...) Expand all
157 } 180 }
158 181
159 182
160 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadProperty(Node* node) { 183 Reduction JSTypeFeedbackSpecializer::ReduceJSLoadProperty(Node* node) {
161 return NoChange(); 184 return NoChange();
162 } 185 }
163 186
164 187
165 Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) { 188 Reduction JSTypeFeedbackSpecializer::ReduceJSStoreNamed(Node* node) {
166 DCHECK(node->opcode() == IrOpcode::kJSStoreNamed); 189 DCHECK(node->opcode() == IrOpcode::kJSStoreNamed);
190 // TODO(turbofan): type feedback currently requires deoptimization.
191 if (!FLAG_turbo_deoptimization) return NoChange();
192
167 TypeFeedbackId id = js_type_feedback_->find(node); 193 TypeFeedbackId id = js_type_feedback_->find(node);
168 if (id.IsNone() || oracle()->StoreIsUninitialized(id)) return NoChange(); 194 if (id.IsNone() || oracle()->StoreIsUninitialized(id)) return NoChange();
169 195
170 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); 196 const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
171 SmallMapList maps; 197 SmallMapList maps;
172 Handle<Name> name = p.name().handle(); 198 Handle<Name> name = p.name().handle();
173 Node* receiver = node->InputAt(0); 199 Node* receiver = node->InputAt(0);
174 Node* effect = NodeProperties::GetEffectInput(node); 200 Node* effect = NodeProperties::GetEffectInput(node);
175 GatherReceiverTypes(receiver, effect, id, name, &maps); 201 GatherReceiverTypes(receiver, effect, id, name, &maps);
176 202
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // TODO(turbofan): filter maps by initial receiver map if known 273 // TODO(turbofan): filter maps by initial receiver map if known
248 // TODO(turbofan): filter maps by native context (if specializing) 274 // TODO(turbofan): filter maps by native context (if specializing)
249 // TODO(turbofan): filter maps by effect chain 275 // TODO(turbofan): filter maps by effect chain
250 oracle()->PropertyReceiverTypes(id, name, maps); 276 oracle()->PropertyReceiverTypes(id, name, maps);
251 } 277 }
252 278
253 279
254 } // namespace compiler 280 } // namespace compiler
255 } // namespace internal 281 } // namespace internal
256 } // namespace v8 282 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-type-feedback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698