Line data Source code
1 : // Copyright 2017 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/interpreter/bytecode-node.h"
6 :
7 : #include <iomanip>
8 : #include "src/source-position-table.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 : namespace interpreter {
13 :
14 0 : void BytecodeNode::Print(std::ostream& os) const {
15 : #ifdef DEBUG
16 : std::ios saved_state(nullptr);
17 : saved_state.copyfmt(os);
18 : os << Bytecodes::ToString(bytecode_);
19 :
20 : for (int i = 0; i < operand_count(); ++i) {
21 : os << ' ' << std::setw(8) << std::setfill('0') << std::hex << operands_[i];
22 : }
23 : os.copyfmt(saved_state);
24 :
25 : if (source_info_.is_valid()) {
26 : os << ' ' << source_info_;
27 : }
28 : os << '\n';
29 : #else
30 : os << static_cast<const void*>(this);
31 : #endif // DEBUG
32 0 : }
33 :
34 5 : bool BytecodeNode::operator==(const BytecodeNode& other) const {
35 5 : if (this == &other) {
36 : return true;
37 6 : } else if (this->bytecode() != other.bytecode() ||
38 : this->source_info() != other.source_info()) {
39 : return false;
40 : } else {
41 18 : for (int i = 0; i < this->operand_count(); ++i) {
42 8 : if (this->operand(i) != other.operand(i)) {
43 : return false;
44 : }
45 : }
46 : }
47 : return true;
48 : }
49 :
50 0 : std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) {
51 : node.Print(os);
52 0 : return os;
53 : }
54 :
55 : } // namespace interpreter
56 : } // namespace internal
57 122036 : } // namespace v8
|