| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 | 141 |
| 142 ContextAccess const& ContextAccessOf(Operator const* op) { | 142 ContextAccess const& ContextAccessOf(Operator const* op) { |
| 143 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || | 143 DCHECK(op->opcode() == IrOpcode::kJSLoadContext || |
| 144 op->opcode() == IrOpcode::kJSStoreContext); | 144 op->opcode() == IrOpcode::kJSStoreContext); |
| 145 return OpParameter<ContextAccess>(op); | 145 return OpParameter<ContextAccess>(op); |
| 146 } | 146 } |
| 147 | 147 |
| 148 | 148 |
| 149 DynamicGlobalAccess::DynamicGlobalAccess(const Handle<String>& name, | 149 DynamicAccess::DynamicAccess(const Handle<String>& name, TypeofMode typeof_mode) |
| 150 uint32_t check_bitset, | 150 : name_(name), typeof_mode_(typeof_mode) {} |
| 151 const VectorSlotPair& feedback, | |
| 152 TypeofMode typeof_mode) | |
| 153 : name_(name), | |
| 154 check_bitset_(check_bitset), | |
| 155 feedback_(feedback), | |
| 156 typeof_mode_(typeof_mode) { | |
| 157 DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); | |
| 158 } | |
| 159 | 151 |
| 160 | 152 |
| 161 bool operator==(DynamicGlobalAccess const& lhs, | 153 bool operator==(DynamicAccess const& lhs, DynamicAccess const& rhs) { |
| 162 DynamicGlobalAccess const& rhs) { | |
| 163 UNIMPLEMENTED(); | 154 UNIMPLEMENTED(); |
| 164 return true; | 155 return true; |
| 165 } | 156 } |
| 166 | 157 |
| 167 | 158 |
| 168 bool operator!=(DynamicGlobalAccess const& lhs, | 159 bool operator!=(DynamicAccess const& lhs, DynamicAccess const& rhs) { |
| 169 DynamicGlobalAccess const& rhs) { | |
| 170 return !(lhs == rhs); | 160 return !(lhs == rhs); |
| 171 } | 161 } |
| 172 | 162 |
| 173 | 163 |
| 174 size_t hash_value(DynamicGlobalAccess const& access) { | 164 size_t hash_value(DynamicAccess const& access) { |
| 175 UNIMPLEMENTED(); | 165 UNIMPLEMENTED(); |
| 176 return 0; | 166 return 0; |
| 177 } | 167 } |
| 178 | 168 |
| 179 | 169 |
| 180 std::ostream& operator<<(std::ostream& os, DynamicGlobalAccess const& access) { | 170 std::ostream& operator<<(std::ostream& os, DynamicAccess const& access) { |
| 181 return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " | 171 return os << Brief(*access.name()) << ", " << access.typeof_mode(); |
| 182 << access.typeof_mode(); | |
| 183 } | 172 } |
| 184 | 173 |
| 185 | 174 |
| 186 DynamicGlobalAccess const& DynamicGlobalAccessOf(Operator const* op) { | 175 DynamicAccess const& DynamicAccessOf(Operator const* op) { |
| 187 DCHECK_EQ(IrOpcode::kJSLoadDynamicGlobal, op->opcode()); | 176 DCHECK_EQ(IrOpcode::kJSLoadDynamic, op->opcode()); |
| 188 return OpParameter<DynamicGlobalAccess>(op); | 177 return OpParameter<DynamicAccess>(op); |
| 189 } | 178 } |
| 190 | 179 |
| 191 | 180 |
| 192 DynamicContextAccess::DynamicContextAccess(const Handle<String>& name, | |
| 193 uint32_t check_bitset, | |
| 194 const ContextAccess& context_access) | |
| 195 : name_(name), | |
| 196 check_bitset_(check_bitset), | |
| 197 context_access_(context_access) { | |
| 198 DCHECK(check_bitset == kFullCheckRequired || check_bitset < 0x80000000U); | |
| 199 } | |
| 200 | |
| 201 | |
| 202 bool operator==(DynamicContextAccess const& lhs, | |
| 203 DynamicContextAccess const& rhs) { | |
| 204 UNIMPLEMENTED(); | |
| 205 return true; | |
| 206 } | |
| 207 | |
| 208 | |
| 209 bool operator!=(DynamicContextAccess const& lhs, | |
| 210 DynamicContextAccess const& rhs) { | |
| 211 return !(lhs == rhs); | |
| 212 } | |
| 213 | |
| 214 | |
| 215 size_t hash_value(DynamicContextAccess const& access) { | |
| 216 UNIMPLEMENTED(); | |
| 217 return 0; | |
| 218 } | |
| 219 | |
| 220 | |
| 221 std::ostream& operator<<(std::ostream& os, DynamicContextAccess const& access) { | |
| 222 return os << Brief(*access.name()) << ", " << access.check_bitset() << ", " | |
| 223 << access.context_access(); | |
| 224 } | |
| 225 | |
| 226 | |
| 227 DynamicContextAccess const& DynamicContextAccessOf(Operator const* op) { | |
| 228 DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, op->opcode()); | |
| 229 return OpParameter<DynamicContextAccess>(op); | |
| 230 } | |
| 231 | |
| 232 | |
| 233 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { | 181 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) { |
| 234 return lhs.name().location() == rhs.name().location() && | 182 return lhs.name().location() == rhs.name().location() && |
| 235 lhs.language_mode() == rhs.language_mode() && | 183 lhs.language_mode() == rhs.language_mode() && |
| 236 lhs.feedback() == rhs.feedback(); | 184 lhs.feedback() == rhs.feedback(); |
| 237 } | 185 } |
| 238 | 186 |
| 239 | 187 |
| 240 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { | 188 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) { |
| 241 return !(lhs == rhs); | 189 return !(lhs == rhs); |
| 242 } | 190 } |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 ContextAccess access(depth, index, false); | 610 ContextAccess access(depth, index, false); |
| 663 return new (zone()) Operator1<ContextAccess>( // -- | 611 return new (zone()) Operator1<ContextAccess>( // -- |
| 664 IrOpcode::kJSStoreContext, // opcode | 612 IrOpcode::kJSStoreContext, // opcode |
| 665 Operator::kNoRead | Operator::kNoThrow, // flags | 613 Operator::kNoRead | Operator::kNoThrow, // flags |
| 666 "JSStoreContext", // name | 614 "JSStoreContext", // name |
| 667 2, 1, 1, 0, 1, 0, // counts | 615 2, 1, 1, 0, 1, 0, // counts |
| 668 access); // parameter | 616 access); // parameter |
| 669 } | 617 } |
| 670 | 618 |
| 671 | 619 |
| 672 const Operator* JSOperatorBuilder::LoadDynamicGlobal( | 620 const Operator* JSOperatorBuilder::LoadDynamic(const Handle<String>& name, |
| 673 const Handle<String>& name, uint32_t check_bitset, | 621 TypeofMode typeof_mode) { |
| 674 const VectorSlotPair& feedback, TypeofMode typeof_mode) { | 622 DynamicAccess access(name, typeof_mode); |
| 675 DynamicGlobalAccess access(name, check_bitset, feedback, typeof_mode); | 623 return new (zone()) Operator1<DynamicAccess>( // -- |
| 676 return new (zone()) Operator1<DynamicGlobalAccess>( // -- | 624 IrOpcode::kJSLoadDynamic, Operator::kNoProperties, // opcode |
| 677 IrOpcode::kJSLoadDynamicGlobal, Operator::kNoProperties, // opcode | 625 "JSLoadDynamic", // name |
| 678 "JSLoadDynamicGlobal", // name | 626 2, 1, 1, 1, 1, 2, // counts |
| 679 2, 1, 1, 1, 1, 2, // counts | 627 access); // parameter |
| 680 access); // parameter | |
| 681 } | 628 } |
| 682 | 629 |
| 683 | 630 |
| 684 const Operator* JSOperatorBuilder::LoadDynamicContext( | |
| 685 const Handle<String>& name, uint32_t check_bitset, size_t depth, | |
| 686 size_t index) { | |
| 687 ContextAccess context_access(depth, index, false); | |
| 688 DynamicContextAccess access(name, check_bitset, context_access); | |
| 689 return new (zone()) Operator1<DynamicContextAccess>( // -- | |
| 690 IrOpcode::kJSLoadDynamicContext, Operator::kNoProperties, // opcode | |
| 691 "JSLoadDynamicContext", // name | |
| 692 1, 1, 1, 1, 1, 2, // counts | |
| 693 access); // parameter | |
| 694 } | |
| 695 | |
| 696 | |
| 697 const Operator* JSOperatorBuilder::CreateArguments( | 631 const Operator* JSOperatorBuilder::CreateArguments( |
| 698 CreateArgumentsParameters::Type type, int start_index) { | 632 CreateArgumentsParameters::Type type, int start_index) { |
| 699 DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray); | 633 DCHECK_IMPLIES(start_index, type == CreateArgumentsParameters::kRestArray); |
| 700 CreateArgumentsParameters parameters(type, start_index); | 634 CreateArgumentsParameters parameters(type, start_index); |
| 701 return new (zone()) Operator1<CreateArgumentsParameters>( // -- | 635 return new (zone()) Operator1<CreateArgumentsParameters>( // -- |
| 702 IrOpcode::kJSCreateArguments, Operator::kNoThrow, // opcode | 636 IrOpcode::kJSCreateArguments, Operator::kNoThrow, // opcode |
| 703 "JSCreateArguments", // name | 637 "JSCreateArguments", // name |
| 704 1, 1, 1, 1, 1, 0, // counts | 638 1, 1, 1, 1, 1, 0, // counts |
| 705 parameters); // parameter | 639 parameters); // parameter |
| 706 } | 640 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 Handle<ScopeInfo>::hash>( // -- | 706 Handle<ScopeInfo>::hash>( // -- |
| 773 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode | 707 IrOpcode::kJSCreateScriptContext, Operator::kNoProperties, // opcode |
| 774 "JSCreateScriptContext", // name | 708 "JSCreateScriptContext", // name |
| 775 1, 1, 1, 1, 1, 2, // counts | 709 1, 1, 1, 1, 1, 2, // counts |
| 776 scpope_info); // parameter | 710 scpope_info); // parameter |
| 777 } | 711 } |
| 778 | 712 |
| 779 } // namespace compiler | 713 } // namespace compiler |
| 780 } // namespace internal | 714 } // namespace internal |
| 781 } // namespace v8 | 715 } // namespace v8 |
| OLD | NEW |