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; 61 case FrameStateType::kTailCallerFunction: 62 os << "TAIL_CALLER_FRAME"; 63 break; 64 case FrameStateType::kConstructStub: 65 os << "CONSTRUCT_STUB"; 66 break; 67 case FrameStateType::kGetterStub: 68 os << "GETTER_STUB"; 69 break; 70 case FrameStateType::kSetterStub: 71 os << "SETTER_STUB"; 72 break; 73 } 74 return os; 75 } 76 77 78 std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { 79 os << info.type() << ", " << info.bailout_id() << ", " 80 << info.state_combine(); 81 Handle<SharedFunctionInfo> shared_info; 82 if (info.shared_info().ToHandle(&shared_info)) { 83 os << ", " << Brief(*shared_info); 84 } 85 return os; 86 } 87 88 } // namespace compiler 89 } // namespace internal 90 } // namespace v8 91