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

Unified 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, 12 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 side-by-side diff with in-line comments
Download patch
Index: src/interpreter/constant-array-builder.h
diff --git a/src/interpreter/constant-array-builder.h b/src/interpreter/constant-array-builder.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b59860fa1fa869b058792569b5ccd448e8523f3
--- /dev/null
+++ b/src/interpreter/constant-array-builder.h
@@ -0,0 +1,90 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
+#define V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_
+
+#include "src/identity-map.h"
+#include "src/zone-containers.h"
+
+namespace v8 {
+namespace internal {
+
+class Factory;
+class Isolate;
+
+namespace interpreter {
+
+// A helper class for constructing constant arrays for the interpreter.
+class ConstantArrayBuilder final : public ZoneObject {
+ public:
+ enum class ReservationToken : uint8_t { kIdx8, kIdx16 };
+ 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.
+ static const size_t kLowCapacity = 256;
rmcilroy 2016/01/04 17:05:48 kMaxUInt8 + 1
oth 2016/01/05 09:30:08 Done.
+
+ ConstantArrayBuilder(Isolate* isolate, Zone* zone);
+
+ // Generate a fixed array of constants based on inserted objects.
+ Handle<FixedArray> ToFixedArray(Factory* factory,
+ 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.
+
+ // Returns the object in the constant pool array that at index
+ // |index|.
+ Handle<Object> at(size_t index) const;
+
+ // Returns the number of elements in the array.
+ size_t size() const;
+
+ // Insert an object into the constants array if it is not already
+ // present. Returns the array index associated with the object.
+ size_t Insert(Handle<Object> object);
+
+ // Creates a reserved entry in the constant pool and returns a
+ // token that can be subsequently committed or discarded.
+ ReservationToken CreateReservedEntry();
+
+ // Commit reserved entry and returns the constant pool index for the
+ // object.
+ size_t CommitReservedEntry(ReservationToken token, Handle<Object> object);
+
+ // Discards constant pool reservation.
+ void DiscardReservedEntry(ReservationToken token);
+
+ private:
+ typedef uint16_t index_t;
+
+ index_t AllocateEntry(Handle<Object> object);
+
+ struct ConstantArraySlice final {
+ ConstantArraySlice(Zone* zone, int width);
+
+ size_t free() const;
+ size_t reserved() const;
+ size_t capacity() const;
+ size_t size() const;
+ size_t start_index() const;
+ void reserve();
+ 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.
+ size_t allocate(Handle<Object> object);
+ Handle<Object> at(size_t index) const;
+
+ private:
+ const size_t width_;
+ size_t reserved_;
+ ZoneVector<Handle<Object>> constants_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConstantArraySlice);
+ };
+
+ Isolate* isolate_;
+ ConstantArraySlice idx8_slice_;
+ ConstantArraySlice idx16_slice_;
+ IdentityMap<index_t> constants_map_;
+};
+
+} // namespace interpreter
+} // namespace internal
+} // namespace v8
+
+#endif // V8_INTERPRETER_CONSTANT_ARRAY_BUILDER_H_

Powered by Google App Engine
This is Rietveld 408576698