Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "src/compiler/frame-states.h" |
| 6 | |
| 7 | #include "src/base/functional.h" |
| 8 | #include "src/handles-inl.h" |
| 9 | |
| 10 | namespace v8 { |
| 11 | namespace internal { |
| 12 | namespace compiler { |
| 13 | |
| 14 | size_t hash_value(OutputFrameStateCombine const& sc) { |
| 15 | return base::hash_combine(sc.kind_, sc.parameter_); |
| 16 | } |
| 17 | |
| 18 | |
| 19 | std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { |
| 20 | switch (sc.kind_) { |
| 21 | case OutputFrameStateCombine::kPushOutput: |
| 22 | if (sc.parameter_ == 0) return os << "Ignore"; |
| 23 | return os << "Push(" << sc.parameter_ << ")"; |
| 24 | case OutputFrameStateCombine::kPokeAt: |
| 25 | return os << "PokeAt(" << sc.parameter_ << ")"; |
| 26 | } |
| 27 | UNREACHABLE(); |
| 28 | return os; |
| 29 | } |
| 30 | |
| 31 | |
| 32 | bool operator==(FrameStateInfo const& lhs, FrameStateInfo const& rhs) { |
| 33 | return lhs.type() == rhs.type() && lhs.bailout_id() == rhs.bailout_id() && |
| 34 | lhs.state_combine() == rhs.state_combine() && |
| 35 | lhs.function_info() == rhs.function_info(); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | bool operator!=(FrameStateInfo const& lhs, FrameStateInfo const& rhs) { |
| 40 | return !(lhs == rhs); |
| 41 | } |
| 42 | |
| 43 | |
| 44 | size_t hash_value(FrameStateInfo const& info) { |
| 45 | return base::hash_combine(static_cast<int>(info.type()), info.bailout_id(), |
| 46 | info.state_combine()); |
| 47 | } |
| 48 | |
| 49 | |
| 50 | std::ostream& operator<<(std::ostream& os, FrameStateType type) { |
| 51 | switch (type) { |
| 52 | case FrameStateType::kJavaScriptFunction: |
| 53 | os << "JS_FRAME"; |
| 54 | break; |
| 55 | case FrameStateType::kInterpretedFunction: |
| 56 | os << "INTERPRETED_FRAME"; |
| 57 | break; |
| 58 | case FrameStateType::kArgumentsAdaptor: |
| 59 | os << "ARGUMENTS_ADAPTOR"; |
| 60 | break; |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 61 | case FrameStateType::kTailCallerFunction: |
| 62 | os << "TAIL_CALLER_FRAME"; |
| 63 | break; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 64 | case FrameStateType::kConstructStub: |
| 65 | os << "CONSTRUCT_STUB"; |
| 66 | break; |
| 67 | } |
| 68 | return os; |
| 69 | } |
| 70 | |
| 71 | |
| 72 | std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { |
| 73 | os << info.type() << ", " << info.bailout_id() << ", " |
| 74 | << info.state_combine(); |
| 75 | Handle<SharedFunctionInfo> shared_info; |
| 76 | if (info.shared_info().ToHandle(&shared_info)) { |
| 77 | os << ", " << Brief(*shared_info); |
| 78 | } |
| 79 | return os; |
| 80 | } |
| 81 | |
| 82 | } // namespace compiler |
| 83 | } // namespace internal |
| 84 | } // namespace v8 |