Commit c933e289 authored by vegorov@chromium.org's avatar vegorov@chromium.org

Make C++ to JS transition faster by avoiding JavaScriptFrameIterator in SaveContext.

R=kmillikin@chromium.org
BUG=v8:1730

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9835 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 0df252b3
......@@ -45,9 +45,7 @@ SaveContext::SaveContext(Isolate* isolate) : prev_(isolate->save_context()) {
}
isolate->set_save_context(this);
// If there is no JS frame under the current C frame, use the value 0.
JavaScriptFrameIterator it(isolate);
js_sp_ = it.done() ? 0 : it.frame()->sp();
c_entry_fp_ = isolate->c_entry_fp(isolate->thread_local_top());
}
......
......@@ -1246,8 +1246,8 @@ class SaveContext BASE_EMBEDDED {
SaveContext* prev() { return prev_; }
// Returns true if this save context is below a given JavaScript frame.
bool below(JavaScriptFrame* frame) {
return (js_sp_ == 0) || (frame->sp() < js_sp_);
bool IsBelowFrame(JavaScriptFrame* frame) {
return (c_entry_fp_ == 0) || (c_entry_fp_ > frame->sp());
}
private:
......@@ -1256,7 +1256,7 @@ class SaveContext BASE_EMBEDDED {
Handle<Context> dummy_;
#endif
SaveContext* prev_;
Address js_sp_; // The top JS frame's sp when saving context.
Address c_entry_fp_;
};
......
......@@ -10725,6 +10725,18 @@ static const int kFrameDetailsAtReturnIndex = 7;
static const int kFrameDetailsFlagsIndex = 8;
static const int kFrameDetailsFirstDynamicIndex = 9;
static SaveContext* FindSavedContextForFrame(Isolate* isolate,
JavaScriptFrame* frame) {
SaveContext* save = isolate->save_context();
while (save != NULL && !save->IsBelowFrame(frame)) {
save = save->prev();
}
ASSERT(save != NULL);
return save;
}
// Return an array with frame details
// args[0]: number: break id
// args[1]: number: frame index
......@@ -10780,11 +10792,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
// Traverse the saved contexts chain to find the active context for the
// selected frame.
SaveContext* save = isolate->save_context();
while (save != NULL && !save->below(it.frame())) {
save = save->prev();
}
ASSERT(save != NULL);
SaveContext* save = FindSavedContextForFrame(isolate, it.frame());
// Get the frame id.
Handle<Object> frame_id(WrapFrameId(it.frame()->id()), isolate);
......@@ -12062,11 +12070,8 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) {
// Traverse the saved contexts chain to find the active context for the
// selected frame.
SaveContext* save = isolate->save_context();
while (save != NULL && !save->below(frame)) {
save = save->prev();
}
ASSERT(save != NULL);
SaveContext* save = FindSavedContextForFrame(isolate, frame);
SaveContext savex(isolate);
isolate->set_context(*(save->context()));
......
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