Revision f230a1cf deps/v8/src/heap-profiler.cc

View differences:

deps/v8/src/heap-profiler.cc
27 27

  
28 28
#include "v8.h"
29 29

  
30
#include "deoptimizer.h"
30 31
#include "heap-profiler.h"
31 32
#include "heap-snapshot-generator-inl.h"
32 33

  
......
35 36

  
36 37
HeapProfiler::HeapProfiler(Heap* heap)
37 38
    : snapshots_(new HeapSnapshotsCollection(heap)),
38
      next_snapshot_uid_(1) {
39
      next_snapshot_uid_(1),
40
      is_tracking_allocations_(false) {
39 41
}
40 42

  
41 43

  
......
132 134
}
133 135

  
134 136

  
135
void HeapProfiler::ObjectMoveEvent(Address from, Address to) {
136
  snapshots_->ObjectMoveEvent(from, to);
137
void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) {
138
  snapshots_->ObjectMoveEvent(from, to, size);
137 139
}
138 140

  
141

  
142
void HeapProfiler::NewObjectEvent(Address addr, int size) {
143
  snapshots_->NewObjectEvent(addr, size);
144
}
145

  
146

  
147
void HeapProfiler::UpdateObjectSizeEvent(Address addr, int size) {
148
  snapshots_->UpdateObjectSizeEvent(addr, size);
149
}
150

  
151

  
139 152
void HeapProfiler::SetRetainedObjectInfo(UniqueId id,
140 153
                                         RetainedObjectInfo* info) {
141 154
  // TODO(yurus, marja): Don't route this information through GlobalHandles.
142 155
  heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info);
143 156
}
144 157

  
158

  
159
void HeapProfiler::StartHeapAllocationsRecording() {
160
  StartHeapObjectsTracking();
161
  is_tracking_allocations_ = true;
162
  DropCompiledCode();
163
  snapshots_->UpdateHeapObjectsMap();
164
}
165

  
166

  
167
void HeapProfiler::StopHeapAllocationsRecording() {
168
  StopHeapObjectsTracking();
169
  is_tracking_allocations_ = false;
170
  DropCompiledCode();
171
}
172

  
173

  
174
void HeapProfiler::RecordObjectAllocationFromMasm(Isolate* isolate,
175
                                                  Address obj,
176
                                                  int size) {
177
  isolate->heap_profiler()->NewObjectEvent(obj, size);
178
}
179

  
180

  
181
void HeapProfiler::DropCompiledCode() {
182
  Isolate* isolate = heap()->isolate();
183
  HandleScope scope(isolate);
184

  
185
  if (FLAG_concurrent_recompilation) {
186
    isolate->optimizing_compiler_thread()->Flush();
187
  }
188

  
189
  Deoptimizer::DeoptimizeAll(isolate);
190

  
191
  Handle<Code> lazy_compile =
192
      Handle<Code>(isolate->builtins()->builtin(Builtins::kLazyCompile));
193

  
194
  heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask,
195
                            "switch allocations tracking");
196

  
197
  DisallowHeapAllocation no_allocation;
198

  
199
  HeapIterator iterator(heap());
200
  HeapObject* obj = NULL;
201
  while (((obj = iterator.next()) != NULL)) {
202
    if (obj->IsJSFunction()) {
203
      JSFunction* function = JSFunction::cast(obj);
204
      SharedFunctionInfo* shared = function->shared();
205

  
206
      if (!shared->allows_lazy_compilation()) continue;
207
      if (!shared->script()->IsScript()) continue;
208

  
209
      Code::Kind kind = function->code()->kind();
210
      if (kind == Code::FUNCTION || kind == Code::BUILTIN) {
211
        function->set_code(*lazy_compile);
212
        shared->set_code(*lazy_compile);
213
      }
214
    }
215
  }
216
}
217

  
218

  
145 219
} }  // namespace v8::internal

Also available in: Unified diff