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

Side by Side Diff: src/interpreter/bytecode-array-writer.h

Issue 2035813002: [Interpreter] Move jump processing to bytecode array writer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_fix_bytecode
Patch Set: Address comments Created 4 years, 6 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-array-builder.cc ('k') | src/interpreter/bytecode-array-writer.cc » ('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 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_ 5 #ifndef V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_
6 #define V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_ 6 #define V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_
7 7
8 #include "src/interpreter/bytecode-pipeline.h" 8 #include "src/interpreter/bytecode-pipeline.h"
9 #include "src/interpreter/source-position-table.h"
9 10
10 namespace v8 { 11 namespace v8 {
11 namespace internal { 12 namespace internal {
12 namespace interpreter { 13 namespace interpreter {
13 14
15 class BytecodeLabel;
14 class SourcePositionTableBuilder; 16 class SourcePositionTableBuilder;
17 class ConstantArrayBuilder;
15 18
16 // Class for emitting bytecode as the final stage of the bytecode 19 // Class for emitting bytecode as the final stage of the bytecode
17 // generation pipeline. 20 // generation pipeline.
18 class BytecodeArrayWriter final : public BytecodePipelineStage { 21 class BytecodeArrayWriter final : public BytecodePipelineStage {
19 public: 22 public:
20 BytecodeArrayWriter( 23 BytecodeArrayWriter(Isolate* isolate, Zone* zone,
21 Zone* zone, SourcePositionTableBuilder* source_position_table_builder); 24 ConstantArrayBuilder* constant_array_builder);
22 virtual ~BytecodeArrayWriter(); 25 virtual ~BytecodeArrayWriter();
23 26
27 // BytecodePipelineStage interface.
24 void Write(BytecodeNode* node) override; 28 void Write(BytecodeNode* node) override;
25 size_t FlushForOffset() override; 29 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override;
26 void FlushBasicBlock() override; 30 void BindLabel(BytecodeLabel* label) override;
27 31 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override;
28 // Get the bytecode vector. 32 Handle<BytecodeArray> ToBytecodeArray(
29 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } 33 int fixed_register_count, int parameter_count,
30 34 Handle<FixedArray> handler_table) override;
31 // Returns the size in bytes of the frame associated with the
32 // bytecode written.
33 int GetMaximumFrameSizeUsed();
34 35
35 private: 36 private:
37 void PatchJump(size_t jump_target, size_t jump_location);
38 void PatchJumpWith8BitOperand(size_t jump_location, int delta);
39 void PatchJumpWith16BitOperand(size_t jump_location, int delta);
40 void PatchJumpWith32BitOperand(size_t jump_location, int delta);
41
36 void EmitBytecode(const BytecodeNode* const node); 42 void EmitBytecode(const BytecodeNode* const node);
43 void EmitJump(BytecodeNode* node, BytecodeLabel* label);
37 void UpdateSourcePositionTable(const BytecodeNode* const node); 44 void UpdateSourcePositionTable(const BytecodeNode* const node);
38 45
46 Isolate* isolate() { return isolate_; }
47 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; }
48 SourcePositionTableBuilder* source_position_table_builder() {
49 return &source_position_table_builder_;
50 }
51 ConstantArrayBuilder* constant_array_builder() {
52 return constant_array_builder_;
53 }
54 int max_register_count() { return max_register_count_; }
55
56 Isolate* isolate_;
39 ZoneVector<uint8_t> bytecodes_; 57 ZoneVector<uint8_t> bytecodes_;
40 int max_register_count_; 58 int max_register_count_;
41 SourcePositionTableBuilder* source_position_table_builder_; 59 int unbound_jumps_;
60 SourcePositionTableBuilder source_position_table_builder_;
61 ConstantArrayBuilder* constant_array_builder_;
42 62
63 friend class BytecodeArrayWriterUnittest;
43 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayWriter); 64 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayWriter);
44 }; 65 };
45 66
46 } // namespace interpreter 67 } // namespace interpreter
47 } // namespace internal 68 } // namespace internal
48 } // namespace v8 69 } // namespace v8
49 70
50 #endif // V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_ 71 #endif // V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-builder.cc ('k') | src/interpreter/bytecode-array-writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698