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

Unified Diff: src/objects.cc

Issue 2144183002: Revert "Avoid creating weak cells for literal arrays that are empty of literals." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 4 years, 5 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/builtins/x87/builtins-x87.cc ('k') | src/type-feedback-vector.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 d7b93146ef2157973d627f9a866c50b4faddeb3a..8d7750ec61683deb4f038e060e3771420dc729c4 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -11642,13 +11642,9 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
isolate->factory()->NewWeakCell(code.ToHandleChecked());
old_code_map->set(entry + kCachedCodeOffset, *code_cell);
}
- if (literals->literals_count() == 0) {
- old_code_map->set(entry + kLiteralsOffset, *literals);
- } else {
- Handle<WeakCell> literals_cell =
- isolate->factory()->NewWeakCell(literals);
- old_code_map->set(entry + kLiteralsOffset, *literals_cell);
- }
+ Handle<WeakCell> literals_cell =
+ isolate->factory()->NewWeakCell(literals);
+ old_code_map->set(entry + kLiteralsOffset, *literals_cell);
return;
}
@@ -11679,18 +11675,12 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
Handle<WeakCell> code_cell =
code.is_null() ? isolate->factory()->empty_weak_cell()
: isolate->factory()->NewWeakCell(code.ToHandleChecked());
+ Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals);
WeakCell* context_cell = native_context->self_weak_cell();
new_code_map->set(entry + kContextOffset, context_cell);
new_code_map->set(entry + kCachedCodeOffset, *code_cell);
-
- if (literals->literals_count() == 0) {
- new_code_map->set(entry + kLiteralsOffset, *literals);
- } else {
- Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals);
- new_code_map->set(entry + kLiteralsOffset, *literals_cell);
- }
-
+ new_code_map->set(entry + kLiteralsOffset, *literals_cell);
new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt()));
#ifdef DEBUG
@@ -11701,16 +11691,8 @@ void SharedFunctionInfo::AddToOptimizedCodeMap(
DCHECK(cell->cleared() ||
(cell->value()->IsCode() &&
Code::cast(cell->value())->kind() == Code::OPTIMIZED_FUNCTION));
- Object* lits = new_code_map->get(i + kLiteralsOffset);
- if (lits->IsWeakCell()) {
- cell = WeakCell::cast(lits);
- DCHECK(cell->cleared() ||
- (cell->value()->IsLiteralsArray() &&
- LiteralsArray::cast(cell->value())->literals_count() > 0));
- } else {
- DCHECK(lits->IsLiteralsArray() &&
- LiteralsArray::cast(lits)->literals_count() == 0);
- }
+ cell = WeakCell::cast(new_code_map->get(i + kLiteralsOffset));
+ DCHECK(cell->cleared() || cell->value()->IsFixedArray());
DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi());
}
#endif
@@ -13361,18 +13343,13 @@ CodeAndLiterals SharedFunctionInfo::SearchOptimizedCodeMap(
} else {
DCHECK_LE(entry + kEntryLength, code_map->length());
WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset));
- Object* lits = code_map->get(entry + kLiteralsOffset);
- LiteralsArray* literals = nullptr;
- if (lits->IsWeakCell()) {
- WeakCell* literal_cell = WeakCell::cast(lits);
- if (!literal_cell->cleared()) {
- literals = LiteralsArray::cast(literal_cell->value());
- }
- } else {
- literals = LiteralsArray::cast(lits);
- }
+ WeakCell* literals_cell =
+ WeakCell::cast(code_map->get(entry + kLiteralsOffset));
+
result = {cell->cleared() ? nullptr : Code::cast(cell->value()),
- literals};
+ literals_cell->cleared()
+ ? nullptr
+ : LiteralsArray::cast(literals_cell->value())};
}
}
return result;
« no previous file with comments | « src/builtins/x87/builtins-x87.cc ('k') | src/type-feedback-vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698