Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Runtime_NotifyDeoptimized should search for function activation in al…
Browse files Browse the repository at this point in the history
…l thread stacks.

R=fschneider@chromium.org
BUG=v8:1763

Review URL: http://codereview.chromium.org/8240004

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@9588 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
  • Loading branch information
mraleph authored and piscisaureus committed May 9, 2012
1 parent 493beb2 commit 52f0c37
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
9 changes: 9 additions & 0 deletions deps/v8/src/frames-inl.h
Expand Up @@ -197,6 +197,15 @@ inline JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp(
if (!done()) Advance();
}


template<typename Iterator>
inline JavaScriptFrameIteratorTemp<Iterator>::JavaScriptFrameIteratorTemp(
Isolate* isolate, ThreadLocalTop* top)
: iterator_(isolate, top) {
if (!done()) Advance();
}


template<typename Iterator>
inline JavaScriptFrame* JavaScriptFrameIteratorTemp<Iterator>::frame() const {
// TODO(1233797): The frame hierarchy needs to change. It's
Expand Down
2 changes: 2 additions & 0 deletions deps/v8/src/frames.h
Expand Up @@ -710,6 +710,8 @@ class JavaScriptFrameIteratorTemp BASE_EMBEDDED {

inline explicit JavaScriptFrameIteratorTemp(Isolate* isolate);

inline JavaScriptFrameIteratorTemp(Isolate* isolate, ThreadLocalTop* top);

// Skip frames until the frame with the given id is reached.
explicit JavaScriptFrameIteratorTemp(StackFrame::Id id) { AdvanceToId(id); }

Expand Down
40 changes: 36 additions & 4 deletions deps/v8/src/runtime.cc
Expand Up @@ -8201,6 +8201,31 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) {
}


class ActivationsFinder : public ThreadVisitor {
public:
explicit ActivationsFinder(JSFunction* function)
: function_(function), has_activations_(false) {}

void VisitThread(Isolate* isolate, ThreadLocalTop* top) {
if (has_activations_) return;

for (JavaScriptFrameIterator it(isolate, top); !it.done(); it.Advance()) {
JavaScriptFrame* frame = it.frame();
if (frame->is_optimized() && frame->function() == function_) {
has_activations_ = true;
return;
}
}
}

bool has_activations() { return has_activations_; }

private:
JSFunction* function_;
bool has_activations_;
};


RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
HandleScope scope(isolate);
ASSERT(args.length() == 1);
Expand Down Expand Up @@ -8247,17 +8272,24 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) {
return isolate->heap()->undefined_value();
}

// Count the number of optimized activations of the function.
int activations = 0;
// Find other optimized activations of the function.
bool has_other_activations = false;
while (!it.done()) {
JavaScriptFrame* frame = it.frame();
if (frame->is_optimized() && frame->function() == *function) {
activations++;
has_other_activations = true;
break;
}
it.Advance();
}

if (activations == 0) {
if (!has_other_activations) {
ActivationsFinder activations_finder(*function);
isolate->thread_manager()->IterateArchivedThreads(&activations_finder);
has_other_activations = activations_finder.has_activations();
}

if (!has_other_activations) {
if (FLAG_trace_deopt) {
PrintF("[removing optimized code for: ");
function->PrintName();
Expand Down

0 comments on commit 52f0c37

Please sign in to comment.