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 4389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4400 | 4400 |
4401 | 4401 |
4402 HeapStatistics::HeapStatistics(): total_heap_size_(0), | 4402 HeapStatistics::HeapStatistics(): total_heap_size_(0), |
4403 total_heap_size_executable_(0), | 4403 total_heap_size_executable_(0), |
4404 total_physical_size_(0), | 4404 total_physical_size_(0), |
4405 used_heap_size_(0), | 4405 used_heap_size_(0), |
4406 heap_size_limit_(0) { } | 4406 heap_size_limit_(0) { } |
4407 | 4407 |
4408 | 4408 |
4409 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { | 4409 void v8::V8::GetHeapStatistics(HeapStatistics* heap_statistics) { |
4410 if (!i::Isolate::Current()->IsInitialized()) { | 4410 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 4411 if (isolate == NULL || !isolate->IsInitialized()) { |
4411 // Isolate is unitialized thus heap is not configured yet. | 4412 // Isolate is unitialized thus heap is not configured yet. |
4412 heap_statistics->set_total_heap_size(0); | 4413 heap_statistics->total_heap_size_ = 0; |
4413 heap_statistics->set_total_heap_size_executable(0); | 4414 heap_statistics->total_heap_size_executable_ = 0; |
4414 heap_statistics->set_total_physical_size(0); | 4415 heap_statistics->total_physical_size_ = 0; |
4415 heap_statistics->set_used_heap_size(0); | 4416 heap_statistics->used_heap_size_ = 0; |
4416 heap_statistics->set_heap_size_limit(0); | 4417 heap_statistics->heap_size_limit_ = 0; |
4417 return; | 4418 return; |
4418 } | 4419 } |
4419 | 4420 Isolate* ext_isolate = reinterpret_cast<Isolate*>(isolate); |
4420 i::Heap* heap = i::Isolate::Current()->heap(); | 4421 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 } | 4422 } |
4428 | 4423 |
4429 | 4424 |
4430 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { | 4425 void v8::V8::VisitExternalResources(ExternalResourceVisitor* visitor) { |
4431 i::Isolate* isolate = i::Isolate::Current(); | 4426 i::Isolate* isolate = i::Isolate::Current(); |
4432 IsDeadCheck(isolate, "v8::V8::VisitExternalResources"); | 4427 IsDeadCheck(isolate, "v8::V8::VisitExternalResources"); |
4433 isolate->heap()->VisitExternalResources(visitor); | 4428 isolate->heap()->VisitExternalResources(visitor); |
4434 } | 4429 } |
4435 | 4430 |
4436 | 4431 |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5602 isolate->Enter(); | 5597 isolate->Enter(); |
5603 } | 5598 } |
5604 | 5599 |
5605 | 5600 |
5606 void Isolate::Exit() { | 5601 void Isolate::Exit() { |
5607 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); | 5602 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
5608 isolate->Exit(); | 5603 isolate->Exit(); |
5609 } | 5604 } |
5610 | 5605 |
5611 | 5606 |
| 5607 void Isolate::GetHeapStatistics(HeapStatistics* heap_statistics) { |
| 5608 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this); |
| 5609 i::Heap* heap = isolate->heap(); |
| 5610 heap_statistics->total_heap_size_ = heap->CommittedMemory(); |
| 5611 heap_statistics->total_heap_size_executable_ = |
| 5612 heap->CommittedMemoryExecutable(); |
| 5613 heap_statistics->total_physical_size_ = heap->CommittedPhysicalMemory(); |
| 5614 heap_statistics->used_heap_size_ = heap->SizeOfObjects(); |
| 5615 heap_statistics->heap_size_limit_ = heap->MaxReserved(); |
| 5616 } |
| 5617 |
| 5618 |
5612 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) | 5619 String::Utf8Value::Utf8Value(v8::Handle<v8::Value> obj) |
5613 : str_(NULL), length_(0) { | 5620 : str_(NULL), length_(0) { |
5614 i::Isolate* isolate = i::Isolate::Current(); | 5621 i::Isolate* isolate = i::Isolate::Current(); |
5615 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; | 5622 if (IsDeadCheck(isolate, "v8::String::Utf8Value::Utf8Value()")) return; |
5616 if (obj.IsEmpty()) return; | 5623 if (obj.IsEmpty()) return; |
5617 ENTER_V8(isolate); | 5624 ENTER_V8(isolate); |
5618 i::HandleScope scope(isolate); | 5625 i::HandleScope scope(isolate); |
5619 TryCatch try_catch; | 5626 TryCatch try_catch; |
5620 Handle<String> str = obj->ToString(); | 5627 Handle<String> str = obj->ToString(); |
5621 if (str.IsEmpty()) return; | 5628 if (str.IsEmpty()) return; |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6695 | 6702 |
6696 v->VisitPointers(blocks_.first(), first_block_limit_); | 6703 v->VisitPointers(blocks_.first(), first_block_limit_); |
6697 | 6704 |
6698 for (int i = 1; i < blocks_.length(); i++) { | 6705 for (int i = 1; i < blocks_.length(); i++) { |
6699 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6706 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
6700 } | 6707 } |
6701 } | 6708 } |
6702 | 6709 |
6703 | 6710 |
6704 } } // namespace v8::internal | 6711 } } // namespace v8::internal |
OLD | NEW |