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

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

Issue 1546683002: [Interpreter] Add support for jumps using constants with wide operands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rationalize jumps in bytecode-graph-builder.cc. Created 5 years 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
6 #define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
7
8 #include "src/identity-map.h"
9 #include "src/zone-containers.h"
10
11 namespace v8 {
12 namespace internal {
13
14 class Factory;
15 class Isolate;
16
17 namespace interpreter {
18
19 // A helper class for constructing constant arrays for the interpreter.
20 class ConstantArrayBuilder final : public ZoneObject {
21 public:
22 enum class ReservationToken : uint8_t { kIdx8, kIdx16 };
23 static const size_t kMaxCapacity = kMaxUInt16 + 1;
24 static const size_t kLowCapacity = kMaxUInt8 + 1;
25
26 ConstantArrayBuilder(Isolate* isolate, Zone* zone);
27
28 // Generate a fixed array of constants based on inserted objects.
29 Handle<FixedArray> ToFixedArray(Factory* factory,
30 PretenureFlag pretenure) const;
31
32 // Returns the object in the constant pool array that at index
33 // |index|.
34 Handle<Object> at(size_t index) const { return constants_[index]; }
35
36 // Returns the number of elements in the array.
37 size_t size() const { return constants_.size(); }
38
39 // Insert an object into the constants array if it is not already
40 // present. Returns the array index associated with the object.
41 size_t Insert(Handle<Object> object);
42
43 // Creates a reserved entry in the constant pool and returns a
44 // token that can be subsequently committed or discarded.
45 ReservationToken CreateReservedEntry();
46
47 // Commit reserved entry and returns the constant pool index for the
48 // object.
49 size_t CommitReservedEntry(ReservationToken token, Handle<Object> object);
50
51 // Discards constant pool reservation.
52 void DiscardReservedEntry(ReservationToken token);
53
54 // Get the number of bytes required to hold the index for a
55 // reservation.
56 static size_t SizeOfReservedArrayIndex(ReservationToken token);
mythria 2015/12/24 15:53:44 I am not sure we use this function.
oth 2015/12/27 08:42:34 Thanks, removed.
57
58 private:
59 typedef uint16_t index_t;
60
61 Isolate* isolate() const { return isolate_; }
62 size_t allocated_and_reserved_low() const {
63 return static_cast<size_t>(allocated_low_ + reserved_low_);
64 }
65
66 index_t AllocateEntry(Handle<Object> object);
67 void EnsureCapacity(size_t minimum_pool_size);
68
69 Isolate* isolate_;
70 IdentityMap<index_t> constants_map_;
71 ZoneVector<Handle<Object>> constants_;
72 // Number of allocated entries with byte index operands
73 uint16_t allocated_low_;
74 // Number of reserved entries with byte index operands
75 uint16_t reserved_low_;
76 // Number of reserved entries with 2-byte index operands
77 uint16_t reserved_high_;
78 };
79
80 } // namespace interpreter
81 } // namespace internal
82 } // namespace v8
83
84 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698