OLD | NEW |
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/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/js-typed-lowering.h" | 7 #include "src/compiler/js-typed-lowering.h" |
8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 node->TrimInputCount(1); | 534 node->TrimInputCount(1); |
535 return Changed(node); | 535 return Changed(node); |
536 } else if (input_type->Is(Type::OrderedNumber())) { | 536 } else if (input_type->Is(Type::OrderedNumber())) { |
537 // JSUnaryNot(x:number) => NumberEqual(x,#0) | 537 // JSUnaryNot(x:number) => NumberEqual(x,#0) |
538 node->set_op(simplified()->NumberEqual()); | 538 node->set_op(simplified()->NumberEqual()); |
539 node->ReplaceInput(1, jsgraph()->ZeroConstant()); | 539 node->ReplaceInput(1, jsgraph()->ZeroConstant()); |
540 node->TrimInputCount(2); | 540 node->TrimInputCount(2); |
541 return Changed(node); | 541 return Changed(node); |
542 } else if (input_type->Is(Type::String())) { | 542 } else if (input_type->Is(Type::String())) { |
543 // JSUnaryNot(x:string) => NumberEqual(x.length,#0) | 543 // JSUnaryNot(x:string) => NumberEqual(x.length,#0) |
544 FieldAccess const access = AccessBuilder::ForStringLength(); | 544 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone()); |
545 // It is safe for the load to be effect-free (i.e. not linked into effect | 545 // It is safe for the load to be effect-free (i.e. not linked into effect |
546 // chain) because we assume String::length to be immutable. | 546 // chain) because we assume String::length to be immutable. |
547 Node* length = graph()->NewNode(simplified()->LoadField(access), input, | 547 Node* length = graph()->NewNode(simplified()->LoadField(access), input, |
548 graph()->start(), graph()->start()); | 548 graph()->start(), graph()->start()); |
549 node->set_op(simplified()->NumberEqual()); | 549 node->set_op(simplified()->NumberEqual()); |
550 node->ReplaceInput(0, length); | 550 node->ReplaceInput(0, length); |
551 node->ReplaceInput(1, jsgraph()->ZeroConstant()); | 551 node->ReplaceInput(1, jsgraph()->ZeroConstant()); |
552 node->TrimInputCount(2); | 552 node->TrimInputCount(2); |
553 NodeProperties::ReplaceWithValue(node, node, length); | 553 NodeProperties::ReplaceWithValue(node, node, length); |
554 return Changed(node); | 554 return Changed(node); |
(...skipping 10 matching lines...) Expand all Loading... |
565 return Replace(input); | 565 return Replace(input); |
566 } else if (input_type->Is(Type::OrderedNumber())) { | 566 } else if (input_type->Is(Type::OrderedNumber())) { |
567 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) | 567 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) |
568 node->set_op(simplified()->BooleanNot()); | 568 node->set_op(simplified()->BooleanNot()); |
569 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, | 569 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, |
570 jsgraph()->ZeroConstant())); | 570 jsgraph()->ZeroConstant())); |
571 node->TrimInputCount(1); | 571 node->TrimInputCount(1); |
572 return Changed(node); | 572 return Changed(node); |
573 } else if (input_type->Is(Type::String())) { | 573 } else if (input_type->Is(Type::String())) { |
574 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) | 574 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) |
575 FieldAccess const access = AccessBuilder::ForStringLength(); | 575 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone()); |
576 // It is safe for the load to be effect-free (i.e. not linked into effect | 576 // It is safe for the load to be effect-free (i.e. not linked into effect |
577 // chain) because we assume String::length to be immutable. | 577 // chain) because we assume String::length to be immutable. |
578 Node* length = graph()->NewNode(simplified()->LoadField(access), input, | 578 Node* length = graph()->NewNode(simplified()->LoadField(access), input, |
579 graph()->start(), graph()->start()); | 579 graph()->start(), graph()->start()); |
580 node->set_op(simplified()->NumberLessThan()); | 580 node->set_op(simplified()->NumberLessThan()); |
581 node->ReplaceInput(0, jsgraph()->ZeroConstant()); | 581 node->ReplaceInput(0, jsgraph()->ZeroConstant()); |
582 node->ReplaceInput(1, length); | 582 node->ReplaceInput(1, length); |
583 node->TrimInputCount(2); | 583 node->TrimInputCount(2); |
584 return Changed(node); | 584 return Changed(node); |
585 } | 585 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 } | 1077 } |
1078 | 1078 |
1079 | 1079 |
1080 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1080 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1081 return jsgraph()->machine(); | 1081 return jsgraph()->machine(); |
1082 } | 1082 } |
1083 | 1083 |
1084 } // namespace compiler | 1084 } // namespace compiler |
1085 } // namespace internal | 1085 } // namespace internal |
1086 } // namespace v8 | 1086 } // namespace v8 |
OLD | NEW |