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

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

Issue 2226333002: [Interpreter] Avoid allocating handles in bytecode-array-writer (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@offheap_varchecks
Patch Set: [Interpreter] Avoid allocating handles in bytecode-array-writer 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-writer.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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 // Inserts the given object into an allocated entry. 55 // Inserts the given object into an allocated entry.
56 void InsertAllocatedEntry(size_t index, Handle<Object> object); 56 void InsertAllocatedEntry(size_t index, Handle<Object> object);
57 57
58 // Creates a reserved entry in the constant pool and returns 58 // Creates a reserved entry in the constant pool and returns
59 // 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
60 // when committed. 60 // when committed.
61 OperandSize CreateReservedEntry(); 61 OperandSize CreateReservedEntry();
62 62
63 // Commit reserved entry and returns the constant pool index for the 63 // Commit reserved entry and returns the constant pool index for the
64 // object. 64 // SMI value.
65 size_t CommitReservedEntry(OperandSize operand_size, Handle<Object> object); 65 size_t CommitReservedEntry(OperandSize operand_size, Smi* value);
66 66
67 // Discards constant pool reservation. 67 // Discards constant pool reservation.
68 void DiscardReservedEntry(OperandSize operand_size); 68 void DiscardReservedEntry(OperandSize operand_size);
69 69
70 private: 70 private:
71 typedef uint32_t index_t; 71 typedef uint32_t index_t;
72 72
73 index_t AllocateEntry(Handle<Object> object); 73 index_t AllocateEntry(Handle<Object> object);
74 index_t AllocateIndex(Handle<Object> object); 74 index_t AllocateIndex(Handle<Object> object);
75 index_t AllocateReservedEntry(Smi* value);
75 76
76 struct ConstantArraySlice final : public ZoneObject { 77 struct ConstantArraySlice final : public ZoneObject {
77 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity, 78 ConstantArraySlice(Zone* zone, size_t start_index, size_t capacity,
78 OperandSize operand_size); 79 OperandSize operand_size);
79 void Reserve(); 80 void Reserve();
80 void Unreserve(); 81 void Unreserve();
81 size_t Allocate(Handle<Object> object); 82 size_t Allocate(Handle<Object> object);
82 Handle<Object> At(size_t index) const; 83 Handle<Object> At(size_t index) const;
83 void InsertAt(size_t index, Handle<Object> object); 84 void InsertAt(size_t index, Handle<Object> object);
84 bool AllElementsAreUnique() const; 85 bool AllElementsAreUnique() const;
(...skipping 15 matching lines...) Expand all
100 101
101 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice); 102 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice);
102 }; 103 };
103 104
104 ConstantArraySlice* IndexToSlice(size_t index) const; 105 ConstantArraySlice* IndexToSlice(size_t index) const;
105 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const; 106 ConstantArraySlice* OperandSizeToSlice(OperandSize operand_size) const;
106 107
107 Isolate* isolate_; 108 Isolate* isolate_;
108 ConstantArraySlice* idx_slice_[3]; 109 ConstantArraySlice* idx_slice_[3];
109 ZoneMap<Address, index_t> constants_map_; 110 ZoneMap<Address, index_t> constants_map_;
111 ZoneMap<Smi*, index_t> smi_map_;
112 ZoneVector<std::pair<Smi*, index_t>> smi_pairs_;
110 }; 113 };
111 114
112 } // namespace interpreter 115 } // namespace interpreter
113 } // namespace internal 116 } // namespace internal
114 } // namespace v8 117 } // namespace v8
115 118
116 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_ 119 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-array-writer.cc ('k') | src/interpreter/constant-array-builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698