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)); |
} |