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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 ContextAccess const& ContextAccessOf(Operator const* op) { | 87 ContextAccess const& ContextAccessOf(Operator const* op) { |
88 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || | 88 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || |
89 op->opcode() == IrOpcode::kJSStoreContext); | 89 op->opcode() == IrOpcode::kJSStoreContext); |
90 return OpParameter<ContextAccess>(op); | 90 return OpParameter<ContextAccess>(op); |
91 } | 91 } |
92 | 92 |
93 | 93 |
| 94 DynamicGlobalAccess::DynamicGlobalAccess(const Handle<String>& name, |
| 95 uint32_t check_bitset, |
| 96 ContextualMode mode) |
| 97 : name_(name), check_bitset_(check_bitset), mode_(mode) { |
| 98 DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); |
| 99 } |
| 100 |
| 101 |
| 102 bool operator==(DynamicGlobalAccess const& lhs, |
| 103 DynamicGlobalAccess const& rhs) { |
| 104 UNIMPLEMENTED(); |
| 105 return true; |
| 106 } |
| 107 |
| 108 |
| 109 bool operator!=(DynamicGlobalAccess const& lhs, |
| 110 DynamicGlobalAccess const& rhs) { |
| 111 return !(lhs == rhs); |
| 112 } |
| 113 |
| 114 |
| 115 size_t hash_value(DynamicGlobalAccess const& access) { |
| 116 UNIMPLEMENTED(); |
| 117 return 0; |
| 118 } |
| 119 |
| 120 |
| 121 std::ostream& operator<<(std::ostream& os, DynamicGlobalAccess const& access) { |
| 122 return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " |
| 123 << access.mode(); |
| 124 } |
| 125 |
| 126 |
| 127 DynamicGlobalAccess const& DynamicGlobalAccessOf(Operator const* op) { |
| 128 DCHECK_EQ(IrOpcode::kJSLoadDynamicGlobal, op->opcode()); |
| 129 return OpParameter<DynamicGlobalAccess>(op); |
| 130 } |
| 131 |
| 132 |
| 133 DynamicContextAccess::DynamicContextAccess(const Handle<String>& name, |
| 134 uint32_t check_bitset, |
| 135 const ContextAccess& context_access) |
| 136 : name_(name), |
| 137 check_bitset_(check_bitset), |
| 138 context_access_(context_access) { |
| 139 DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); |
| 140 } |
| 141 |
| 142 |
| 143 bool operator==(DynamicContextAccess const& lhs, |
| 144 DynamicContextAccess const& rhs) { |
| 145 UNIMPLEMENTED(); |
| 146 return true; |
| 147 } |
| 148 |
| 149 |
| 150 bool operator!=(DynamicContextAccess const& lhs, |
| 151 DynamicContextAccess const& rhs) { |
| 152 return !(lhs == rhs); |
| 153 } |
| 154 |
| 155 |
| 156 size_t hash_value(DynamicContextAccess const& access) { |
| 157 UNIMPLEMENTED(); |
| 158 return 0; |
| 159 } |
| 160 |
| 161 |
| 162 std::ostream& operator<<(std::ostream& os, DynamicContextAccess const& access) { |
| 163 return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " |
| 164 << access.context_access(); |
| 165 } |
| 166 |
| 167 |
| 168 DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { |
| 169 DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, op->opcode()); |
| 170 return OpParameter<DynamicContextAccess>(op); |
| 171 } |
| 172 |
| 173 |
94 bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs) { | 174 bool operator==(VectorSlotPair const& lhs, VectorSlotPair const& rhs) { |
95 return lhs.slot().ToInt() == rhs.slot().ToInt() && | 175 return lhs.slot().ToInt() == rhs.slot().ToInt() && |
96 lhs.vector().is_identical_to(rhs.vector()); | 176 lhs.vector().is_identical_to(rhs.vector()); |
97 } | 177 } |
98 | 178 |
99 | 179 |
100 size_t hash_value(VectorSlotPair const& p) { | 180 size_t hash_value(VectorSlotPair const& p) { |
101 // TODO(mvstanton): include the vector in the hash. | 181 // TODO(mvstanton): include the vector in the hash. |
102 base::hash<int> h; | 182 base::hash<int> h; |
103 return h(p.slot().ToInt()); | 183 return h(p.slot().ToInt()); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 ContextAccess access(depth, index, false); | 509 ContextAccess access(depth, index, false); |
430 return new (zone()) Operator1<ContextAccess>( // -- | 510 return new (zone()) Operator1<ContextAccess>( // -- |
431 IrOpcode::kJSStoreContext, // opcode | 511 IrOpcode::kJSStoreContext, // opcode |
432 Operator::kNoRead | Operator::kNoThrow, // flags | 512 Operator::kNoRead | Operator::kNoThrow, // flags |
433 "JSStoreContext", // name | 513 "JSStoreContext", // name |
434 2, 1, 1, 0, 1, 0, // counts | 514 2, 1, 1, 0, 1, 0, // counts |
435 access); // parameter | 515 access); // parameter |
436 } | 516 } |
437 | 517 |
438 | 518 |
| 519 const Operator* JSOperatorBuilder::LoadDynamicGlobal(const Handle<String>& name, |
| 520 uint32_t check_bitset, |
| 521 ContextualMode mode) { |
| 522 DynamicGlobalAccess access(name, check_bitset, mode); |
| 523 return new (zone()) Operator1<DynamicGlobalAccess>( // -- |
| 524 IrOpcode::kJSLoadDynamicGlobal, Operator::kNoProperties, // opcode |
| 525 "JSLoadDynamicGlobal", // name |
| 526 1, 1, 1, 1, 1, 2, // counts |
| 527 access); // parameter |
| 528 } |
| 529 |
| 530 |
| 531 const Operator* JSOperatorBuilder::LoadDynamicContext( |
| 532 const Handle<String>& name, uint32_t check_bitset, size_t depth, |
| 533 size_t index) { |
| 534 ContextAccess context_access(depth, index, false); |
| 535 DynamicContextAccess access(name, check_bitset, context_access); |
| 536 return new (zone()) Operator1<DynamicContextAccess>( // -- |
| 537 IrOpcode::kJSLoadDynamicContext, Operator::kNoProperties, // opcode |
| 538 "JSLoadDynamicContext", // name |
| 539 1, 1, 1, 1, 1, 2, // counts |
| 540 access); // parameter |
| 541 } |
| 542 |
| 543 |
439 const Operator* JSOperatorBuilder::CreateClosure( | 544 const Operator* JSOperatorBuilder::CreateClosure( |
440 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { | 545 Handle<SharedFunctionInfo> shared_info, PretenureFlag pretenure) { |
441 CreateClosureParameters parameters(shared_info, pretenure); | 546 CreateClosureParameters parameters(shared_info, pretenure); |
442 return new (zone()) Operator1<CreateClosureParameters>( // -- | 547 return new (zone()) Operator1<CreateClosureParameters>( // -- |
443 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode | 548 IrOpcode::kJSCreateClosure, Operator::kNoThrow, // opcode |
444 "JSCreateClosure", // name | 549 "JSCreateClosure", // name |
445 1, 1, 1, 1, 1, 0, // counts | 550 1, 1, 1, 1, 1, 0, // counts |
446 parameters); // parameter | 551 parameters); // parameter |
447 } | 552 } |
448 | 553 |
(...skipping 21 matching lines...) Expand all Loading... |
470 return new (zone()) Operator1<Unique<String>>( // -- | 575 return new (zone()) Operator1<Unique<String>>( // -- |
471 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode | 576 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode |
472 "JSCreateCatchContext", // name | 577 "JSCreateCatchContext", // name |
473 2, 1, 1, 1, 1, 2, // counts | 578 2, 1, 1, 1, 1, 2, // counts |
474 name); // parameter | 579 name); // parameter |
475 } | 580 } |
476 | 581 |
477 } // namespace compiler | 582 } // namespace compiler |
478 } // namespace internal | 583 } // namespace internal |
479 } // namespace v8 | 584 } // namespace v8 |
OLD | NEW |