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

Side by Side Diff: src/interpreter/constant-array-builder.h

Issue 2167763003: [Interpreter] Avoid allocating pairs array in VisitDeclarations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_merge_binary
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-generator.cc ('k') | src/interpreter/constant-array-builder.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_CONSTANT_ARRAY_BUILDER_H_ 5 #ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
6 #define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ 6 #define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
7 7
8 #include "src/identity-map.h" 8 #include "src/identity-map.h"
9 #include "src/interpreter/bytecodes.h" 9 #include "src/interpreter/bytecodes.h"
10 #include "src/zone-containers.h" 10 #include "src/zone-containers.h"
(...skipping 30 matching lines...) Expand all
41 // |index|. 41 // |index|.
42 Handle<Object> At(size_t index) const; 42 Handle<Object> At(size_t index) const;
43 43
44 // Returns the number of elements in the array. 44 // Returns the number of elements in the array.
45 size_t size() const; 45 size_t size() const;
46 46
47 // Insert an object into the constants array if it is not already 47 // Insert an object into the constants array if it is not already
48 // present. Returns the array index associated with the object. 48 // present. Returns the array index associated with the object.
49 size_t Insert(Handle<Object> object); 49 size_t Insert(Handle<Object> object);
50 50
51 // Allocates an empty entry and returns the array index associated with the
52 // reservation. Entry can be inserted by calling InsertReservedEntry().
53 size_t AllocateEntry();
54
55 // Inserts the given object into an allocated entry.
56 void InsertAllocatedEntry(size_t index, Handle<Object> object);
57
51 // Creates a reserved entry in the constant pool and returns 58 // Creates a reserved entry in the constant pool and returns
52 // the size of the operand that'll be required to hold the entry 59 // the size of the operand that'll be required to hold the entry
53 // when committed. 60 // when committed.
54 OperandSize CreateReservedEntry(); 61 OperandSize CreateReservedEntry();
55 62
56 // Commit reserved entry and returns the constant pool index for the 63 // Commit reserved entry and returns the constant pool index for the
57 // object. 64 // object.
58 size_t CommitReservedEntry(OperandSize operand_size, Handle<Object> object); 65 size_t CommitReservedEntry(OperandSize operand_size, Handle<Object> object);
59 66
60 // Discards constant pool reservation. 67 // Discards constant pool reservation.
61 void DiscardReservedEntry(OperandSize operand_size); 68 void DiscardReservedEntry(OperandSize operand_size);
62 69
63 private: 70 private:
64 typedef uint32_t index_t; 71 typedef uint32_t index_t;
65 72
66 index_t AllocateEntry(Handle<Object> object); 73 index_t AllocateEntry(Handle<Object> object);
74 index_t AllocateIndex(Handle<Object> object);
67 75
68 struct ConstantArraySlice final : public ZoneObject { 76 struct ConstantArraySlice final : public ZoneObject {
69 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, 77 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity,
70 OperandSize operand_size); 78 OperandSize operand_size);
71 void Reserve(); 79 void Reserve();
72 void Unreserve(); 80 void Unreserve();
73 size_t Allocate(Handle<Object> object); 81 size_t Allocate(Handle<Object> object);
74 Handle<Object> At(size_t index) const; 82 Handle<Object> At(size_t index) const;
83 void InsertAt(size_t index, Handle<Object> object);
75 84
76 inline size_t available() const { return capacity() - reserved() - size(); } 85 inline size_t available() const { return capacity() - reserved() - size(); }
77 inline size_t reserved() const { return reserved_; } 86 inline size_t reserved() const { return reserved_; }
78 inline size_t capacity() const { return capacity_; } 87 inline size_t capacity() const { return capacity_; }
79 inline size_t size() const { return constants_.size(); } 88 inline size_t size() const { return constants_.size(); }
80 inline size_t start_index() const { return start_index_; } 89 inline size_t start_index() const { return start_index_; }
81 inline size_t max_index() const { return start_index_ + capacity() - 1; } 90 inline size_t max_index() const { return start_index_ + capacity() - 1; }
82 inline OperandSize operand_size() const { return operand_size_; } 91 inline OperandSize operand_size() const { return operand_size_; }
83 92
84 private: 93 private:
85 const size_t start_index_; 94 const size_t start_index_;
86 const size_t capacity_; 95 const size_t capacity_;
87 size_t reserved_; 96 size_t reserved_;
88 OperandSize operand_size_; 97 OperandSize operand_size_;
89 ZoneVector<Handle<Object>> constants_; 98 ZoneVector<Handle<Object>> constants_;
90 99
91 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); 100 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice);
92 }; 101 };
93 102
94 const ConstantArraySlice* IndexToSlice(size_t index) const; 103 ConstantArraySlice* IndexToSlice(size_t index) const;
95 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; 104 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const;
96 105
97 IdentityMap<index_t>* constants_map() { return &constants_map_; } 106 IdentityMap<index_t>* constants_map() { return &constants_map_; }
98 107
99 Isolate* isolate_; 108 Isolate* isolate_;
100 ConstantArraySlice* idx_slice_[3]; 109 ConstantArraySlice* idx_slice_[3];
101 IdentityMap<index_t> constants_map_; 110 IdentityMap<index_t> constants_map_;
102 }; 111 };
103 112
104 } // namespace interpreter 113 } // namespace interpreter
105 } // namespace internal 114 } // namespace internal
106 } // namespace v8 115 } // namespace v8
107 116
108 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ 117 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/constant-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698