Refactoring only: Move stuff to DeoptimizerData where it belongs. Use "for".

Review URL: https://codereview.chromium.org/11637034

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13250 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 4cb7b834
......@@ -79,6 +79,36 @@ void DeoptimizerData::Iterate(ObjectVisitor* v) {
#endif
Code* DeoptimizerData::FindDeoptimizingCode(Address addr) {
for (DeoptimizingCodeListNode* node = deoptimizing_code_list_;
node != NULL;
node = node->next()) {
if (node->code()->contains(addr)) return *node->code();
}
return NULL;
}
void DeoptimizerData::RemoveDeoptimizingCode(Code* code) {
for (DeoptimizingCodeListNode *prev = NULL, *cur = deoptimizing_code_list_;
cur != NULL;
prev = cur, cur = cur->next()) {
if (*cur->code() == code) {
if (prev == NULL) {
deoptimizing_code_list_ = cur->next();
} else {
prev->set_next(cur->next());
}
delete cur;
return;
}
}
// Deoptimizing code is removed through weak callback. Each object is expected
// to be removed once and only once.
UNREACHABLE();
}
// We rely on this function not causing a GC. It is called from generated code
// without having a real stack frame in place.
Deoptimizer* Deoptimizer::New(JSFunction* function,
......@@ -426,16 +456,17 @@ void Deoptimizer::DeoptimizeAllFunctionsWith(OptimizedFunctionFilter* filter) {
}
void Deoptimizer::HandleWeakDeoptimizedCode(
v8::Persistent<v8::Value> obj, void* data) {
void Deoptimizer::HandleWeakDeoptimizedCode(v8::Persistent<v8::Value> obj,
void* parameter) {
DeoptimizingCodeListNode* node =
reinterpret_cast<DeoptimizingCodeListNode*>(data);
RemoveDeoptimizingCode(*node->code());
reinterpret_cast<DeoptimizingCodeListNode*>(parameter);
DeoptimizerData* data = Isolate::Current()->deoptimizer_data();
data->RemoveDeoptimizingCode(*node->code());
#ifdef DEBUG
node = Isolate::Current()->deoptimizer_data()->deoptimizing_code_list_;
while (node != NULL) {
ASSERT(node != reinterpret_cast<DeoptimizingCodeListNode*>(data));
node = node->next();
for (DeoptimizingCodeListNode* current = data->deoptimizing_code_list_;
current != NULL;
current = current->next()) {
ASSERT(current != node);
}
#endif
}
......@@ -519,7 +550,7 @@ Deoptimizer::Deoptimizer(Isolate* isolate,
}
}
} else if (type == LAZY) {
compiled_code_ = FindDeoptimizingCodeFromAddress(from);
compiled_code_ = isolate->deoptimizer_data()->FindDeoptimizingCode(from);
if (compiled_code_ == NULL) {
compiled_code_ =
static_cast<Code*>(isolate->heap()->FindCodeObject(from));
......@@ -1534,44 +1565,6 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(BailoutType type,
}
Code* Deoptimizer::FindDeoptimizingCodeFromAddress(Address addr) {
DeoptimizingCodeListNode* node =
Isolate::Current()->deoptimizer_data()->deoptimizing_code_list_;
while (node != NULL) {
if (node->code()->contains(addr)) return *node->code();
node = node->next();
}
return NULL;
}
void Deoptimizer::RemoveDeoptimizingCode(Code* code) {
DeoptimizerData* data = Isolate::Current()->deoptimizer_data();
ASSERT(data->deoptimizing_code_list_ != NULL);
// Run through the code objects to find this one and remove it.
DeoptimizingCodeListNode* prev = NULL;
DeoptimizingCodeListNode* current = data->deoptimizing_code_list_;
while (current != NULL) {
if (*current->code() == code) {
// Unlink from list. If prev is NULL we are looking at the first element.
if (prev == NULL) {
data->deoptimizing_code_list_ = current->next();
} else {
prev->set_next(current->next());
}
delete current;
return;
}
// Move to next in list.
prev = current;
current = current->next();
}
// Deoptimizing code is removed through weak callback. Each object is expected
// to be removed once and only once.
UNREACHABLE();
}
void Deoptimizer::ReplaceCodeForRelatedFunctions(JSFunction* function,
Code* code) {
SharedFunctionInfo* shared = function->shared();
......
......@@ -107,6 +107,9 @@ class DeoptimizerData {
void Iterate(ObjectVisitor* v);
#endif
Code* FindDeoptimizingCode(Address addr);
void RemoveDeoptimizingCode(Code* code);
private:
int eager_deoptimization_entry_code_entries_;
int lazy_deoptimization_entry_code_entries_;
......@@ -365,8 +368,6 @@ class Deoptimizer : public Malloced {
// Weak handle callback for deoptimizing code objects.
static void HandleWeakDeoptimizedCode(
v8::Persistent<v8::Value> obj, void* data);
static Code* FindDeoptimizingCodeFromAddress(Address addr);
static void RemoveDeoptimizingCode(Code* code);
// Deoptimize function assuming that function->next_function_link() points
// to a list that contains all functions that share the same optimized code.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment