DEFINE_BOOL(turbo_cf_optimization, true, "optimize control flow in TurboFan")
DEFINE_BOOL(turbo_frame_elision, true, "elide frames in TurboFan")
DEFINE_BOOL(turbo_cache_shared_code, true, "cache context-independent code")
+DEFINE_BOOL(turbo_preserve_shared_code, false, "keep context-independent code")
DEFINE_INT(typed_array_max_size_in_heap, 64,
"threshold for in-heap typed array")
// Add the shared function info holding an optimized code map to
// the code flusher for processing of code maps after marking.
collector->code_flusher()->AddOptimizedCodeMap(shared);
- // Treat all references within the code map weakly by marking the
+ // Treat some references within the code map weakly by marking the
// code map itself but not pushing it onto the marking deque.
FixedArray* code_map = FixedArray::cast(shared->optimized_code_map());
- StaticVisitor::MarkObjectWithoutPush(heap, code_map);
+ MarkOptimizedCodeMap(heap, code_map);
}
if (IsFlushable(heap, shared)) {
// This function's code looks flushable. But we have to postpone
}
+template <typename StaticVisitor>
+void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap(
+ Heap* heap, FixedArray* code_map) {
+ if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return;
+
+ // Mark the context-independent entry in the optimized code map. Depending on
+ // the age of the code object, we treat it as a strong or a weak reference.
+ Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex);
+ if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() &&
+ FLAG_age_code && !Code::cast(shared_object)->IsOld()) {
+ StaticVisitor::VisitPointer(
+ heap,
+ code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex));
+ }
+}
+
+
template <typename StaticVisitor>
void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap,
Code* code) {
// Skip the weak next code link in a code object.
INLINE(static void VisitNextCodeLink(Heap* heap, Object** slot)) {}
- // TODO(mstarzinger): This should be made protected once refactoring is done.
// Mark non-optimize code for functions inlined into the given optimized
// code. This will prevent it from being flushed.
static void MarkInlinedFunctionsCode(Heap* heap, Code* code);
static void MarkMapContents(Heap* heap, Map* map);
static void MarkTransitionArray(Heap* heap, TransitionArray* transitions);
+ // Mark pointers in the optimized code map that should act as strong
+ // references, possibly treating some entries weak.
+ static void MarkOptimizedCodeMap(Heap* heap, FixedArray* code_map);
+
// Code flushing support.
INLINE(static bool IsFlushable(Heap* heap, JSFunction* function));
INLINE(static bool IsFlushable(Heap* heap, SharedFunctionInfo* shared_info));