Commit 15ec32b4 authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

[ic] Add elements kind to handlers

Bug: v8:10582, v8:9684
Change-Id: I4b53b161f9154212568856206ff011e61975e431
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2247652
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69348}
parent e9245e46
......@@ -48,16 +48,20 @@ Handle<Smi> LoadHandler::LoadSlow(Isolate* isolate) {
return handle(Smi::FromInt(config), isolate);
}
Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index) {
Handle<Smi> LoadHandler::LoadField(Isolate* isolate, FieldIndex field_index,
ElementsKind kind) {
int config = KindBits::encode(kField) |
IsInobjectBits::encode(field_index.is_inobject()) |
IsDoubleBits::encode(field_index.is_double()) |
FieldIndexBits::encode(field_index.index());
FieldIndexBits::encode(field_index.index()) |
CompactElementsKindBits::encode(ToCompactElementsKind(kind));
return handle(Smi::FromInt(config), isolate);
}
Handle<Smi> LoadHandler::LoadConstantFromPrototype(Isolate* isolate) {
int config = KindBits::encode(kConstantFromPrototype);
Handle<Smi> LoadHandler::LoadConstantFromPrototype(Isolate* isolate,
ElementsKind kind) {
int config = KindBits::encode(kConstantFromPrototype) |
CompactElementsKindBits::encode(ToCompactElementsKind(kind));
return handle(Smi::FromInt(config), isolate);
}
......
......@@ -78,8 +78,9 @@ class LoadHandler final : public DataHandler {
// +1 here is to cover all possible JSObject header sizes.
using FieldIndexBits =
IsDoubleBits::Next<unsigned, kDescriptorIndexBitCount + 1>;
using CompactElementsKindBits = FieldIndexBits::Next<CompactElementsKind, 3>;
// Make sure we don't overflow the smi.
STATIC_ASSERT(FieldIndexBits::kLastUsedBit < kSmiValueSize);
STATIC_ASSERT(CompactElementsKindBits::kLastUsedBit < kSmiValueSize);
//
// Encoding when KindBits contains kElement or kIndexedString.
......@@ -118,11 +119,13 @@ class LoadHandler final : public DataHandler {
static inline Handle<Smi> LoadSlow(Isolate* isolate);
// Creates a Smi-handler for loading a field from fast object.
static inline Handle<Smi> LoadField(Isolate* isolate, FieldIndex field_index);
static inline Handle<Smi> LoadField(Isolate* isolate, FieldIndex field_index,
ElementsKind kind);
// Creates a Smi-handler for loading a cached constant from fast
// prototype object.
static inline Handle<Smi> LoadConstantFromPrototype(Isolate* isolate);
static inline Handle<Smi> LoadConstantFromPrototype(Isolate* isolate,
ElementsKind kind);
// Creates a Smi-handler for calling a getter on a fast object.
static inline Handle<Smi> LoadAccessor(Isolate* isolate, int descriptor);
......
......@@ -823,7 +823,7 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
if (Accessors::IsJSObjectFieldAccessor(isolate(), map, lookup->name(),
&index)) {
TRACE_HANDLER_STATS(isolate(), LoadIC_LoadFieldDH);
return LoadHandler::LoadField(isolate(), index);
return LoadHandler::LoadField(isolate(), index, map->elements_kind());
}
if (holder->IsJSModuleNamespace()) {
Handle<ObjectHashTable> exports(
......@@ -956,7 +956,8 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
} else {
DCHECK_EQ(kField, lookup->property_details().location());
FieldIndex field = lookup->GetFieldIndex();
smi_handler = LoadHandler::LoadField(isolate(), field);
smi_handler =
LoadHandler::LoadField(isolate(), field, map->elements_kind());
TRACE_HANDLER_STATS(isolate(), LoadIC_LoadFieldDH);
if (receiver_is_holder) return smi_handler;
TRACE_HANDLER_STATS(isolate(), LoadIC_LoadFieldFromPrototypeDH);
......@@ -982,7 +983,8 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
value->IsSmi() ? MaybeObjectHandle(*value, isolate())
: MaybeObjectHandle::Weak(*value, isolate());
smi_handler = LoadHandler::LoadConstantFromPrototype(isolate());
smi_handler = LoadHandler::LoadConstantFromPrototype(
isolate(), map->elements_kind());
TRACE_HANDLER_STATS(isolate(), LoadIC_LoadConstantFromPrototypeDH);
return LoadHandler::LoadFromPrototype(isolate(), map, holder,
smi_handler, weak_value);
......
......@@ -350,6 +350,27 @@ inline bool IsTransitionableFastElementsKind(ElementsKind from_kind) {
inline bool ElementsKindEqual(ElementsKind a, ElementsKind b) { return a == b; }
enum class CompactElementsKind : uint8_t {
PACKED_SMI_ELEMENTS = PACKED_SMI_ELEMENTS,
HOLEY_SMI_ELEMENTS = HOLEY_SMI_ELEMENTS,
PACKED_ELEMENTS = PACKED_ELEMENTS,
HOLEY_ELEMENTS = HOLEY_ELEMENTS,
PACKED_DOUBLE_ELEMENTS = PACKED_DOUBLE_ELEMENTS,
HOLEY_DOUBLE_ELEMENTS = HOLEY_DOUBLE_ELEMENTS,
NON_COMPACT_ELEMENTS_KIND
};
inline CompactElementsKind ToCompactElementsKind(ElementsKind kind) {
if (base::IsInRange(kind, PACKED_ELEMENTS, HOLEY_DOUBLE_ELEMENTS)) {
return static_cast<CompactElementsKind>(kind);
}
return CompactElementsKind::NON_COMPACT_ELEMENTS_KIND;
}
} // namespace internal
} // namespace v8
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment