Index: src/feedback_slots.h |
diff --git a/test/cctest/trace-extension.h b/src/feedback_slots.h |
similarity index 50% |
copy from test/cctest/trace-extension.h |
copy to src/feedback_slots.h |
index b80b3d45dc81579629ddccb6761cfa709b17e4e9..e85fa23454c7ae824e16fb9e657faf04a970684b 100644 |
--- a/test/cctest/trace-extension.h |
+++ b/src/feedback_slots.h |
@@ -25,32 +25,78 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-#ifndef V8_TEST_CCTEST_TRACE_EXTENSION_H_ |
-#define V8_TEST_CCTEST_TRACE_EXTENSION_H_ |
+#ifndef V8_FEEDBACK_SLOTS_H_ |
+#define V8_FEEDBACK_SLOTS_H_ |
#include "v8.h" |
+#include "isolate.h" |
+ |
namespace v8 { |
namespace internal { |
-class TraceExtension : public v8::Extension { |
+class FeedbackSlotInterface { |
Benedikt Meurer
2014/02/04 08:53:50
Hm, do we really need a new header file for this i
mvstanton
2014/02/04 13:03:27
Since deferred slot processor is rather involved,
|
public: |
- TraceExtension() : v8::Extension("v8/trace", kSource) { } |
- virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
- v8::Isolate* isolate, |
- v8::Handle<v8::String> name); |
- static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args); |
- static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args); |
- static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); |
- static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args); |
- static Address GetJsEntrySp(); |
- static void InitTraceEnv(TickSample* sample); |
- static void DoTrace(Address fp); |
+ static const int kInvalidFeedbackSlot = -1; |
+ |
+ virtual ~FeedbackSlotInterface() {} |
+ virtual int StaticFeedbackSlotCount() = 0; |
+ virtual int GetFeedbackSlotCount(Isolate* isolate) = 0; |
+ virtual void SetFirstFeedbackSlot(int slot) = 0; |
+}; |
+ |
+ |
+class DeferredFeedbackSlotProcessor { |
+ public: |
+ DeferredFeedbackSlotProcessor() |
+ : slot_nodes_(NULL), |
+ slot_count_(0) { } |
+ |
+ void add_slot_node(Zone* zone, FeedbackSlotInterface* slot) { |
+ int count = slot->StaticFeedbackSlotCount(); |
+ if (count > 0) { |
+ // No need to add to the list |
+ slot->SetFirstFeedbackSlot(slot_count_); |
+ slot_count_ += count; |
+ } else if (count < 0) { |
+ if (slot_nodes_ == NULL) { |
+ slot_nodes_ = new(zone) ZoneList<FeedbackSlotInterface*>(10, zone); |
+ } |
+ slot_nodes_->Add(slot, zone); |
+ } |
+ } |
+ |
+ void ProcessFeedbackSlots(Isolate* isolate) { |
+ // Scope analysis must have been done. |
+ if (slot_nodes_ == NULL) { |
+ return; |
+ } |
+ |
+ int current_slot = slot_count_; |
+ for (int i = 0; i < slot_nodes_->length(); i++) { |
+ FeedbackSlotInterface* slot_interface = slot_nodes_->at(i); |
+ int count = slot_interface->GetFeedbackSlotCount(isolate); |
+ if (count > 0) { |
+ slot_interface->SetFirstFeedbackSlot(current_slot); |
+ current_slot += count; |
+ } |
+ } |
+ |
+ slot_count_ = current_slot; |
+ slot_nodes_->Clear(); |
+ } |
+ |
+ int slot_count() { |
+ ASSERT(slot_count_ >= 0); |
+ return slot_count_; |
+ } |
+ |
private: |
- static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args); |
- static const char* kSource; |
+ ZoneList<FeedbackSlotInterface*>* slot_nodes_; |
+ int slot_count_; |
}; |
+ |
} } // namespace v8::internal |
-#endif |
+#endif // V8_FEEDBACK_SLOTS_H_ |