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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 602563002: [turbofan] Add length operand to LoadElement and StoreElement. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-generic-lowering.cc ('k') | src/compiler/simplified-lowering.cc » ('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 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/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/graph-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/js-builtin-reducer.h" 7 #include "src/compiler/js-builtin-reducer.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/node-aux-data-inl.h" 9 #include "src/compiler/node-aux-data-inl.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 // TODO(mstarzinger): This lowering is not correct if: 533 // TODO(mstarzinger): This lowering is not correct if:
534 // a) The typed array turns external (i.e. MaterializeArrayBuffer) 534 // a) The typed array turns external (i.e. MaterializeArrayBuffer)
535 // b) The typed array or it's buffer is neutered. 535 // b) The typed array or it's buffer is neutered.
536 // c) The index is out of bounds. 536 // c) The index is out of bounds.
537 if (base_type->IsConstant() && key_type->Is(Type::Integral32()) && 537 if (base_type->IsConstant() && key_type->Is(Type::Integral32()) &&
538 base_type->AsConstant()->Value()->IsJSTypedArray()) { 538 base_type->AsConstant()->Value()->IsJSTypedArray()) {
539 // JSLoadProperty(typed-array, int32) 539 // JSLoadProperty(typed-array, int32)
540 JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value()); 540 JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value());
541 ElementsKind elements_kind = array->map()->elements_kind(); 541 ElementsKind elements_kind = array->map()->elements_kind();
542 ExternalArrayType type = array->type(); 542 ExternalArrayType type = array->type();
543 uint32_t length;
544 CHECK(array->length()->ToUint32(&length));
543 ElementAccess element_access; 545 ElementAccess element_access;
544 Node* elements = graph()->NewNode( 546 Node* elements = graph()->NewNode(
545 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base, 547 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), base,
546 NodeProperties::GetEffectInput(node)); 548 NodeProperties::GetEffectInput(node));
547 if (IsExternalArrayElementsKind(elements_kind)) { 549 if (IsExternalArrayElementsKind(elements_kind)) {
548 elements = graph()->NewNode( 550 elements = graph()->NewNode(
549 simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()), 551 simplified()->LoadField(AccessBuilder::ForExternalArrayPointer()),
550 elements, NodeProperties::GetEffectInput(node)); 552 elements, NodeProperties::GetEffectInput(node));
551 element_access = AccessBuilder::ForTypedArrayElement(type, true); 553 element_access = AccessBuilder::ForTypedArrayElement(type, true);
552 } else { 554 } else {
553 DCHECK(IsFixedTypedArrayElementsKind(elements_kind)); 555 DCHECK(IsFixedTypedArrayElementsKind(elements_kind));
554 element_access = AccessBuilder::ForTypedArrayElement(type, false); 556 element_access = AccessBuilder::ForTypedArrayElement(type, false);
555 } 557 }
556 Node* value = 558 Node* value =
557 graph()->NewNode(simplified()->LoadElement(element_access), elements, 559 graph()->NewNode(simplified()->LoadElement(element_access), elements,
558 key, NodeProperties::GetEffectInput(node)); 560 key, jsgraph()->Uint32Constant(length),
561 NodeProperties::GetEffectInput(node));
559 return ReplaceEagerly(node, value); 562 return ReplaceEagerly(node, value);
560 } 563 }
561 return NoChange(); 564 return NoChange();
562 } 565 }
563 566
564 567
565 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { 568 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
566 Node* key = NodeProperties::GetValueInput(node, 1); 569 Node* key = NodeProperties::GetValueInput(node, 1);
567 Node* base = NodeProperties::GetValueInput(node, 0); 570 Node* base = NodeProperties::GetValueInput(node, 0);
568 Node* value = NodeProperties::GetValueInput(node, 2); 571 Node* value = NodeProperties::GetValueInput(node, 2);
(...skipping 23 matching lines...) Expand all
592 DCHECK(IsFixedTypedArrayElementsKind(elements_kind)); 595 DCHECK(IsFixedTypedArrayElementsKind(elements_kind));
593 element_access = AccessBuilder::ForTypedArrayElement(type, false); 596 element_access = AccessBuilder::ForTypedArrayElement(type, false);
594 } 597 }
595 598
596 Node* check = graph()->NewNode(machine()->Uint32LessThan(), key, 599 Node* check = graph()->NewNode(machine()->Uint32LessThan(), key,
597 jsgraph()->Uint32Constant(length)); 600 jsgraph()->Uint32Constant(length));
598 Node* branch = graph()->NewNode(common()->Branch(), check, 601 Node* branch = graph()->NewNode(common()->Branch(), check,
599 NodeProperties::GetControlInput(node)); 602 NodeProperties::GetControlInput(node));
600 603
601 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); 604 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
602 Node* store = graph()->NewNode( 605 Node* store =
603 simplified()->StoreElement(element_access), elements, key, value, 606 graph()->NewNode(simplified()->StoreElement(element_access), elements,
604 NodeProperties::GetEffectInput(node), if_true); 607 key, jsgraph()->Uint32Constant(length), value,
608 NodeProperties::GetEffectInput(node), if_true);
605 609
606 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); 610 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
607 611
608 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); 612 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
609 Node* phi = graph()->NewNode(common()->EffectPhi(2), store, 613 Node* phi = graph()->NewNode(common()->EffectPhi(2), store,
610 NodeProperties::GetEffectInput(node), merge); 614 NodeProperties::GetEffectInput(node), merge);
611 615
612 return ReplaceWith(phi); 616 return ReplaceWith(phi);
613 } 617 }
614 return NoChange(); 618 return NoChange();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return JSBuiltinReducer(jsgraph()).Reduce(node); 701 return JSBuiltinReducer(jsgraph()).Reduce(node);
698 default: 702 default:
699 break; 703 break;
700 } 704 }
701 return NoChange(); 705 return NoChange();
702 } 706 }
703 707
704 } // namespace compiler 708 } // namespace compiler
705 } // namespace internal 709 } // namespace internal
706 } // namespace v8 710 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-generic-lowering.cc ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698