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

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

Issue 516853002: Preliminary lowering of typed array loads in TF. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address feedback by Ben Titzer. Created 6 years, 3 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
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/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-typed-lowering.h" 6 #include "src/compiler/js-typed-lowering.h"
7 #include "src/compiler/node-aux-data-inl.h" 7 #include "src/compiler/node-aux-data-inl.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 ReplaceEagerly(input, inv); 492 ReplaceEagerly(input, inv);
493 // TODO(titzer): Ugly. ReplaceEagerly smashes all uses. Smash it back here. 493 // TODO(titzer): Ugly. ReplaceEagerly smashes all uses. Smash it back here.
494 cmp->ReplaceInput(0, input); 494 cmp->ReplaceInput(0, input);
495 return Changed(inv); 495 return Changed(inv);
496 } 496 }
497 // TODO(turbofan): js-typed-lowering of ToBoolean(string) 497 // TODO(turbofan): js-typed-lowering of ToBoolean(string)
498 return NoChange(); 498 return NoChange();
499 } 499 }
500 500
501 501
502 Reduction JSTypedLowering::ReduceJSPropertyLoad(Node* node) {
503 Node* key = NodeProperties::GetValueInput(node, 1);
504 Node* base = NodeProperties::GetValueInput(node, 0);
505 Type* key_type = NodeProperties::GetBounds(key).upper;
506 Type* base_type = NodeProperties::GetBounds(base).upper;
507 // TODO(mstarzinger): This lowering is not correct if:
508 // a) The typed array turns external (i.e. MaterializeArrayBuffer)
509 // b) The typed array or it's buffer is neutered.
510 // c) The index is out of bounds.
511 if (base_type->IsConstant() && key_type->Is(Type::Integral32()) &&
512 base_type->AsConstant()->Value()->IsJSTypedArray()) {
513 // JSLoadProperty(typed-array, int32)
514 JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value());
515 ElementsKind elements_kind = array->map()->elements_kind();
516 ExternalArrayType type = array->type();
517 ElementAccess element_access;
518 Node* elements =
519 graph()->NewNode(simplified()->LoadField(Access::ForJSObjectElements()),
520 base, NodeProperties::GetEffectInput(node));
521 if (IsExternalArrayElementsKind(elements_kind)) {
522 elements = graph()->NewNode(
523 simplified()->LoadField(Access::ForExternalArrayPointer()), elements,
524 NodeProperties::GetEffectInput(node));
525 element_access = Access::ForTypedArrayElement(type, true);
526 } else {
527 DCHECK(IsFixedTypedArrayElementsKind(elements_kind));
528 element_access = Access::ForTypedArrayElement(type, false);
529 }
530 Node* value =
531 graph()->NewNode(simplified()->LoadElement(element_access), elements,
532 key, NodeProperties::GetEffectInput(node));
533 return ReplaceEagerly(node, value);
534 }
535 return NoChange();
536 }
537
538
502 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) { 539 static Reduction ReplaceWithReduction(Node* node, Reduction reduction) {
503 if (reduction.Changed()) { 540 if (reduction.Changed()) {
504 NodeProperties::ReplaceWithValue(node, reduction.replacement()); 541 NodeProperties::ReplaceWithValue(node, reduction.replacement());
505 return reduction; 542 return reduction;
506 } 543 }
507 return Reducer::NoChange(); 544 return Reducer::NoChange();
508 } 545 }
509 546
510 547
511 Reduction JSTypedLowering::Reduce(Node* node) { 548 Reduction JSTypedLowering::Reduce(Node* node) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 } 603 }
567 case IrOpcode::kJSToBoolean: 604 case IrOpcode::kJSToBoolean:
568 return ReplaceWithReduction(node, 605 return ReplaceWithReduction(node,
569 ReduceJSToBooleanInput(node->InputAt(0))); 606 ReduceJSToBooleanInput(node->InputAt(0)));
570 case IrOpcode::kJSToNumber: 607 case IrOpcode::kJSToNumber:
571 return ReplaceWithReduction(node, 608 return ReplaceWithReduction(node,
572 ReduceJSToNumberInput(node->InputAt(0))); 609 ReduceJSToNumberInput(node->InputAt(0)));
573 case IrOpcode::kJSToString: 610 case IrOpcode::kJSToString:
574 return ReplaceWithReduction(node, 611 return ReplaceWithReduction(node,
575 ReduceJSToStringInput(node->InputAt(0))); 612 ReduceJSToStringInput(node->InputAt(0)));
613 case IrOpcode::kJSLoadProperty:
614 return ReduceJSPropertyLoad(node);
576 default: 615 default:
577 break; 616 break;
578 } 617 }
579 return NoChange(); 618 return NoChange();
580 } 619 }
581 } 620 }
582 } 621 }
583 } // namespace v8::internal::compiler 622 } // namespace v8::internal::compiler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698