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::kConstructStub: 62 os << "CONSTRUCT_STUB"; 63 break; 64 } 65 return os; 66 } 67 68 69 std::ostream& operator<<(std::ostream& os, FrameStateInfo const& info) { 70 os << info.type() << ", " << info.bailout_id() << ", " 71 << info.state_combine(); 72 Handle<SharedFunctionInfo> shared_info; 73 if (info.shared_info().ToHandle(&shared_info)) { 74 os << ", " << Brief(*shared_info); 75 } 76 return os; 77 } 78 79 } // namespace compiler 80 } // namespace internal 81 } // namespace v8 82