Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
| (...skipping 4381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4392 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), | 4392 if (!ApiCheck(isolate != NULL && isolate->IsDefaultIsolate(), |
| 4393 "v8::V8::Dispose()", | 4393 "v8::V8::Dispose()", |
| 4394 "Use v8::Isolate::Dispose() for a non-default isolate.")) { | 4394 "Use v8::Isolate::Dispose() for a non-default isolate.")) { |
| 4395 return false; | 4395 return false; |
| 4396 } | 4396 } |
| 4397 i::V8::TearDown(); | 4397 i::V8::TearDown(); |
| 4398 return true; | 4398 return true; |
| 4399 } | 4399 } |
| 4400 | 4400 |
| 4401 | 4401 |
| 4402 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 4402 HeapStatistics::HeapStatistics() { |
| 4403 total_heap_size_executable_(0), | 4403 Clear(); |
| 4404 total_physical_size_(0), | 4404 } |
| 4405 used_heap_size_(0), | 4405 |
| 4406 heap_size_limit_(0) { } | 4406 |
| 4407 void HeapStatistics::Clear() { | |
| 4408 total_heap_size_ = 0; | |
| 4409 total_heap_size_executable_ = 0; | |
| 4410 total_physical_size_ = 0; | |
| 4411 used_heap_size_ = 0; | |
| 4412 heap_size_limit_ = 0; | |
| 4413 } | |
| 4407 | 4414 |
| 4408 | 4415 |
| 4409 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { | 4416 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| 4410 if (!i::Isolate::Current()->IsInitialized()) { | 4417 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 4418 if (isolate == NULL || !isolate->IsInitialized()) { | |
| 4411 // Isolate is unitialized thus heap is not configured yet. | 4419 // Isolate is unitialized thus heap is not configured yet. |
| 4412 heap_statistics->set_total_heap_size(0); | 4420 heap_statistics->Clear(); |
|
Michael Starzinger
2013/02/08 12:30:11
Since there is only one use of the Clear() method
Sven Panne
2013/02/08 12:41:37
Good point, leaving the duplication as it is until
| |
| 4413 heap_statistics->set_total_heap_size_executable(0); | |
| 4414 heap_statistics->set_total_physical_size(0); | |
| 4415 heap_statistics->set_used_heap_size(0); | |
| 4416 heap_statistics->set_heap_size_limit(0); | |
| 4417 return; | 4421 return; |
| 4418 } | 4422 } |
| 4419 | 4423 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); |
| 4420 i::Heap* heap = i::Isolate::Current()->heap(); | 4424 return ext_isolate->GetHeapStatistics(heap_statistics); |
| 4421 heap_statistics->set_total_heap_size(heap->CommittedMemory()); | |
| 4422 heap_statistics->set_total_heap_size_executable( | |
| 4423 heap->CommittedMemoryExecutable()); | |
| 4424 heap_statistics->set_total_physical_size(heap->CommittedPhysicalMemory()); | |
| 4425 heap_statistics->set_used_heap_size(heap->SizeOfObjects()); | |
| 4426 heap_statistics->set_heap_size_limit(heap->MaxReserved()); | |
| 4427 } | 4425 } |
| 4428 | 4426 |
| 4429 | 4427 |
| 4430 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { | 4428 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { |
| 4431 i::Isolate* isolate = i::Isolate::Current(); | 4429 i::Isolate* isolate = i::Isolate::Current(); |
| 4432 IsDeadCheck(isolate, "v8::V8::VisitExternalResources"); | 4430 IsDeadCheck(isolate, "v8::V8::VisitExternalResources"); |
| 4433 isolate->heap()->VisitExternalResources(visitor); | 4431 isolate->heap()->VisitExternalResources(visitor); |
| 4434 } | 4432 } |
| 4435 | 4433 |
| 4436 | 4434 |
| (...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5602 isolate->Enter(); | 5600 isolate->Enter(); |
| 5603 } | 5601 } |
| 5604 | 5602 |
| 5605 | 5603 |
| 5606 void Isolate::Exit() { | 5604 void Isolate::Exit() { |
| 5607 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 5605 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 5608 isolate->Exit(); | 5606 isolate->Exit(); |
| 5609 } | 5607 } |
| 5610 | 5608 |
| 5611 | 5609 |
| 5610 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { | |
| 5611 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | |
| 5612 i::Heap* heap = isolate->heap(); | |
| 5613 heap_statistics->total_heap_size_ = heap->CommittedMemory(); | |
| 5614 heap_statistics->total_heap_size_executable_ = | |
| 5615 heap->CommittedMemoryExecutable(); | |
| 5616 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); | |
| 5617 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); | |
| 5618 heap_statistics->heap_size_limit_ = heap->MaxReserved(); | |
| 5619 } | |
| 5620 | |
| 5621 | |
| 5612 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 5622 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
| 5613 : str_(NULL), length_(0) { | 5623 : str_(NULL), length_(0) { |
| 5614 i::Isolate* isolate = i::Isolate::Current(); | 5624 i::Isolate* isolate = i::Isolate::Current(); |
| 5615 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; | 5625 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; |
| 5616 if (obj.IsEmpty()) return; | 5626 if (obj.IsEmpty()) return; |
| 5617 ENTER_V8(isolate); | 5627 ENTER_V8(isolate); |
| 5618 i::HandleScope scope(isolate); | 5628 i::HandleScope scope(isolate); |
| 5619 TryCatch try_catch; | 5629 TryCatch try_catch; |
| 5620 Handle<String> str = obj->ToString(); | 5630 Handle<String> str = obj->ToString(); |
| 5621 if (str.IsEmpty()) return; | 5631 if (str.IsEmpty()) return; |
| (...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6695 | 6705 |
| 6696 v->VisitPointers(blocks_.first(), first_block_limit_); | 6706 v->VisitPointers(blocks_.first(), first_block_limit_); |
| 6697 | 6707 |
| 6698 for (int i = 1; i < blocks_.length(); i++) { | 6708 for (int i = 1; i < blocks_.length(); i++) { |
| 6699 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6709 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
| 6700 } | 6710 } |
| 6701 } | 6711 } |
| 6702 | 6712 |
| 6703 | 6713 |
| 6704 } } // namespace v8::internal | 6714 } } // namespace v8::internal |
| OLD | NEW |