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

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

Issue 2242193002: [Interpreter] Avoid accessing Isolate from during bytecode generation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_sourceposition
Patch Set: Rebase Created 4 years, 4 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/source-position-table.h" 9 #include "src/source-position-table.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 class SourcePositionTableBuilder; 14 class SourcePositionTableBuilder;
15 15
16 namespace interpreter { 16 namespace interpreter {
17 17
18 class BytecodeLabel; 18 class BytecodeLabel;
19 class ConstantArrayBuilder; 19 class ConstantArrayBuilder;
20 20
21 // Class for emitting bytecode as the final stage of the bytecode 21 // Class for emitting bytecode as the final stage of the bytecode
22 // generation pipeline. 22 // generation pipeline.
23 class BytecodeArrayWriter final : public BytecodePipelineStage { 23 class BytecodeArrayWriter final : public BytecodePipelineStage {
24 public: 24 public:
25 BytecodeArrayWriter( 25 BytecodeArrayWriter(
26 Isolate* isolate, Zone* zone, 26 Zone* zone, ConstantArrayBuilder* constant_array_builder,
27 ConstantArrayBuilder* constant_array_builder,
28 SourcePositionTableBuilder::RecordingMode source_position_mode); 27 SourcePositionTableBuilder::RecordingMode source_position_mode);
29 virtual ~BytecodeArrayWriter(); 28 virtual ~BytecodeArrayWriter();
30 29
31 // BytecodePipelineStage interface. 30 // BytecodePipelineStage interface.
32 void Write(BytecodeNode* node) override; 31 void Write(BytecodeNode* node) override;
33 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override; 32 void WriteJump(BytecodeNode* node, BytecodeLabel* label) override;
34 void BindLabel(BytecodeLabel* label) override; 33 void BindLabel(BytecodeLabel* label) override;
35 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override; 34 void BindLabel(const BytecodeLabel& target, BytecodeLabel* label) override;
36 Handle<BytecodeArray> ToBytecodeArray( 35 Handle<BytecodeArray> ToBytecodeArray(
37 int fixed_register_count, int parameter_count, 36 Isolate* isolate, int fixed_register_count, int parameter_count,
38 Handle<FixedArray> handler_table) override; 37 Handle<FixedArray> handler_table) override;
39 38
40 private: 39 private:
41 // Maximum sized packed bytecode is comprised of a prefix bytecode, 40 // Maximum sized packed bytecode is comprised of a prefix bytecode,
42 // plus the actual bytecode, plus the maximum number of operands times 41 // plus the actual bytecode, plus the maximum number of operands times
43 // the maximum operand size. 42 // the maximum operand size.
44 static const size_t kMaxSizeOfPackedBytecode = 43 static const size_t kMaxSizeOfPackedBytecode =
45 2 * sizeof(Bytecode) + 44 2 * sizeof(Bytecode) +
46 Bytecodes::kMaxOperands * static_cast<size_t>(OperandSize::kLast); 45 Bytecodes::kMaxOperands * static_cast<size_t>(OperandSize::kLast);
47 46
48 // Constants that act as placeholders for jump operands to be 47 // Constants that act as placeholders for jump operands to be
49 // patched. These have operand sizes that match the sizes of 48 // patched. These have operand sizes that match the sizes of
50 // reserved constant pool entries. 49 // reserved constant pool entries.
51 const uint32_t k8BitJumpPlaceholder = 0x7f; 50 const uint32_t k8BitJumpPlaceholder = 0x7f;
52 const uint32_t k16BitJumpPlaceholder = 51 const uint32_t k16BitJumpPlaceholder =
53 k8BitJumpPlaceholder | (k8BitJumpPlaceholder << 8); 52 k8BitJumpPlaceholder | (k8BitJumpPlaceholder << 8);
54 const uint32_t k32BitJumpPlaceholder = 53 const uint32_t k32BitJumpPlaceholder =
55 k16BitJumpPlaceholder | (k16BitJumpPlaceholder << 16); 54 k16BitJumpPlaceholder | (k16BitJumpPlaceholder << 16);
56 55
57 void PatchJump(size_t jump_target, size_t jump_location); 56 void PatchJump(size_t jump_target, size_t jump_location);
58 void PatchJumpWith8BitOperand(size_t jump_location, int delta); 57 void PatchJumpWith8BitOperand(size_t jump_location, int delta);
59 void PatchJumpWith16BitOperand(size_t jump_location, int delta); 58 void PatchJumpWith16BitOperand(size_t jump_location, int delta);
60 void PatchJumpWith32BitOperand(size_t jump_location, int delta); 59 void PatchJumpWith32BitOperand(size_t jump_location, int delta);
61 60
62 void EmitBytecode(const BytecodeNode* const node); 61 void EmitBytecode(const BytecodeNode* const node);
63 void EmitJump(BytecodeNode* node, BytecodeLabel* label); 62 void EmitJump(BytecodeNode* node, BytecodeLabel* label);
64 void UpdateSourcePositionTable(const BytecodeNode* const node); 63 void UpdateSourcePositionTable(const BytecodeNode* const node);
65 64
66 Isolate* isolate() { return isolate_; }
67 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; } 65 ZoneVector<uint8_t>* bytecodes() { return &bytecodes_; }
68 SourcePositionTableBuilder* source_position_table_builder() { 66 SourcePositionTableBuilder* source_position_table_builder() {
69 return &source_position_table_builder_; 67 return &source_position_table_builder_;
70 } 68 }
71 ConstantArrayBuilder* constant_array_builder() { 69 ConstantArrayBuilder* constant_array_builder() {
72 return constant_array_builder_; 70 return constant_array_builder_;
73 } 71 }
74 int max_register_count() { return max_register_count_; } 72 int max_register_count() { return max_register_count_; }
75 73
76 Isolate* isolate_;
77 ZoneVector<uint8_t> bytecodes_; 74 ZoneVector<uint8_t> bytecodes_;
78 int max_register_count_; 75 int max_register_count_;
79 int unbound_jumps_; 76 int unbound_jumps_;
80 SourcePositionTableBuilder source_position_table_builder_; 77 SourcePositionTableBuilder source_position_table_builder_;
81 ConstantArrayBuilder* constant_array_builder_; 78 ConstantArrayBuilder* constant_array_builder_;
82 79
83 friend class BytecodeArrayWriterUnittest; 80 friend class BytecodeArrayWriterUnittest;
84 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayWriter); 81 DISALLOW_COPY_AND_ASSIGN(BytecodeArrayWriter);
85 }; 82 };
86 83
87 } // namespace interpreter 84 } // namespace interpreter
88 } // namespace internal 85 } // namespace internal
89 } // namespace v8 86 } // namespace v8
90 87
91 #endif // V8_INTERPRETER_BYTECODE_ARRAY_WRITER_H_ 88 #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