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 #ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_ | 5 #ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_H_ | 6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/compiler/machine-type.h" | 10 #include "src/compiler/machine-type.h" |
(...skipping 15 matching lines...) Loading... |
26 // Forward declarations. | 26 // Forward declarations. |
27 class Operator; | 27 class Operator; |
28 struct SimplifiedOperatorGlobalCache; | 28 struct SimplifiedOperatorGlobalCache; |
29 | 29 |
30 | 30 |
31 enum BaseTaggedness { kUntaggedBase, kTaggedBase }; | 31 enum BaseTaggedness { kUntaggedBase, kTaggedBase }; |
32 | 32 |
33 std::ostream& operator<<(std::ostream&, BaseTaggedness); | 33 std::ostream& operator<<(std::ostream&, BaseTaggedness); |
34 | 34 |
35 | 35 |
| 36 // An access descriptor for loads/stores of array buffers. |
| 37 class BufferAccess FINAL { |
| 38 public: |
| 39 explicit BufferAccess(ExternalArrayType external_array_type) |
| 40 : external_array_type_(external_array_type) {} |
| 41 |
| 42 ExternalArrayType external_array_type() const { return external_array_type_; } |
| 43 MachineType machine_type() const; |
| 44 |
| 45 private: |
| 46 ExternalArrayType const external_array_type_; |
| 47 }; |
| 48 |
| 49 bool operator==(BufferAccess, BufferAccess); |
| 50 bool operator!=(BufferAccess, BufferAccess); |
| 51 |
| 52 size_t hash_value(BufferAccess); |
| 53 |
| 54 std::ostream& operator<<(std::ostream&, BufferAccess); |
| 55 |
| 56 BufferAccess const BufferAccessOf(const Operator* op) WARN_UNUSED_RESULT; |
| 57 |
| 58 |
36 // An access descriptor for loads/stores of fixed structures like field | 59 // An access descriptor for loads/stores of fixed structures like field |
37 // accesses of heap objects. Accesses from either tagged or untagged base | 60 // accesses of heap objects. Accesses from either tagged or untagged base |
38 // pointers are supported; untagging is done automatically during lowering. | 61 // pointers are supported; untagging is done automatically during lowering. |
39 struct FieldAccess { | 62 struct FieldAccess { |
40 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. | 63 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. |
41 int offset; // offset of the field, without tag. | 64 int offset; // offset of the field, without tag. |
42 MaybeHandle<Name> name; // debugging only. | 65 MaybeHandle<Name> name; // debugging only. |
43 Type* type; // type of the field. | 66 Type* type; // type of the field. |
44 MachineType machine_type; // machine type of the field. | 67 MachineType machine_type; // machine type of the field. |
45 | 68 |
46 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } | 69 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } |
47 }; | 70 }; |
48 | 71 |
49 bool operator==(FieldAccess const&, FieldAccess const&); | 72 bool operator==(FieldAccess const&, FieldAccess const&); |
50 bool operator!=(FieldAccess const&, FieldAccess const&); | 73 bool operator!=(FieldAccess const&, FieldAccess const&); |
51 | 74 |
52 size_t hash_value(FieldAccess const&); | 75 size_t hash_value(FieldAccess const&); |
53 | 76 |
54 std::ostream& operator<<(std::ostream&, FieldAccess const&); | 77 std::ostream& operator<<(std::ostream&, FieldAccess const&); |
55 | 78 |
56 | 79 FieldAccess const& FieldAccessOf(const Operator* op) WARN_UNUSED_RESULT; |
57 // The bound checking mode for ElementAccess below. | |
58 enum BoundsCheckMode { kNoBoundsCheck, kTypedArrayBoundsCheck }; | |
59 | |
60 std::ostream& operator<<(std::ostream&, BoundsCheckMode); | |
61 | 80 |
62 | 81 |
63 // An access descriptor for loads/stores of indexed structures like characters | 82 // An access descriptor for loads/stores of indexed structures like characters |
64 // in strings or off-heap backing stores. Accesses from either tagged or | 83 // in strings or off-heap backing stores. Accesses from either tagged or |
65 // untagged base pointers are supported; untagging is done automatically during | 84 // untagged base pointers are supported; untagging is done automatically during |
66 // lowering. | 85 // lowering. |
67 struct ElementAccess { | 86 struct ElementAccess { |
68 BoundsCheckMode bounds_check; // specifies the bounds checking mode. | |
69 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. | 87 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. |
70 int header_size; // size of the header, without tag. | 88 int header_size; // size of the header, without tag. |
71 Type* type; // type of the element. | 89 Type* type; // type of the element. |
72 MachineType machine_type; // machine type of the element. | 90 MachineType machine_type; // machine type of the element. |
73 | 91 |
74 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } | 92 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } |
75 }; | 93 }; |
76 | 94 |
77 bool operator==(ElementAccess const&, ElementAccess const&); | 95 bool operator==(ElementAccess const&, ElementAccess const&); |
78 bool operator!=(ElementAccess const&, ElementAccess const&); | 96 bool operator!=(ElementAccess const&, ElementAccess const&); |
79 | 97 |
80 size_t hash_value(ElementAccess const&); | 98 size_t hash_value(ElementAccess const&); |
81 | 99 |
82 std::ostream& operator<<(std::ostream&, ElementAccess const&); | 100 std::ostream& operator<<(std::ostream&, ElementAccess const&); |
83 | 101 |
84 | 102 ElementAccess const& ElementAccessOf(const Operator* op) WARN_UNUSED_RESULT; |
85 // If the accessed object is not a heap object, add this to the header_size. | |
86 static const int kNonHeapObjectHeaderSize = kHeapObjectTag; | |
87 | |
88 | |
89 const FieldAccess& FieldAccessOf(const Operator* op) WARN_UNUSED_RESULT; | |
90 const ElementAccess& ElementAccessOf(const Operator* op) WARN_UNUSED_RESULT; | |
91 | 103 |
92 | 104 |
93 // Interface for building simplified operators, which represent the | 105 // Interface for building simplified operators, which represent the |
94 // medium-level operations of V8, including adding numbers, allocating objects, | 106 // medium-level operations of V8, including adding numbers, allocating objects, |
95 // indexing into objects and arrays, etc. | 107 // indexing into objects and arrays, etc. |
96 // All operators are typed but many are representation independent. | 108 // All operators are typed but many are representation independent. |
97 | 109 |
98 // Number values from JS can be in one of these representations: | 110 // Number values from JS can be in one of these representations: |
99 // - Tagged: word-sized integer that is either | 111 // - Tagged: word-sized integer that is either |
100 // - a signed small integer (31 or 32 bits plus a tag) | 112 // - a signed small integer (31 or 32 bits plus a tag) |
(...skipping 41 matching lines...) Loading... |
142 const Operator* ChangeTaggedToFloat64(); | 154 const Operator* ChangeTaggedToFloat64(); |
143 const Operator* ChangeInt32ToTagged(); | 155 const Operator* ChangeInt32ToTagged(); |
144 const Operator* ChangeUint32ToTagged(); | 156 const Operator* ChangeUint32ToTagged(); |
145 const Operator* ChangeFloat64ToTagged(); | 157 const Operator* ChangeFloat64ToTagged(); |
146 const Operator* ChangeBoolToBit(); | 158 const Operator* ChangeBoolToBit(); |
147 const Operator* ChangeBitToBool(); | 159 const Operator* ChangeBitToBool(); |
148 | 160 |
149 const Operator* ObjectIsSmi(); | 161 const Operator* ObjectIsSmi(); |
150 const Operator* ObjectIsNonNegativeSmi(); | 162 const Operator* ObjectIsNonNegativeSmi(); |
151 | 163 |
152 const Operator* LoadField(const FieldAccess&); | 164 const Operator* LoadField(FieldAccess const&); |
153 const Operator* StoreField(const FieldAccess&); | 165 const Operator* StoreField(FieldAccess const&); |
| 166 |
| 167 // load-buffer buffer, offset, length |
| 168 const Operator* LoadBuffer(BufferAccess); |
| 169 |
| 170 // store-buffer buffer, offset, length, value |
| 171 const Operator* StoreBuffer(BufferAccess); |
154 | 172 |
155 // load-element [base + index], length | 173 // load-element [base + index], length |
156 const Operator* LoadElement(ElementAccess const&); | 174 const Operator* LoadElement(ElementAccess const&); |
157 | 175 |
158 // store-element [base + index], length, value | 176 // store-element [base + index], length, value |
159 const Operator* StoreElement(ElementAccess const&); | 177 const Operator* StoreElement(ElementAccess const&); |
160 | 178 |
161 private: | 179 private: |
162 Zone* zone() const { return zone_; } | 180 Zone* zone() const { return zone_; } |
163 | 181 |
164 const SimplifiedOperatorGlobalCache& cache_; | 182 const SimplifiedOperatorGlobalCache& cache_; |
165 Zone* const zone_; | 183 Zone* const zone_; |
166 | 184 |
167 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorBuilder); | 185 DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorBuilder); |
168 }; | 186 }; |
169 | 187 |
170 } // namespace compiler | 188 } // namespace compiler |
171 } // namespace internal | 189 } // namespace internal |
172 } // namespace v8 | 190 } // namespace v8 |
173 | 191 |
174 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_ | 192 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_ |
OLD | NEW |