Revision: 9835
Author: [email protected]
Date: Fri Oct 28 05:49:09 2011
Log: Make C++ to JS transition faster by avoiding
JavaScriptFrameIterator in SaveContext.
[email protected]
BUG=v8:1730
Review URL: http://codereview.chromium.org/8403037
http://code.google.com/p/v8/source/detail?r=9835
Modified:
/branches/bleeding_edge/src/isolate-inl.h
/branches/bleeding_edge/src/isolate.h
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/isolate-inl.h Mon Oct 3 04:13:20 2011
+++ /branches/bleeding_edge/src/isolate-inl.h Fri Oct 28 05:49:09 2011
@@ -45,9 +45,7 @@
}
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());
}
=======================================
--- /branches/bleeding_edge/src/isolate.h Mon Oct 24 05:12:21 2011
+++ /branches/bleeding_edge/src/isolate.h Fri Oct 28 05:49:09 2011
@@ -1246,8 +1246,8 @@
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 @@
Handle<Context> dummy_;
#endif
SaveContext* prev_;
- Address js_sp_; // The top JS frame's sp when saving context.
+ Address c_entry_fp_;
};
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Oct 28 03:35:38 2011
+++ /branches/bleeding_edge/src/runtime.cc Fri Oct 28 05:49:09 2011
@@ -10725,6 +10725,18 @@
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 @@
// 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 @@
// 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()));
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev