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

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

Issue 2220513002: Revert of [turbofan] Add support for copy-on-write element stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/load-elimination.h ('k') | src/compiler/opcodes.h » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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"
8 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
10 9
11 namespace v8 { 10 namespace v8 {
12 namespace internal { 11 namespace internal {
13 namespace compiler { 12 namespace compiler {
14 13
15 namespace { 14 namespace {
16 15
17 enum Aliasing { kNoAlias, kMayAlias, kMustAlias }; 16 enum Aliasing { kNoAlias, kMayAlias, kMustAlias };
(...skipping 29 matching lines...) Expand all
47 bool MayAlias(Node* a, Node* b) { return QueryAlias(a, b) != kNoAlias; } 46 bool MayAlias(Node* a, Node* b) { return QueryAlias(a, b) != kNoAlias; }
48 47
49 bool MustAlias(Node* a, Node* b) { return QueryAlias(a, b) == kMustAlias; } 48 bool MustAlias(Node* a, Node* b) { return QueryAlias(a, b) == kMustAlias; }
50 49
51 } // namespace 50 } // namespace
52 51
53 Reduction LoadElimination::Reduce(Node* node) { 52 Reduction LoadElimination::Reduce(Node* node) {
54 switch (node->opcode()) { 53 switch (node->opcode()) {
55 case IrOpcode::kCheckMaps: 54 case IrOpcode::kCheckMaps:
56 return ReduceCheckMaps(node); 55 return ReduceCheckMaps(node);
57 case IrOpcode::kEnsureWritableFastElements:
58 return ReduceEnsureWritableFastElements(node);
59 case IrOpcode::kTransitionElementsKind: 56 case IrOpcode::kTransitionElementsKind:
60 return ReduceTransitionElementsKind(node); 57 return ReduceTransitionElementsKind(node);
61 case IrOpcode::kLoadField: 58 case IrOpcode::kLoadField:
62 return ReduceLoadField(node); 59 return ReduceLoadField(node);
63 case IrOpcode::kStoreField: 60 case IrOpcode::kStoreField:
64 return ReduceStoreField(node); 61 return ReduceStoreField(node);
65 case IrOpcode::kLoadElement: 62 case IrOpcode::kLoadElement:
66 return ReduceLoadElement(node); 63 return ReduceLoadElement(node);
67 case IrOpcode::kStoreElement: 64 case IrOpcode::kStoreElement:
68 return ReduceStoreElement(node); 65 return ReduceStoreElement(node);
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 if (map == object_map) return Replace(effect); 319 if (map == object_map) return Replace(effect);
323 } 320 }
324 } 321 }
325 if (map_input_count == 1) { 322 if (map_input_count == 1) {
326 Node* const map0 = NodeProperties::GetValueInput(node, 1); 323 Node* const map0 = NodeProperties::GetValueInput(node, 1);
327 state = state->AddField(object, 0, map0, zone()); 324 state = state->AddField(object, 0, map0, zone());
328 } 325 }
329 return UpdateState(node, state); 326 return UpdateState(node, state);
330 } 327 }
331 328
332 Reduction LoadElimination::ReduceEnsureWritableFastElements(Node* node) {
333 Node* const object = NodeProperties::GetValueInput(node, 0);
334 Node* const elements = NodeProperties::GetValueInput(node, 1);
335 Node* const effect = NodeProperties::GetEffectInput(node);
336 AbstractState const* state = node_states_.Get(effect);
337 if (state == nullptr) return NoChange();
338 Node* fixed_array_map = jsgraph()->FixedArrayMapConstant();
339 if (Node* const elements_map = state->LookupField(elements, 0)) {
340 // Check if the {elements} already have the fixed array map.
341 if (elements_map == fixed_array_map) {
342 ReplaceWithValue(node, elements, effect);
343 return Replace(elements);
344 }
345 }
346 // We know that the resulting elements have the fixed array map.
347 state = state->AddField(node, 0, fixed_array_map, zone());
348 // Kill the previous elements on {object}.
349 state = state->KillField(object, 2, zone());
350 // Add the new elements on {object}.
351 state = state->AddField(object, 2, node, zone());
352 return UpdateState(node, state);
353 }
354
355 Reduction LoadElimination::ReduceTransitionElementsKind(Node* node) { 329 Reduction LoadElimination::ReduceTransitionElementsKind(Node* node) {
356 Node* const object = NodeProperties::GetValueInput(node, 0); 330 Node* const object = NodeProperties::GetValueInput(node, 0);
357 Node* const source_map = NodeProperties::GetValueInput(node, 1); 331 Node* const source_map = NodeProperties::GetValueInput(node, 1);
358 Node* const target_map = NodeProperties::GetValueInput(node, 2); 332 Node* const target_map = NodeProperties::GetValueInput(node, 2);
359 Node* const effect = NodeProperties::GetEffectInput(node); 333 Node* const effect = NodeProperties::GetEffectInput(node);
360 AbstractState const* state = node_states_.Get(effect); 334 AbstractState const* state = node_states_.Get(effect);
361 if (state == nullptr) return NoChange(); 335 if (state == nullptr) return NoChange();
362 if (Node* const object_map = state->LookupField(object, 0)) { 336 if (Node* const object_map = state->LookupField(object, 0)) {
363 state = state->KillField(object, 0, zone()); 337 state = state->KillField(object, 0, zone());
364 if (source_map == object_map) { 338 if (source_map == object_map) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 for (int i = 1; i < control->InputCount(); ++i) { 545 for (int i = 1; i < control->InputCount(); ++i) {
572 queue.push(node->InputAt(i)); 546 queue.push(node->InputAt(i));
573 } 547 }
574 while (!queue.empty()) { 548 while (!queue.empty()) {
575 Node* const current = queue.front(); 549 Node* const current = queue.front();
576 queue.pop(); 550 queue.pop();
577 if (visited.find(current) == visited.end()) { 551 if (visited.find(current) == visited.end()) {
578 visited.insert(current); 552 visited.insert(current);
579 if (!current->op()->HasProperty(Operator::kNoWrite)) { 553 if (!current->op()->HasProperty(Operator::kNoWrite)) {
580 switch (current->opcode()) { 554 switch (current->opcode()) {
581 case IrOpcode::kEnsureWritableFastElements: {
582 Node* const object = NodeProperties::GetValueInput(current, 0);
583 Node* const elements = NodeProperties::GetValueInput(current, 1);
584 state = state->KillField(elements, 0, zone());
585 state = state->KillField(object, 2, zone());
586 break;
587 }
588 case IrOpcode::kTransitionElementsKind: {
589 Node* const object = NodeProperties::GetValueInput(current, 0);
590 state = state->KillField(object, 0, zone());
591 state = state->KillField(object, 2, zone());
592 break;
593 }
594 case IrOpcode::kStoreField: { 555 case IrOpcode::kStoreField: {
595 FieldAccess const& access = FieldAccessOf(current->op()); 556 FieldAccess const& access = FieldAccessOf(current->op());
596 Node* const object = NodeProperties::GetValueInput(current, 0); 557 Node* const object = NodeProperties::GetValueInput(current, 0);
597 int field_index = FieldIndexOf(access); 558 int field_index = FieldIndexOf(access);
598 if (field_index < 0) return empty_state(); 559 if (field_index < 0) return empty_state();
599 state = state->KillField(object, field_index, zone()); 560 state = state->KillField(object, field_index, zone());
600 break; 561 break;
601 } 562 }
602 case IrOpcode::kStoreElement: { 563 case IrOpcode::kStoreElement: {
603 Node* const object = NodeProperties::GetValueInput(current, 0); 564 Node* const object = NodeProperties::GetValueInput(current, 0);
604 Node* const index = NodeProperties::GetValueInput(current, 1); 565 Node* const index = NodeProperties::GetValueInput(current, 1);
605 state = state->KillElement(object, index, zone()); 566 state = state->KillElement(object, index, zone());
606 break; 567 break;
607 } 568 }
608 case IrOpcode::kStoreBuffer:
609 case IrOpcode::kStoreTypedElement: {
610 // Doesn't affect anything we track with the state currently.
611 break;
612 }
613 default: 569 default:
614 return empty_state(); 570 return empty_state();
615 } 571 }
616 } 572 }
617 for (int i = 0; i < current->op()->EffectInputCount(); ++i) { 573 for (int i = 0; i < current->op()->EffectInputCount(); ++i) {
618 queue.push(NodeProperties::GetEffectInput(current, i)); 574 queue.push(NodeProperties::GetEffectInput(current, i));
619 } 575 }
620 } 576 }
621 } 577 }
622 return state; 578 return state;
(...skipping 27 matching lines...) Expand all
650 DCHECK_EQ(kTaggedBase, access.base_is_tagged); 606 DCHECK_EQ(kTaggedBase, access.base_is_tagged);
651 DCHECK_EQ(0, access.offset % kPointerSize); 607 DCHECK_EQ(0, access.offset % kPointerSize);
652 int field_index = access.offset / kPointerSize; 608 int field_index = access.offset / kPointerSize;
653 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1; 609 if (field_index >= static_cast<int>(kMaxTrackedFields)) return -1;
654 return field_index; 610 return field_index;
655 } 611 }
656 612
657 } // namespace compiler 613 } // namespace compiler
658 } // namespace internal 614 } // namespace internal
659 } // namespace v8 615 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/load-elimination.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698