| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/interpreter/bytecode-array-writer.h" | 9 #include "src/interpreter/bytecode-array-writer.h" |
| 10 #include "src/interpreter/bytecode-label.h" | 10 #include "src/interpreter/bytecode-label.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 int max_register_count() { return writer()->max_register_count(); } | 53 int max_register_count() { return writer()->max_register_count(); } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 ConstantArrayBuilder constant_array_builder_; | 56 ConstantArrayBuilder constant_array_builder_; |
| 57 BytecodeArrayWriter bytecode_array_writer_; | 57 BytecodeArrayWriter bytecode_array_writer_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 void BytecodeArrayWriterUnittest::Write(BytecodeNode* node, | 60 void BytecodeArrayWriterUnittest::Write(BytecodeNode* node, |
| 61 const BytecodeSourceInfo& info) { | 61 const BytecodeSourceInfo& info) { |
| 62 if (info.is_valid()) { | 62 if (info.is_valid()) { |
| 63 node->source_info().Update(info); | 63 node->source_info().Clone(info); |
| 64 } | 64 } |
| 65 writer()->Write(node); | 65 writer()->Write(node); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void BytecodeArrayWriterUnittest::Write(Bytecode bytecode, | 68 void BytecodeArrayWriterUnittest::Write(Bytecode bytecode, |
| 69 const BytecodeSourceInfo& info) { | 69 const BytecodeSourceInfo& info) { |
| 70 BytecodeNode node(bytecode); | 70 BytecodeNode node(bytecode); |
| 71 Write(&node, info); | 71 Write(&node, info); |
| 72 } | 72 } |
| 73 | 73 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 97 const BytecodeSourceInfo& info) { | 97 const BytecodeSourceInfo& info) { |
| 98 BytecodeNode node(bytecode, operand0, operand1, operand2, operand3); | 98 BytecodeNode node(bytecode, operand0, operand1, operand2, operand3); |
| 99 Write(&node, info); | 99 Write(&node, info); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void BytecodeArrayWriterUnittest::WriteJump(Bytecode bytecode, | 102 void BytecodeArrayWriterUnittest::WriteJump(Bytecode bytecode, |
| 103 BytecodeLabel* label, | 103 BytecodeLabel* label, |
| 104 const BytecodeSourceInfo& info) { | 104 const BytecodeSourceInfo& info) { |
| 105 BytecodeNode node(bytecode, 0); | 105 BytecodeNode node(bytecode, 0); |
| 106 if (info.is_valid()) { | 106 if (info.is_valid()) { |
| 107 node.source_info().Update(info); | 107 node.source_info().Clone(info); |
| 108 } | 108 } |
| 109 writer()->WriteJump(&node, label); | 109 writer()->WriteJump(&node, label); |
| 110 } | 110 } |
| 111 | 111 |
| 112 TEST_F(BytecodeArrayWriterUnittest, SimpleExample) { | 112 TEST_F(BytecodeArrayWriterUnittest, SimpleExample) { |
| 113 CHECK_EQ(bytecodes()->size(), 0); | 113 CHECK_EQ(bytecodes()->size(), 0); |
| 114 | 114 |
| 115 Write(Bytecode::kStackCheck, {10, false}); | 115 Write(Bytecode::kStackCheck, {10, false}); |
| 116 CHECK_EQ(bytecodes()->size(), 1); | 116 CHECK_EQ(bytecodes()->size(), 1); |
| 117 CHECK_EQ(max_register_count(), 0); | 117 CHECK_EQ(max_register_count(), 0); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 CHECK_EQ(source_iterator.source_position(), expected.source_position); | 245 CHECK_EQ(source_iterator.source_position(), expected.source_position); |
| 246 CHECK_EQ(source_iterator.is_statement(), expected.is_statement); | 246 CHECK_EQ(source_iterator.is_statement(), expected.is_statement); |
| 247 source_iterator.Advance(); | 247 source_iterator.Advance(); |
| 248 } | 248 } |
| 249 CHECK(source_iterator.done()); | 249 CHECK(source_iterator.done()); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace interpreter | 252 } // namespace interpreter |
| 253 } // namespace internal | 253 } // namespace internal |
| 254 } // namespace v8 | 254 } // namespace v8 |
| OLD | NEW |