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

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: Rebase. Created 4 years, 11 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
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 = 65536;
rmcilroy 2016/01/04 17:05:48 nit - newline above
rmcilroy 2016/01/04 17:05:48 /s/65536/kMaxUInt16 + 1/
oth 2016/01/05 09:30:08 Done.
oth 2016/01/05 09:30:08 Done.
24 static const size_t kLowCapacity = 256;
rmcilroy 2016/01/04 17:05:48 kMaxUInt8 + 1
oth 2016/01/05 09:30:08 Done.
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;
rmcilroy 2016/01/04 17:05:48 no need for PretenureFlag argument - this should a
oth 2016/01/05 09:30:08 Done.
31
32 // Returns the object in the constant pool array that at index
33 // |index|.
34 Handle<Object> at(size_t index) const;
35
36 // Returns the number of elements in the array.
37 size_t size() const;
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 private:
55 typedef uint16_t index_t;
56
57 index_t AllocateEntry(Handle<Object> object);
58
59 struct ConstantArraySlice final {
60 ConstantArraySlice(Zone* zone, int width);
61
62 size_t free() const;
63 size_t reserved() const;
64 size_t capacity() const;
65 size_t size() const;
66 size_t start_index() const;
67 void reserve();
68 void unreserve();
rmcilroy 2016/01/04 17:05:48 lower case only for getters / setters (which you c
oth 2016/01/05 09:30:08 Done.
69 size_t allocate(Handle<Object> object);
70 Handle<Object> at(size_t index) const;
71
72 private:
73 const size_t width_;
74 size_t reserved_;
75 ZoneVector<Handle<Object>> constants_;
76
77 DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice);
78 };
79
80 Isolate* isolate_;
81 ConstantArraySlice idx8_slice_;
82 ConstantArraySlice idx16_slice_;
83 IdentityMap<index_t> constants_map_;
84 };
85
86 } // namespace interpreter
87 } // namespace internal
88 } // namespace v8
89
90 #endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698