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 #include "src/objects-inl.h" 10 11 namespace v8 { 12 namespace internal { 13 namespace compiler { 14 15 size_t hash_value(OutputFrameStateCombine const& sc) { 16 return base::hash_combine(sc.kind_, sc.parameter_); 17 } 18 19 20 std::ostream& operator<<(std::ostream& os, OutputFrameStateCombine const& sc) { 21 switch (sc.kind_) { 22 case OutputFrameStateCombine::kPushOutput: 23 if (sc.parameter_ == 0) return os << "Ignore"; 24 return os << "Push(" << sc.parameter_ << ")"; 25 case OutputFrameStateCombine::kPokeAt: 26 return os << "PokeAt(" << sc.parameter_ << ")"; 27 } 28 UNREACHABLE(); 29 return os; 30 } 31 32 33 bool operator==(FrameStateInfo const& lhs, FrameStateInfo const& rhs) { 34 return lhs.type() == rhs.type() && lhs.bailout_id() == rhs.bailout_id() && 35 lhs.state_combine() == rhs.state_combine() && 36 lhs.function_info() == rhs.function_info(); 37 } 38 39 40 bool operator!=(FrameStateInfo const& lhs, FrameStateInfo const& rhs) { 41 return !(lhs == rhs); 42 } 43 44 45 size_t hash_value(FrameStateInfo const& info) { 46 return base::hash_combine(static_cast<int>(info.type()), info.bailout_id(), 47 info.state_combine()); 48 } 49 50 51 std::ostream& operator<<(std::ostream& os, FrameStateType type) { 52 switch (type) { 53 case FrameStateType::kJavaScriptFunction: 54 os << "JS_FRAME"; 55 break; 56 case FrameStateType::kInterpretedFunction: 57 os << "INTERPRETED_FRAME"; 58 break; 59 case FrameStateType::kArgumentsAdaptor: 60 os << "ARGUMENTS_ADAPTOR"; 61 break; 62 case FrameStateType::kTailCallerFunction: 63 os << "TAIL_CALLER_FRAME"; 64 break; 65 case FrameStateType::kConstructStub: 66 os << "CONSTRUCT_STUB"; 67 break; 68 case FrameStateType::kGetterStub: 69 os << "GETTER_STUB"; 70 break; 71 case FrameStateType::kSetterStub: 72 os << "SETTER_STUB"; 73 break; 74 } 75 return os; 76 } 77 78 79 std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { 80 os << info.type() << ", " << info.bailout_id() << ", " 81 << info.state_combine(); 82 Handle<SharedFunctionInfo> shared_info; 83 if (info.shared_info().ToHandle(&shared_info)) { 84 os << ", " << Brief(*shared_info); 85 } 86 return os; 87 } 88 89 } // namespace compiler 90 } // namespace internal 91 } // namespace v8 92