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

Unified Diff: src/deoptimizer.cc

Issue 11637034: Refactoring only: Move stuff to DeoptimizerData where it belongs. Use "for". (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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/deoptimizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/deoptimizer.cc
diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc
index c9386d407585724bcc3ab9e7624206202eca489a..7018346842a84eb4c493444e6b3bf1cb2dc17192 100644
--- a/src/deoptimizer.cc
+++ b/src/deoptimizer.cc
@@ -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();
« no previous file with comments | « src/deoptimizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698