diff options
Diffstat (limited to 'deps/v8/src/feedback-vector.cc')
-rw-r--r-- | deps/v8/src/feedback-vector.cc | 71 |
1 files changed, 52 insertions, 19 deletions
diff --git a/deps/v8/src/feedback-vector.cc b/deps/v8/src/feedback-vector.cc index 37663f590b..afbcf2a923 100644 --- a/deps/v8/src/feedback-vector.cc +++ b/deps/v8/src/feedback-vector.cc @@ -203,6 +203,7 @@ Handle<FeedbackVector> FeedbackVector::New(Isolate* isolate, Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); array->set_map_no_write_barrier(isolate->heap()->feedback_vector_map()); array->set(kSharedFunctionInfoIndex, *shared); + array->set(kOptimizedCodeIndex, *factory->empty_weak_cell()); array->set(kInvocationCountIndex, Smi::kZero); // Ensure we can skip the write barrier @@ -296,6 +297,40 @@ void FeedbackVector::AddToCodeCoverageList(Isolate* isolate, isolate->SetCodeCoverageList(*list); } +// static +void FeedbackVector::SetOptimizedCode(Handle<FeedbackVector> vector, + Handle<Code> code) { + DCHECK_EQ(code->kind(), Code::OPTIMIZED_FUNCTION); + Factory* factory = vector->GetIsolate()->factory(); + Handle<WeakCell> cell = factory->NewWeakCell(code); + vector->set(kOptimizedCodeIndex, *cell); +} + +void FeedbackVector::ClearOptimizedCode() { + set(kOptimizedCodeIndex, GetIsolate()->heap()->empty_weak_cell()); +} + +void FeedbackVector::EvictOptimizedCodeMarkedForDeoptimization( + SharedFunctionInfo* shared, const char* reason) { + WeakCell* cell = WeakCell::cast(get(kOptimizedCodeIndex)); + if (!cell->cleared()) { + Code* code = Code::cast(cell->value()); + if (code->marked_for_deoptimization()) { + if (FLAG_trace_deopt) { + PrintF("[evicting optimizing code marked for deoptimization (%s) for ", + reason); + shared->ShortPrint(); + PrintF("]\n"); + } + if (!code->deopt_already_counted()) { + shared->increment_deopt_count(); + code->set_deopt_already_counted(true); + } + ClearOptimizedCode(); + } + } +} + void FeedbackVector::ClearSlots(JSFunction* host_function) { Isolate* isolate = GetIsolate(); @@ -646,9 +681,10 @@ void FeedbackNexus::ConfigureMonomorphic(Handle<Name> name, } } -void FeedbackNexus::ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, +void FeedbackNexus::ConfigurePolymorphic(Handle<Name> name, + MapHandles const& maps, List<Handle<Object>>* handlers) { - int receiver_count = maps->length(); + int receiver_count = static_cast<int>(maps.size()); DCHECK(receiver_count > 1); Handle<FixedArray> array; if (name.is_null()) { @@ -661,14 +697,14 @@ void FeedbackNexus::ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, } for (int current = 0; current < receiver_count; ++current) { - Handle<Map> map = maps->at(current); + Handle<Map> map = maps[current]; Handle<WeakCell> cell = Map::WeakCellForMap(map); array->set(current * 2, *cell); array->set(current * 2 + 1, *handlers->at(current)); } } -int FeedbackNexus::ExtractMaps(MapHandleList* maps) const { +int FeedbackNexus::ExtractMaps(MapHandles* maps) const { Isolate* isolate = GetIsolate(); Object* feedback = GetFeedback(); bool is_named_feedback = IsPropertyNameFeedback(feedback); @@ -684,7 +720,7 @@ int FeedbackNexus::ExtractMaps(MapHandleList* maps) const { WeakCell* cell = WeakCell::cast(array->get(i)); if (!cell->cleared()) { Map* map = Map::cast(cell->value()); - maps->Add(handle(map, isolate)); + maps->push_back(handle(map, isolate)); found++; } } @@ -693,7 +729,7 @@ int FeedbackNexus::ExtractMaps(MapHandleList* maps) const { WeakCell* cell = WeakCell::cast(feedback); if (!cell->cleared()) { Map* map = Map::cast(cell->value()); - maps->Add(handle(map, isolate)); + maps->push_back(handle(map, isolate)); return 1; } } @@ -791,13 +827,13 @@ Name* KeyedStoreICNexus::FindFirstName() const { KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const { KeyedAccessStoreMode mode = STANDARD_STORE; - MapHandleList maps; + MapHandles maps; List<Handle<Object>> handlers; if (GetKeyType() == PROPERTY) return mode; ExtractMaps(&maps); - FindHandlers(&handlers, maps.length()); + FindHandlers(&handlers, static_cast<int>(maps.size())); for (int i = 0; i < handlers.length(); i++) { // The first handler that isn't the slow handler will have the bits we need. Handle<Object> maybe_code_handler = handlers.at(i); @@ -911,7 +947,7 @@ InlineCacheState CollectTypeProfileNexus::StateFromFeedback() const { } void CollectTypeProfileNexus::Collect(Handle<String> type, int position) { - DCHECK_GT(position, 0); + DCHECK_GE(position, 0); Isolate* isolate = GetIsolate(); Object* const feedback = GetFeedback(); @@ -922,8 +958,7 @@ void CollectTypeProfileNexus::Collect(Handle<String> type, int position) { if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) { types = UnseededNumberDictionary::NewEmpty(isolate); } else { - types = Handle<UnseededNumberDictionary>( - UnseededNumberDictionary::cast(feedback), isolate); + types = handle(UnseededNumberDictionary::cast(feedback)); } Handle<ArrayList> position_specific_types; @@ -931,8 +966,7 @@ void CollectTypeProfileNexus::Collect(Handle<String> type, int position) { if (types->Has(position)) { int entry = types->FindEntry(position); DCHECK(types->ValueAt(entry)->IsArrayList()); - position_specific_types = - Handle<ArrayList>(ArrayList::cast(types->ValueAt(entry))); + position_specific_types = handle(ArrayList::cast(types->ValueAt(entry))); } else { position_specific_types = ArrayList::New(isolate, 1); } @@ -957,8 +991,8 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate, if (key->IsSmi()) { int value_index = index + UnseededNumberDictionary::kEntryValueIndex; - Handle<ArrayList> position_specific_types = Handle<ArrayList>( - ArrayList::cast(feedback->get(value_index)), isolate); + Handle<ArrayList> position_specific_types( + ArrayList::cast(feedback->get(value_index))); int position = Smi::cast(key)->value(); JSObject::AddDataElement(type_profile, position, @@ -978,12 +1012,11 @@ JSObject* CollectTypeProfileNexus::GetTypeProfile() const { Object* const feedback = GetFeedback(); if (feedback == *FeedbackVector::UninitializedSentinel(isolate)) { - return *isolate->factory()->NewJSMap(); + return *isolate->factory()->NewJSObject(isolate->object_function()); } - return *ConvertToJSObject( - isolate, Handle<UnseededNumberDictionary>( - UnseededNumberDictionary::cast(feedback), isolate)); + return *ConvertToJSObject(isolate, + handle(UnseededNumberDictionary::cast(feedback))); } } // namespace internal |