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

Side by Side Diff: src/compiler/load-elimination.cc

Issue 1857133003: [turbofan] Restrict types in load elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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
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/compiler/load-elimination.h" 5 #include "src/compiler/load-elimination.h"
6 6
7 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
8 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/types.h"
9 11
10 namespace v8 { 12 namespace v8 {
11 namespace internal { 13 namespace internal {
12 namespace compiler { 14 namespace compiler {
13 15
14 LoadElimination::~LoadElimination() {} 16 LoadElimination::~LoadElimination() {}
15 17
16 18
17 Reduction LoadElimination::Reduce(Node* node) { 19 Reduction LoadElimination::Reduce(Node* node) {
18 switch (node->opcode()) { 20 switch (node->opcode()) {
(...skipping 19 matching lines...) Expand all
38 Node* const value = effect; 40 Node* const value = effect;
39 ReplaceWithValue(node, value); 41 ReplaceWithValue(node, value);
40 return Replace(value); 42 return Replace(value);
41 } 43 }
42 break; 44 break;
43 } 45 }
44 case IrOpcode::kStoreField: { 46 case IrOpcode::kStoreField: {
45 if (access == FieldAccessOf(effect->op())) { 47 if (access == FieldAccessOf(effect->op())) {
46 if (object == NodeProperties::GetValueInput(effect, 0)) { 48 if (object == NodeProperties::GetValueInput(effect, 0)) {
47 Node* const value = NodeProperties::GetValueInput(effect, 1); 49 Node* const value = NodeProperties::GetValueInput(effect, 1);
48 ReplaceWithValue(node, value); 50 Type* stored_value_type = NodeProperties::GetType(value);
49 return Replace(value); 51 Type* load_type = NodeProperties::GetType(node);
52 // Make sure the replacement's type is a subtype of the node's
53 // type. Otherwise we could confuse optimizations that were
54 // based on the original type.
55 if (stored_value_type->Is(load_type)) {
56 ReplaceWithValue(node, value);
57 return Replace(value);
58 } else {
59 Node* renamed = graph()->NewNode(
60 common()->Guard(Type::Intersect(stored_value_type, load_type,
61 graph()->zone())),
62 value, NodeProperties::GetControlInput(node));
63 ReplaceWithValue(node, renamed);
64 return Replace(renamed);
65 }
50 } 66 }
51 // TODO(turbofan): Alias analysis to the rescue? 67 // TODO(turbofan): Alias analysis to the rescue?
52 return NoChange(); 68 return NoChange();
53 } 69 }
54 break; 70 break;
55 } 71 }
56 case IrOpcode::kBeginRegion: 72 case IrOpcode::kBeginRegion:
57 case IrOpcode::kStoreBuffer: 73 case IrOpcode::kStoreBuffer:
58 case IrOpcode::kStoreElement: { 74 case IrOpcode::kStoreElement: {
59 // These can never interfere with field loads. 75 // These can never interfere with field loads.
(...skipping 20 matching lines...) Expand all
80 } 96 }
81 } 97 }
82 } 98 }
83 UNREACHABLE(); 99 UNREACHABLE();
84 return NoChange(); 100 return NoChange();
85 } 101 }
86 102
87 } // namespace compiler 103 } // namespace compiler
88 } // namespace internal 104 } // namespace internal
89 } // namespace v8 105 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698