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(UnaryNot, Operator::kPure, 1, 1) \ | 247 V(UnaryNot, Operator::kPure, 1, 1) \ |
217 V(ToBoolean, Operator::kPure, 1, 1) \ | 248 V(ToBoolean, Operator::kPure, 1, 1) \ |
218 V(ToNumber, Operator::kNoProperties, 1, 1) \ | 249 V(ToNumber, Operator::kNoProperties, 1, 1) \ |
219 V(ToString, Operator::kNoProperties, 1, 1) \ | 250 V(ToString, Operator::kNoProperties, 1, 1) \ |
220 V(ToName, Operator::kNoProperties, 1, 1) \ | 251 V(ToName, Operator::kNoProperties, 1, 1) \ |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 ContextAccess access(depth, index, false); | 461 ContextAccess access(depth, index, false); |
431 return new (zone()) Operator1<ContextAccess>( // -- | 462 return new (zone()) Operator1<ContextAccess>( // -- |
432 IrOpcode::kJSStoreContext, // opcode | 463 IrOpcode::kJSStoreContext, // opcode |
433 Operator::kNoRead | Operator::kNoThrow, // flags | 464 Operator::kNoRead | Operator::kNoThrow, // flags |
434 "JSStoreContext", // name | 465 "JSStoreContext", // name |
435 2, 1, 1, 0, 1, 0, // counts | 466 2, 1, 1, 0, 1, 0, // counts |
436 access); // parameter | 467 access); // parameter |
437 } | 468 } |
438 | 469 |
439 | 470 |
| 471 const Operator* JSOperatorBuilder::CreateClosure( |
| 472 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { |
| 473 CreateClosureParameters parameters(shared_info, pretenure); |
| 474 return new (zone()) Operator1<CreateClosureParameters>( // -- |
| 475 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode |
| 476 "JSCreateClosure", // name |
| 477 1, 1, 1, 1, 1, 0, // counts |
| 478 parameters); // parameter |
| 479 } |
| 480 |
| 481 |
440 const Operator* JSOperatorBuilder::CreateCatchContext( | 482 const Operator* JSOperatorBuilder::CreateCatchContext( |
441 const Unique<String>& name) { | 483 const Unique<String>& name) { |
442 return new (zone()) Operator1<Unique<String>>( // -- | 484 return new (zone()) Operator1<Unique<String>>( // -- |
443 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 485 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
444 "JSCreateCatchContext", // name | 486 "JSCreateCatchContext", // name |
445 2, 1, 1, 1, 1, 2, // counts | 487 2, 1, 1, 1, 1, 2, // counts |
446 name); // parameter | 488 name); // parameter |
447 } | 489 } |
448 | 490 |
449 } // namespace compiler | 491 } // namespace compiler |
450 } // namespace internal | 492 } // namespace internal |
451 } // namespace v8 | 493 } // namespace v8 |
OLD | NEW |