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 #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" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 return os << p.language_mode() << ", " << Brief(*p.name().handle()); | 201 return os << p.language_mode() << ", " << Brief(*p.name().handle()); |
202 } | 202 } |
203 | 203 |
204 | 204 |
205 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { | 205 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op) { |
206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); | 206 DCHECK_EQ(IrOpcode::kJSStoreNamed, op->opcode()); |
207 return OpParameter<StoreNamedParameters>(op); | 207 return OpParameter<StoreNamedParameters>(op); |
208 } | 208 } |
209 | 209 |
210 | 210 |
| 211 bool operator==(CreateClosureParameters const& lhs, |
| 212 CreateClosureParameters const& rhs) { |
| 213 return lhs.pretenure() == rhs.pretenure() && |
| 214 lhs.shared_info().is_identical_to(rhs.shared_info()); |
| 215 } |
| 216 |
| 217 |
| 218 bool operator!=(CreateClosureParameters const& lhs, |
| 219 CreateClosureParameters const& rhs) { |
| 220 return !(lhs == rhs); |
| 221 } |
| 222 |
| 223 |
| 224 size_t hash_value(CreateClosureParameters const& p) { |
| 225 // TODO(mstarzinger): Include hash of the SharedFunctionInfo here. |
| 226 base::hash<PretenureFlag> h; |
| 227 return h(p.pretenure()); |
| 228 } |
| 229 |
| 230 |
| 231 std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) { |
| 232 return os << p.pretenure() << ", " << Brief(*p.shared_info()); |
| 233 } |
| 234 |
| 235 |
| 236 const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) { |
| 237 DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode()); |
| 238 return OpParameter<CreateClosureParameters>(op); |
| 239 } |
| 240 |
| 241 |
211 #define CACHED_OP_LIST(V) \ | 242 #define CACHED_OP_LIST(V) \ |
212 V(Equal, Operator::kNoProperties, 2, 1) \ | 243 V(Equal, Operator::kNoProperties, 2, 1) \ |
213 V(NotEqual, Operator::kNoProperties, 2, 1) \ | 244 V(NotEqual, Operator::kNoProperties, 2, 1) \ |
214 V(StrictEqual, Operator::kPure, 2, 1) \ | 245 V(StrictEqual, Operator::kPure, 2, 1) \ |
215 V(StrictNotEqual, Operator::kPure, 2, 1) \ | 246 V(StrictNotEqual, Operator::kPure, 2, 1) \ |
216 V(LessThan, Operator::kNoProperties, 2, 1) \ | 247 V(LessThan, Operator::kNoProperties, 2, 1) \ |
217 V(GreaterThan, Operator::kNoProperties, 2, 1) \ | 248 V(GreaterThan, Operator::kNoProperties, 2, 1) \ |
218 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ | 249 V(LessThanOrEqual, Operator::kNoProperties, 2, 1) \ |
219 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ | 250 V(GreaterThanOrEqual, Operator::kNoProperties, 2, 1) \ |
220 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ | 251 V(BitwiseOr, Operator::kNoProperties, 2, 1) \ |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ContextAccess access(depth, index, false); | 425 ContextAccess access(depth, index, false); |
395 return new (zone()) Operator1<ContextAccess>( // -- | 426 return new (zone()) Operator1<ContextAccess>( // -- |
396 IrOpcode::kJSStoreContext, // opcode | 427 IrOpcode::kJSStoreContext, // opcode |
397 Operator::kNoRead | Operator::kNoThrow, // flags | 428 Operator::kNoRead | Operator::kNoThrow, // flags |
398 "JSStoreContext", // name | 429 "JSStoreContext", // name |
399 2, 1, 1, 0, 1, 0, // counts | 430 2, 1, 1, 0, 1, 0, // counts |
400 access); // parameter | 431 access); // parameter |
401 } | 432 } |
402 | 433 |
403 | 434 |
| 435 const Operator* JSOperatorBuilder::CreateClosure( |
| 436 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { |
| 437 CreateClosureParameters parameters(shared_info, pretenure); |
| 438 return new (zone()) Operator1<CreateClosureParameters>( // -- |
| 439 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode |
| 440 "JSCreateClosure", // name |
| 441 1, 1, 1, 1, 1, 0, // counts |
| 442 parameters); // parameter |
| 443 } |
| 444 |
| 445 |
404 const Operator* JSOperatorBuilder::CreateCatchContext( | 446 const Operator* JSOperatorBuilder::CreateCatchContext( |
405 const Unique<String>& name) { | 447 const Unique<String>& name) { |
406 return new (zone()) Operator1<Unique<String>>( // -- | 448 return new (zone()) Operator1<Unique<String>>( // -- |
407 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 449 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
408 "JSCreateCatchContext", // name | 450 "JSCreateCatchContext", // name |
409 2, 1, 1, 1, 1, 2, // counts | 451 2, 1, 1, 1, 1, 2, // counts |
410 name); // parameter | 452 name); // parameter |
411 } | 453 } |
412 | 454 |
413 } // namespace compiler | 455 } // namespace compiler |
414 } // namespace internal | 456 } // namespace internal |
415 } // namespace v8 | 457 } // namespace v8 |
OLD | NEW |