Index: src/deoptimizer.cc |
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc |
index d7d392a966a8203cbe236a03d79c8656dd207203..fc4168eabb749d0755afa8e22e9b7e570ae05836 100644 |
--- a/src/deoptimizer.cc |
+++ b/src/deoptimizer.cc |
@@ -1443,6 +1443,54 @@ void Deoptimizer::RemoveDeoptimizingCode(Code* code) { |
} |
+static Object* CutOutRelatedFunctionsList(Context* context, |
+ Code* code, |
+ Object* undefined) { |
+ Object* result_list_head = undefined; |
+ Object* head; |
+ Object* current; |
+ current = head = context->get(Context::OPTIMIZED_FUNCTIONS_LIST); |
+ JSFunction* prev = NULL; |
+ while (!current->IsUndefined()) { |
danno
2012/10/21 19:56:15
Why not current != undefined, if you already have
ulan
2012/10/22 08:39:56
Done.
|
+ JSFunction* func = JSFunction::cast(current); |
+ current = func->next_function_link(); |
+ if (func->code() == code) { |
+ func->set_next_function_link(result_list_head); |
+ result_list_head = func; |
+ if (prev) { |
+ prev->set_next_function_link(current); |
+ } else { |
+ head = current; |
+ } |
+ } else { |
+ prev = func; |
+ } |
+ } |
+ if (head != context->get(Context::OPTIMIZED_FUNCTIONS_LIST)) { |
danno
2012/10/21 19:56:15
If this extra compare just to avoid a write barrie
ulan
2012/10/22 08:39:56
Yep, I think head will be unchanged most of the ti
|
+ context->set(Context::OPTIMIZED_FUNCTIONS_LIST, head); |
+ } |
+ return result_list_head; |
+} |
+ |
+ |
+void Deoptimizer::ReplaceCodeForRelatedFunctions(JSFunction* function, |
+ Code* code) { |
+ Context* context = function->context()->native_context(); |
+ |
+ SharedFunctionInfo* shared = function->shared(); |
+ |
+ Object* undefined = Isolate::Current()->heap()->undefined_value(); |
+ Object* current = CutOutRelatedFunctionsList(context, code, undefined); |
+ |
+ while (!current->IsUndefined()) { |
danno
2012/10/21 19:56:15
Why not current != undefined, if you already have
ulan
2012/10/22 08:39:56
Done.
|
+ JSFunction* func = JSFunction::cast(current); |
+ current = func->next_function_link(); |
+ func->set_code(shared->code()); |
+ func->set_next_function_link(undefined); |
+ } |
+} |
+ |
+ |
FrameDescription::FrameDescription(uint32_t frame_size, |
JSFunction* function) |
: frame_size_(frame_size), |