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

Unified Diff: src/contexts.cc

Issue 2597163002: Revert of [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: Created 4 years 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/contexts.h ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/contexts.cc
diff --git a/src/contexts.cc b/src/contexts.cc
index 67c85f1381b91286e45ec533b627d195b2fbfb7b..47ffb275b489c9bc9fef1482374f0b619ff633ba 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -412,8 +412,9 @@
static const int kSharedOffset = 0;
static const int kCachedCodeOffset = 1;
-static const int kOsrAstIdOffset = 2;
-static const int kEntryLength = 3;
+static const int kLiteralsOffset = 2;
+static const int kOsrAstIdOffset = 3;
+static const int kEntryLength = 4;
static const int kInitialLength = kEntryLength;
int Context::SearchOptimizedCodeMapEntry(SharedFunctionInfo* shared,
@@ -435,29 +436,38 @@
return -1;
}
-Code* Context::SearchOptimizedCodeMap(SharedFunctionInfo* shared,
- BailoutId osr_ast_id) {
+void Context::SearchOptimizedCodeMap(SharedFunctionInfo* shared,
+ BailoutId osr_ast_id, Code** pcode,
+ LiteralsArray** pliterals) {
DCHECK(this->IsNativeContext());
int entry = SearchOptimizedCodeMapEntry(shared, osr_ast_id);
if (entry != -1) {
FixedArray* code_map = osr_code_table();
DCHECK_LE(entry + kEntryLength, code_map->length());
WeakCell* cell = WeakCell::cast(code_map->get(entry + kCachedCodeOffset));
-
- return cell->cleared() ? nullptr : Code::cast(cell->value());
- }
- return nullptr;
+ WeakCell* literals_cell =
+ WeakCell::cast(code_map->get(entry + kLiteralsOffset));
+
+ *pcode = cell->cleared() ? nullptr : Code::cast(cell->value());
+ *pliterals = literals_cell->cleared()
+ ? nullptr
+ : LiteralsArray::cast(literals_cell->value());
+ } else {
+ *pcode = nullptr;
+ *pliterals = nullptr;
+ }
}
void Context::AddToOptimizedCodeMap(Handle<Context> native_context,
Handle<SharedFunctionInfo> shared,
Handle<Code> code,
+ Handle<LiteralsArray> literals,
BailoutId osr_ast_id) {
DCHECK(native_context->IsNativeContext());
Isolate* isolate = native_context->GetIsolate();
if (isolate->serializer_enabled()) return;
- STATIC_ASSERT(kEntryLength == 3);
+ STATIC_ASSERT(kEntryLength == 4);
Handle<FixedArray> new_code_map;
int entry;
@@ -468,9 +478,12 @@
Handle<FixedArray> old_code_map(native_context->osr_code_table(), isolate);
entry = native_context->SearchOptimizedCodeMapEntry(*shared, osr_ast_id);
if (entry >= 0) {
- // Just set the code of the entry.
+ // Just set the code and literals of the entry.
Handle<WeakCell> code_cell = isolate->factory()->NewWeakCell(code);
old_code_map->set(entry + kCachedCodeOffset, *code_cell);
+ Handle<WeakCell> literals_cell =
+ isolate->factory()->NewWeakCell(literals);
+ old_code_map->set(entry + kLiteralsOffset, *literals_cell);
return;
}
@@ -494,10 +507,12 @@
}
Handle<WeakCell> code_cell = isolate->factory()->NewWeakCell(code);
+ Handle<WeakCell> literals_cell = isolate->factory()->NewWeakCell(literals);
Handle<WeakCell> shared_cell = isolate->factory()->NewWeakCell(shared);
new_code_map->set(entry + kSharedOffset, *shared_cell);
new_code_map->set(entry + kCachedCodeOffset, *code_cell);
+ new_code_map->set(entry + kLiteralsOffset, *literals_cell);
new_code_map->set(entry + kOsrAstIdOffset, Smi::FromInt(osr_ast_id.ToInt()));
#ifdef DEBUG
@@ -508,6 +523,8 @@
DCHECK(cell->cleared() ||
(cell->value()->IsCode() &&
Code::cast(cell->value())->kind() == Code::OPTIMIZED_FUNCTION));
+ cell = WeakCell::cast(new_code_map->get(i + kLiteralsOffset));
+ DCHECK(cell->cleared() || cell->value()->IsFixedArray());
DCHECK(new_code_map->get(i + kOsrAstIdOffset)->IsSmi());
}
#endif
@@ -548,6 +565,8 @@
code_map->set(dst + kSharedOffset, code_map->get(src + kSharedOffset));
code_map->set(dst + kCachedCodeOffset,
code_map->get(src + kCachedCodeOffset));
+ code_map->set(dst + kLiteralsOffset,
+ code_map->get(src + kLiteralsOffset));
code_map->set(dst + kOsrAstIdOffset,
code_map->get(src + kOsrAstIdOffset));
}
« no previous file with comments | « src/contexts.h ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698