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

Side by Side Diff: src/compiler/simplified-operator.h

Issue 526313002: [turbofan] First step of Operator refactoring. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE 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 | « src/compiler/operator.cc ('k') | src/compiler/simplified-operator.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 #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 "src/compiler/machine-operator.h" 8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/opcodes.h" 9 #include "src/compiler/opcodes.h"
10 #include "src/zone.h" 10 #include "src/zone.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14
15 // Forward declarations.
16 template <class>
17 class TypeImpl;
18 struct ZoneTypeConfig;
19 typedef TypeImpl<ZoneTypeConfig> Type;
20
21
14 namespace compiler { 22 namespace compiler {
15 23
16 enum BaseTaggedness { kUntaggedBase, kTaggedBase }; 24 enum BaseTaggedness { kUntaggedBase, kTaggedBase };
17 25
18 // An access descriptor for loads/stores of fixed structures like field 26 // An access descriptor for loads/stores of fixed structures like field
19 // accesses of heap objects. Accesses from either tagged or untagged base 27 // accesses of heap objects. Accesses from either tagged or untagged base
20 // pointers are supported; untagging is done automatically during lowering. 28 // pointers are supported; untagging is done automatically during lowering.
21 struct FieldAccess { 29 struct FieldAccess {
22 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged. 30 BaseTaggedness base_is_tagged; // specifies if the base pointer is tagged.
23 int offset; // offset of the field, without tag. 31 int offset; // offset of the field, without tag.
(...skipping 18 matching lines...) Expand all
42 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; } 50 int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
43 }; 51 };
44 52
45 53
46 // If the accessed object is not a heap object, add this to the header_size. 54 // If the accessed object is not a heap object, add this to the header_size.
47 static const int kNonHeapObjectHeaderSize = kHeapObjectTag; 55 static const int kNonHeapObjectHeaderSize = kHeapObjectTag;
48 56
49 57
50 // Specialization for static parameters of type {FieldAccess}. 58 // Specialization for static parameters of type {FieldAccess}.
51 template <> 59 template <>
52 struct StaticParameterTraits<const FieldAccess> { 60 struct StaticParameterTraits<FieldAccess> {
53 static OStream& PrintTo(OStream& os, const FieldAccess& val) { // NOLINT 61 static OStream& PrintTo(OStream& os, const FieldAccess& val) { // NOLINT
54 return os << val.offset; 62 return os << val.offset;
55 } 63 }
56 static int HashCode(const FieldAccess& val) { 64 static int HashCode(const FieldAccess& val) {
57 return (val.offset < 16) | (val.machine_type & 0xffff); 65 return (val.offset < 16) | (val.machine_type & 0xffff);
58 } 66 }
59 static bool Equals(const FieldAccess& a, const FieldAccess& b) { 67 static bool Equals(const FieldAccess& lhs, const FieldAccess& rhs);
60 return a.base_is_tagged == b.base_is_tagged && a.offset == b.offset &&
61 a.machine_type == b.machine_type && a.type->Is(b.type);
62 }
63 }; 68 };
64 69
65 70
66 // Specialization for static parameters of type {ElementAccess}. 71 // Specialization for static parameters of type {ElementAccess}.
67 template <> 72 template <>
68 struct StaticParameterTraits<const ElementAccess> { 73 struct StaticParameterTraits<ElementAccess> {
69 static OStream& PrintTo(OStream& os, const ElementAccess& val) { // NOLINT 74 static OStream& PrintTo(OStream& os, const ElementAccess& val) { // NOLINT
70 return os << val.header_size; 75 return os << val.header_size;
71 } 76 }
72 static int HashCode(const ElementAccess& val) { 77 static int HashCode(const ElementAccess& val) {
73 return (val.header_size < 16) | (val.machine_type & 0xffff); 78 return (val.header_size < 16) | (val.machine_type & 0xffff);
74 } 79 }
75 static bool Equals(const ElementAccess& a, const ElementAccess& b) { 80 static bool Equals(const ElementAccess& lhs, const ElementAccess& rhs);
76 return a.base_is_tagged == b.base_is_tagged &&
77 a.header_size == b.header_size && a.machine_type == b.machine_type &&
78 a.type->Is(b.type);
79 }
80 }; 81 };
81 82
82 83
83 inline const FieldAccess FieldAccessOf(Operator* op) { 84 inline const FieldAccess FieldAccessOf(Operator* op) {
84 DCHECK(op->opcode() == IrOpcode::kLoadField || 85 DCHECK(op->opcode() == IrOpcode::kLoadField ||
85 op->opcode() == IrOpcode::kStoreField); 86 op->opcode() == IrOpcode::kStoreField);
86 return static_cast<Operator1<FieldAccess>*>(op)->parameter(); 87 return static_cast<Operator1<FieldAccess>*>(op)->parameter();
87 } 88 }
88 89
89 90
90 inline const ElementAccess ElementAccessOf(Operator* op) { 91 inline const ElementAccess ElementAccessOf(Operator* op) {
91 DCHECK(op->opcode() == IrOpcode::kLoadElement || 92 DCHECK(op->opcode() == IrOpcode::kLoadElement ||
92 op->opcode() == IrOpcode::kStoreElement); 93 op->opcode() == IrOpcode::kStoreElement);
93 return static_cast<Operator1<ElementAccess>*>(op)->parameter(); 94 return static_cast<Operator1<ElementAccess>*>(op)->parameter();
94 } 95 }
95 96
96 97
97 // This access helper provides a set of static methods constructing commonly
98 // used FieldAccess and ElementAccess descriptors.
99 class Access : public AllStatic {
100 public:
101 // Provides access to JSObject::elements() field.
102 static FieldAccess ForJSObjectElements() {
103 return {kTaggedBase, JSObject::kElementsOffset, Handle<Name>(),
104 Type::Internal(), kMachAnyTagged};
105 }
106
107 // Provides access to ExternalArray::external_pointer() field.
108 static FieldAccess ForExternalArrayPointer() {
109 return {kTaggedBase, ExternalArray::kExternalPointerOffset, Handle<Name>(),
110 Type::UntaggedPtr(), kMachPtr};
111 }
112
113 // Provides access to Fixed{type}TypedArray and External{type}Array elements.
114 static ElementAccess ForTypedArrayElement(ExternalArrayType type,
115 bool is_external) {
116 BaseTaggedness taggedness = is_external ? kUntaggedBase : kTaggedBase;
117 int header_size = is_external ? 0 : FixedTypedArrayBase::kDataOffset;
118 switch (type) {
119 case kExternalInt8Array:
120 return {taggedness, header_size, Type::Signed32(), kMachInt8};
121 case kExternalUint8Array:
122 case kExternalUint8ClampedArray:
123 return {taggedness, header_size, Type::Unsigned32(), kMachUint8};
124 case kExternalInt16Array:
125 return {taggedness, header_size, Type::Signed32(), kMachInt16};
126 case kExternalUint16Array:
127 return {taggedness, header_size, Type::Unsigned32(), kMachUint16};
128 case kExternalInt32Array:
129 return {taggedness, header_size, Type::Signed32(), kMachInt32};
130 case kExternalUint32Array:
131 return {taggedness, header_size, Type::Unsigned32(), kMachUint32};
132 case kExternalFloat32Array:
133 return {taggedness, header_size, Type::Number(), kRepFloat32};
134 case kExternalFloat64Array:
135 return {taggedness, header_size, Type::Number(), kRepFloat64};
136 }
137 UNREACHABLE();
138 return {kUntaggedBase, 0, Type::None(), kMachNone};
139 }
140
141 private:
142 DISALLOW_COPY_AND_ASSIGN(Access);
143 };
144
145
146 // Interface for building simplified operators, which represent the 98 // Interface for building simplified operators, which represent the
147 // medium-level operations of V8, including adding numbers, allocating objects, 99 // medium-level operations of V8, including adding numbers, allocating objects,
148 // indexing into objects and arrays, etc. 100 // indexing into objects and arrays, etc.
149 // All operators are typed but many are representation independent. 101 // All operators are typed but many are representation independent.
150 102
151 // Number values from JS can be in one of these representations: 103 // Number values from JS can be in one of these representations:
152 // - Tagged: word-sized integer that is either 104 // - Tagged: word-sized integer that is either
153 // - a signed small integer (31 or 32 bits plus a tag) 105 // - a signed small integer (31 or 32 bits plus a tag)
154 // - a tagged pointer to a HeapNumber object that has a float64 field 106 // - a tagged pointer to a HeapNumber object that has a float64 field
155 // - Int32: an untagged signed 32-bit integer 107 // - Int32: an untagged signed 32-bit integer
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 #undef SIMPLE 181 #undef SIMPLE
230 182
231 private: 183 private:
232 Zone* zone_; 184 Zone* zone_;
233 }; 185 };
234 } 186 }
235 } 187 }
236 } // namespace v8::internal::compiler 188 } // namespace v8::internal::compiler
237 189
238 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_ 190 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/operator.cc ('k') | src/compiler/simplified-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698