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

Side by Side Diff: src/compiler/typer.cc

Issue 795993002: Introduce unsigned representation types (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/access-builder.cc ('k') | src/compiler/verifier.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/bootstrapper.h" 5 #include "src/bootstrapper.h"
6 #include "src/compiler/graph-inl.h" 6 #include "src/compiler/graph-inl.h"
7 #include "src/compiler/graph-reducer.h" 7 #include "src/compiler/graph-reducer.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node.h" 9 #include "src/compiler/node.h"
10 #include "src/compiler/node-properties-inl.h" 10 #include "src/compiler/node-properties-inl.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 int index = static_cast<int>(type); 52 int index = static_cast<int>(type);
53 DCHECK(index < kNumLazyCachedTypes); 53 DCHECK(index < kNumLazyCachedTypes);
54 if (cache_[index] == NULL) cache_[index] = Create(type); 54 if (cache_[index] == NULL) cache_[index] = Create(type);
55 return cache_[index]; 55 return cache_[index];
56 } 56 }
57 57
58 private: 58 private:
59 Type* Create(LazyCachedType type) { 59 Type* Create(LazyCachedType type) {
60 switch (type) { 60 switch (type) {
61 case kInt8: 61 case kInt8:
62 return CreateNative(CreateRange<int8_t>(), Type::UntaggedInt8()); 62 return CreateNative(CreateRange<int8_t>(), Type::UntaggedSigned8());
63 case kUint8: 63 case kUint8:
64 return CreateNative(CreateRange<uint8_t>(), Type::UntaggedInt8()); 64 return CreateNative(CreateRange<uint8_t>(), Type::UntaggedUnsigned8());
65 case kInt16: 65 case kInt16:
66 return CreateNative(CreateRange<int16_t>(), Type::UntaggedInt16()); 66 return CreateNative(CreateRange<int16_t>(), Type::UntaggedSigned16());
67 case kUint16: 67 case kUint16:
68 return CreateNative(CreateRange<uint16_t>(), Type::UntaggedInt16()); 68 return CreateNative(CreateRange<uint16_t>(),
69 Type::UntaggedUnsigned16());
69 case kInt32: 70 case kInt32:
70 return CreateNative(Type::Signed32(), Type::UntaggedInt32()); 71 return CreateNative(Type::Signed32(), Type::UntaggedSigned32());
71 case kUint32: 72 case kUint32:
72 return CreateNative(Type::Unsigned32(), Type::UntaggedInt32()); 73 return CreateNative(Type::Unsigned32(), Type::UntaggedUnsigned32());
73 case kFloat32: 74 case kFloat32:
74 return CreateNative(Type::Number(), Type::UntaggedFloat32()); 75 return CreateNative(Type::Number(), Type::UntaggedFloat32());
75 case kFloat64: 76 case kFloat64:
76 return CreateNative(Type::Number(), Type::UntaggedFloat64()); 77 return CreateNative(Type::Number(), Type::UntaggedFloat64());
77 case kNumberFunc0: 78 case kNumberFunc0:
78 return Type::Function(Type::Number(), zone()); 79 return Type::Function(Type::Number(), zone());
79 case kNumberFunc1: 80 case kNumberFunc1:
80 return Type::Function(Type::Number(), Type::Number(), zone()); 81 return Type::Function(Type::Number(), Type::Number(), zone());
81 case kNumberFunc2: 82 case kNumberFunc2:
82 return Type::Function(Type::Number(), Type::Number(), Type::Number(), 83 return Type::Function(Type::Number(), Type::Number(), Type::Number(),
83 zone()); 84 zone());
84 case kImulFunc: 85 case kImulFunc:
85 return Type::Function(Type::Signed32(), Type::Integral32(), 86 return Type::Function(Type::Signed32(), Type::Integral32(),
86 Type::Integral32(), zone()); 87 Type::Integral32(), zone());
87 case kClz32Func: 88 case kClz32Func:
88 return Type::Function(CreateRange(0, 32), Type::Number(), zone()); 89 return Type::Function(CreateRange(0, 32), Type::Number(), zone());
89 case kArrayBufferFunc: 90 case kArrayBufferFunc:
90 return Type::Function(Type::Buffer(zone()), Type::Unsigned32(), zone()); 91 return Type::Function(Type::Object(zone()), Type::Unsigned32(), zone());
91 #define NATIVE_TYPE_CASE(Type) \ 92 #define NATIVE_TYPE_CASE(Type) \
92 case k##Type##Array: \ 93 case k##Type##Array: \
93 return CreateArray(Get(k##Type)); \ 94 return CreateArray(Get(k##Type)); \
94 case k##Type##ArrayFunc: \ 95 case k##Type##ArrayFunc: \
95 return CreateArrayFunction(Get(k##Type##Array)); 96 return CreateArrayFunction(Get(k##Type##Array));
96 NATIVE_TYPES(NATIVE_TYPE_CASE) 97 NATIVE_TYPES(NATIVE_TYPE_CASE)
97 #undef NATIVE_TYPE_CASE 98 #undef NATIVE_TYPE_CASE
98 case kNumLazyCachedTypes: 99 case kNumLazyCachedTypes:
99 break; 100 break;
100 } 101 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 592
592 Bounds Typer::Visitor::TypeParameter(Node* node) { 593 Bounds Typer::Visitor::TypeParameter(Node* node) {
593 return Bounds::Unbounded(zone()); 594 return Bounds::Unbounded(zone());
594 } 595 }
595 596
596 597
597 Bounds Typer::Visitor::TypeInt32Constant(Node* node) { 598 Bounds Typer::Visitor::TypeInt32Constant(Node* node) {
598 Factory* f = isolate()->factory(); 599 Factory* f = isolate()->factory();
599 Handle<Object> number = f->NewNumber(OpParameter<int32_t>(node)); 600 Handle<Object> number = f->NewNumber(OpParameter<int32_t>(node));
600 return Bounds(Type::Intersect( 601 return Bounds(Type::Intersect(
601 Type::Range(number, number, zone()), Type::UntaggedInt32(), zone())); 602 Type::Range(number, number, zone()), Type::UntaggedSigned32(), zone()));
602 } 603 }
603 604
604 605
605 Bounds Typer::Visitor::TypeInt64Constant(Node* node) { 606 Bounds Typer::Visitor::TypeInt64Constant(Node* node) {
607 // TODO(rossberg): This actually seems to be a PointerConstant so far...
606 return Bounds(Type::Internal()); // TODO(rossberg): Add int64 bitset type? 608 return Bounds(Type::Internal()); // TODO(rossberg): Add int64 bitset type?
607 } 609 }
608 610
609 611
610 Bounds Typer::Visitor::TypeFloat32Constant(Node* node) { 612 Bounds Typer::Visitor::TypeFloat32Constant(Node* node) {
611 return Bounds(Type::Intersect( 613 return Bounds(Type::Intersect(
612 Type::Of(OpParameter<float>(node), zone()), 614 Type::Of(OpParameter<float>(node), zone()),
613 Type::UntaggedFloat32(), zone())); 615 Type::UntaggedFloat32(), zone()));
614 } 616 }
615 617
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 Type::Intersect(rep, Type::Representation(), zone), zone); 1530 Type::Intersect(rep, Type::Representation(), zone), zone);
1529 */ 1531 */
1530 return type; 1532 return type;
1531 } 1533 }
1532 1534
1533 1535
1534 Bounds Typer::Visitor::TypeChangeTaggedToInt32(Node* node) { 1536 Bounds Typer::Visitor::TypeChangeTaggedToInt32(Node* node) {
1535 Bounds arg = Operand(node, 0); 1537 Bounds arg = Operand(node, 0);
1536 // TODO(neis): DCHECK(arg.upper->Is(Type::Signed32())); 1538 // TODO(neis): DCHECK(arg.upper->Is(Type::Signed32()));
1537 return Bounds( 1539 return Bounds(
1538 ChangeRepresentation(arg.lower, Type::UntaggedInt32(), zone()), 1540 ChangeRepresentation(arg.lower, Type::UntaggedSigned32(), zone()),
1539 ChangeRepresentation(arg.upper, Type::UntaggedInt32(), zone())); 1541 ChangeRepresentation(arg.upper, Type::UntaggedSigned32(), zone()));
1540 } 1542 }
1541 1543
1542 1544
1543 Bounds Typer::Visitor::TypeChangeTaggedToUint32(Node* node) { 1545 Bounds Typer::Visitor::TypeChangeTaggedToUint32(Node* node) {
1544 Bounds arg = Operand(node, 0); 1546 Bounds arg = Operand(node, 0);
1545 // TODO(neis): DCHECK(arg.upper->Is(Type::Unsigned32())); 1547 // TODO(neis): DCHECK(arg.upper->Is(Type::Unsigned32()));
1546 return Bounds( 1548 return Bounds(
1547 ChangeRepresentation(arg.lower, Type::UntaggedInt32(), zone()), 1549 ChangeRepresentation(arg.lower, Type::UntaggedUnsigned32(), zone()),
1548 ChangeRepresentation(arg.upper, Type::UntaggedInt32(), zone())); 1550 ChangeRepresentation(arg.upper, Type::UntaggedUnsigned32(), zone()));
1549 } 1551 }
1550 1552
1551 1553
1552 Bounds Typer::Visitor::TypeChangeTaggedToFloat64(Node* node) { 1554 Bounds Typer::Visitor::TypeChangeTaggedToFloat64(Node* node) {
1553 Bounds arg = Operand(node, 0); 1555 Bounds arg = Operand(node, 0);
1554 // TODO(neis): DCHECK(arg.upper->Is(Type::Number())); 1556 // TODO(neis): DCHECK(arg.upper->Is(Type::Number()));
1555 return Bounds( 1557 return Bounds(
1556 ChangeRepresentation(arg.lower, Type::UntaggedFloat64(), zone()), 1558 ChangeRepresentation(arg.lower, Type::UntaggedFloat64(), zone()),
1557 ChangeRepresentation(arg.upper, Type::UntaggedFloat64(), zone())); 1559 ChangeRepresentation(arg.upper, Type::UntaggedFloat64(), zone()));
1558 } 1560 }
(...skipping 23 matching lines...) Expand all
1582 return Bounds( 1584 return Bounds(
1583 ChangeRepresentation(arg.lower, Type::Tagged(), zone()), 1585 ChangeRepresentation(arg.lower, Type::Tagged(), zone()),
1584 ChangeRepresentation(arg.upper, Type::Tagged(), zone())); 1586 ChangeRepresentation(arg.upper, Type::Tagged(), zone()));
1585 } 1587 }
1586 1588
1587 1589
1588 Bounds Typer::Visitor::TypeChangeBoolToBit(Node* node) { 1590 Bounds Typer::Visitor::TypeChangeBoolToBit(Node* node) {
1589 Bounds arg = Operand(node, 0); 1591 Bounds arg = Operand(node, 0);
1590 // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean())); 1592 // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean()));
1591 return Bounds( 1593 return Bounds(
1592 ChangeRepresentation(arg.lower, Type::UntaggedInt1(), zone()), 1594 ChangeRepresentation(arg.lower, Type::UntaggedBit(), zone()),
1593 ChangeRepresentation(arg.upper, Type::UntaggedInt1(), zone())); 1595 ChangeRepresentation(arg.upper, Type::UntaggedBit(), zone()));
1594 } 1596 }
1595 1597
1596 1598
1597 Bounds Typer::Visitor::TypeChangeBitToBool(Node* node) { 1599 Bounds Typer::Visitor::TypeChangeBitToBool(Node* node) {
1598 Bounds arg = Operand(node, 0); 1600 Bounds arg = Operand(node, 0);
1599 // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean())); 1601 // TODO(neis): DCHECK(arg.upper->Is(Type::Boolean()));
1600 return Bounds( 1602 return Bounds(
1601 ChangeRepresentation(arg.lower, Type::TaggedPtr(), zone()), 1603 ChangeRepresentation(arg.lower, Type::TaggedPointer(), zone()),
1602 ChangeRepresentation(arg.upper, Type::TaggedPtr(), zone())); 1604 ChangeRepresentation(arg.upper, Type::TaggedPointer(), zone()));
1603 } 1605 }
1604 1606
1605 1607
1606 Bounds Typer::Visitor::TypeLoadField(Node* node) { 1608 Bounds Typer::Visitor::TypeLoadField(Node* node) {
1607 return Bounds(FieldAccessOf(node->op()).type); 1609 return Bounds(FieldAccessOf(node->op()).type);
1608 } 1610 }
1609 1611
1610 1612
1611 Bounds Typer::Visitor::TypeLoadBuffer(Node* node) { 1613 Bounds Typer::Visitor::TypeLoadBuffer(Node* node) {
1612 // TODO(bmeurer): This typing is not yet correct. Since we can still access 1614 // TODO(bmeurer): This typing is not yet correct. Since we can still access
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 1879
1878 1880
1879 Bounds Typer::Visitor::TypeChangeFloat32ToFloat64(Node* node) { 1881 Bounds Typer::Visitor::TypeChangeFloat32ToFloat64(Node* node) {
1880 return Bounds(Type::Intersect( 1882 return Bounds(Type::Intersect(
1881 Type::Number(), Type::UntaggedFloat64(), zone())); 1883 Type::Number(), Type::UntaggedFloat64(), zone()));
1882 } 1884 }
1883 1885
1884 1886
1885 Bounds Typer::Visitor::TypeChangeFloat64ToInt32(Node* node) { 1887 Bounds Typer::Visitor::TypeChangeFloat64ToInt32(Node* node) {
1886 return Bounds(Type::Intersect( 1888 return Bounds(Type::Intersect(
1887 Type::Signed32(), Type::UntaggedInt32(), zone())); 1889 Type::Signed32(), Type::UntaggedSigned32(), zone()));
1888 } 1890 }
1889 1891
1890 1892
1891 Bounds Typer::Visitor::TypeChangeFloat64ToUint32(Node* node) { 1893 Bounds Typer::Visitor::TypeChangeFloat64ToUint32(Node* node) {
1892 return Bounds(Type::Intersect( 1894 return Bounds(Type::Intersect(
1893 Type::Unsigned32(), Type::UntaggedInt32(), zone())); 1895 Type::Unsigned32(), Type::UntaggedUnsigned32(), zone()));
1894 } 1896 }
1895 1897
1896 1898
1897 Bounds Typer::Visitor::TypeChangeInt32ToFloat64(Node* node) { 1899 Bounds Typer::Visitor::TypeChangeInt32ToFloat64(Node* node) {
1898 return Bounds(Type::Intersect( 1900 return Bounds(Type::Intersect(
1899 Type::Signed32(), Type::UntaggedFloat64(), zone())); 1901 Type::Signed32(), Type::UntaggedFloat64(), zone()));
1900 } 1902 }
1901 1903
1902 1904
1903 Bounds Typer::Visitor::TypeChangeInt32ToInt64(Node* node) { 1905 Bounds Typer::Visitor::TypeChangeInt32ToInt64(Node* node) {
(...skipping 13 matching lines...) Expand all
1917 1919
1918 1920
1919 Bounds Typer::Visitor::TypeTruncateFloat64ToFloat32(Node* node) { 1921 Bounds Typer::Visitor::TypeTruncateFloat64ToFloat32(Node* node) {
1920 return Bounds(Type::Intersect( 1922 return Bounds(Type::Intersect(
1921 Type::Number(), Type::UntaggedFloat32(), zone())); 1923 Type::Number(), Type::UntaggedFloat32(), zone()));
1922 } 1924 }
1923 1925
1924 1926
1925 Bounds Typer::Visitor::TypeTruncateFloat64ToInt32(Node* node) { 1927 Bounds Typer::Visitor::TypeTruncateFloat64ToInt32(Node* node) {
1926 return Bounds(Type::Intersect( 1928 return Bounds(Type::Intersect(
1927 Type::Signed32(), Type::UntaggedInt32(), zone())); 1929 Type::Signed32(), Type::UntaggedSigned32(), zone()));
1928 } 1930 }
1929 1931
1930 1932
1931 Bounds Typer::Visitor::TypeTruncateInt64ToInt32(Node* node) { 1933 Bounds Typer::Visitor::TypeTruncateInt64ToInt32(Node* node) {
1932 return Bounds(Type::Intersect( 1934 return Bounds(Type::Intersect(
1933 Type::Signed32(), Type::UntaggedInt32(), zone())); 1935 Type::Signed32(), Type::UntaggedSigned32(), zone()));
1934 } 1936 }
1935 1937
1936 1938
1937 Bounds Typer::Visitor::TypeFloat64Add(Node* node) { 1939 Bounds Typer::Visitor::TypeFloat64Add(Node* node) {
1938 return Bounds(Type::Number()); 1940 return Bounds(Type::Number());
1939 } 1941 }
1940 1942
1941 1943
1942 Bounds Typer::Visitor::TypeFloat64Sub(Node* node) { 1944 Bounds Typer::Visitor::TypeFloat64Sub(Node* node) {
1943 return Bounds(Type::Number()); 1945 return Bounds(Type::Number());
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2094 // TODO(rossberg): Do we want some ClampedArray type to express this? 2096 // TODO(rossberg): Do we want some ClampedArray type to express this?
2095 break; 2097 break;
2096 } 2098 }
2097 } 2099 }
2098 return Type::Constant(value, zone()); 2100 return Type::Constant(value, zone());
2099 } 2101 }
2100 2102
2101 } // namespace compiler 2103 } // namespace compiler
2102 } // namespace internal 2104 } // namespace internal
2103 } // namespace v8 2105 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-builder.cc ('k') | src/compiler/verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698