Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: src/interpreter/bytecode-pipeline.cc

Issue 2360193003: Revert of [Interpreter] Optimize BytecodeArrayBuilder and BytecodeArrayWriter. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-register-optimizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-pipeline.h" 5 #include "src/interpreter/bytecode-pipeline.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include "src/source-position-table.h" 8 #include "src/source-position-table.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 namespace interpreter { 12 namespace interpreter {
13 13
14 BytecodeNode::BytecodeNode(Bytecode bytecode) {
15 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
16 bytecode_ = bytecode;
17 }
18
19 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0) {
20 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 1);
21 bytecode_ = bytecode;
22 operands_[0] = operand0;
23 }
24
25 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
26 uint32_t operand1) {
27 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 2);
28 bytecode_ = bytecode;
29 operands_[0] = operand0;
30 operands_[1] = operand1;
31 }
32
33 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
34 uint32_t operand1, uint32_t operand2) {
35 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 3);
36 bytecode_ = bytecode;
37 operands_[0] = operand0;
38 operands_[1] = operand1;
39 operands_[2] = operand2;
40 }
41
42 BytecodeNode::BytecodeNode(Bytecode bytecode, uint32_t operand0,
43 uint32_t operand1, uint32_t operand2,
44 uint32_t operand3) {
45 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 4);
46 bytecode_ = bytecode;
47 operands_[0] = operand0;
48 operands_[1] = operand1;
49 operands_[2] = operand2;
50 operands_[3] = operand3;
51 }
52
14 BytecodeNode::BytecodeNode(const BytecodeNode& other) { 53 BytecodeNode::BytecodeNode(const BytecodeNode& other) {
15 memcpy(this, &other, sizeof(other)); 54 memcpy(this, &other, sizeof(other));
16 } 55 }
17 56
18 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) { 57 BytecodeNode& BytecodeNode::operator=(const BytecodeNode& other) {
19 memcpy(this, &other, sizeof(other)); 58 memcpy(this, &other, sizeof(other));
20 return *this; 59 return *this;
21 } 60 }
22 61
23 void BytecodeNode::Clone(const BytecodeNode* const other) { 62 void BytecodeNode::Clone(const BytecodeNode* const other) {
(...skipping 13 matching lines...) Expand all
37 76
38 if (source_info_.is_valid()) { 77 if (source_info_.is_valid()) {
39 os << ' ' << source_info_; 78 os << ' ' << source_info_;
40 } 79 }
41 os << '\n'; 80 os << '\n';
42 #else 81 #else
43 os << static_cast<const void*>(this); 82 os << static_cast<const void*>(this);
44 #endif // DEBUG 83 #endif // DEBUG
45 } 84 }
46 85
86 void BytecodeNode::Transform(Bytecode new_bytecode, uint32_t extra_operand) {
87 DCHECK_EQ(Bytecodes::NumberOfOperands(new_bytecode),
88 Bytecodes::NumberOfOperands(bytecode()) + 1);
89 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 1 ||
90 Bytecodes::GetOperandType(new_bytecode, 0) ==
91 Bytecodes::GetOperandType(bytecode(), 0));
92 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 2 ||
93 Bytecodes::GetOperandType(new_bytecode, 1) ==
94 Bytecodes::GetOperandType(bytecode(), 1));
95 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 3 ||
96 Bytecodes::GetOperandType(new_bytecode, 2) ==
97 Bytecodes::GetOperandType(bytecode(), 2));
98 DCHECK(Bytecodes::NumberOfOperands(bytecode()) < 4);
99 operands_[operand_count()] = extra_operand;
100 bytecode_ = new_bytecode;
101 }
102
47 bool BytecodeNode::operator==(const BytecodeNode& other) const { 103 bool BytecodeNode::operator==(const BytecodeNode& other) const {
48 if (this == &other) { 104 if (this == &other) {
49 return true; 105 return true;
50 } else if (this->bytecode() != other.bytecode() || 106 } else if (this->bytecode() != other.bytecode() ||
51 this->source_info() != other.source_info()) { 107 this->source_info() != other.source_info()) {
52 return false; 108 return false;
53 } else { 109 } else {
54 for (int i = 0; i < this->operand_count(); ++i) { 110 for (int i = 0; i < this->operand_count(); ++i) {
55 if (this->operand(i) != other.operand(i)) { 111 if (this->operand(i) != other.operand(i)) {
56 return false; 112 return false;
(...skipping 12 matching lines...) Expand all
69 } 125 }
70 126
71 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) { 127 std::ostream& operator<<(std::ostream& os, const BytecodeNode& node) {
72 node.Print(os); 128 node.Print(os);
73 return os; 129 return os;
74 } 130 }
75 131
76 } // namespace interpreter 132 } // namespace interpreter
77 } // namespace internal 133 } // namespace internal
78 } // namespace v8 134 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-pipeline.h ('k') | src/interpreter/bytecode-register-optimizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698