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

Side by Side Diff: src/compiler/js-operator.cc

Issue 636893002: [turbofan] Drop broken StaticParameterTraits. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo... Created 6 years, 2 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/js-operator.h ('k') | src/compiler/machine-operator.h » ('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/compiler/js-operator.h" 5 #include "src/compiler/js-operator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/lazy-instance.h" 9 #include "src/base/lazy-instance.h"
10 #include "src/compiler/opcodes.h" 10 #include "src/compiler/opcodes.h"
11 #include "src/compiler/operator.h" 11 #include "src/compiler/operator.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 namespace compiler { 15 namespace compiler {
16 16
17 bool operator==(CallFunctionParameters const& lhs,
18 CallFunctionParameters const& rhs) {
19 return lhs.arity() == rhs.arity() && lhs.flags() == rhs.flags();
20 }
21
22
23 bool operator!=(CallFunctionParameters const& lhs,
24 CallFunctionParameters const& rhs) {
25 return !(lhs == rhs);
26 }
27
28
29 size_t hash_value(CallFunctionParameters const& p) {
30 return base::hash_combine(p.arity(), p.flags());
31 }
32
33
34 std::ostream& operator<<(std::ostream& os, CallFunctionParameters const& p) {
35 return os << p.arity() << ", " << p.flags();
36 }
37
38
17 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) { 39 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op) {
18 DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode()); 40 DCHECK_EQ(IrOpcode::kJSCallFunction, op->opcode());
19 return OpParameter<CallFunctionParameters>(op); 41 return OpParameter<CallFunctionParameters>(op);
20 } 42 }
21 43
22 44
45 bool operator==(CallRuntimeParameters const& lhs,
46 CallRuntimeParameters const& rhs) {
47 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity();
48 }
49
50
51 bool operator!=(CallRuntimeParameters const& lhs,
52 CallRuntimeParameters const& rhs) {
53 return !(lhs == rhs);
54 }
55
56
57 size_t hash_value(CallRuntimeParameters const& p) {
58 return base::hash_combine(p.id(), p.arity());
59 }
60
61
62 std::ostream& operator<<(std::ostream& os, CallRuntimeParameters const& p) {
63 return os << p.id() << ", " << p.arity();
64 }
65
66
23 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) { 67 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
24 DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode()); 68 DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
25 return OpParameter<CallRuntimeParameters>(op); 69 return OpParameter<CallRuntimeParameters>(op);
26 } 70 }
27 71
28 72
29 ContextAccess::ContextAccess(size_t depth, size_t index, bool immutable) 73 ContextAccess::ContextAccess(size_t depth, size_t index, bool immutable)
30 : immutable_(immutable), 74 : immutable_(immutable),
31 depth_(static_cast<uint16_t>(depth)), 75 depth_(static_cast<uint16_t>(depth)),
32 index_(static_cast<uint32_t>(index)) { 76 index_(static_cast<uint32_t>(index)) {
33 DCHECK(depth <= std::numeric_limits<uint16_t>::max()); 77 DCHECK(depth <= std::numeric_limits<uint16_t>::max());
34 DCHECK(index <= std::numeric_limits<uint32_t>::max()); 78 DCHECK(index <= std::numeric_limits<uint32_t>::max());
35 } 79 }
36 80
37 81
38 bool operator==(const ContextAccess& lhs, const ContextAccess& rhs) { 82 bool operator==(ContextAccess const& lhs, ContextAccess const& rhs) {
39 return lhs.depth() == rhs.depth() && lhs.index() == rhs.index() && 83 return lhs.depth() == rhs.depth() && lhs.index() == rhs.index() &&
40 lhs.immutable() == rhs.immutable(); 84 lhs.immutable() == rhs.immutable();
41 } 85 }
42 86
43 87
44 bool operator!=(const ContextAccess& lhs, const ContextAccess& rhs) { 88 bool operator!=(ContextAccess const& lhs, ContextAccess const& rhs) {
45 return !(lhs == rhs); 89 return !(lhs == rhs);
46 } 90 }
47 91
48 92
49 const ContextAccess& ContextAccessOf(const Operator* op) { 93 size_t hash_value(ContextAccess const& access) {
94 return base::hash_combine(access.depth(), access.index(), access.immutable());
95 }
96
97
98 std::ostream& operator<<(std::ostream& os, ContextAccess const& access) {
99 return os << access.depth() << ", " << access.index() << ", "
100 << access.immutable();
101 }
102
103
104 ContextAccess const& ContextAccessOf(Operator const* op) {
50 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || 105 DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
51 op->opcode() == IrOpcode::kJSStoreContext); 106 op->opcode() == IrOpcode::kJSStoreContext);
52 return OpParameter<ContextAccess>(op); 107 return OpParameter<ContextAccess>(op);
53 } 108 }
54 109
55 110
111 bool operator==(LoadNamedParameters const& lhs,
112 LoadNamedParameters const& rhs) {
113 return lhs.name() == rhs.name() &&
114 lhs.contextual_mode() == rhs.contextual_mode();
115 }
116
117
118 bool operator!=(LoadNamedParameters const& lhs,
119 LoadNamedParameters const& rhs) {
120 return !(lhs == rhs);
121 }
122
123
124 size_t hash_value(LoadNamedParameters const& p) {
125 return base::hash_combine(p.name(), p.contextual_mode());
126 }
127
128
129 std::ostream& operator<<(std::ostream& os, LoadNamedParameters const& p) {
130 return os << Brief(*p.name().handle()) << ", " << p.contextual_mode();
131 }
132
133
56 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) { 134 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op) {
57 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode()); 135 DCHECK_EQ(IrOpcode::kJSLoadNamed, op->opcode());
58 return OpParameter<LoadNamedParameters>(op); 136 return OpParameter<LoadNamedParameters>(op);
59 } 137 }
60 138
61 139
140 bool operator==(StoreNamedParameters const& lhs,
141 StoreNamedParameters const& rhs) {
142 return lhs.strict_mode() == rhs.strict_mode() && lhs.name() == rhs.name();
143 }
144
145
146 bool operator!=(StoreNamedParameters const& lhs,
147 StoreNamedParameters const& rhs) {
148 return !(lhs == rhs);
149 }
150
151
152 size_t hash_value(StoreNamedParameters const& p) {
153 return base::hash_combine(p.strict_mode(), p.name());
154 }
155
156
157 std::ostream& operator<<(std::ostream& os, StoreNamedParameters const& p) {
158 return os << p.strict_mode() << ", " << Brief(*p.name().handle());
159 }
160
161
62 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { 162 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) {
63 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); 163 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode());
64 return OpParameter<StoreNamedParameters>(op); 164 return OpParameter<StoreNamedParameters>(op);
65 } 165 }
66 166
67 167
68 // Specialization for static parameters of type {ContextAccess}.
69 template <>
70 struct StaticParameterTraits<ContextAccess> {
71 static std::ostream& PrintTo(std::ostream& os, const ContextAccess& access) {
72 return os << access.depth() << "," << access.index()
73 << (access.immutable() ? ",imm" : "");
74 }
75 static int HashCode(const ContextAccess& access) {
76 return static_cast<int>((access.depth() << 16) | (access.index() & 0xffff));
77 }
78 static bool Equals(const ContextAccess& lhs, const ContextAccess& rhs) {
79 return lhs == rhs;
80 }
81 };
82
83
84 // Specialization for static parameters of type {Runtime::FunctionId}.
85 template <>
86 struct StaticParameterTraits<Runtime::FunctionId> {
87 static std::ostream& PrintTo(std::ostream& os, Runtime::FunctionId val) {
88 const Runtime::Function* f = Runtime::FunctionForId(val);
89 return os << (f->name ? f->name : "?Runtime?");
90 }
91 static int HashCode(Runtime::FunctionId val) { return static_cast<int>(val); }
92 static bool Equals(Runtime::FunctionId a, Runtime::FunctionId b) {
93 return a == b;
94 }
95 };
96
97
98 #define SHARED_OP_LIST(V) \ 168 #define SHARED_OP_LIST(V) \
99 V(Equal, Operator::kNoProperties, 2, 1) \ 169 V(Equal, Operator::kNoProperties, 2, 1) \
100 V(NotEqual, Operator::kNoProperties, 2, 1) \ 170 V(NotEqual, Operator::kNoProperties, 2, 1) \
101 V(StrictEqual, Operator::kPure, 2, 1) \ 171 V(StrictEqual, Operator::kPure, 2, 1) \
102 V(StrictNotEqual, Operator::kPure, 2, 1) \ 172 V(StrictNotEqual, Operator::kPure, 2, 1) \
103 V(LessThan, Operator::kNoProperties, 2, 1) \ 173 V(LessThan, Operator::kNoProperties, 2, 1) \
104 V(GreaterThan, Operator::kNoProperties, 2, 1) \ 174 V(GreaterThan, Operator::kNoProperties, 2, 1) \
105 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ 175 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \
106 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ 176 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \
107 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ 177 V(BitwiseOr, Operator::kNoProperties, 2, 1) \
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) { 304 const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
235 ContextAccess access(depth, index, false); 305 ContextAccess access(depth, index, false);
236 return new (zone()) Operator1<ContextAccess>(IrOpcode::kJSStoreContext, 306 return new (zone()) Operator1<ContextAccess>(IrOpcode::kJSStoreContext,
237 Operator::kNoProperties, 2, 0, 307 Operator::kNoProperties, 2, 0,
238 "JSStoreContext", access); 308 "JSStoreContext", access);
239 } 309 }
240 310
241 311
242 const Operator* JSOperatorBuilder::CreateCatchContext( 312 const Operator* JSOperatorBuilder::CreateCatchContext(
243 const Unique<String>& name) { 313 const Unique<String>& name) {
244 return new (zone()) Operator1<Unique<String> >( 314 return new (zone()) Operator1<Unique<String>>(IrOpcode::kJSCreateCatchContext,
245 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, 1, 1, 315 Operator::kNoProperties, 1, 1,
246 "JSCreateCatchContext", name); 316 "JSCreateCatchContext", name);
247 } 317 }
248 318
249 } // namespace compiler 319 } // namespace compiler
250 } // namespace internal 320 } // namespace internal
251 } // namespace v8 321 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-operator.h ('k') | src/compiler/machine-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698