| Index: src/objects.cc
|
| diff --git a/src/objects.cc b/src/objects.cc
|
| index 5cb3a37b523bc1bb0fb39865fb46a0586bd7b9e3..a47a45dcb4b01df9d29e384b9f1adff55a26e3b3 100644
|
| --- a/src/objects.cc
|
| +++ b/src/objects.cc
|
| @@ -9900,12 +9900,21 @@ Handle<DeoptimizationOutputData> DeoptimizationOutputData::New(
|
| return Handle<DeoptimizationOutputData>::cast(result);
|
| }
|
|
|
| +const int LiteralsArray::kFeedbackVectorOffset =
|
| + LiteralsArray::OffsetOfElementAt(LiteralsArray::kVectorIndex);
|
| +
|
| +const int LiteralsArray::kOffsetToFirstLiteral =
|
| + LiteralsArray::OffsetOfElementAt(LiteralsArray::kFirstLiteralIndex);
|
|
|
| // static
|
| Handle<LiteralsArray> LiteralsArray::New(Isolate* isolate,
|
| Handle<TypeFeedbackVector> vector,
|
| int number_of_literals,
|
| PretenureFlag pretenure) {
|
| + if (vector->is_empty() && number_of_literals == 0) {
|
| + return Handle<LiteralsArray>::cast(
|
| + isolate->factory()->empty_literals_array());
|
| + }
|
| Handle<FixedArray> literals = isolate->factory()->NewFixedArray(
|
| number_of_literals + kFirstLiteralIndex, pretenure);
|
| Handle<LiteralsArray> casted_literals = Handle<LiteralsArray>::cast(literals);
|
| @@ -11286,6 +11295,30 @@ void JSFunction::AttemptConcurrentOptimization() {
|
| // No write barrier required, since the builtin is part of the root set.
|
| }
|
|
|
| +// static
|
| +Handle<LiteralsArray> SharedFunctionInfo::FindOrCreateLiterals(
|
| + Handle<SharedFunctionInfo> shared, Handle<Context> native_context) {
|
| + Isolate* isolate = shared->GetIsolate();
|
| + CodeAndLiterals result =
|
| + shared->SearchOptimizedCodeMap(*native_context, BailoutId::None());
|
| + if (result.literals != nullptr) {
|
| + DCHECK(shared->feedback_metadata()->is_empty() ||
|
| + !result.literals->feedback_vector()->is_empty());
|
| + return handle(result.literals, isolate);
|
| + }
|
| +
|
| + Handle<TypeFeedbackVector> feedback_vector =
|
| + TypeFeedbackVector::New(isolate, handle(shared->feedback_metadata()));
|
| + Handle<LiteralsArray> literals = LiteralsArray::New(
|
| + isolate, feedback_vector, shared->num_literals(), TENURED);
|
| + Handle<Code> code;
|
| + if (result.code != nullptr) {
|
| + code = Handle<Code>(result.code, isolate);
|
| + }
|
| + AddToOptimizedCodeMap(shared, native_context, code, literals,
|
| + BailoutId::None());
|
| + return literals;
|
| +}
|
|
|
| void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
|
| Handle<SharedFunctionInfo> shared, Handle<Code> code) {
|
| @@ -11482,6 +11515,17 @@ void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) {
|
| }
|
| }
|
|
|
| +// static
|
| +void JSFunction::EnsureLiterals(Handle<JSFunction> function) {
|
| + Handle<SharedFunctionInfo> shared(function->shared());
|
| + Handle<Context> native_context(function->context()->native_context());
|
| + if (function->literals() ==
|
| + function->GetIsolate()->heap()->empty_literals_array()) {
|
| + Handle<LiteralsArray> literals =
|
| + SharedFunctionInfo::FindOrCreateLiterals(shared, native_context);
|
| + function->set_literals(*literals);
|
| + }
|
| +}
|
|
|
| static void GetMinInobjectSlack(Map* map, void* data) {
|
| int slack = map->unused_property_fields();
|
| @@ -12912,9 +12956,6 @@ void Map::StartInobjectSlackTracking() {
|
|
|
| void SharedFunctionInfo::ResetForNewContext(int new_ic_age) {
|
| code()->ClearInlineCaches();
|
| - // If we clear ICs, we need to clear the type feedback vector too, since
|
| - // CallICs are synced with a feedback vector slot.
|
| - ClearTypeFeedbackInfo();
|
| set_ic_age(new_ic_age);
|
| if (code()->kind() == Code::FUNCTION) {
|
| code()->set_profiler_ticks(0);
|
| @@ -12960,6 +13001,19 @@ int SharedFunctionInfo::SearchOptimizedCodeMapEntry(Context* native_context,
|
| return -1;
|
| }
|
|
|
| +void SharedFunctionInfo::ClearCodeFromOptimizedCodeMap() {
|
| + if (!OptimizedCodeMapIsCleared()) {
|
| + FixedArray* optimized_code_map = this->optimized_code_map();
|
| + int length = optimized_code_map->length();
|
| + WeakCell* empty_weak_cell = GetHeap()->empty_weak_cell();
|
| + for (int i = kEntriesStart; i < length; i += kEntryLength) {
|
| + optimized_code_map->set(i + kCachedCodeOffset, empty_weak_cell,
|
| + SKIP_WRITE_BARRIER);
|
| + }
|
| + optimized_code_map->set(kSharedCodeIndex, empty_weak_cell,
|
| + SKIP_WRITE_BARRIER);
|
| + }
|
| +}
|
|
|
| CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap(
|
| Context* native_context, BailoutId osr_ast_id) {
|
| @@ -13294,16 +13348,14 @@ int AbstractCode::SourceStatementPosition(int offset) {
|
| : GetCode()->SourceStatementPosition(offset);
|
| }
|
|
|
| -void SharedFunctionInfo::ClearTypeFeedbackInfo() {
|
| - feedback_vector()->ClearSlots(this);
|
| +void JSFunction::ClearTypeFeedbackInfo() {
|
| + feedback_vector()->ClearSlots(shared());
|
| }
|
|
|
| -
|
| -void SharedFunctionInfo::ClearTypeFeedbackInfoAtGCTime() {
|
| - feedback_vector()->ClearSlotsAtGCTime(this);
|
| +void JSFunction::ClearTypeFeedbackInfoAtGCTime() {
|
| + feedback_vector()->ClearSlotsAtGCTime(shared());
|
| }
|
|
|
| -
|
| BailoutId Code::TranslatePcOffsetToAstId(uint32_t pc_offset) {
|
| DisallowHeapAllocation no_gc;
|
| DCHECK(kind() == FUNCTION);
|
|
|