| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags) | 375 void V8GCController::gcEpilogue(v8::GCType type, v8::GCCallbackFlags flags) |
| 376 { | 376 { |
| 377 // FIXME: It would be nice if the GC callbacks passed the Isolate directly..
.. | 377 // FIXME: It would be nice if the GC callbacks passed the Isolate directly..
.. |
| 378 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 378 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 379 if (type == v8::kGCTypeScavenge) | 379 if (type == v8::kGCTypeScavenge) |
| 380 minorGCEpilogue(isolate); | 380 minorGCEpilogue(isolate); |
| 381 else if (type == v8::kGCTypeMarkSweepCompact) | 381 else if (type == v8::kGCTypeMarkSweepCompact) |
| 382 majorGCEpilogue(isolate); | 382 majorGCEpilogue(isolate); |
| 383 | 383 |
| 384 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent",
"usedHeapSizeAfter", usedHeapSize(isolate)); | 384 TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent",
"usedHeapSizeAfter", usedHeapSize(isolate)); |
| 385 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); | 385 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_PROCESS, "data", InspectorUpdateCountersEvent::data
()); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void V8GCController::minorGCEpilogue(v8::Isolate* isolate) | 388 void V8GCController::minorGCEpilogue(v8::Isolate* isolate) |
| 389 { | 389 { |
| 390 TRACE_EVENT_END0("v8", "minorGC"); | 390 TRACE_EVENT_END0("v8", "minorGC"); |
| 391 if (isMainThread()) { | 391 if (isMainThread()) |
| 392 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)-
>previousSamplingState()); | |
| 393 ScriptForbiddenScope::exit(); | 392 ScriptForbiddenScope::exit(); |
| 394 } | |
| 395 } | 393 } |
| 396 | 394 |
| 397 void V8GCController::majorGCEpilogue(v8::Isolate* isolate) | 395 void V8GCController::majorGCEpilogue(v8::Isolate* isolate) |
| 398 { | 396 { |
| 399 v8::HandleScope scope(isolate); | 397 v8::HandleScope scope(isolate); |
| 400 | 398 |
| 401 TRACE_EVENT_END0("v8", "majorGC"); | 399 TRACE_EVENT_END0("v8", "majorGC"); |
| 402 if (isMainThread()) { | 400 if (isMainThread()) |
| 403 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)-
>previousSamplingState()); | |
| 404 ScriptForbiddenScope::exit(); | 401 ScriptForbiddenScope::exit(); |
| 405 } | |
| 406 } | 402 } |
| 407 | 403 |
| 408 void V8GCController::collectGarbage(v8::Isolate* isolate) | 404 void V8GCController::collectGarbage(v8::Isolate* isolate) |
| 409 { | 405 { |
| 410 v8::HandleScope handleScope(isolate); | 406 v8::HandleScope handleScope(isolate); |
| 411 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola
te), DOMWrapperWorld::create()); | 407 RefPtr<ScriptState> scriptState = ScriptState::create(v8::Context::New(isola
te), DOMWrapperWorld::create()); |
| 412 ScriptState::Scope scope(scriptState.get()); | 408 ScriptState::Scope scope(scriptState.get()); |
| 413 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();
"), isolate); | 409 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();
"), isolate); |
| 414 scriptState->disposePerContextData(); | 410 scriptState->disposePerContextData(); |
| 415 } | 411 } |
| 416 | 412 |
| 417 void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate) | 413 void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate) |
| 418 { | 414 { |
| 419 if (!isMainThread()) | 415 if (!isMainThread()) |
| 420 return; | 416 return; |
| 421 | 417 |
| 422 static size_t lastUsageReportedToV8 = 0; | 418 static size_t lastUsageReportedToV8 = 0; |
| 423 | 419 |
| 424 size_t currentUsage = Partitions::currentDOMMemoryUsage(); | 420 size_t currentUsage = Partitions::currentDOMMemoryUsage(); |
| 425 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las
tUsageReportedToV8); | 421 int64_t diff = static_cast<int64_t>(currentUsage) - static_cast<int64_t>(las
tUsageReportedToV8); |
| 426 isolate->AdjustAmountOfExternalAllocatedMemory(diff); | 422 isolate->AdjustAmountOfExternalAllocatedMemory(diff); |
| 427 | 423 |
| 428 lastUsageReportedToV8 = currentUsage; | 424 lastUsageReportedToV8 = currentUsage; |
| 429 } | 425 } |
| 430 | 426 |
| 431 } // namespace blink | 427 } // namespace blink |
| OLD | NEW |