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

Unified Diff: src/objects.cc

Issue 1668103002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 10 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
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index dd2723029a15d5873f73e402678ebbc16c6f2e5b..d95bcc6ec790530c3a99648e7ec72e13ac5db589 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12366,6 +12366,22 @@ 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) {
+ 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);
+ AddLiteralsToOptimizedCodeMap(shared, native_context, literals);
+ return literals;
+}
void SharedFunctionInfo::AddSharedCodeToOptimizedCodeMap(
Handle<SharedFunctionInfo> shared, Handle<Code> code) {
@@ -12569,6 +12585,14 @@ 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());
+ 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();
@@ -13846,9 +13870,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);
@@ -13887,6 +13908,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) {
@@ -14330,13 +14364,12 @@ int AbstractCode::SourcePosition(int offset) {
return GetCode()->SourcePosition(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());
}
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698