2014-09-18 09:59:53 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
#include "src/feedback-vector.h"
|
2015-05-11 11:45:02 +00:00
|
|
|
#include "src/code-stubs.h"
|
2017-02-07 14:05:02 +00:00
|
|
|
#include "src/feedback-vector-inl.h"
|
2016-10-13 12:02:05 +00:00
|
|
|
#include "src/ic/ic-inl.h"
|
2014-10-20 11:42:56 +00:00
|
|
|
#include "src/ic/ic-state.h"
|
2014-09-18 09:59:53 +00:00
|
|
|
#include "src/objects.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2015-10-23 08:17:48 +00:00
|
|
|
static bool IsPropertyNameFeedback(Object* feedback) {
|
2016-02-10 14:12:03 +00:00
|
|
|
if (feedback->IsString()) return true;
|
|
|
|
if (!feedback->IsSymbol()) return false;
|
|
|
|
Symbol* symbol = Symbol::cast(feedback);
|
|
|
|
Heap* heap = symbol->GetHeap();
|
|
|
|
return symbol != heap->uninitialized_symbol() &&
|
|
|
|
symbol != heap->premonomorphic_symbol() &&
|
|
|
|
symbol != heap->megamorphic_symbol();
|
2015-10-23 08:17:48 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 15:19:35 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, FeedbackSlotKind kind) {
|
2017-02-07 14:05:02 +00:00
|
|
|
return os << FeedbackMetadata::Kind2String(kind);
|
2014-10-27 16:34:28 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlotKind FeedbackMetadata::GetKind(FeedbackSlot slot) const {
|
2014-10-27 16:34:28 +00:00
|
|
|
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
|
|
|
|
int data = Smi::cast(get(index))->value();
|
2015-09-28 08:23:35 +00:00
|
|
|
return VectorICComputer::decode(data, slot.ToInt());
|
2014-10-27 16:34:28 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 15:19:35 +00:00
|
|
|
void FeedbackMetadata::SetKind(FeedbackSlot slot, FeedbackSlotKind kind) {
|
2014-10-27 16:34:28 +00:00
|
|
|
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
|
|
|
|
int data = Smi::cast(get(index))->value();
|
2015-09-28 08:23:35 +00:00
|
|
|
int new_data = VectorICComputer::encode(data, slot.ToInt(), kind);
|
2014-10-27 16:34:28 +00:00
|
|
|
set(index, Smi::FromInt(new_data));
|
|
|
|
}
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
template Handle<FeedbackMetadata> FeedbackMetadata::New(
|
2015-09-28 11:41:40 +00:00
|
|
|
Isolate* isolate, const StaticFeedbackVectorSpec* spec);
|
2017-02-07 14:05:02 +00:00
|
|
|
template Handle<FeedbackMetadata> FeedbackMetadata::New(
|
2015-09-28 11:41:40 +00:00
|
|
|
Isolate* isolate, const FeedbackVectorSpec* spec);
|
2015-03-17 15:16:21 +00:00
|
|
|
|
2014-10-20 11:42:56 +00:00
|
|
|
// static
|
2015-03-17 15:16:21 +00:00
|
|
|
template <typename Spec>
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackMetadata> FeedbackMetadata::New(Isolate* isolate,
|
|
|
|
const Spec* spec) {
|
2016-06-24 14:08:09 +00:00
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
|
2015-03-17 15:16:21 +00:00
|
|
|
const int slot_count = spec->slots();
|
2015-10-07 10:33:22 +00:00
|
|
|
const int slot_kinds_length = VectorICComputer::word_count(slot_count);
|
|
|
|
const int length = slot_kinds_length + kReservedIndexCount;
|
2014-10-20 11:42:56 +00:00
|
|
|
if (length == kReservedIndexCount) {
|
2017-02-07 14:05:02 +00:00
|
|
|
return Handle<FeedbackMetadata>::cast(factory->empty_fixed_array());
|
2014-10-20 11:42:56 +00:00
|
|
|
}
|
2015-10-01 13:48:05 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
for (int i = 0; i < slot_count;) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i));
|
2017-02-07 14:05:02 +00:00
|
|
|
int entry_size = FeedbackMetadata::GetSlotSize(kind);
|
2015-10-01 13:48:05 +00:00
|
|
|
for (int j = 1; j < entry_size; j++) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlotKind kind = spec->GetKind(FeedbackSlot(i + j));
|
2017-02-07 17:49:58 +00:00
|
|
|
DCHECK_EQ(FeedbackSlotKind::kInvalid, kind);
|
2015-10-01 13:48:05 +00:00
|
|
|
}
|
|
|
|
i += entry_size;
|
|
|
|
}
|
|
|
|
#endif
|
2014-10-20 11:42:56 +00:00
|
|
|
|
2016-06-24 14:08:09 +00:00
|
|
|
Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
|
2015-10-01 13:48:05 +00:00
|
|
|
array->set(kSlotsCountIndex, Smi::FromInt(slot_count));
|
2015-10-07 10:33:22 +00:00
|
|
|
// Fill the bit-vector part with zeros.
|
|
|
|
for (int i = 0; i < slot_kinds_length; i++) {
|
2016-10-07 13:05:07 +00:00
|
|
|
array->set(kReservedIndexCount + i, Smi::kZero);
|
2014-12-12 13:56:11 +00:00
|
|
|
}
|
2014-10-20 11:42:56 +00:00
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackMetadata> metadata = Handle<FeedbackMetadata>::cast(array);
|
2016-06-24 14:08:09 +00:00
|
|
|
|
2015-10-07 10:33:22 +00:00
|
|
|
for (int i = 0; i < slot_count; i++) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot(i);
|
|
|
|
FeedbackSlotKind kind = spec->GetKind(slot);
|
2017-02-06 09:31:52 +00:00
|
|
|
metadata->SetKind(slot, kind);
|
2015-10-07 10:33:22 +00:00
|
|
|
}
|
2016-05-27 08:09:12 +00:00
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
// It's important that the FeedbackMetadata have a COW map, since it's
|
2016-05-27 08:09:12 +00:00
|
|
|
// pointed to by both a SharedFunctionInfo and indirectly by closures through
|
2017-02-07 14:05:02 +00:00
|
|
|
// the FeedbackVector. The serializer uses the COW map type to decide
|
2016-05-27 08:09:12 +00:00
|
|
|
// this object belongs in the startup snapshot and not the partial
|
|
|
|
// snapshot(s).
|
|
|
|
metadata->set_map(isolate->heap()->fixed_cow_array_map());
|
|
|
|
|
2015-10-07 10:33:22 +00:00
|
|
|
return metadata;
|
|
|
|
}
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
bool FeedbackMetadata::SpecDiffersFrom(
|
2015-10-07 10:33:22 +00:00
|
|
|
const FeedbackVectorSpec* other_spec) const {
|
|
|
|
if (other_spec->slots() != slot_count()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int slots = slot_count();
|
2016-06-24 14:08:09 +00:00
|
|
|
for (int i = 0; i < slots;) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot(i);
|
|
|
|
FeedbackSlotKind kind = GetKind(slot);
|
2017-02-07 14:05:02 +00:00
|
|
|
int entry_size = FeedbackMetadata::GetSlotSize(kind);
|
2016-06-24 14:08:09 +00:00
|
|
|
|
2017-02-06 09:31:52 +00:00
|
|
|
if (kind != other_spec->GetKind(slot)) {
|
2015-10-07 10:33:22 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-06-24 14:08:09 +00:00
|
|
|
i += entry_size;
|
2015-10-07 10:33:22 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-02-07 15:19:35 +00:00
|
|
|
const char* FeedbackMetadata::Kind2String(FeedbackSlotKind kind) {
|
2015-10-07 10:33:22 +00:00
|
|
|
switch (kind) {
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kInvalid:
|
2015-10-07 10:33:22 +00:00
|
|
|
return "INVALID";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCall:
|
2015-10-07 10:33:22 +00:00
|
|
|
return "CALL_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadProperty:
|
2015-10-07 10:33:22 +00:00
|
|
|
return "LOAD_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadGlobalInsideTypeof:
|
2017-02-07 09:03:16 +00:00
|
|
|
return "LOAD_GLOBAL_INSIDE_TYPEOF_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
|
2017-02-07 09:03:16 +00:00
|
|
|
return "LOAD_GLOBAL_NOT_INSIDE_TYPEOF_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadKeyed:
|
2015-10-07 10:33:22 +00:00
|
|
|
return "KEYED_LOAD_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStorePropertySloppy:
|
2017-02-06 09:31:52 +00:00
|
|
|
return "STORE_SLOPPY_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStorePropertyStrict:
|
2017-02-06 09:31:52 +00:00
|
|
|
return "STORE_STRICT_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStoreKeyedSloppy:
|
2017-02-06 09:31:52 +00:00
|
|
|
return "KEYED_STORE_SLOPPY_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStoreKeyedStrict:
|
2017-02-06 09:31:52 +00:00
|
|
|
return "KEYED_STORE_STRICT_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kBinaryOp:
|
2016-09-20 13:53:32 +00:00
|
|
|
return "INTERPRETER_BINARYOP_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCompareOp:
|
2016-09-20 13:53:32 +00:00
|
|
|
return "INTERPRETER_COMPARE_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kToBoolean:
|
2017-02-07 17:41:32 +00:00
|
|
|
return "TO_BOOLEAN_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStoreDataPropertyInLiteral:
|
2017-01-05 07:30:01 +00:00
|
|
|
return "STORE_DATA_PROPERTY_IN_LITERAL_IC";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCreateClosure:
|
|
|
|
return "kCreateClosure";
|
|
|
|
case FeedbackSlotKind::kLiteral:
|
2017-01-30 12:31:35 +00:00
|
|
|
return "LITERAL";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kGeneral:
|
2015-10-07 10:33:22 +00:00
|
|
|
return "STUB";
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kKindsNumber:
|
2015-10-07 10:33:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
return "?";
|
|
|
|
}
|
|
|
|
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlotKind FeedbackVector::GetKind(FeedbackSlot slot) const {
|
2016-06-06 14:17:29 +00:00
|
|
|
DCHECK(!is_empty());
|
|
|
|
return metadata()->GetKind(slot);
|
|
|
|
}
|
2015-10-07 10:33:22 +00:00
|
|
|
|
|
|
|
// static
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate,
|
2017-02-08 08:33:33 +00:00
|
|
|
Handle<SharedFunctionInfo> shared) {
|
2015-10-07 10:33:22 +00:00
|
|
|
Factory* factory = isolate->factory();
|
|
|
|
|
2017-02-08 08:33:33 +00:00
|
|
|
const int slot_count = shared->feedback_metadata()->slot_count();
|
2015-10-07 10:33:22 +00:00
|
|
|
const int length = slot_count + kReservedIndexCount;
|
|
|
|
|
|
|
|
Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
|
2017-02-07 14:05:02 +00:00
|
|
|
array->set_map_no_write_barrier(isolate->heap()->feedback_vector_map());
|
2017-02-08 08:33:33 +00:00
|
|
|
array->set(kSharedFunctionInfoIndex, *shared);
|
2016-10-07 13:05:07 +00:00
|
|
|
array->set(kInvocationCountIndex, Smi::kZero);
|
2015-10-07 10:33:22 +00:00
|
|
|
|
2014-10-20 11:42:56 +00:00
|
|
|
// Ensure we can skip the write barrier
|
|
|
|
Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
|
2016-10-26 11:22:14 +00:00
|
|
|
DCHECK_EQ(isolate->heap()->uninitialized_symbol(), *uninitialized_sentinel);
|
2017-02-06 10:18:05 +00:00
|
|
|
Handle<Oddball> undefined_value = factory->undefined_value();
|
2016-06-15 12:34:57 +00:00
|
|
|
for (int i = 0; i < slot_count;) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot(i);
|
2017-02-08 08:33:33 +00:00
|
|
|
FeedbackSlotKind kind = shared->feedback_metadata()->GetKind(slot);
|
2017-02-07 14:05:02 +00:00
|
|
|
int index = FeedbackVector::GetIndex(slot);
|
|
|
|
int entry_size = FeedbackMetadata::GetSlotSize(kind);
|
2014-11-27 16:36:18 +00:00
|
|
|
|
2017-02-01 16:22:03 +00:00
|
|
|
Object* extra_value = *uninitialized_sentinel;
|
|
|
|
switch (kind) {
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadGlobalInsideTypeof:
|
|
|
|
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof:
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, isolate->heap()->empty_weak_cell(),
|
|
|
|
SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCompareOp:
|
|
|
|
case FeedbackSlotKind::kBinaryOp:
|
|
|
|
case FeedbackSlotKind::kToBoolean:
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCreateClosure: {
|
2017-02-10 15:19:19 +00:00
|
|
|
Handle<Cell> cell = factory->NewNoClosuresCell(undefined_value);
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, *cell);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
2017-02-06 10:18:05 +00:00
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLiteral:
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, *undefined_value, SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCall:
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
extra_value = Smi::kZero;
|
|
|
|
break;
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadProperty:
|
|
|
|
case FeedbackSlotKind::kLoadKeyed:
|
|
|
|
case FeedbackSlotKind::kStorePropertySloppy:
|
|
|
|
case FeedbackSlotKind::kStorePropertyStrict:
|
|
|
|
case FeedbackSlotKind::kStoreKeyedSloppy:
|
|
|
|
case FeedbackSlotKind::kStoreKeyedStrict:
|
|
|
|
case FeedbackSlotKind::kStoreDataPropertyInLiteral:
|
|
|
|
case FeedbackSlotKind::kGeneral:
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, *uninitialized_sentinel, SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
|
|
|
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kInvalid:
|
|
|
|
case FeedbackSlotKind::kKindsNumber:
|
2017-02-01 16:22:03 +00:00
|
|
|
UNREACHABLE();
|
2017-02-06 10:18:05 +00:00
|
|
|
array->set(index, Smi::kZero, SKIP_WRITE_BARRIER);
|
2017-02-01 16:22:03 +00:00
|
|
|
break;
|
2016-06-15 12:34:57 +00:00
|
|
|
}
|
2017-02-01 16:22:03 +00:00
|
|
|
for (int j = 1; j < entry_size; j++) {
|
|
|
|
array->set(index + j, extra_value, SKIP_WRITE_BARRIER);
|
2016-06-15 12:34:57 +00:00
|
|
|
}
|
|
|
|
i += entry_size;
|
|
|
|
}
|
2017-02-10 08:21:03 +00:00
|
|
|
|
|
|
|
Handle<FeedbackVector> result = Handle<FeedbackVector>::cast(array);
|
|
|
|
if (isolate->IsCodeCoverageEnabled()) AddToCodeCoverageList(isolate, result);
|
|
|
|
return result;
|
2014-10-20 11:42:56 +00:00
|
|
|
}
|
|
|
|
|
2014-09-18 09:59:53 +00:00
|
|
|
// static
|
2017-02-07 14:05:02 +00:00
|
|
|
Handle<FeedbackVector> FeedbackVector::Copy(Isolate* isolate,
|
|
|
|
Handle<FeedbackVector> vector) {
|
|
|
|
Handle<FeedbackVector> result;
|
|
|
|
result = Handle<FeedbackVector>::cast(
|
2014-09-18 09:59:53 +00:00
|
|
|
isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector)));
|
2017-02-10 08:21:03 +00:00
|
|
|
if (isolate->IsCodeCoverageEnabled()) AddToCodeCoverageList(isolate, result);
|
2014-09-18 09:59:53 +00:00
|
|
|
return result;
|
|
|
|
}
|
2014-10-20 11:42:56 +00:00
|
|
|
|
2017-02-10 08:21:03 +00:00
|
|
|
// static
|
|
|
|
void FeedbackVector::AddToCodeCoverageList(Isolate* isolate,
|
|
|
|
Handle<FeedbackVector> vector) {
|
|
|
|
DCHECK(isolate->IsCodeCoverageEnabled());
|
|
|
|
if (!vector->shared_function_info()->IsSubjectToDebugging()) return;
|
|
|
|
Handle<ArrayList> list =
|
|
|
|
Handle<ArrayList>::cast(isolate->factory()->code_coverage_list());
|
|
|
|
list = ArrayList::Add(list, vector);
|
|
|
|
isolate->SetCodeCoverageList(*list);
|
|
|
|
}
|
|
|
|
|
2017-02-15 12:12:46 +00:00
|
|
|
void FeedbackVector::ClearSlots(JSFunction* host_function) {
|
2015-10-01 13:48:05 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2016-12-21 14:06:29 +00:00
|
|
|
|
2015-04-02 09:39:32 +00:00
|
|
|
Object* uninitialized_sentinel =
|
2017-02-07 14:05:02 +00:00
|
|
|
FeedbackVector::RawUninitializedSentinel(isolate);
|
2017-01-30 12:31:35 +00:00
|
|
|
Oddball* undefined_value = isolate->heap()->undefined_value();
|
2014-10-20 11:42:56 +00:00
|
|
|
|
2017-02-15 12:12:46 +00:00
|
|
|
bool feedback_updated = false;
|
2017-02-07 14:05:02 +00:00
|
|
|
FeedbackMetadataIterator iter(metadata());
|
2015-10-01 13:48:05 +00:00
|
|
|
while (iter.HasNext()) {
|
2017-02-07 15:19:35 +00:00
|
|
|
FeedbackSlot slot = iter.Next();
|
|
|
|
FeedbackSlotKind kind = iter.kind();
|
2015-02-04 09:46:05 +00:00
|
|
|
|
2014-10-20 11:42:56 +00:00
|
|
|
Object* obj = Get(slot);
|
|
|
|
if (obj != uninitialized_sentinel) {
|
2015-09-28 08:23:35 +00:00
|
|
|
switch (kind) {
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCall: {
|
2015-09-28 08:23:35 +00:00
|
|
|
CallICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2015-09-28 08:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadProperty: {
|
2015-09-28 08:23:35 +00:00
|
|
|
LoadICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2015-09-28 08:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadGlobalInsideTypeof:
|
|
|
|
case FeedbackSlotKind::kLoadGlobalNotInsideTypeof: {
|
2016-06-14 13:20:42 +00:00
|
|
|
LoadGlobalICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2016-06-14 13:20:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLoadKeyed: {
|
2015-09-28 08:23:35 +00:00
|
|
|
KeyedLoadICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2015-09-28 08:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStorePropertySloppy:
|
|
|
|
case FeedbackSlotKind::kStorePropertyStrict: {
|
2015-09-28 08:23:35 +00:00
|
|
|
StoreICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2015-09-28 08:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStoreKeyedSloppy:
|
|
|
|
case FeedbackSlotKind::kStoreKeyedStrict: {
|
2015-09-28 08:23:35 +00:00
|
|
|
KeyedStoreICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2015-10-01 13:48:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kBinaryOp:
|
|
|
|
case FeedbackSlotKind::kCompareOp: {
|
2016-09-20 13:53:32 +00:00
|
|
|
DCHECK(Get(slot)->IsSmi());
|
|
|
|
// don't clear these smi slots.
|
2016-10-07 13:05:07 +00:00
|
|
|
// Set(slot, Smi::kZero);
|
2016-09-20 13:53:32 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kCreateClosure: {
|
2017-01-09 15:31:00 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kGeneral: {
|
2015-10-01 13:48:05 +00:00
|
|
|
if (obj->IsHeapObject()) {
|
|
|
|
InstanceType instance_type =
|
|
|
|
HeapObject::cast(obj)->map()->instance_type();
|
|
|
|
// AllocationSites are exempt from clearing. They don't store Maps
|
|
|
|
// or Code pointers which can cause memory leaks if not cleared
|
|
|
|
// regularly.
|
|
|
|
if (instance_type != ALLOCATION_SITE_TYPE) {
|
|
|
|
Set(slot, uninitialized_sentinel, SKIP_WRITE_BARRIER);
|
2017-02-15 12:12:46 +00:00
|
|
|
feedback_updated = true;
|
2015-10-01 13:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-28 08:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kLiteral: {
|
2017-01-30 12:31:35 +00:00
|
|
|
Set(slot, undefined_value, SKIP_WRITE_BARRIER);
|
2017-02-15 12:12:46 +00:00
|
|
|
feedback_updated = true;
|
2017-01-30 12:31:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kStoreDataPropertyInLiteral: {
|
2017-01-05 07:30:01 +00:00
|
|
|
StoreDataPropertyInLiteralICNexus nexus(this, slot);
|
2017-02-15 12:12:46 +00:00
|
|
|
if (!nexus.IsCleared()) {
|
|
|
|
nexus.Clear();
|
|
|
|
feedback_updated = true;
|
|
|
|
}
|
2017-01-05 07:30:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-02-07 17:49:58 +00:00
|
|
|
case FeedbackSlotKind::kToBoolean:
|
|
|
|
case FeedbackSlotKind::kInvalid:
|
|
|
|
case FeedbackSlotKind::kKindsNumber:
|
2015-09-28 08:23:35 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
break;
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
2014-10-20 11:42:56 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-15 12:12:46 +00:00
|
|
|
if (feedback_updated) {
|
|
|
|
IC::OnFeedbackChanged(isolate, host_function);
|
|
|
|
}
|
2014-10-20 11:42:56 +00:00
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
|
|
|
|
Handle<FixedArray> FeedbackNexus::EnsureArrayOfSize(int length) {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Handle<Object> feedback = handle(GetFeedback(), isolate);
|
|
|
|
if (!feedback->IsFixedArray() ||
|
|
|
|
FixedArray::cast(*feedback)->length() != length) {
|
|
|
|
Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
|
|
|
|
SetFeedback(*array);
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
return Handle<FixedArray>::cast(feedback);
|
|
|
|
}
|
|
|
|
|
2015-03-17 11:28:09 +00:00
|
|
|
Handle<FixedArray> FeedbackNexus::EnsureExtraArrayOfSize(int length) {
|
2014-10-28 16:05:08 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2015-03-17 11:28:09 +00:00
|
|
|
Handle<Object> feedback_extra = handle(GetFeedbackExtra(), isolate);
|
|
|
|
if (!feedback_extra->IsFixedArray() ||
|
|
|
|
FixedArray::cast(*feedback_extra)->length() != length) {
|
|
|
|
Handle<FixedArray> array = isolate->factory()->NewFixedArray(length);
|
|
|
|
SetFeedbackExtra(*array);
|
|
|
|
return array;
|
|
|
|
}
|
|
|
|
return Handle<FixedArray>::cast(feedback_extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FeedbackNexus::InstallHandlers(Handle<FixedArray> array,
|
|
|
|
MapHandleList* maps,
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-02-17 15:33:26 +00:00
|
|
|
int receiver_count = maps->length();
|
2014-10-28 16:05:08 +00:00
|
|
|
for (int current = 0; current < receiver_count; ++current) {
|
2015-02-17 15:33:26 +00:00
|
|
|
Handle<Map> map = maps->at(current);
|
2014-12-19 16:53:41 +00:00
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(map);
|
2015-03-17 11:28:09 +00:00
|
|
|
array->set(current * 2, *cell);
|
|
|
|
array->set(current * 2 + 1, *handlers->at(current));
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void FeedbackNexus::ConfigureUninitialized() {
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FeedbackNexus::ConfigurePremonomorphic() {
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::PremonomorphicSentinel(GetIsolate()),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FeedbackNexus::ConfigureMegamorphic() {
|
2016-04-21 13:18:00 +00:00
|
|
|
// Keyed ICs must use ConfigureMegamorphicKeyed.
|
2017-02-01 16:22:03 +00:00
|
|
|
DCHECK(!vector()->IsKeyedLoadIC(slot()));
|
|
|
|
DCHECK(!vector()->IsKeyedStoreIC(slot()));
|
2016-04-21 13:18:00 +00:00
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::MegamorphicSentinel(isolate),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(isolate),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
2016-04-21 13:18:00 +00:00
|
|
|
void KeyedLoadICNexus::ConfigureMegamorphicKeyed(IcCheckType property_type) {
|
|
|
|
Isolate* isolate = GetIsolate();
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::MegamorphicSentinel(isolate),
|
2016-04-21 13:18:00 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
SetFeedbackExtra(Smi::FromInt(static_cast<int>(property_type)),
|
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KeyedStoreICNexus::ConfigureMegamorphicKeyed(IcCheckType property_type) {
|
|
|
|
Isolate* isolate = GetIsolate();
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::MegamorphicSentinel(isolate),
|
2016-04-21 13:18:00 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
SetFeedbackExtra(Smi::FromInt(static_cast<int>(property_type)),
|
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
2015-06-30 09:51:43 +00:00
|
|
|
|
2014-11-27 16:36:18 +00:00
|
|
|
InlineCacheState LoadICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
2015-03-17 11:28:09 +00:00
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return UNINITIALIZED;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return MEGAMORPHIC;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::PremonomorphicSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return PREMONOMORPHIC;
|
|
|
|
} else if (feedback->IsFixedArray()) {
|
2014-12-19 16:53:41 +00:00
|
|
|
// Determine state purely by our structure, don't check if the maps are
|
|
|
|
// cleared.
|
2015-03-17 11:28:09 +00:00
|
|
|
return POLYMORPHIC;
|
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
// Don't check if the map is cleared.
|
|
|
|
return MONOMORPHIC;
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2016-06-14 13:20:42 +00:00
|
|
|
InlineCacheState LoadGlobalICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
|
|
|
|
2016-06-16 09:47:52 +00:00
|
|
|
Object* extra = GetFeedbackExtra();
|
|
|
|
if (!WeakCell::cast(feedback)->cleared() ||
|
2017-02-07 14:05:02 +00:00
|
|
|
extra != *FeedbackVector::UninitializedSentinel(isolate)) {
|
2016-06-16 09:47:52 +00:00
|
|
|
return MONOMORPHIC;
|
2016-06-15 12:34:57 +00:00
|
|
|
}
|
2016-06-14 13:20:42 +00:00
|
|
|
return UNINITIALIZED;
|
|
|
|
}
|
2014-11-27 16:36:18 +00:00
|
|
|
|
|
|
|
InlineCacheState KeyedLoadICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
2015-03-17 11:28:09 +00:00
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return UNINITIALIZED;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::PremonomorphicSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return PREMONOMORPHIC;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
|
2015-01-30 12:40:57 +00:00
|
|
|
return MEGAMORPHIC;
|
2014-11-27 16:36:18 +00:00
|
|
|
} else if (feedback->IsFixedArray()) {
|
2014-12-19 16:53:41 +00:00
|
|
|
// Determine state purely by our structure, don't check if the maps are
|
|
|
|
// cleared.
|
2015-03-17 11:28:09 +00:00
|
|
|
return POLYMORPHIC;
|
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
// Don't check if the map is cleared.
|
|
|
|
return MONOMORPHIC;
|
|
|
|
} else if (feedback->IsName()) {
|
|
|
|
Object* extra = GetFeedbackExtra();
|
|
|
|
FixedArray* extra_array = FixedArray::cast(extra);
|
|
|
|
return extra_array->length() > 2 ? POLYMORPHIC : MONOMORPHIC;
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
InlineCacheState StoreICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return UNINITIALIZED;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return MEGAMORPHIC;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::PremonomorphicSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return PREMONOMORPHIC;
|
|
|
|
} else if (feedback->IsFixedArray()) {
|
|
|
|
// Determine state purely by our structure, don't check if the maps are
|
|
|
|
// cleared.
|
|
|
|
return POLYMORPHIC;
|
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
// Don't check if the map is cleared.
|
|
|
|
return MONOMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
InlineCacheState KeyedStoreICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return UNINITIALIZED;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::PremonomorphicSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return PREMONOMORPHIC;
|
2017-02-07 14:05:02 +00:00
|
|
|
} else if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return MEGAMORPHIC;
|
|
|
|
} else if (feedback->IsFixedArray()) {
|
|
|
|
// Determine state purely by our structure, don't check if the maps are
|
|
|
|
// cleared.
|
|
|
|
return POLYMORPHIC;
|
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
// Don't check if the map is cleared.
|
|
|
|
return MONOMORPHIC;
|
|
|
|
} else if (feedback->IsName()) {
|
|
|
|
Object* extra = GetFeedbackExtra();
|
|
|
|
FixedArray* extra_array = FixedArray::cast(extra);
|
|
|
|
return extra_array->length() > 2 ? POLYMORPHIC : MONOMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return UNINITIALIZED;
|
|
|
|
}
|
|
|
|
|
2014-10-28 16:05:08 +00:00
|
|
|
InlineCacheState CallICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
2015-06-25 08:43:28 +00:00
|
|
|
DCHECK(GetFeedbackExtra() ==
|
2017-02-07 14:05:02 +00:00
|
|
|
*FeedbackVector::UninitializedSentinel(isolate) ||
|
2015-06-25 08:43:28 +00:00
|
|
|
GetFeedbackExtra()->IsSmi());
|
2014-10-28 16:05:08 +00:00
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::MegamorphicSentinel(isolate)) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return GENERIC;
|
2015-02-04 09:46:05 +00:00
|
|
|
} else if (feedback->IsAllocationSite() || feedback->IsWeakCell()) {
|
2014-11-27 16:36:18 +00:00
|
|
|
return MONOMORPHIC;
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
CHECK(feedback == *FeedbackVector::UninitializedSentinel(isolate));
|
2014-11-27 16:36:18 +00:00
|
|
|
return UNINITIALIZED;
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
2015-06-25 08:43:28 +00:00
|
|
|
int CallICNexus::ExtractCallCount() {
|
|
|
|
Object* call_count = GetFeedbackExtra();
|
2016-09-13 11:03:43 +00:00
|
|
|
CHECK(call_count->IsSmi());
|
|
|
|
int value = Smi::cast(call_count)->value();
|
|
|
|
return value;
|
2015-06-25 08:43:28 +00:00
|
|
|
}
|
|
|
|
|
2016-09-14 10:20:08 +00:00
|
|
|
float CallICNexus::ComputeCallFrequency() {
|
|
|
|
double const invocation_count = vector()->invocation_count();
|
|
|
|
double const call_count = ExtractCallCount();
|
|
|
|
return static_cast<float>(call_count / invocation_count);
|
|
|
|
}
|
|
|
|
|
2016-09-13 11:03:43 +00:00
|
|
|
void CallICNexus::ConfigureUninitialized() {
|
|
|
|
Isolate* isolate = GetIsolate();
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::UninitializedSentinel(isolate),
|
2016-09-13 11:03:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2016-10-07 13:05:07 +00:00
|
|
|
SetFeedbackExtra(Smi::kZero, SKIP_WRITE_BARRIER);
|
2016-09-13 11:03:43 +00:00
|
|
|
}
|
2014-11-27 16:36:18 +00:00
|
|
|
|
2014-10-28 16:05:08 +00:00
|
|
|
void CallICNexus::ConfigureMonomorphicArray() {
|
|
|
|
Object* feedback = GetFeedback();
|
|
|
|
if (!feedback->IsAllocationSite()) {
|
|
|
|
Handle<AllocationSite> new_site =
|
|
|
|
GetIsolate()->factory()->NewAllocationSite();
|
|
|
|
SetFeedback(*new_site);
|
|
|
|
}
|
2016-05-30 20:42:43 +00:00
|
|
|
SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER);
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CallICNexus::ConfigureMonomorphic(Handle<JSFunction> function) {
|
2015-02-04 09:46:05 +00:00
|
|
|
Handle<WeakCell> new_cell = GetIsolate()->factory()->NewWeakCell(function);
|
|
|
|
SetFeedback(*new_cell);
|
2016-05-30 20:42:43 +00:00
|
|
|
SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER);
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 12:19:37 +00:00
|
|
|
void CallICNexus::ConfigureMegamorphic() {
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::MegamorphicSentinel(GetIsolate()),
|
2016-09-13 11:03:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
Smi* count = Smi::cast(GetFeedbackExtra());
|
|
|
|
int new_count = count->value() + 1;
|
|
|
|
SetFeedbackExtra(Smi::FromInt(new_count), SKIP_WRITE_BARRIER);
|
2015-11-13 12:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CallICNexus::ConfigureMegamorphic(int call_count) {
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedback(*FeedbackVector::MegamorphicSentinel(GetIsolate()),
|
2015-11-13 12:19:37 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2016-05-30 20:42:43 +00:00
|
|
|
SetFeedbackExtra(Smi::FromInt(call_count), SKIP_WRITE_BARRIER);
|
2015-11-13 12:19:37 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void LoadICNexus::ConfigureMonomorphic(Handle<Map> receiver_map,
|
2016-07-15 17:41:14 +00:00
|
|
|
Handle<Object> handler) {
|
2015-06-30 09:51:43 +00:00
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
|
|
|
|
SetFeedback(*cell);
|
|
|
|
SetFeedbackExtra(*handler);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
2016-06-15 12:34:57 +00:00
|
|
|
void LoadGlobalICNexus::ConfigureUninitialized() {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
SetFeedback(isolate->heap()->empty_weak_cell(), SKIP_WRITE_BARRIER);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(isolate),
|
2016-06-15 12:34:57 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadGlobalICNexus::ConfigurePropertyCellMode(Handle<PropertyCell> cell) {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
SetFeedback(*isolate->factory()->NewWeakCell(cell));
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(isolate),
|
2016-06-15 12:34:57 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
2016-11-17 12:18:22 +00:00
|
|
|
void LoadGlobalICNexus::ConfigureHandlerMode(Handle<Object> handler) {
|
2016-06-15 12:34:57 +00:00
|
|
|
SetFeedback(GetIsolate()->heap()->empty_weak_cell());
|
|
|
|
SetFeedbackExtra(*handler);
|
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void KeyedLoadICNexus::ConfigureMonomorphic(Handle<Name> name,
|
|
|
|
Handle<Map> receiver_map,
|
2016-07-26 17:51:25 +00:00
|
|
|
Handle<Object> handler) {
|
2015-06-30 09:51:43 +00:00
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
|
|
|
|
if (name.is_null()) {
|
|
|
|
SetFeedback(*cell);
|
|
|
|
SetFeedbackExtra(*handler);
|
|
|
|
} else {
|
|
|
|
Handle<FixedArray> array = EnsureExtraArrayOfSize(2);
|
2015-12-10 17:39:51 +00:00
|
|
|
SetFeedback(*name);
|
2015-06-30 09:51:43 +00:00
|
|
|
array->set(0, *cell);
|
|
|
|
array->set(1, *handler);
|
|
|
|
}
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void StoreICNexus::ConfigureMonomorphic(Handle<Map> receiver_map,
|
2016-10-24 10:00:04 +00:00
|
|
|
Handle<Object> handler) {
|
2014-12-19 16:53:41 +00:00
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
|
2015-03-17 11:28:09 +00:00
|
|
|
SetFeedback(*cell);
|
|
|
|
SetFeedbackExtra(*handler);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void KeyedStoreICNexus::ConfigureMonomorphic(Handle<Name> name,
|
|
|
|
Handle<Map> receiver_map,
|
2016-10-24 10:00:04 +00:00
|
|
|
Handle<Object> handler) {
|
2015-03-17 11:28:09 +00:00
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
|
2014-11-27 16:36:18 +00:00
|
|
|
if (name.is_null()) {
|
2015-03-17 11:28:09 +00:00
|
|
|
SetFeedback(*cell);
|
|
|
|
SetFeedbackExtra(*handler);
|
2014-11-27 16:36:18 +00:00
|
|
|
} else {
|
2015-03-17 11:28:09 +00:00
|
|
|
Handle<FixedArray> array = EnsureExtraArrayOfSize(2);
|
2015-12-10 17:39:51 +00:00
|
|
|
SetFeedback(*name);
|
2015-03-17 11:28:09 +00:00
|
|
|
array->set(0, *cell);
|
|
|
|
array->set(1, *handler);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:33:26 +00:00
|
|
|
void LoadICNexus::ConfigurePolymorphic(MapHandleList* maps,
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-03-17 11:28:09 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2015-02-17 15:33:26 +00:00
|
|
|
int receiver_count = maps->length();
|
2015-03-17 11:28:09 +00:00
|
|
|
Handle<FixedArray> array = EnsureArrayOfSize(receiver_count * 2);
|
|
|
|
InstallHandlers(array, maps, handlers);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(isolate),
|
2015-03-17 11:28:09 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeyedLoadICNexus::ConfigurePolymorphic(Handle<Name> name,
|
2015-02-17 15:33:26 +00:00
|
|
|
MapHandleList* maps,
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-02-17 15:33:26 +00:00
|
|
|
int receiver_count = maps->length();
|
2015-03-17 11:28:09 +00:00
|
|
|
DCHECK(receiver_count > 1);
|
|
|
|
Handle<FixedArray> array;
|
2014-11-27 16:36:18 +00:00
|
|
|
if (name.is_null()) {
|
2015-03-17 11:28:09 +00:00
|
|
|
array = EnsureArrayOfSize(receiver_count * 2);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-03-17 11:28:09 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
2014-11-27 16:36:18 +00:00
|
|
|
} else {
|
2015-03-17 11:28:09 +00:00
|
|
|
array = EnsureExtraArrayOfSize(receiver_count * 2);
|
2015-12-10 17:39:51 +00:00
|
|
|
SetFeedback(*name);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
2015-03-17 11:28:09 +00:00
|
|
|
|
|
|
|
InstallHandlers(array, maps, handlers);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 09:51:43 +00:00
|
|
|
void StoreICNexus::ConfigurePolymorphic(MapHandleList* maps,
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-06-30 09:51:43 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
int receiver_count = maps->length();
|
|
|
|
Handle<FixedArray> array = EnsureArrayOfSize(receiver_count * 2);
|
|
|
|
InstallHandlers(array, maps, handlers);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(isolate),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KeyedStoreICNexus::ConfigurePolymorphic(Handle<Name> name,
|
|
|
|
MapHandleList* maps,
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-06-30 09:51:43 +00:00
|
|
|
int receiver_count = maps->length();
|
|
|
|
DCHECK(receiver_count > 1);
|
|
|
|
Handle<FixedArray> array;
|
|
|
|
if (name.is_null()) {
|
|
|
|
array = EnsureArrayOfSize(receiver_count * 2);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-06-30 09:51:43 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
} else {
|
|
|
|
array = EnsureExtraArrayOfSize(receiver_count * 2);
|
2015-12-10 17:39:51 +00:00
|
|
|
SetFeedback(*name);
|
2015-06-30 09:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
InstallHandlers(array, maps, handlers);
|
|
|
|
}
|
|
|
|
|
2015-08-28 09:01:22 +00:00
|
|
|
void KeyedStoreICNexus::ConfigurePolymorphic(MapHandleList* maps,
|
|
|
|
MapHandleList* transitioned_maps,
|
2016-12-02 10:03:18 +00:00
|
|
|
List<Handle<Object>>* handlers) {
|
2015-08-28 09:01:22 +00:00
|
|
|
int receiver_count = maps->length();
|
|
|
|
DCHECK(receiver_count > 1);
|
|
|
|
Handle<FixedArray> array = EnsureArrayOfSize(receiver_count * 3);
|
2017-02-07 14:05:02 +00:00
|
|
|
SetFeedbackExtra(*FeedbackVector::UninitializedSentinel(GetIsolate()),
|
2015-08-28 09:01:22 +00:00
|
|
|
SKIP_WRITE_BARRIER);
|
|
|
|
|
|
|
|
Handle<Oddball> undefined_value = GetIsolate()->factory()->undefined_value();
|
|
|
|
for (int i = 0; i < receiver_count; ++i) {
|
|
|
|
Handle<Map> map = maps->at(i);
|
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(map);
|
|
|
|
array->set(i * 3, *cell);
|
|
|
|
if (!transitioned_maps->at(i).is_null()) {
|
|
|
|
Handle<Map> transitioned_map = transitioned_maps->at(i);
|
|
|
|
cell = Map::WeakCellForMap(transitioned_map);
|
|
|
|
array->set((i * 3) + 1, *cell);
|
|
|
|
} else {
|
|
|
|
array->set((i * 3) + 1, *undefined_value);
|
|
|
|
}
|
|
|
|
array->set((i * 3) + 2, *handlers->at(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-15 17:41:14 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
int GetStepSize(FixedArray* array, Isolate* isolate) {
|
|
|
|
// The array should be of the form
|
|
|
|
// [map, handler, map, handler, ...]
|
|
|
|
// or
|
|
|
|
// [map, map, handler, map, map, handler, ...]
|
|
|
|
// where "map" is either a WeakCell or |undefined|,
|
|
|
|
// and "handler" is either a Code object or a Smi.
|
|
|
|
DCHECK(array->length() >= 2);
|
|
|
|
Object* second = array->get(1);
|
|
|
|
if (second->IsWeakCell() || second->IsUndefined(isolate)) return 3;
|
2016-10-13 12:02:05 +00:00
|
|
|
DCHECK(IC::IsHandler(second));
|
2016-07-15 17:41:14 +00:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2015-08-28 09:01:22 +00:00
|
|
|
|
2015-03-17 11:28:09 +00:00
|
|
|
int FeedbackNexus::ExtractMaps(MapHandleList* maps) const {
|
2014-10-28 16:05:08 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
2015-10-23 08:17:48 +00:00
|
|
|
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
|
|
|
if (feedback->IsFixedArray() || is_named_feedback) {
|
2014-12-19 16:53:41 +00:00
|
|
|
int found = 0;
|
2015-10-23 08:17:48 +00:00
|
|
|
if (is_named_feedback) {
|
2015-03-17 11:28:09 +00:00
|
|
|
feedback = GetFeedbackExtra();
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
FixedArray* array = FixedArray::cast(feedback);
|
2016-07-15 17:41:14 +00:00
|
|
|
int increment = GetStepSize(array, isolate);
|
2015-08-28 09:01:22 +00:00
|
|
|
for (int i = 0; i < array->length(); i += increment) {
|
2015-03-19 14:22:28 +00:00
|
|
|
DCHECK(array->get(i)->IsWeakCell());
|
2014-12-19 16:53:41 +00:00
|
|
|
WeakCell* cell = WeakCell::cast(array->get(i));
|
|
|
|
if (!cell->cleared()) {
|
|
|
|
Map* map = Map::cast(cell->value());
|
|
|
|
maps->Add(handle(map, isolate));
|
|
|
|
found++;
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
2014-12-19 16:53:41 +00:00
|
|
|
return found;
|
2015-03-17 11:28:09 +00:00
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
WeakCell* cell = WeakCell::cast(feedback);
|
|
|
|
if (!cell->cleared()) {
|
|
|
|
Map* map = Map::cast(cell->value());
|
|
|
|
maps->Add(handle(map, isolate));
|
|
|
|
return 1;
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-15 17:41:14 +00:00
|
|
|
MaybeHandle<Object> FeedbackNexus::FindHandlerForMap(Handle<Map> map) const {
|
2014-10-28 16:05:08 +00:00
|
|
|
Object* feedback = GetFeedback();
|
2016-07-15 17:41:14 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2015-10-23 08:17:48 +00:00
|
|
|
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
|
|
|
if (feedback->IsFixedArray() || is_named_feedback) {
|
|
|
|
if (is_named_feedback) {
|
2015-03-17 11:28:09 +00:00
|
|
|
feedback = GetFeedbackExtra();
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
FixedArray* array = FixedArray::cast(feedback);
|
2016-07-15 17:41:14 +00:00
|
|
|
int increment = GetStepSize(array, isolate);
|
2015-08-28 09:01:22 +00:00
|
|
|
for (int i = 0; i < array->length(); i += increment) {
|
2015-03-19 14:22:28 +00:00
|
|
|
DCHECK(array->get(i)->IsWeakCell());
|
2014-12-19 16:53:41 +00:00
|
|
|
WeakCell* cell = WeakCell::cast(array->get(i));
|
|
|
|
if (!cell->cleared()) {
|
|
|
|
Map* array_map = Map::cast(cell->value());
|
|
|
|
if (array_map == *map) {
|
2016-07-15 17:41:14 +00:00
|
|
|
Object* code = array->get(i + increment - 1);
|
2016-10-13 12:02:05 +00:00
|
|
|
DCHECK(IC::IsHandler(code));
|
2016-07-15 17:41:14 +00:00
|
|
|
return handle(code, isolate);
|
2014-12-19 16:53:41 +00:00
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-17 11:28:09 +00:00
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
WeakCell* cell = WeakCell::cast(feedback);
|
|
|
|
if (!cell->cleared()) {
|
|
|
|
Map* cell_map = Map::cast(cell->value());
|
|
|
|
if (cell_map == *map) {
|
2016-07-15 17:41:14 +00:00
|
|
|
Object* code = GetFeedbackExtra();
|
2016-10-13 12:02:05 +00:00
|
|
|
DCHECK(IC::IsHandler(code));
|
2016-07-15 17:41:14 +00:00
|
|
|
return handle(code, isolate);
|
2015-03-17 11:28:09 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return MaybeHandle<Code>();
|
|
|
|
}
|
|
|
|
|
2016-07-15 17:41:14 +00:00
|
|
|
bool FeedbackNexus::FindHandlers(List<Handle<Object>>* code_list,
|
|
|
|
int length) const {
|
2014-10-28 16:05:08 +00:00
|
|
|
Object* feedback = GetFeedback();
|
2016-07-15 17:41:14 +00:00
|
|
|
Isolate* isolate = GetIsolate();
|
2014-10-28 16:05:08 +00:00
|
|
|
int count = 0;
|
2015-10-23 08:17:48 +00:00
|
|
|
bool is_named_feedback = IsPropertyNameFeedback(feedback);
|
|
|
|
if (feedback->IsFixedArray() || is_named_feedback) {
|
|
|
|
if (is_named_feedback) {
|
2015-03-17 11:28:09 +00:00
|
|
|
feedback = GetFeedbackExtra();
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
FixedArray* array = FixedArray::cast(feedback);
|
2016-07-15 17:41:14 +00:00
|
|
|
int increment = GetStepSize(array, isolate);
|
2015-08-28 09:01:22 +00:00
|
|
|
for (int i = 0; i < array->length(); i += increment) {
|
2015-03-19 14:22:28 +00:00
|
|
|
DCHECK(array->get(i)->IsWeakCell());
|
2014-12-19 16:53:41 +00:00
|
|
|
WeakCell* cell = WeakCell::cast(array->get(i));
|
2016-07-15 17:41:14 +00:00
|
|
|
// Be sure to skip handlers whose maps have been cleared.
|
2014-12-19 16:53:41 +00:00
|
|
|
if (!cell->cleared()) {
|
2016-07-15 17:41:14 +00:00
|
|
|
Object* code = array->get(i + increment - 1);
|
2016-10-13 12:02:05 +00:00
|
|
|
DCHECK(IC::IsHandler(code));
|
2016-07-15 17:41:14 +00:00
|
|
|
code_list->Add(handle(code, isolate));
|
2014-12-19 16:53:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
2015-03-17 11:28:09 +00:00
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
WeakCell* cell = WeakCell::cast(feedback);
|
|
|
|
if (!cell->cleared()) {
|
2016-07-15 17:41:14 +00:00
|
|
|
Object* code = GetFeedbackExtra();
|
2016-10-13 12:02:05 +00:00
|
|
|
DCHECK(IC::IsHandler(code));
|
2016-07-15 17:41:14 +00:00
|
|
|
code_list->Add(handle(code, isolate));
|
2015-03-17 11:28:09 +00:00
|
|
|
count++;
|
|
|
|
}
|
2014-10-28 16:05:08 +00:00
|
|
|
}
|
|
|
|
return count == length;
|
|
|
|
}
|
2014-11-27 16:36:18 +00:00
|
|
|
|
|
|
|
Name* KeyedLoadICNexus::FindFirstName() const {
|
|
|
|
Object* feedback = GetFeedback();
|
2015-10-23 08:17:48 +00:00
|
|
|
if (IsPropertyNameFeedback(feedback)) {
|
2015-03-17 11:28:09 +00:00
|
|
|
return Name::cast(feedback);
|
2014-11-27 16:36:18 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-06-30 09:51:43 +00:00
|
|
|
|
|
|
|
Name* KeyedStoreICNexus::FindFirstName() const {
|
|
|
|
Object* feedback = GetFeedback();
|
2015-10-23 08:17:48 +00:00
|
|
|
if (IsPropertyNameFeedback(feedback)) {
|
2015-06-30 09:51:43 +00:00
|
|
|
return Name::cast(feedback);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-08-28 09:01:22 +00:00
|
|
|
KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const {
|
|
|
|
KeyedAccessStoreMode mode = STANDARD_STORE;
|
|
|
|
MapHandleList maps;
|
2016-07-15 17:41:14 +00:00
|
|
|
List<Handle<Object>> handlers;
|
2015-08-28 09:01:22 +00:00
|
|
|
|
|
|
|
if (GetKeyType() == PROPERTY) return mode;
|
|
|
|
|
|
|
|
ExtractMaps(&maps);
|
|
|
|
FindHandlers(&handlers, maps.length());
|
|
|
|
for (int i = 0; i < handlers.length(); i++) {
|
|
|
|
// The first handler that isn't the slow handler will have the bits we need.
|
2016-12-02 10:03:18 +00:00
|
|
|
Handle<Object> maybe_code_handler = handlers.at(i);
|
|
|
|
Handle<Code> handler;
|
|
|
|
if (maybe_code_handler->IsTuple2()) {
|
|
|
|
Handle<Tuple2> data_handler = Handle<Tuple2>::cast(maybe_code_handler);
|
|
|
|
handler = handle(Code::cast(data_handler->value2()));
|
|
|
|
} else {
|
|
|
|
handler = Handle<Code>::cast(maybe_code_handler);
|
|
|
|
}
|
2015-08-28 09:01:22 +00:00
|
|
|
CodeStub::Major major_key = CodeStub::MajorKeyFromKey(handler->stub_key());
|
|
|
|
uint32_t minor_key = CodeStub::MinorKeyFromKey(handler->stub_key());
|
|
|
|
CHECK(major_key == CodeStub::KeyedStoreSloppyArguments ||
|
|
|
|
major_key == CodeStub::StoreFastElement ||
|
2017-02-06 10:04:58 +00:00
|
|
|
major_key == CodeStub::StoreSlowElement ||
|
2015-08-28 09:01:22 +00:00
|
|
|
major_key == CodeStub::ElementsTransitionAndStore ||
|
|
|
|
major_key == CodeStub::NoCache);
|
|
|
|
if (major_key != CodeStub::NoCache) {
|
|
|
|
mode = CommonStoreModeBits::decode(minor_key);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return mode;
|
|
|
|
}
|
|
|
|
|
2016-04-21 13:18:00 +00:00
|
|
|
IcCheckType KeyedLoadICNexus::GetKeyType() const {
|
|
|
|
Object* feedback = GetFeedback();
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::MegamorphicSentinel(GetIsolate())) {
|
2016-04-21 13:18:00 +00:00
|
|
|
return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
|
|
|
|
}
|
|
|
|
return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
|
|
|
|
}
|
2015-08-28 09:01:22 +00:00
|
|
|
|
|
|
|
IcCheckType KeyedStoreICNexus::GetKeyType() const {
|
2016-04-21 13:18:00 +00:00
|
|
|
Object* feedback = GetFeedback();
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::MegamorphicSentinel(GetIsolate())) {
|
2016-04-21 13:18:00 +00:00
|
|
|
return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
|
|
|
|
}
|
|
|
|
return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
|
2015-08-28 09:01:22 +00:00
|
|
|
}
|
2016-09-20 13:53:32 +00:00
|
|
|
|
|
|
|
InlineCacheState BinaryOpICNexus::StateFromFeedback() const {
|
|
|
|
BinaryOperationHint hint = GetBinaryOperationFeedback();
|
|
|
|
if (hint == BinaryOperationHint::kNone) {
|
|
|
|
return UNINITIALIZED;
|
|
|
|
} else if (hint == BinaryOperationHint::kAny) {
|
|
|
|
return GENERIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MONOMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
InlineCacheState CompareICNexus::StateFromFeedback() const {
|
|
|
|
CompareOperationHint hint = GetCompareOperationFeedback();
|
|
|
|
if (hint == CompareOperationHint::kNone) {
|
|
|
|
return UNINITIALIZED;
|
|
|
|
} else if (hint == CompareOperationHint::kAny) {
|
|
|
|
return GENERIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MONOMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
BinaryOperationHint BinaryOpICNexus::GetBinaryOperationFeedback() const {
|
|
|
|
int feedback = Smi::cast(GetFeedback())->value();
|
|
|
|
return BinaryOperationHintFromFeedback(feedback);
|
|
|
|
}
|
|
|
|
|
|
|
|
CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const {
|
|
|
|
int feedback = Smi::cast(GetFeedback())->value();
|
|
|
|
return CompareOperationHintFromFeedback(feedback);
|
|
|
|
}
|
|
|
|
|
2017-01-05 07:30:01 +00:00
|
|
|
InlineCacheState StoreDataPropertyInLiteralICNexus::StateFromFeedback() const {
|
|
|
|
Isolate* isolate = GetIsolate();
|
|
|
|
Object* feedback = GetFeedback();
|
|
|
|
|
2017-02-07 14:05:02 +00:00
|
|
|
if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) {
|
2017-01-05 07:30:01 +00:00
|
|
|
return UNINITIALIZED;
|
|
|
|
} else if (feedback->IsWeakCell()) {
|
|
|
|
// Don't check if the map is cleared.
|
|
|
|
return MONOMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MEGAMORPHIC;
|
|
|
|
}
|
|
|
|
|
|
|
|
void StoreDataPropertyInLiteralICNexus::ConfigureMonomorphic(
|
|
|
|
Handle<Name> name, Handle<Map> receiver_map) {
|
|
|
|
Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
|
|
|
|
|
|
|
|
SetFeedback(*cell);
|
|
|
|
SetFeedbackExtra(*name);
|
|
|
|
}
|
|
|
|
|
2015-06-01 22:46:54 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|