Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_TEST_CCTEST_TRACE_EXTENSION_H_ | 28 #ifndef V8_FEEDBACK_SLOTS_H_ |
| 29 #define V8_TEST_CCTEST_TRACE_EXTENSION_H_ | 29 #define V8_FEEDBACK_SLOTS_H_ |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "isolate.h" | |
| 34 | |
| 33 namespace v8 { | 35 namespace v8 { |
| 34 namespace internal { | 36 namespace internal { |
| 35 | 37 |
| 36 class TraceExtension : public v8::Extension { | 38 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,
| |
| 37 public: | 39 public: |
| 38 TraceExtension() : v8::Extension("v8/trace", kSource) { } | 40 static const int kInvalidFeedbackSlot = -1; |
| 39 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 41 |
| 40 v8::Isolate* isolate, | 42 virtual ~FeedbackSlotInterface() {} |
| 41 v8::Handle<v8::String> name); | 43 virtual int StaticFeedbackSlotCount() = 0; |
| 42 static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args); | 44 virtual int GetFeedbackSlotCount(Isolate* isolate) = 0; |
| 43 static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args); | 45 virtual void SetFirstFeedbackSlot(int slot) = 0; |
| 44 static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args); | 46 }; |
| 45 static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args); | 47 |
| 46 static Address GetJsEntrySp(); | 48 |
| 47 static void InitTraceEnv(TickSample* sample); | 49 class DeferredFeedbackSlotProcessor { |
| 48 static void DoTrace(Address fp); | 50 public: |
| 51 DeferredFeedbackSlotProcessor() | |
| 52 : slot_nodes_(NULL), | |
| 53 slot_count_(0) { } | |
| 54 | |
| 55 void add_slot_node(Zone* zone, FeedbackSlotInterface* slot) { | |
| 56 int count = slot->StaticFeedbackSlotCount(); | |
| 57 if (count > 0) { | |
| 58 // No need to add to the list | |
| 59 slot->SetFirstFeedbackSlot(slot_count_); | |
| 60 slot_count_ += count; | |
| 61 } else if (count < 0) { | |
| 62 if (slot_nodes_ == NULL) { | |
| 63 slot_nodes_ = new(zone) ZoneList<FeedbackSlotInterface*>(10, zone); | |
| 64 } | |
| 65 slot_nodes_->Add(slot, zone); | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 void ProcessFeedbackSlots(Isolate* isolate) { | |
| 70 // Scope analysis must have been done. | |
| 71 if (slot_nodes_ == NULL) { | |
| 72 return; | |
| 73 } | |
| 74 | |
| 75 int current_slot = slot_count_; | |
| 76 for (int i = 0; i < slot_nodes_->length(); i++) { | |
| 77 FeedbackSlotInterface* slot_interface = slot_nodes_->at(i); | |
| 78 int count = slot_interface->GetFeedbackSlotCount(isolate); | |
| 79 if (count > 0) { | |
| 80 slot_interface->SetFirstFeedbackSlot(current_slot); | |
| 81 current_slot += count; | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 slot_count_ = current_slot; | |
| 86 slot_nodes_->Clear(); | |
| 87 } | |
| 88 | |
| 89 int slot_count() { | |
| 90 ASSERT(slot_count_ >= 0); | |
| 91 return slot_count_; | |
| 92 } | |
| 93 | |
| 49 private: | 94 private: |
| 50 static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args); | 95 ZoneList<FeedbackSlotInterface*>* slot_nodes_; |
| 51 static const char* kSource; | 96 int slot_count_; |
| 52 }; | 97 }; |
| 53 | 98 |
| 99 | |
| 54 } } // namespace v8::internal | 100 } } // namespace v8::internal |
| 55 | 101 |
| 56 #endif | 102 #endif // V8_FEEDBACK_SLOTS_H_ |
| OLD | NEW |