Index: src/hydrogen-escape-analysis.cc |
diff --git a/src/marking-thread.h b/src/hydrogen-escape-analysis.cc |
similarity index 59% |
copy from src/marking-thread.h |
copy to src/hydrogen-escape-analysis.cc |
index 9efa3af13262165972abf179defac6f83fed4ac9..59151ad10196fae2e27fdb37a0c0a32141fd9519 100644 |
--- a/src/marking-thread.h |
+++ b/src/hydrogen-escape-analysis.cc |
@@ -25,47 +25,48 @@ |
// (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_MARKING_THREAD_H_ |
-#define V8_MARKING_THREAD_H_ |
- |
-#include "atomicops.h" |
-#include "flags.h" |
-#include "platform.h" |
-#include "v8utils.h" |
- |
-#include "spaces.h" |
- |
-#include "heap.h" |
+#include "hydrogen-escape-analysis.h" |
namespace v8 { |
namespace internal { |
-class MarkingThread : public Thread { |
- public: |
- explicit MarkingThread(Isolate* isolate); |
- void Run(); |
- void Stop(); |
- void StartMarking(); |
- void WaitForMarkingThread(); |
+void HEscapeAnalysis::CollectIfNoEscapingUses(HInstruction* instr) { |
+ for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
+ HValue* use = it.value(); |
+ if (use->HasEscapingOperandAt(it.index())) { |
+ if (FLAG_trace_escape_analysis) { |
+ PrintF("#%d (%s) escapes through #%d (%s) @%d\n", instr->id(), |
+ instr->Mnemonic(), use->id(), use->Mnemonic(), it.index()); |
+ } |
+ return; |
+ } |
+ } |
+ if (FLAG_trace_escape_analysis) { |
+ PrintF("#%d (%s) is being captured\n", instr->id(), instr->Mnemonic()); |
+ } |
+ captured_.Add(instr, zone_); |
+} |
- ~MarkingThread() { |
- delete start_marking_semaphore_; |
- delete end_marking_semaphore_; |
- delete stop_semaphore_; |
+ |
+void HEscapeAnalysis::CollectCapturedValues() { |
+ int block_count = graph_->blocks()->length(); |
+ for (int i = 0; i < block_count; ++i) { |
+ HBasicBlock* block = graph_->blocks()->at(i); |
+ for (HInstructionIterator it(block); !it.Done(); it.Advance()) { |
+ HInstruction* instr = it.Current(); |
+ if (instr->IsAllocate() || instr->IsAllocateObject()) { |
+ CollectIfNoEscapingUses(instr); |
+ } |
+ } |
} |
+} |
- private: |
- Isolate* isolate_; |
- Heap* heap_; |
- Semaphore* start_marking_semaphore_; |
- Semaphore* end_marking_semaphore_; |
- Semaphore* stop_semaphore_; |
- volatile AtomicWord stop_thread_; |
- int id_; |
- static Atomic32 id_counter_; |
-}; |
-} } // namespace v8::internal |
+void HEscapeAnalysis::Analyze() { |
+ HPhase phase("H_Escape analysis", graph_); |
+ CollectCapturedValues(); |
+} |
-#endif // V8_MARKING_THREAD_H_ |
+ |
+} } // namespace v8::internal |