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

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

Issue 602693002: Give more precise types to some Math functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « no previous file | src/compiler/typer.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 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 Node* ConvertToNumber(Node* node) { 156 Node* ConvertToNumber(Node* node) {
157 // Avoid introducing too many eager ToNumber() operations. 157 // Avoid introducing too many eager ToNumber() operations.
158 Reduction reduced = lowering_->ReduceJSToNumberInput(node); 158 Reduction reduced = lowering_->ReduceJSToNumberInput(node);
159 if (reduced.Changed()) return reduced.replacement(); 159 if (reduced.Changed()) return reduced.replacement();
160 Node* n = graph()->NewNode(javascript()->ToNumber(), node, context(), 160 Node* n = graph()->NewNode(javascript()->ToNumber(), node, context(),
161 effect(), control()); 161 effect(), control());
162 update_effect(n); 162 update_effect(n);
163 return n; 163 return n;
164 } 164 }
165 165
166 // Try to narrowing a double or number operation to an Int32 operation. 166 // Try narrowing a double or number operation to an Int32 operation.
167 bool TryNarrowingToI32(Type* type, Node* node) { 167 bool TryNarrowingToI32(Type* type, Node* node) {
168 switch (node->opcode()) { 168 switch (node->opcode()) {
169 case IrOpcode::kFloat64Add: 169 case IrOpcode::kFloat64Add:
170 case IrOpcode::kNumberAdd: { 170 case IrOpcode::kNumberAdd: {
171 JSBinopReduction r(lowering_, node); 171 JSBinopReduction r(lowering_, node);
172 if (r.BothInputsAre(Type::Integral32())) { 172 if (r.BothInputsAre(Type::Integral32())) {
173 node->set_op(lowering_->machine()->Int32Add()); 173 node->set_op(lowering_->machine()->Int32Add());
174 // TODO(titzer): narrow bounds instead of overwriting. 174 // TODO(titzer): narrow bounds instead of overwriting.
175 NodeProperties::SetBounds(node, Bounds(type)); 175 NodeProperties::SetBounds(node, Bounds(type));
176 return true; 176 return true;
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 567
568 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { 568 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
569 Node* key = NodeProperties::GetValueInput(node, 1); 569 Node* key = NodeProperties::GetValueInput(node, 1);
570 Node* base = NodeProperties::GetValueInput(node, 0); 570 Node* base = NodeProperties::GetValueInput(node, 0);
571 Node* value = NodeProperties::GetValueInput(node, 2); 571 Node* value = NodeProperties::GetValueInput(node, 2);
572 Type* key_type = NodeProperties::GetBounds(key).upper; 572 Type* key_type = NodeProperties::GetBounds(key).upper;
573 Type* base_type = NodeProperties::GetBounds(base).upper; 573 Type* base_type = NodeProperties::GetBounds(base).upper;
574 // TODO(mstarzinger): This lowering is not correct if: 574 // TODO(mstarzinger): This lowering is not correct if:
575 // a) The typed array turns external (i.e. MaterializeArrayBuffer) 575 // a) The typed array turns external (i.e. MaterializeArrayBuffer)
576 // b) The typed array or it's buffer is neutered. 576 // b) The typed array or its buffer is neutered.
577 if (key_type->Is(Type::Integral32()) && base_type->IsConstant() && 577 if (key_type->Is(Type::Integral32()) && base_type->IsConstant() &&
578 base_type->AsConstant()->Value()->IsJSTypedArray()) { 578 base_type->AsConstant()->Value()->IsJSTypedArray()) {
579 // JSStoreProperty(typed-array, int32, value) 579 // JSStoreProperty(typed-array, int32, value)
580 JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value()); 580 JSTypedArray* array = JSTypedArray::cast(*base_type->AsConstant()->Value());
581 ElementsKind elements_kind = array->map()->elements_kind(); 581 ElementsKind elements_kind = array->map()->elements_kind();
582 ExternalArrayType type = array->type(); 582 ExternalArrayType type = array->type();
583 uint32_t length; 583 uint32_t length;
584 CHECK(array->length()->ToUint32(&length)); 584 CHECK(array->length()->ToUint32(&length));
585 ElementAccess element_access; 585 ElementAccess element_access;
586 Node* elements = graph()->NewNode( 586 Node* elements = graph()->NewNode(
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 return JSBuiltinReducer(jsgraph()).Reduce(node); 701 return JSBuiltinReducer(jsgraph()).Reduce(node);
702 default: 702 default:
703 break; 703 break;
704 } 704 }
705 return NoChange(); 705 return NoChange();
706 } 706 }
707 707
708 } // namespace compiler 708 } // namespace compiler
709 } // namespace internal 709 } // namespace internal
710 } // namespace v8 710 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/typer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698