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

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

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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/simplified-node-factory.h ('k') | src/compiler/source-position.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_
6 #define V8_COMPILER_SIMPLIFIED_OPERATOR_H_
7
8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/opcodes.h"
10 #include "src/zone.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 // An access descriptor for loads/stores from/to fixed structures
17 // like field accesses of heap objects.
18 struct FieldAccess {
19 int offset;
20 Handle<Name> name; // debug only.
21 Type* type;
22 MachineRepresentation representation;
23 };
24
25
26 // An access descriptor for loads/stores of indexed structures
27 // like characters in strings or off-heap backing stores.
28 struct ElementAccess {
29 int header_size;
30 Type* type;
31 MachineRepresentation representation;
32 };
33
34
35 // If the accessed object is not a heap object, add this to the header_size.
36 static const int kNonHeapObjectHeaderSize = kHeapObjectTag;
37
38
39 // Specialization for static parameters of type {FieldAccess}.
40 template <>
41 struct StaticParameterTraits<const FieldAccess> {
42 static OStream& PrintTo(OStream& os, const FieldAccess& val) { // NOLINT
43 return os << val.offset;
44 }
45 static int HashCode(const FieldAccess& val) {
46 return (val.offset < 16) | (val.representation & 0xffff);
47 }
48 static bool Equals(const FieldAccess& a, const FieldAccess& b) {
49 return a.offset == b.offset && a.representation == b.representation &&
50 a.type->Is(b.type);
51 }
52 };
53
54
55 // Specialization for static parameters of type {ElementAccess}.
56 template <>
57 struct StaticParameterTraits<const ElementAccess> {
58 static OStream& PrintTo(OStream& os, const ElementAccess& val) { // NOLINT
59 return os << val.header_size;
60 }
61 static int HashCode(const ElementAccess& val) {
62 return (val.header_size < 16) | (val.representation & 0xffff);
63 }
64 static bool Equals(const ElementAccess& a, const ElementAccess& b) {
65 return a.header_size == b.header_size &&
66 a.representation == b.representation && a.type->Is(b.type);
67 }
68 };
69
70
71 inline const FieldAccess FieldAccessOf(Operator* op) {
72 ASSERT(op->opcode() == IrOpcode::kLoadField ||
73 op->opcode() == IrOpcode::kStoreField);
74 return static_cast<Operator1<FieldAccess>*>(op)->parameter();
75 }
76
77
78 inline const ElementAccess ElementAccessOf(Operator* op) {
79 ASSERT(op->opcode() == IrOpcode::kLoadElement ||
80 op->opcode() == IrOpcode::kStoreElement);
81 return static_cast<Operator1<ElementAccess>*>(op)->parameter();
82 }
83
84
85 // Interface for building simplified operators, which represent the
86 // medium-level operations of V8, including adding numbers, allocating objects,
87 // indexing into objects and arrays, etc.
88 // All operators are typed but many are representation independent.
89
90 // Number values from JS can be in one of these representations:
91 // - Tagged: word-sized integer that is either
92 // - a signed small integer (31 or 32 bits plus a tag)
93 // - a tagged pointer to a HeapNumber object that has a float64 field
94 // - Int32: an untagged signed 32-bit integer
95 // - Uint32: an untagged unsigned 32-bit integer
96 // - Float64: an untagged float64
97
98 // Additional representations for intermediate code or non-JS code:
99 // - Int64: an untagged signed 64-bit integer
100 // - Uint64: an untagged unsigned 64-bit integer
101 // - Float32: an untagged float32
102
103 // Boolean values can be:
104 // - Bool: a tagged pointer to either the canonical JS #false or
105 // the canonical JS #true object
106 // - Bit: an untagged integer 0 or 1, but word-sized
107 class SimplifiedOperatorBuilder {
108 public:
109 explicit inline SimplifiedOperatorBuilder(Zone* zone) : zone_(zone) {}
110
111 #define SIMPLE(name, properties, inputs, outputs) \
112 return new (zone_) \
113 SimpleOperator(IrOpcode::k##name, properties, inputs, outputs, #name);
114
115 #define OP1(name, ptype, pname, properties, inputs, outputs) \
116 return new (zone_) \
117 Operator1<ptype>(IrOpcode::k##name, properties | Operator::kNoThrow, \
118 inputs, outputs, #name, pname)
119
120 #define UNOP(name) SIMPLE(name, Operator::kPure, 1, 1)
121 #define BINOP(name) SIMPLE(name, Operator::kPure, 2, 1)
122
123 Operator* BooleanNot() const { UNOP(BooleanNot); }
124
125 Operator* NumberEqual() const { BINOP(NumberEqual); }
126 Operator* NumberLessThan() const { BINOP(NumberLessThan); }
127 Operator* NumberLessThanOrEqual() const { BINOP(NumberLessThanOrEqual); }
128 Operator* NumberAdd() const { BINOP(NumberAdd); }
129 Operator* NumberSubtract() const { BINOP(NumberSubtract); }
130 Operator* NumberMultiply() const { BINOP(NumberMultiply); }
131 Operator* NumberDivide() const { BINOP(NumberDivide); }
132 Operator* NumberModulus() const { BINOP(NumberModulus); }
133 Operator* NumberToInt32() const { UNOP(NumberToInt32); }
134 Operator* NumberToUint32() const { UNOP(NumberToUint32); }
135
136 Operator* ReferenceEqual(Type* type) const { BINOP(ReferenceEqual); }
137
138 Operator* StringEqual() const { BINOP(StringEqual); }
139 Operator* StringLessThan() const { BINOP(StringLessThan); }
140 Operator* StringLessThanOrEqual() const { BINOP(StringLessThanOrEqual); }
141 Operator* StringAdd() const { BINOP(StringAdd); }
142
143 Operator* ChangeTaggedToInt32() const { UNOP(ChangeTaggedToInt32); }
144 Operator* ChangeTaggedToUint32() const { UNOP(ChangeTaggedToUint32); }
145 Operator* ChangeTaggedToFloat64() const { UNOP(ChangeTaggedToFloat64); }
146 Operator* ChangeInt32ToTagged() const { UNOP(ChangeInt32ToTagged); }
147 Operator* ChangeUint32ToTagged() const { UNOP(ChangeUint32ToTagged); }
148 Operator* ChangeFloat64ToTagged() const { UNOP(ChangeFloat64ToTagged); }
149 Operator* ChangeBoolToBit() const { UNOP(ChangeBoolToBit); }
150 Operator* ChangeBitToBool() const { UNOP(ChangeBitToBool); }
151
152 Operator* LoadField(const FieldAccess& access) const {
153 OP1(LoadField, FieldAccess, access, Operator::kNoWrite, 1, 1);
154 }
155 Operator* StoreField(const FieldAccess& access) const {
156 OP1(StoreField, FieldAccess, access, Operator::kNoRead, 2, 0);
157 }
158 Operator* LoadElement(const ElementAccess& access) const {
159 OP1(LoadElement, ElementAccess, access, Operator::kNoWrite, 2, 1);
160 }
161 Operator* StoreElement(const ElementAccess& access) const {
162 OP1(StoreElement, ElementAccess, access, Operator::kNoRead, 3, 0);
163 }
164
165 #undef BINOP
166 #undef UNOP
167 #undef OP1
168 #undef SIMPLE
169
170 private:
171 Zone* zone_;
172 };
173 }
174 }
175 } // namespace v8::internal::compiler
176
177 #endif // V8_COMPILER_SIMPLIFIED_OPERATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/simplified-node-factory.h ('k') | src/compiler/source-position.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698