| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include "arguments.h" | 32 #include "arguments.h" |
| 33 #include "bootstrapper.h" | 33 #include "bootstrapper.h" |
| 34 #include "compiler.h" | 34 #include "compiler.h" |
| 35 #include "debug.h" | 35 #include "debug.h" |
| 36 #include "deoptimizer.h" | 36 #include "deoptimizer.h" |
| 37 #include "execution.h" | 37 #include "execution.h" |
| 38 #include "global-handles.h" | 38 #include "global-handles.h" |
| 39 #include "heap-profiler.h" | 39 #include "heap-profiler.h" |
| 40 #include "messages.h" | 40 #include "messages.h" |
| 41 #include "natives.h" |
| 41 #include "parser.h" | 42 #include "parser.h" |
| 42 #include "platform.h" | 43 #include "platform.h" |
| 43 #include "profile-generator-inl.h" | 44 #include "profile-generator-inl.h" |
| 44 #include "runtime-profiler.h" | 45 #include "runtime-profiler.h" |
| 45 #include "serialize.h" | 46 #include "serialize.h" |
| 46 #include "snapshot.h" | 47 #include "snapshot.h" |
| 47 #include "v8threads.h" | 48 #include "v8threads.h" |
| 48 #include "version.h" | 49 #include "version.h" |
| 49 #include "vm-state-inl.h" | 50 #include "vm-state-inl.h" |
| 50 | 51 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 (isolate)->is_out_of_memory()) { \ | 91 (isolate)->is_out_of_memory()) { \ |
| 91 if (!handle_scope_implementer->ignore_out_of_memory()) \ | 92 if (!handle_scope_implementer->ignore_out_of_memory()) \ |
| 92 i::V8::FatalProcessOutOfMemory(NULL); \ | 93 i::V8::FatalProcessOutOfMemory(NULL); \ |
| 93 } \ | 94 } \ |
| 94 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ | 95 bool call_depth_is_zero = handle_scope_implementer->CallDepthIsZero(); \ |
| 95 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ | 96 (isolate)->OptionalRescheduleException(call_depth_is_zero); \ |
| 96 return value; \ | 97 return value; \ |
| 97 } \ | 98 } \ |
| 98 } while (false) | 99 } while (false) |
| 99 | 100 |
| 100 // TODO(isolates): Add a parameter to this macro for an isolate. | |
| 101 | 101 |
| 102 #define API_ENTRY_CHECK(msg) \ | 102 #define API_ENTRY_CHECK(isolate, msg) \ |
| 103 do { \ | 103 do { \ |
| 104 if (v8::Locker::IsActive()) { \ | 104 if (v8::Locker::IsActive()) { \ |
| 105 ApiCheck(i::Isolate::Current()->thread_manager()-> \ | 105 ApiCheck(isolate->thread_manager()->IsLockedByCurrentThread(), \ |
| 106 IsLockedByCurrentThread(), \ | |
| 107 msg, \ | 106 msg, \ |
| 108 "Entering the V8 API without proper locking in place"); \ | 107 "Entering the V8 API without proper locking in place"); \ |
| 109 } \ | 108 } \ |
| 110 } while (false) | 109 } while (false) |
| 111 | 110 |
| 112 | 111 |
| 113 // --- E x c e p t i o n B e h a v i o r --- | 112 // --- E x c e p t i o n B e h a v i o r --- |
| 114 | 113 |
| 115 | 114 |
| 116 static void DefaultFatalErrorHandler(const char* location, | 115 static void DefaultFatalErrorHandler(const char* location, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 intptr_t lo_space_size; | 168 intptr_t lo_space_size; |
| 170 heap_stats.lo_space_size = &lo_space_size; | 169 heap_stats.lo_space_size = &lo_space_size; |
| 171 int global_handle_count; | 170 int global_handle_count; |
| 172 heap_stats.global_handle_count = &global_handle_count; | 171 heap_stats.global_handle_count = &global_handle_count; |
| 173 int weak_global_handle_count; | 172 int weak_global_handle_count; |
| 174 heap_stats.weak_global_handle_count = &weak_global_handle_count; | 173 heap_stats.weak_global_handle_count = &weak_global_handle_count; |
| 175 int pending_global_handle_count; | 174 int pending_global_handle_count; |
| 176 heap_stats.pending_global_handle_count = &pending_global_handle_count; | 175 heap_stats.pending_global_handle_count = &pending_global_handle_count; |
| 177 int near_death_global_handle_count; | 176 int near_death_global_handle_count; |
| 178 heap_stats.near_death_global_handle_count = &near_death_global_handle_count; | 177 heap_stats.near_death_global_handle_count = &near_death_global_handle_count; |
| 179 int destroyed_global_handle_count; | 178 int free_global_handle_count; |
| 180 heap_stats.destroyed_global_handle_count = &destroyed_global_handle_count; | 179 heap_stats.free_global_handle_count = &free_global_handle_count; |
| 181 intptr_t memory_allocator_size; | 180 intptr_t memory_allocator_size; |
| 182 heap_stats.memory_allocator_size = &memory_allocator_size; | 181 heap_stats.memory_allocator_size = &memory_allocator_size; |
| 183 intptr_t memory_allocator_capacity; | 182 intptr_t memory_allocator_capacity; |
| 184 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; | 183 heap_stats.memory_allocator_capacity = &memory_allocator_capacity; |
| 185 int objects_per_type[LAST_TYPE + 1] = {0}; | 184 int objects_per_type[LAST_TYPE + 1] = {0}; |
| 186 heap_stats.objects_per_type = objects_per_type; | 185 heap_stats.objects_per_type = objects_per_type; |
| 187 int size_per_type[LAST_TYPE + 1] = {0}; | 186 int size_per_type[LAST_TYPE + 1] = {0}; |
| 188 heap_stats.size_per_type = size_per_type; | 187 heap_stats.size_per_type = size_per_type; |
| 189 int os_error; | 188 int os_error; |
| 190 heap_stats.os_error = &os_error; | 189 heap_stats.os_error = &os_error; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 303 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 305 if (isolate != NULL) | 304 if (isolate != NULL) |
| 306 return isolate; | 305 return isolate; |
| 307 | 306 |
| 308 i::Isolate::EnterDefaultIsolate(); | 307 i::Isolate::EnterDefaultIsolate(); |
| 309 isolate = i::Isolate::Current(); | 308 isolate = i::Isolate::Current(); |
| 310 return isolate; | 309 return isolate; |
| 311 } | 310 } |
| 312 | 311 |
| 313 | 312 |
| 313 StartupDataDecompressor::StartupDataDecompressor() |
| 314 : raw_data(i::NewArray<char*>(V8::GetCompressedStartupDataCount())) { |
| 315 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { |
| 316 raw_data[i] = NULL; |
| 317 } |
| 318 } |
| 319 |
| 320 |
| 321 StartupDataDecompressor::~StartupDataDecompressor() { |
| 322 for (int i = 0; i < V8::GetCompressedStartupDataCount(); ++i) { |
| 323 i::DeleteArray(raw_data[i]); |
| 324 } |
| 325 i::DeleteArray(raw_data); |
| 326 } |
| 327 |
| 328 |
| 329 int StartupDataDecompressor::Decompress() { |
| 330 int compressed_data_count = V8::GetCompressedStartupDataCount(); |
| 331 StartupData* compressed_data = |
| 332 i::NewArray<StartupData>(compressed_data_count); |
| 333 V8::GetCompressedStartupData(compressed_data); |
| 334 for (int i = 0; i < compressed_data_count; ++i) { |
| 335 char* decompressed = raw_data[i] = |
| 336 i::NewArray<char>(compressed_data[i].raw_size); |
| 337 if (compressed_data[i].compressed_size != 0) { |
| 338 int result = DecompressData(decompressed, |
| 339 &compressed_data[i].raw_size, |
| 340 compressed_data[i].data, |
| 341 compressed_data[i].compressed_size); |
| 342 if (result != 0) return result; |
| 343 } else { |
| 344 ASSERT_EQ(0, compressed_data[i].raw_size); |
| 345 } |
| 346 compressed_data[i].data = decompressed; |
| 347 } |
| 348 V8::SetDecompressedStartupData(compressed_data); |
| 349 return 0; |
| 350 } |
| 351 |
| 352 |
| 314 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { | 353 StartupData::CompressionAlgorithm V8::GetCompressedStartupDataAlgorithm() { |
| 315 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 354 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 316 return StartupData::kBZip2; | 355 return StartupData::kBZip2; |
| 317 #else | 356 #else |
| 318 return StartupData::kUncompressed; | 357 return StartupData::kUncompressed; |
| 319 #endif | 358 #endif |
| 320 } | 359 } |
| 321 | 360 |
| 322 | 361 |
| 323 enum CompressedStartupDataItems { | 362 enum CompressedStartupDataItems { |
| 324 kSnapshot = 0, | 363 kSnapshot = 0, |
| 325 kSnapshotContext, | 364 kSnapshotContext, |
| 365 kLibraries, |
| 366 kExperimentalLibraries, |
| 326 kCompressedStartupDataCount | 367 kCompressedStartupDataCount |
| 327 }; | 368 }; |
| 328 | 369 |
| 329 int V8::GetCompressedStartupDataCount() { | 370 int V8::GetCompressedStartupDataCount() { |
| 330 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 371 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 331 return kCompressedStartupDataCount; | 372 return kCompressedStartupDataCount; |
| 332 #else | 373 #else |
| 333 return 0; | 374 return 0; |
| 334 #endif | 375 #endif |
| 335 } | 376 } |
| 336 | 377 |
| 337 | 378 |
| 338 void V8::GetCompressedStartupData(StartupData* compressed_data) { | 379 void V8::GetCompressedStartupData(StartupData* compressed_data) { |
| 339 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 380 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 340 compressed_data[kSnapshot].data = | 381 compressed_data[kSnapshot].data = |
| 341 reinterpret_cast<const char*>(i::Snapshot::data()); | 382 reinterpret_cast<const char*>(i::Snapshot::data()); |
| 342 compressed_data[kSnapshot].compressed_size = i::Snapshot::size(); | 383 compressed_data[kSnapshot].compressed_size = i::Snapshot::size(); |
| 343 compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size(); | 384 compressed_data[kSnapshot].raw_size = i::Snapshot::raw_size(); |
| 344 | 385 |
| 345 compressed_data[kSnapshotContext].data = | 386 compressed_data[kSnapshotContext].data = |
| 346 reinterpret_cast<const char*>(i::Snapshot::context_data()); | 387 reinterpret_cast<const char*>(i::Snapshot::context_data()); |
| 347 compressed_data[kSnapshotContext].compressed_size = | 388 compressed_data[kSnapshotContext].compressed_size = |
| 348 i::Snapshot::context_size(); | 389 i::Snapshot::context_size(); |
| 349 compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size(); | 390 compressed_data[kSnapshotContext].raw_size = i::Snapshot::context_raw_size(); |
| 391 |
| 392 i::Vector<const i::byte> libraries_source = i::Natives::GetScriptsSource(); |
| 393 compressed_data[kLibraries].data = |
| 394 reinterpret_cast<const char*>(libraries_source.start()); |
| 395 compressed_data[kLibraries].compressed_size = libraries_source.length(); |
| 396 compressed_data[kLibraries].raw_size = i::Natives::GetRawScriptsSize(); |
| 397 |
| 398 i::Vector<const i::byte> exp_libraries_source = |
| 399 i::ExperimentalNatives::GetScriptsSource(); |
| 400 compressed_data[kExperimentalLibraries].data = |
| 401 reinterpret_cast<const char*>(exp_libraries_source.start()); |
| 402 compressed_data[kExperimentalLibraries].compressed_size = |
| 403 exp_libraries_source.length(); |
| 404 compressed_data[kExperimentalLibraries].raw_size = |
| 405 i::ExperimentalNatives::GetRawScriptsSize(); |
| 350 #endif | 406 #endif |
| 351 } | 407 } |
| 352 | 408 |
| 353 | 409 |
| 354 void V8::SetDecompressedStartupData(StartupData* decompressed_data) { | 410 void V8::SetDecompressedStartupData(StartupData* decompressed_data) { |
| 355 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 411 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
| 356 ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size); | 412 ASSERT_EQ(i::Snapshot::raw_size(), decompressed_data[kSnapshot].raw_size); |
| 357 i::Snapshot::set_raw_data( | 413 i::Snapshot::set_raw_data( |
| 358 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data)); | 414 reinterpret_cast<const i::byte*>(decompressed_data[kSnapshot].data)); |
| 359 | 415 |
| 360 ASSERT_EQ(i::Snapshot::context_raw_size(), | 416 ASSERT_EQ(i::Snapshot::context_raw_size(), |
| 361 decompressed_data[kSnapshotContext].raw_size); | 417 decompressed_data[kSnapshotContext].raw_size); |
| 362 i::Snapshot::set_context_raw_data( | 418 i::Snapshot::set_context_raw_data( |
| 363 reinterpret_cast<const i::byte*>( | 419 reinterpret_cast<const i::byte*>( |
| 364 decompressed_data[kSnapshotContext].data)); | 420 decompressed_data[kSnapshotContext].data)); |
| 421 |
| 422 ASSERT_EQ(i::Natives::GetRawScriptsSize(), |
| 423 decompressed_data[kLibraries].raw_size); |
| 424 i::Vector<const char> libraries_source( |
| 425 decompressed_data[kLibraries].data, |
| 426 decompressed_data[kLibraries].raw_size); |
| 427 i::Natives::SetRawScriptsSource(libraries_source); |
| 428 |
| 429 ASSERT_EQ(i::ExperimentalNatives::GetRawScriptsSize(), |
| 430 decompressed_data[kExperimentalLibraries].raw_size); |
| 431 i::Vector<const char> exp_libraries_source( |
| 432 decompressed_data[kExperimentalLibraries].data, |
| 433 decompressed_data[kExperimentalLibraries].raw_size); |
| 434 i::ExperimentalNatives::SetRawScriptsSource(exp_libraries_source); |
| 365 #endif | 435 #endif |
| 366 } | 436 } |
| 367 | 437 |
| 368 | 438 |
| 369 void V8::SetFatalErrorHandler(FatalErrorCallback that) { | 439 void V8::SetFatalErrorHandler(FatalErrorCallback that) { |
| 370 i::Isolate* isolate = EnterIsolateIfNeeded(); | 440 i::Isolate* isolate = EnterIsolateIfNeeded(); |
| 371 isolate->set_exception_behavior(that); | 441 isolate->set_exception_behavior(that); |
| 372 } | 442 } |
| 373 | 443 |
| 374 | 444 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 i::Isolate* isolate = i::Isolate::Current(); | 636 i::Isolate* isolate = i::Isolate::Current(); |
| 567 LOG_API(isolate, "DisposeGlobal"); | 637 LOG_API(isolate, "DisposeGlobal"); |
| 568 if (!isolate->IsInitialized()) return; | 638 if (!isolate->IsInitialized()) return; |
| 569 isolate->global_handles()->Destroy(obj); | 639 isolate->global_handles()->Destroy(obj); |
| 570 } | 640 } |
| 571 | 641 |
| 572 // --- H a n d l e s --- | 642 // --- H a n d l e s --- |
| 573 | 643 |
| 574 | 644 |
| 575 HandleScope::HandleScope() { | 645 HandleScope::HandleScope() { |
| 576 API_ENTRY_CHECK("HandleScope::HandleScope"); | |
| 577 i::Isolate* isolate = i::Isolate::Current(); | 646 i::Isolate* isolate = i::Isolate::Current(); |
| 647 API_ENTRY_CHECK(isolate, "HandleScope::HandleScope"); |
| 578 v8::ImplementationUtilities::HandleScopeData* current = | 648 v8::ImplementationUtilities::HandleScopeData* current = |
| 579 isolate->handle_scope_data(); | 649 isolate->handle_scope_data(); |
| 580 isolate_ = isolate; | 650 isolate_ = isolate; |
| 581 prev_next_ = current->next; | 651 prev_next_ = current->next; |
| 582 prev_limit_ = current->limit; | 652 prev_limit_ = current->limit; |
| 583 is_closed_ = false; | 653 is_closed_ = false; |
| 584 current->level++; | 654 current->level++; |
| 585 } | 655 } |
| 586 | 656 |
| 587 | 657 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 693 |
| 624 | 694 |
| 625 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { | 695 i::Object** HandleScope::CreateHandle(i::HeapObject* value) { |
| 626 ASSERT(value->IsHeapObject()); | 696 ASSERT(value->IsHeapObject()); |
| 627 return reinterpret_cast<i::Object**>( | 697 return reinterpret_cast<i::Object**>( |
| 628 i::HandleScope::CreateHandle(value, value->GetIsolate())); | 698 i::HandleScope::CreateHandle(value, value->GetIsolate())); |
| 629 } | 699 } |
| 630 | 700 |
| 631 | 701 |
| 632 void Context::Enter() { | 702 void Context::Enter() { |
| 633 // TODO(isolates): Context should have a pointer to isolate. | 703 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 634 i::Isolate* isolate = i::Isolate::Current(); | 704 i::Isolate* isolate = env->GetIsolate(); |
| 635 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return; | 705 if (IsDeadCheck(isolate, "v8::Context::Enter()")) return; |
| 636 ENTER_V8(isolate); | 706 ENTER_V8(isolate); |
| 637 | 707 |
| 638 i::Handle<i::Context> env = Utils::OpenHandle(this); | |
| 639 isolate->handle_scope_implementer()->EnterContext(env); | 708 isolate->handle_scope_implementer()->EnterContext(env); |
| 640 | 709 |
| 641 isolate->handle_scope_implementer()->SaveContext(isolate->context()); | 710 isolate->handle_scope_implementer()->SaveContext(isolate->context()); |
| 642 isolate->set_context(*env); | 711 isolate->set_context(*env); |
| 643 } | 712 } |
| 644 | 713 |
| 645 | 714 |
| 646 void Context::Exit() { | 715 void Context::Exit() { |
| 647 // TODO(isolates): Context should have a pointer to isolate. | 716 // Exit is essentially a static function and doesn't use the |
| 717 // receiver, so we have to get the current isolate from the thread |
| 718 // local. |
| 648 i::Isolate* isolate = i::Isolate::Current(); | 719 i::Isolate* isolate = i::Isolate::Current(); |
| 649 if (!isolate->IsInitialized()) return; | 720 if (!isolate->IsInitialized()) return; |
| 650 | 721 |
| 651 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), | 722 if (!ApiCheck(isolate->handle_scope_implementer()->LeaveLastContext(), |
| 652 "v8::Context::Exit()", | 723 "v8::Context::Exit()", |
| 653 "Cannot exit non-entered context")) { | 724 "Cannot exit non-entered context")) { |
| 654 return; | 725 return; |
| 655 } | 726 } |
| 656 | 727 |
| 657 // Content of 'last_context' could be NULL. | 728 // Content of 'last_context' could be NULL. |
| 658 i::Context* last_context = | 729 i::Context* last_context = |
| 659 isolate->handle_scope_implementer()->RestoreContext(); | 730 isolate->handle_scope_implementer()->RestoreContext(); |
| 660 isolate->set_context(last_context); | 731 isolate->set_context(last_context); |
| 661 } | 732 } |
| 662 | 733 |
| 663 | 734 |
| 664 void Context::SetData(v8::Handle<String> data) { | 735 void Context::SetData(v8::Handle<String> data) { |
| 665 // TODO(isolates): Context should have a pointer to isolate. | 736 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 666 i::Isolate* isolate = i::Isolate::Current(); | 737 i::Isolate* isolate = env->GetIsolate(); |
| 667 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; | 738 if (IsDeadCheck(isolate, "v8::Context::SetData()")) return; |
| 668 ENTER_V8(isolate); | 739 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); |
| 669 { | 740 ASSERT(env->IsGlobalContext()); |
| 670 i::HandleScope scope(isolate); | 741 if (env->IsGlobalContext()) { |
| 671 i::Handle<i::Context> env = Utils::OpenHandle(this); | 742 env->set_data(*raw_data); |
| 672 i::Handle<i::Object> raw_data = Utils::OpenHandle(*data); | |
| 673 ASSERT(env->IsGlobalContext()); | |
| 674 if (env->IsGlobalContext()) { | |
| 675 env->set_data(*raw_data); | |
| 676 } | |
| 677 } | 743 } |
| 678 } | 744 } |
| 679 | 745 |
| 680 | 746 |
| 681 v8::Local<v8::Value> Context::GetData() { | 747 v8::Local<v8::Value> Context::GetData() { |
| 682 // TODO(isolates): Context should have a pointer to isolate. | 748 i::Handle<i::Context> env = Utils::OpenHandle(this); |
| 683 i::Isolate* isolate = i::Isolate::Current(); | 749 i::Isolate* isolate = env->GetIsolate(); |
| 684 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { | 750 if (IsDeadCheck(isolate, "v8::Context::GetData()")) { |
| 685 return v8::Local<Value>(); | 751 return v8::Local<Value>(); |
| 686 } | 752 } |
| 687 ENTER_V8(isolate); | |
| 688 i::Object* raw_result = NULL; | 753 i::Object* raw_result = NULL; |
| 689 { | 754 ASSERT(env->IsGlobalContext()); |
| 690 i::HandleScope scope(isolate); | 755 if (env->IsGlobalContext()) { |
| 691 i::Handle<i::Context> env = Utils::OpenHandle(this); | 756 raw_result = env->data(); |
| 692 ASSERT(env->IsGlobalContext()); | 757 } else { |
| 693 if (env->IsGlobalContext()) { | 758 return Local<Value>(); |
| 694 raw_result = env->data(); | |
| 695 } else { | |
| 696 return Local<Value>(); | |
| 697 } | |
| 698 } | 759 } |
| 699 i::Handle<i::Object> result(raw_result); | 760 i::Handle<i::Object> result(raw_result, isolate); |
| 700 return Utils::ToLocal(result); | 761 return Utils::ToLocal(result); |
| 701 } | 762 } |
| 702 | 763 |
| 703 | 764 |
| 704 i::Object** v8::HandleScope::RawClose(i::Object** value) { | 765 i::Object** v8::HandleScope::RawClose(i::Object** value) { |
| 705 if (!ApiCheck(!is_closed_, | 766 if (!ApiCheck(!is_closed_, |
| 706 "v8::HandleScope::Close()", | 767 "v8::HandleScope::Close()", |
| 707 "Local scope has already been closed")) { | 768 "Local scope has already been closed")) { |
| 708 return 0; | 769 return 0; |
| 709 } | 770 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 array.add(Utils::OpenHandle(*value)); | 877 array.add(Utils::OpenHandle(*value)); |
| 817 array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); | 878 array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); |
| 818 } | 879 } |
| 819 | 880 |
| 820 | 881 |
| 821 // --- F u n c t i o n T e m p l a t e --- | 882 // --- F u n c t i o n T e m p l a t e --- |
| 822 static void InitializeFunctionTemplate( | 883 static void InitializeFunctionTemplate( |
| 823 i::Handle<i::FunctionTemplateInfo> info) { | 884 i::Handle<i::FunctionTemplateInfo> info) { |
| 824 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 885 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
| 825 info->set_flag(0); | 886 info->set_flag(0); |
| 887 info->set_prototype_attributes(i::Smi::FromInt(v8::None)); |
| 826 } | 888 } |
| 827 | 889 |
| 828 | 890 |
| 829 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 891 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
| 830 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 892 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 831 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) { | 893 if (IsDeadCheck(isolate, "v8::FunctionTemplate::PrototypeTemplate()")) { |
| 832 return Local<ObjectTemplate>(); | 894 return Local<ObjectTemplate>(); |
| 833 } | 895 } |
| 834 ENTER_V8(isolate); | 896 ENTER_V8(isolate); |
| 835 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); | 897 i::Handle<i::Object> result(Utils::OpenHandle(this)->prototype_template()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 i::Handle<i::TypeSwitchInfo> obj = | 980 i::Handle<i::TypeSwitchInfo> obj = |
| 919 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); | 981 i::Handle<i::TypeSwitchInfo>::cast(struct_obj); |
| 920 obj->set_types(*vector); | 982 obj->set_types(*vector); |
| 921 return Utils::ToLocal(obj); | 983 return Utils::ToLocal(obj); |
| 922 } | 984 } |
| 923 | 985 |
| 924 | 986 |
| 925 int TypeSwitch::match(v8::Handle<Value> value) { | 987 int TypeSwitch::match(v8::Handle<Value> value) { |
| 926 i::Isolate* isolate = i::Isolate::Current(); | 988 i::Isolate* isolate = i::Isolate::Current(); |
| 927 LOG_API(isolate, "TypeSwitch::match"); | 989 LOG_API(isolate, "TypeSwitch::match"); |
| 990 USE(isolate); |
| 928 i::Handle<i::Object> obj = Utils::OpenHandle(*value); | 991 i::Handle<i::Object> obj = Utils::OpenHandle(*value); |
| 929 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); | 992 i::Handle<i::TypeSwitchInfo> info = Utils::OpenHandle(this); |
| 930 i::FixedArray* types = i::FixedArray::cast(info->types()); | 993 i::FixedArray* types = i::FixedArray::cast(info->types()); |
| 931 for (int i = 0; i < types->length(); i++) { | 994 for (int i = 0; i < types->length(); i++) { |
| 932 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) | 995 if (obj->IsInstanceOf(i::FunctionTemplateInfo::cast(types->get(i)))) |
| 933 return i + 1; | 996 return i + 1; |
| 934 } | 997 } |
| 935 return 0; | 998 return 0; |
| 936 } | 999 } |
| 937 | 1000 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 void FunctionTemplate::SetHiddenPrototype(bool value) { | 1100 void FunctionTemplate::SetHiddenPrototype(bool value) { |
| 1038 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1101 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1039 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) { | 1102 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetHiddenPrototype()")) { |
| 1040 return; | 1103 return; |
| 1041 } | 1104 } |
| 1042 ENTER_V8(isolate); | 1105 ENTER_V8(isolate); |
| 1043 Utils::OpenHandle(this)->set_hidden_prototype(value); | 1106 Utils::OpenHandle(this)->set_hidden_prototype(value); |
| 1044 } | 1107 } |
| 1045 | 1108 |
| 1046 | 1109 |
| 1110 void FunctionTemplate::SetPrototypeAttributes(int attributes) { |
| 1111 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1112 if (IsDeadCheck(isolate, "v8::FunctionTemplate::SetPrototypeAttributes()")) { |
| 1113 return; |
| 1114 } |
| 1115 ENTER_V8(isolate); |
| 1116 Utils::OpenHandle(this)->set_prototype_attributes( |
| 1117 i::Smi::FromInt(attributes)); |
| 1118 } |
| 1119 |
| 1120 |
| 1047 void FunctionTemplate::SetNamedInstancePropertyHandler( | 1121 void FunctionTemplate::SetNamedInstancePropertyHandler( |
| 1048 NamedPropertyGetter getter, | 1122 NamedPropertyGetter getter, |
| 1049 NamedPropertySetter setter, | 1123 NamedPropertySetter setter, |
| 1050 NamedPropertyQuery query, | 1124 NamedPropertyQuery query, |
| 1051 NamedPropertyDeleter remover, | 1125 NamedPropertyDeleter remover, |
| 1052 NamedPropertyEnumerator enumerator, | 1126 NamedPropertyEnumerator enumerator, |
| 1053 Handle<Value> data) { | 1127 Handle<Value> data) { |
| 1054 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1128 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 1055 if (IsDeadCheck(isolate, | 1129 if (IsDeadCheck(isolate, |
| 1056 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { | 1130 "v8::FunctionTemplate::SetNamedInstancePropertyHandler()")) { |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 i::Handle<i::Script> script(i::Script::cast(function_info->script())); | 1612 i::Handle<i::Script> script(i::Script::cast(function_info->script())); |
| 1539 script->set_data(*raw_data); | 1613 script->set_data(*raw_data); |
| 1540 } | 1614 } |
| 1541 } | 1615 } |
| 1542 | 1616 |
| 1543 | 1617 |
| 1544 // --- E x c e p t i o n s --- | 1618 // --- E x c e p t i o n s --- |
| 1545 | 1619 |
| 1546 | 1620 |
| 1547 v8::TryCatch::TryCatch() | 1621 v8::TryCatch::TryCatch() |
| 1548 : next_(i::Isolate::Current()->try_catch_handler_address()), | 1622 : isolate_(i::Isolate::Current()), |
| 1549 exception_(HEAP->the_hole_value()), | 1623 next_(isolate_->try_catch_handler_address()), |
| 1624 exception_(isolate_->heap()->the_hole_value()), |
| 1550 message_(i::Smi::FromInt(0)), | 1625 message_(i::Smi::FromInt(0)), |
| 1551 is_verbose_(false), | 1626 is_verbose_(false), |
| 1552 can_continue_(true), | 1627 can_continue_(true), |
| 1553 capture_message_(true), | 1628 capture_message_(true), |
| 1554 rethrow_(false) { | 1629 rethrow_(false) { |
| 1555 i::Isolate::Current()->RegisterTryCatchHandler(this); | 1630 isolate_->RegisterTryCatchHandler(this); |
| 1556 } | 1631 } |
| 1557 | 1632 |
| 1558 | 1633 |
| 1559 v8::TryCatch::~TryCatch() { | 1634 v8::TryCatch::~TryCatch() { |
| 1560 i::Isolate* isolate = i::Isolate::Current(); | 1635 ASSERT(isolate_ == i::Isolate::Current()); |
| 1561 if (rethrow_) { | 1636 if (rethrow_) { |
| 1562 v8::HandleScope scope; | 1637 v8::HandleScope scope; |
| 1563 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); | 1638 v8::Local<v8::Value> exc = v8::Local<v8::Value>::New(Exception()); |
| 1564 isolate->UnregisterTryCatchHandler(this); | 1639 isolate_->UnregisterTryCatchHandler(this); |
| 1565 v8::ThrowException(exc); | 1640 v8::ThrowException(exc); |
| 1566 } else { | 1641 } else { |
| 1567 isolate->UnregisterTryCatchHandler(this); | 1642 isolate_->UnregisterTryCatchHandler(this); |
| 1568 } | 1643 } |
| 1569 } | 1644 } |
| 1570 | 1645 |
| 1571 | 1646 |
| 1572 bool v8::TryCatch::HasCaught() const { | 1647 bool v8::TryCatch::HasCaught() const { |
| 1573 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); | 1648 return !reinterpret_cast<i::Object*>(exception_)->IsTheHole(); |
| 1574 } | 1649 } |
| 1575 | 1650 |
| 1576 | 1651 |
| 1577 bool v8::TryCatch::CanContinue() const { | 1652 bool v8::TryCatch::CanContinue() const { |
| 1578 return can_continue_; | 1653 return can_continue_; |
| 1579 } | 1654 } |
| 1580 | 1655 |
| 1581 | 1656 |
| 1582 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { | 1657 v8::Handle<v8::Value> v8::TryCatch::ReThrow() { |
| 1583 if (!HasCaught()) return v8::Local<v8::Value>(); | 1658 if (!HasCaught()) return v8::Local<v8::Value>(); |
| 1584 rethrow_ = true; | 1659 rethrow_ = true; |
| 1585 return v8::Undefined(); | 1660 return v8::Undefined(); |
| 1586 } | 1661 } |
| 1587 | 1662 |
| 1588 | 1663 |
| 1589 v8::Local<Value> v8::TryCatch::Exception() const { | 1664 v8::Local<Value> v8::TryCatch::Exception() const { |
| 1665 ASSERT(isolate_ == i::Isolate::Current()); |
| 1590 if (HasCaught()) { | 1666 if (HasCaught()) { |
| 1591 // Check for out of memory exception. | 1667 // Check for out of memory exception. |
| 1592 i::Object* exception = reinterpret_cast<i::Object*>(exception_); | 1668 i::Object* exception = reinterpret_cast<i::Object*>(exception_); |
| 1593 return v8::Utils::ToLocal(i::Handle<i::Object>(exception)); | 1669 return v8::Utils::ToLocal(i::Handle<i::Object>(exception, isolate_)); |
| 1594 } else { | 1670 } else { |
| 1595 return v8::Local<Value>(); | 1671 return v8::Local<Value>(); |
| 1596 } | 1672 } |
| 1597 } | 1673 } |
| 1598 | 1674 |
| 1599 | 1675 |
| 1600 v8::Local<Value> v8::TryCatch::StackTrace() const { | 1676 v8::Local<Value> v8::TryCatch::StackTrace() const { |
| 1677 ASSERT(isolate_ == i::Isolate::Current()); |
| 1601 if (HasCaught()) { | 1678 if (HasCaught()) { |
| 1602 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); | 1679 i::Object* raw_obj = reinterpret_cast<i::Object*>(exception_); |
| 1603 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); | 1680 if (!raw_obj->IsJSObject()) return v8::Local<Value>(); |
| 1604 v8::HandleScope scope; | 1681 i::HandleScope scope(isolate_); |
| 1605 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj)); | 1682 i::Handle<i::JSObject> obj(i::JSObject::cast(raw_obj), isolate_); |
| 1606 i::Handle<i::String> name = FACTORY->LookupAsciiSymbol("stack"); | 1683 i::Handle<i::String> name = isolate_->factory()->LookupAsciiSymbol("stack"); |
| 1607 if (!obj->HasProperty(*name)) | 1684 if (!obj->HasProperty(*name)) return v8::Local<Value>(); |
| 1608 return v8::Local<Value>(); | 1685 i::Handle<i::Object> value = i::GetProperty(obj, name); |
| 1609 return scope.Close(v8::Utils::ToLocal(i::GetProperty(obj, name))); | 1686 if (value.is_null()) return v8::Local<Value>(); |
| 1687 return v8::Utils::ToLocal(scope.CloseAndEscape(value)); |
| 1610 } else { | 1688 } else { |
| 1611 return v8::Local<Value>(); | 1689 return v8::Local<Value>(); |
| 1612 } | 1690 } |
| 1613 } | 1691 } |
| 1614 | 1692 |
| 1615 | 1693 |
| 1616 v8::Local<v8::Message> v8::TryCatch::Message() const { | 1694 v8::Local<v8::Message> v8::TryCatch::Message() const { |
| 1695 ASSERT(isolate_ == i::Isolate::Current()); |
| 1617 if (HasCaught() && message_ != i::Smi::FromInt(0)) { | 1696 if (HasCaught() && message_ != i::Smi::FromInt(0)) { |
| 1618 i::Object* message = reinterpret_cast<i::Object*>(message_); | 1697 i::Object* message = reinterpret_cast<i::Object*>(message_); |
| 1619 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message)); | 1698 return v8::Utils::MessageToLocal(i::Handle<i::Object>(message, isolate_)); |
| 1620 } else { | 1699 } else { |
| 1621 return v8::Local<v8::Message>(); | 1700 return v8::Local<v8::Message>(); |
| 1622 } | 1701 } |
| 1623 } | 1702 } |
| 1624 | 1703 |
| 1625 | 1704 |
| 1626 void v8::TryCatch::Reset() { | 1705 void v8::TryCatch::Reset() { |
| 1627 exception_ = HEAP->the_hole_value(); | 1706 ASSERT(isolate_ == i::Isolate::Current()); |
| 1707 exception_ = isolate_->heap()->the_hole_value(); |
| 1628 message_ = i::Smi::FromInt(0); | 1708 message_ = i::Smi::FromInt(0); |
| 1629 } | 1709 } |
| 1630 | 1710 |
| 1631 | 1711 |
| 1632 void v8::TryCatch::SetVerbose(bool value) { | 1712 void v8::TryCatch::SetVerbose(bool value) { |
| 1633 is_verbose_ = value; | 1713 is_verbose_ = value; |
| 1634 } | 1714 } |
| 1635 | 1715 |
| 1636 | 1716 |
| 1637 void v8::TryCatch::SetCaptureMessage(bool value) { | 1717 void v8::TryCatch::SetCaptureMessage(bool value) { |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2690 // Because we use caching to speed up enumeration it is important | 2770 // Because we use caching to speed up enumeration it is important |
| 2691 // to never change the result of the basic enumeration function so | 2771 // to never change the result of the basic enumeration function so |
| 2692 // we clone the result. | 2772 // we clone the result. |
| 2693 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); | 2773 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); |
| 2694 i::Handle<i::JSArray> result = | 2774 i::Handle<i::JSArray> result = |
| 2695 isolate->factory()->NewJSArrayWithElements(elms); | 2775 isolate->factory()->NewJSArrayWithElements(elms); |
| 2696 return Utils::ToLocal(scope.CloseAndEscape(result)); | 2776 return Utils::ToLocal(scope.CloseAndEscape(result)); |
| 2697 } | 2777 } |
| 2698 | 2778 |
| 2699 | 2779 |
| 2780 Local<Array> v8::Object::GetOwnPropertyNames() { |
| 2781 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2782 ON_BAILOUT(isolate, "v8::Object::GetOwnPropertyNames()", |
| 2783 return Local<v8::Array>()); |
| 2784 ENTER_V8(isolate); |
| 2785 i::HandleScope scope(isolate); |
| 2786 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2787 i::Handle<i::FixedArray> value = |
| 2788 i::GetKeysInFixedArrayFor(self, i::LOCAL_ONLY); |
| 2789 // Because we use caching to speed up enumeration it is important |
| 2790 // to never change the result of the basic enumeration function so |
| 2791 // we clone the result. |
| 2792 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); |
| 2793 i::Handle<i::JSArray> result = |
| 2794 isolate->factory()->NewJSArrayWithElements(elms); |
| 2795 return Utils::ToLocal(scope.CloseAndEscape(result)); |
| 2796 } |
| 2797 |
| 2798 |
| 2700 Local<String> v8::Object::ObjectProtoToString() { | 2799 Local<String> v8::Object::ObjectProtoToString() { |
| 2701 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 2800 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 2702 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()", | 2801 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()", |
| 2703 return Local<v8::String>()); | 2802 return Local<v8::String>()); |
| 2704 ENTER_V8(isolate); | 2803 ENTER_V8(isolate); |
| 2705 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 2804 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
| 2706 | 2805 |
| 2707 i::Handle<i::Object> name(self->class_name()); | 2806 i::Handle<i::Object> name(self->class_name()); |
| 2708 | 2807 |
| 2709 // Native implementation of Object.prototype.toString (v8natives.js): | 2808 // Native implementation of Object.prototype.toString (v8natives.js): |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3385 raw_result = *returned; | 3484 raw_result = *returned; |
| 3386 } | 3485 } |
| 3387 i::Handle<i::Object> result(raw_result); | 3486 i::Handle<i::Object> result(raw_result); |
| 3388 return Utils::ToLocal(result); | 3487 return Utils::ToLocal(result); |
| 3389 } | 3488 } |
| 3390 | 3489 |
| 3391 | 3490 |
| 3392 void Function::SetName(v8::Handle<v8::String> name) { | 3491 void Function::SetName(v8::Handle<v8::String> name) { |
| 3393 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3492 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3394 ENTER_V8(isolate); | 3493 ENTER_V8(isolate); |
| 3494 USE(isolate); |
| 3395 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 3495 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 3396 func->shared()->set_name(*Utils::OpenHandle(*name)); | 3496 func->shared()->set_name(*Utils::OpenHandle(*name)); |
| 3397 } | 3497 } |
| 3398 | 3498 |
| 3399 | 3499 |
| 3400 Handle<Value> Function::GetName() const { | 3500 Handle<Value> Function::GetName() const { |
| 3401 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); | 3501 i::Handle<i::JSFunction> func = Utils::OpenHandle(this); |
| 3402 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); | 3502 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name())); |
| 3403 } | 3503 } |
| 3404 | 3504 |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4255 i::Handle<i::String> obj = Utils::OpenHandle(this); | 4355 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 4256 i::Isolate* isolate = obj->GetIsolate(); | 4356 i::Isolate* isolate = obj->GetIsolate(); |
| 4257 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; | 4357 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; |
| 4258 if (i::StringShape(*obj).IsExternalTwoByte()) { | 4358 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 4259 return false; // Already an external string. | 4359 return false; // Already an external string. |
| 4260 } | 4360 } |
| 4261 ENTER_V8(isolate); | 4361 ENTER_V8(isolate); |
| 4262 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 4362 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 4263 return false; | 4363 return false; |
| 4264 } | 4364 } |
| 4365 if (isolate->heap()->IsInGCPostProcessing()) { |
| 4366 return false; |
| 4367 } |
| 4265 bool result = obj->MakeExternal(resource); | 4368 bool result = obj->MakeExternal(resource); |
| 4266 if (result && !obj->IsSymbol()) { | 4369 if (result && !obj->IsSymbol()) { |
| 4267 isolate->heap()->external_string_table()->AddString(*obj); | 4370 isolate->heap()->external_string_table()->AddString(*obj); |
| 4268 } | 4371 } |
| 4269 return result; | 4372 return result; |
| 4270 } | 4373 } |
| 4271 | 4374 |
| 4272 | 4375 |
| 4273 Local<String> v8::String::NewExternal( | 4376 Local<String> v8::String::NewExternal( |
| 4274 v8::String::ExternalAsciiStringResource* resource) { | 4377 v8::String::ExternalAsciiStringResource* resource) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4287 i::Handle<i::String> obj = Utils::OpenHandle(this); | 4390 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 4288 i::Isolate* isolate = obj->GetIsolate(); | 4391 i::Isolate* isolate = obj->GetIsolate(); |
| 4289 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; | 4392 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; |
| 4290 if (i::StringShape(*obj).IsExternalTwoByte()) { | 4393 if (i::StringShape(*obj).IsExternalTwoByte()) { |
| 4291 return false; // Already an external string. | 4394 return false; // Already an external string. |
| 4292 } | 4395 } |
| 4293 ENTER_V8(isolate); | 4396 ENTER_V8(isolate); |
| 4294 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { | 4397 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { |
| 4295 return false; | 4398 return false; |
| 4296 } | 4399 } |
| 4400 if (isolate->heap()->IsInGCPostProcessing()) { |
| 4401 return false; |
| 4402 } |
| 4297 bool result = obj->MakeExternal(resource); | 4403 bool result = obj->MakeExternal(resource); |
| 4298 if (result && !obj->IsSymbol()) { | 4404 if (result && !obj->IsSymbol()) { |
| 4299 isolate->heap()->external_string_table()->AddString(*obj); | 4405 isolate->heap()->external_string_table()->AddString(*obj); |
| 4300 } | 4406 } |
| 4301 return result; | 4407 return result; |
| 4302 } | 4408 } |
| 4303 | 4409 |
| 4304 | 4410 |
| 4305 bool v8::String::CanMakeExternal() { | 4411 bool v8::String::CanMakeExternal() { |
| 4306 i::Handle<i::String> obj = Utils::OpenHandle(this); | 4412 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4720 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { | 4826 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { |
| 4721 i::Isolate* isolate = i::Isolate::Current(); | 4827 i::Isolate* isolate = i::Isolate::Current(); |
| 4722 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; | 4828 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; |
| 4723 isolate->memory_allocator()->RemoveMemoryAllocationCallback( | 4829 isolate->memory_allocator()->RemoveMemoryAllocationCallback( |
| 4724 callback); | 4830 callback); |
| 4725 } | 4831 } |
| 4726 | 4832 |
| 4727 | 4833 |
| 4728 void V8::PauseProfiler() { | 4834 void V8::PauseProfiler() { |
| 4729 #ifdef ENABLE_LOGGING_AND_PROFILING | 4835 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4730 PauseProfilerEx(PROFILER_MODULE_CPU); | 4836 i::Isolate* isolate = i::Isolate::Current(); |
| 4837 isolate->logger()->PauseProfiler(); |
| 4731 #endif | 4838 #endif |
| 4732 } | 4839 } |
| 4733 | 4840 |
| 4734 | 4841 |
| 4735 void V8::ResumeProfiler() { | 4842 void V8::ResumeProfiler() { |
| 4736 #ifdef ENABLE_LOGGING_AND_PROFILING | 4843 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4737 ResumeProfilerEx(PROFILER_MODULE_CPU); | 4844 i::Isolate* isolate = i::Isolate::Current(); |
| 4845 isolate->logger()->ResumeProfiler(); |
| 4738 #endif | 4846 #endif |
| 4739 } | 4847 } |
| 4740 | 4848 |
| 4741 | 4849 |
| 4742 bool V8::IsProfilerPaused() { | 4850 bool V8::IsProfilerPaused() { |
| 4743 #ifdef ENABLE_LOGGING_AND_PROFILING | 4851 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4744 return LOGGER->GetActiveProfilerModules() & PROFILER_MODULE_CPU; | 4852 i::Isolate* isolate = i::Isolate::Current(); |
| 4853 return isolate->logger()->IsProfilerPaused(); |
| 4745 #else | 4854 #else |
| 4746 return true; | 4855 return true; |
| 4747 #endif | 4856 #endif |
| 4748 } | 4857 } |
| 4749 | 4858 |
| 4750 | 4859 |
| 4751 void V8::ResumeProfilerEx(int flags, int tag) { | |
| 4752 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 4753 i::Isolate* isolate = i::Isolate::Current(); | |
| 4754 if (flags & PROFILER_MODULE_HEAP_SNAPSHOT) { | |
| 4755 // Snapshot mode: resume modules, perform GC, then pause only | |
| 4756 // those modules which haven't been started prior to making a | |
| 4757 // snapshot. | |
| 4758 | |
| 4759 // Make a GC prior to taking a snapshot. | |
| 4760 isolate->heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 4761 // Reset snapshot flag and CPU module flags. | |
| 4762 flags &= ~(PROFILER_MODULE_HEAP_SNAPSHOT | PROFILER_MODULE_CPU); | |
| 4763 const int current_flags = isolate->logger()->GetActiveProfilerModules(); | |
| 4764 isolate->logger()->ResumeProfiler(flags, tag); | |
| 4765 isolate->heap()->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 4766 isolate->logger()->PauseProfiler(~current_flags & flags, tag); | |
| 4767 } else { | |
| 4768 isolate->logger()->ResumeProfiler(flags, tag); | |
| 4769 } | |
| 4770 #endif | |
| 4771 } | |
| 4772 | |
| 4773 | |
| 4774 void V8::PauseProfilerEx(int flags, int tag) { | |
| 4775 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 4776 LOGGER->PauseProfiler(flags, tag); | |
| 4777 #endif | |
| 4778 } | |
| 4779 | |
| 4780 | |
| 4781 int V8::GetActiveProfilerModules() { | |
| 4782 #ifdef ENABLE_LOGGING_AND_PROFILING | |
| 4783 return LOGGER->GetActiveProfilerModules(); | |
| 4784 #else | |
| 4785 return PROFILER_MODULE_NONE; | |
| 4786 #endif | |
| 4787 } | |
| 4788 | |
| 4789 | |
| 4790 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) { | 4860 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) { |
| 4791 #ifdef ENABLE_LOGGING_AND_PROFILING | 4861 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 4792 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); | 4862 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer); |
| 4793 return LOGGER->GetLogLines(from_pos, dest_buf, max_size); | 4863 return LOGGER->GetLogLines(from_pos, dest_buf, max_size); |
| 4794 #endif | 4864 #endif |
| 4795 return 0; | 4865 return 0; |
| 4796 } | 4866 } |
| 4797 | 4867 |
| 4798 | 4868 |
| 4799 int V8::GetCurrentThreadId() { | 4869 int V8::GetCurrentThreadId() { |
| 4800 i::Isolate* isolate = i::Isolate::Current(); | 4870 i::Isolate* isolate = i::Isolate::Current(); |
| 4801 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); | 4871 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); |
| 4802 return isolate->thread_id().ToInteger(); | 4872 return isolate->thread_id().ToInteger(); |
| 4803 } | 4873 } |
| 4804 | 4874 |
| 4805 | 4875 |
| 4806 void V8::TerminateExecution(int thread_id) { | 4876 void V8::TerminateExecution(int thread_id) { |
| 4807 i::Isolate* isolate = i::Isolate::Current(); | 4877 i::Isolate* isolate = i::Isolate::Current(); |
| 4808 if (!isolate->IsInitialized()) return; | 4878 if (!isolate->IsInitialized()) return; |
| 4809 API_ENTRY_CHECK("V8::TerminateExecution()"); | 4879 API_ENTRY_CHECK(isolate, "V8::TerminateExecution()"); |
| 4810 // If the thread_id identifies the current thread just terminate | 4880 // If the thread_id identifies the current thread just terminate |
| 4811 // execution right away. Otherwise, ask the thread manager to | 4881 // execution right away. Otherwise, ask the thread manager to |
| 4812 // terminate the thread with the given id if any. | 4882 // terminate the thread with the given id if any. |
| 4813 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id); | 4883 i::ThreadId internal_tid = i::ThreadId::FromInteger(thread_id); |
| 4814 if (isolate->thread_id().Equals(internal_tid)) { | 4884 if (isolate->thread_id().Equals(internal_tid)) { |
| 4815 isolate->stack_guard()->TerminateExecution(); | 4885 isolate->stack_guard()->TerminateExecution(); |
| 4816 } else { | 4886 } else { |
| 4817 isolate->thread_manager()->TerminateExecution(internal_tid); | 4887 isolate->thread_manager()->TerminateExecution(internal_tid); |
| 4818 } | 4888 } |
| 4819 } | 4889 } |
| 4820 | 4890 |
| 4821 | 4891 |
| 4822 void V8::TerminateExecution(Isolate* isolate) { | 4892 void V8::TerminateExecution(Isolate* isolate) { |
| 4823 // If no isolate is supplied, use the default isolate. | 4893 // If no isolate is supplied, use the default isolate. |
| 4824 if (isolate != NULL) { | 4894 if (isolate != NULL) { |
| 4825 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); | 4895 reinterpret_cast<i::Isolate*>(isolate)->stack_guard()->TerminateExecution(); |
| 4826 } else { | 4896 } else { |
| 4827 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); | 4897 i::Isolate::GetDefaultIsolateStackGuard()->TerminateExecution(); |
| 4828 } | 4898 } |
| 4829 } | 4899 } |
| 4830 | 4900 |
| 4831 | 4901 |
| 4832 bool V8::IsExecutionTerminating() { | 4902 bool V8::IsExecutionTerminating(Isolate* isolate) { |
| 4833 i::Isolate* isolate = i::Isolate::Current(); | 4903 i::Isolate* i_isolate = isolate != NULL ? |
| 4834 return IsExecutionTerminatingCheck(isolate); | 4904 reinterpret_cast<i::Isolate*>(isolate) : i::Isolate::Current(); |
| 4905 return IsExecutionTerminatingCheck(i_isolate); |
| 4835 } | 4906 } |
| 4836 | 4907 |
| 4837 | 4908 |
| 4838 Isolate* Isolate::GetCurrent() { | 4909 Isolate* Isolate::GetCurrent() { |
| 4839 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); | 4910 i::Isolate* isolate = i::Isolate::UncheckedCurrent(); |
| 4840 return reinterpret_cast<Isolate*>(isolate); | 4911 return reinterpret_cast<Isolate*>(isolate); |
| 4841 } | 4912 } |
| 4842 | 4913 |
| 4843 | 4914 |
| 4844 Isolate* Isolate::New() { | 4915 Isolate* Isolate::New() { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5248 Local<Context> Debug::GetDebugContext() { | 5319 Local<Context> Debug::GetDebugContext() { |
| 5249 i::Isolate* isolate = i::Isolate::Current(); | 5320 i::Isolate* isolate = i::Isolate::Current(); |
| 5250 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); | 5321 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); |
| 5251 ENTER_V8(isolate); | 5322 ENTER_V8(isolate); |
| 5252 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); | 5323 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); |
| 5253 } | 5324 } |
| 5254 | 5325 |
| 5255 #endif // ENABLE_DEBUGGER_SUPPORT | 5326 #endif // ENABLE_DEBUGGER_SUPPORT |
| 5256 | 5327 |
| 5257 | 5328 |
| 5329 Handle<String> CpuProfileNode::GetFunctionName() const { |
| 5258 #ifdef ENABLE_LOGGING_AND_PROFILING | 5330 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5259 | |
| 5260 Handle<String> CpuProfileNode::GetFunctionName() const { | |
| 5261 i::Isolate* isolate = i::Isolate::Current(); | 5331 i::Isolate* isolate = i::Isolate::Current(); |
| 5262 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); | 5332 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); |
| 5263 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 5333 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 5264 const i::CodeEntry* entry = node->entry(); | 5334 const i::CodeEntry* entry = node->entry(); |
| 5265 if (!entry->has_name_prefix()) { | 5335 if (!entry->has_name_prefix()) { |
| 5266 return Handle<String>(ToApi<String>( | 5336 return Handle<String>(ToApi<String>( |
| 5267 isolate->factory()->LookupAsciiSymbol(entry->name()))); | 5337 isolate->factory()->LookupAsciiSymbol(entry->name()))); |
| 5268 } else { | 5338 } else { |
| 5269 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString( | 5339 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString( |
| 5270 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()), | 5340 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()), |
| 5271 isolate->factory()->LookupAsciiSymbol(entry->name())))); | 5341 isolate->factory()->LookupAsciiSymbol(entry->name())))); |
| 5272 } | 5342 } |
| 5343 #else |
| 5344 return v8::String::Empty(); |
| 5345 #endif |
| 5273 } | 5346 } |
| 5274 | 5347 |
| 5275 | 5348 |
| 5276 Handle<String> CpuProfileNode::GetScriptResourceName() const { | 5349 Handle<String> CpuProfileNode::GetScriptResourceName() const { |
| 5350 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5277 i::Isolate* isolate = i::Isolate::Current(); | 5351 i::Isolate* isolate = i::Isolate::Current(); |
| 5278 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); | 5352 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); |
| 5279 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); | 5353 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| 5280 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( | 5354 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( |
| 5281 node->entry()->resource_name()))); | 5355 node->entry()->resource_name()))); |
| 5356 #else |
| 5357 return v8::String::Empty(); |
| 5358 #endif |
| 5282 } | 5359 } |
| 5283 | 5360 |
| 5284 | 5361 |
| 5285 int CpuProfileNode::GetLineNumber() const { | 5362 int CpuProfileNode::GetLineNumber() const { |
| 5363 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5286 i::Isolate* isolate = i::Isolate::Current(); | 5364 i::Isolate* isolate = i::Isolate::Current(); |
| 5287 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber"); | 5365 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber"); |
| 5288 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | 5366 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); |
| 5367 #else |
| 5368 return 0; |
| 5369 #endif |
| 5289 } | 5370 } |
| 5290 | 5371 |
| 5291 | 5372 |
| 5292 double CpuProfileNode::GetTotalTime() const { | 5373 double CpuProfileNode::GetTotalTime() const { |
| 5374 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5293 i::Isolate* isolate = i::Isolate::Current(); | 5375 i::Isolate* isolate = i::Isolate::Current(); |
| 5294 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime"); | 5376 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime"); |
| 5295 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis(); | 5377 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis(); |
| 5378 #else |
| 5379 return 0.0; |
| 5380 #endif |
| 5296 } | 5381 } |
| 5297 | 5382 |
| 5298 | 5383 |
| 5299 double CpuProfileNode::GetSelfTime() const { | 5384 double CpuProfileNode::GetSelfTime() const { |
| 5385 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5300 i::Isolate* isolate = i::Isolate::Current(); | 5386 i::Isolate* isolate = i::Isolate::Current(); |
| 5301 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime"); | 5387 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime"); |
| 5302 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis(); | 5388 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis(); |
| 5389 #else |
| 5390 return 0.0; |
| 5391 #endif |
| 5303 } | 5392 } |
| 5304 | 5393 |
| 5305 | 5394 |
| 5306 double CpuProfileNode::GetTotalSamplesCount() const { | 5395 double CpuProfileNode::GetTotalSamplesCount() const { |
| 5396 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5307 i::Isolate* isolate = i::Isolate::Current(); | 5397 i::Isolate* isolate = i::Isolate::Current(); |
| 5308 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount"); | 5398 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount"); |
| 5309 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks(); | 5399 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks(); |
| 5400 #else |
| 5401 return 0.0; |
| 5402 #endif |
| 5310 } | 5403 } |
| 5311 | 5404 |
| 5312 | 5405 |
| 5313 double CpuProfileNode::GetSelfSamplesCount() const { | 5406 double CpuProfileNode::GetSelfSamplesCount() const { |
| 5407 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5314 i::Isolate* isolate = i::Isolate::Current(); | 5408 i::Isolate* isolate = i::Isolate::Current(); |
| 5315 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); | 5409 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); |
| 5316 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); | 5410 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); |
| 5411 #else |
| 5412 return 0.0; |
| 5413 #endif |
| 5317 } | 5414 } |
| 5318 | 5415 |
| 5319 | 5416 |
| 5320 unsigned CpuProfileNode::GetCallUid() const { | 5417 unsigned CpuProfileNode::GetCallUid() const { |
| 5418 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5321 i::Isolate* isolate = i::Isolate::Current(); | 5419 i::Isolate* isolate = i::Isolate::Current(); |
| 5322 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid"); | 5420 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid"); |
| 5323 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); | 5421 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); |
| 5422 #else |
| 5423 return 0; |
| 5424 #endif |
| 5324 } | 5425 } |
| 5325 | 5426 |
| 5326 | 5427 |
| 5327 int CpuProfileNode::GetChildrenCount() const { | 5428 int CpuProfileNode::GetChildrenCount() const { |
| 5429 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5328 i::Isolate* isolate = i::Isolate::Current(); | 5430 i::Isolate* isolate = i::Isolate::Current(); |
| 5329 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); | 5431 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); |
| 5330 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); | 5432 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); |
| 5433 #else |
| 5434 return 0; |
| 5435 #endif |
| 5331 } | 5436 } |
| 5332 | 5437 |
| 5333 | 5438 |
| 5334 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { | 5439 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { |
| 5440 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5335 i::Isolate* isolate = i::Isolate::Current(); | 5441 i::Isolate* isolate = i::Isolate::Current(); |
| 5336 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); | 5442 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); |
| 5337 const i::ProfileNode* child = | 5443 const i::ProfileNode* child = |
| 5338 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); | 5444 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); |
| 5339 return reinterpret_cast<const CpuProfileNode*>(child); | 5445 return reinterpret_cast<const CpuProfileNode*>(child); |
| 5446 #else |
| 5447 return NULL; |
| 5448 #endif |
| 5340 } | 5449 } |
| 5341 | 5450 |
| 5342 | 5451 |
| 5343 void CpuProfile::Delete() { | 5452 void CpuProfile::Delete() { |
| 5453 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5344 i::Isolate* isolate = i::Isolate::Current(); | 5454 i::Isolate* isolate = i::Isolate::Current(); |
| 5345 IsDeadCheck(isolate, "v8::CpuProfile::Delete"); | 5455 IsDeadCheck(isolate, "v8::CpuProfile::Delete"); |
| 5346 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); | 5456 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); |
| 5347 if (i::CpuProfiler::GetProfilesCount() == 0 && | 5457 if (i::CpuProfiler::GetProfilesCount() == 0 && |
| 5348 !i::CpuProfiler::HasDetachedProfiles()) { | 5458 !i::CpuProfiler::HasDetachedProfiles()) { |
| 5349 // If this was the last profile, clean up all accessory data as well. | 5459 // If this was the last profile, clean up all accessory data as well. |
| 5350 i::CpuProfiler::DeleteAllProfiles(); | 5460 i::CpuProfiler::DeleteAllProfiles(); |
| 5351 } | 5461 } |
| 5462 #endif |
| 5352 } | 5463 } |
| 5353 | 5464 |
| 5354 | 5465 |
| 5355 unsigned CpuProfile::GetUid() const { | 5466 unsigned CpuProfile::GetUid() const { |
| 5467 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5356 i::Isolate* isolate = i::Isolate::Current(); | 5468 i::Isolate* isolate = i::Isolate::Current(); |
| 5357 IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); | 5469 IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); |
| 5358 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); | 5470 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); |
| 5471 #else |
| 5472 return 0; |
| 5473 #endif |
| 5359 } | 5474 } |
| 5360 | 5475 |
| 5361 | 5476 |
| 5362 Handle<String> CpuProfile::GetTitle() const { | 5477 Handle<String> CpuProfile::GetTitle() const { |
| 5478 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5363 i::Isolate* isolate = i::Isolate::Current(); | 5479 i::Isolate* isolate = i::Isolate::Current(); |
| 5364 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); | 5480 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); |
| 5365 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 5481 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 5366 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( | 5482 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( |
| 5367 profile->title()))); | 5483 profile->title()))); |
| 5484 #else |
| 5485 return v8::String::Empty(); |
| 5486 #endif |
| 5368 } | 5487 } |
| 5369 | 5488 |
| 5370 | 5489 |
| 5371 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { | 5490 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { |
| 5491 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5372 i::Isolate* isolate = i::Isolate::Current(); | 5492 i::Isolate* isolate = i::Isolate::Current(); |
| 5373 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot"); | 5493 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot"); |
| 5374 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 5494 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 5375 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root()); | 5495 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root()); |
| 5496 #else |
| 5497 return NULL; |
| 5498 #endif |
| 5376 } | 5499 } |
| 5377 | 5500 |
| 5378 | 5501 |
| 5379 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { | 5502 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { |
| 5503 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5380 i::Isolate* isolate = i::Isolate::Current(); | 5504 i::Isolate* isolate = i::Isolate::Current(); |
| 5381 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot"); | 5505 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot"); |
| 5382 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); | 5506 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); |
| 5383 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); | 5507 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); |
| 5508 #else |
| 5509 return NULL; |
| 5510 #endif |
| 5384 } | 5511 } |
| 5385 | 5512 |
| 5386 | 5513 |
| 5387 int CpuProfiler::GetProfilesCount() { | 5514 int CpuProfiler::GetProfilesCount() { |
| 5515 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5388 i::Isolate* isolate = i::Isolate::Current(); | 5516 i::Isolate* isolate = i::Isolate::Current(); |
| 5389 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); | 5517 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); |
| 5390 return i::CpuProfiler::GetProfilesCount(); | 5518 return i::CpuProfiler::GetProfilesCount(); |
| 5519 #else |
| 5520 return 0; |
| 5521 #endif |
| 5391 } | 5522 } |
| 5392 | 5523 |
| 5393 | 5524 |
| 5394 const CpuProfile* CpuProfiler::GetProfile(int index, | 5525 const CpuProfile* CpuProfiler::GetProfile(int index, |
| 5395 Handle<Value> security_token) { | 5526 Handle<Value> security_token) { |
| 5527 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5396 i::Isolate* isolate = i::Isolate::Current(); | 5528 i::Isolate* isolate = i::Isolate::Current(); |
| 5397 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); | 5529 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); |
| 5398 return reinterpret_cast<const CpuProfile*>( | 5530 return reinterpret_cast<const CpuProfile*>( |
| 5399 i::CpuProfiler::GetProfile( | 5531 i::CpuProfiler::GetProfile( |
| 5400 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), | 5532 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 5401 index)); | 5533 index)); |
| 5534 #else |
| 5535 return NULL; |
| 5536 #endif |
| 5402 } | 5537 } |
| 5403 | 5538 |
| 5404 | 5539 |
| 5405 const CpuProfile* CpuProfiler::FindProfile(unsigned uid, | 5540 const CpuProfile* CpuProfiler::FindProfile(unsigned uid, |
| 5406 Handle<Value> security_token) { | 5541 Handle<Value> security_token) { |
| 5542 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5407 i::Isolate* isolate = i::Isolate::Current(); | 5543 i::Isolate* isolate = i::Isolate::Current(); |
| 5408 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); | 5544 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); |
| 5409 return reinterpret_cast<const CpuProfile*>( | 5545 return reinterpret_cast<const CpuProfile*>( |
| 5410 i::CpuProfiler::FindProfile( | 5546 i::CpuProfiler::FindProfile( |
| 5411 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), | 5547 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 5412 uid)); | 5548 uid)); |
| 5549 #else |
| 5550 return NULL; |
| 5551 #endif |
| 5413 } | 5552 } |
| 5414 | 5553 |
| 5415 | 5554 |
| 5416 void CpuProfiler::StartProfiling(Handle<String> title) { | 5555 void CpuProfiler::StartProfiling(Handle<String> title) { |
| 5556 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5417 i::Isolate* isolate = i::Isolate::Current(); | 5557 i::Isolate* isolate = i::Isolate::Current(); |
| 5418 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); | 5558 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); |
| 5419 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); | 5559 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); |
| 5560 #endif |
| 5420 } | 5561 } |
| 5421 | 5562 |
| 5422 | 5563 |
| 5423 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, | 5564 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, |
| 5424 Handle<Value> security_token) { | 5565 Handle<Value> security_token) { |
| 5566 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5425 i::Isolate* isolate = i::Isolate::Current(); | 5567 i::Isolate* isolate = i::Isolate::Current(); |
| 5426 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); | 5568 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); |
| 5427 return reinterpret_cast<const CpuProfile*>( | 5569 return reinterpret_cast<const CpuProfile*>( |
| 5428 i::CpuProfiler::StopProfiling( | 5570 i::CpuProfiler::StopProfiling( |
| 5429 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), | 5571 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), |
| 5430 *Utils::OpenHandle(*title))); | 5572 *Utils::OpenHandle(*title))); |
| 5573 #else |
| 5574 return NULL; |
| 5575 #endif |
| 5431 } | 5576 } |
| 5432 | 5577 |
| 5433 | 5578 |
| 5434 void CpuProfiler::DeleteAllProfiles() { | 5579 void CpuProfiler::DeleteAllProfiles() { |
| 5580 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5435 i::Isolate* isolate = i::Isolate::Current(); | 5581 i::Isolate* isolate = i::Isolate::Current(); |
| 5436 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); | 5582 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); |
| 5437 i::CpuProfiler::DeleteAllProfiles(); | 5583 i::CpuProfiler::DeleteAllProfiles(); |
| 5584 #endif |
| 5438 } | 5585 } |
| 5439 | 5586 |
| 5440 | 5587 |
| 5588 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5441 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { | 5589 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { |
| 5442 return const_cast<i::HeapGraphEdge*>( | 5590 return const_cast<i::HeapGraphEdge*>( |
| 5443 reinterpret_cast<const i::HeapGraphEdge*>(edge)); | 5591 reinterpret_cast<const i::HeapGraphEdge*>(edge)); |
| 5444 } | 5592 } |
| 5593 #endif |
| 5594 |
| 5445 | 5595 |
| 5446 HeapGraphEdge::Type HeapGraphEdge::GetType() const { | 5596 HeapGraphEdge::Type HeapGraphEdge::GetType() const { |
| 5597 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5447 i::Isolate* isolate = i::Isolate::Current(); | 5598 i::Isolate* isolate = i::Isolate::Current(); |
| 5448 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); | 5599 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); |
| 5449 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); | 5600 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); |
| 5601 #else |
| 5602 return static_cast<HeapGraphEdge::Type>(0); |
| 5603 #endif |
| 5450 } | 5604 } |
| 5451 | 5605 |
| 5452 | 5606 |
| 5453 Handle<Value> HeapGraphEdge::GetName() const { | 5607 Handle<Value> HeapGraphEdge::GetName() const { |
| 5608 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5454 i::Isolate* isolate = i::Isolate::Current(); | 5609 i::Isolate* isolate = i::Isolate::Current(); |
| 5455 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); | 5610 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); |
| 5456 i::HeapGraphEdge* edge = ToInternal(this); | 5611 i::HeapGraphEdge* edge = ToInternal(this); |
| 5457 switch (edge->type()) { | 5612 switch (edge->type()) { |
| 5458 case i::HeapGraphEdge::kContextVariable: | 5613 case i::HeapGraphEdge::kContextVariable: |
| 5459 case i::HeapGraphEdge::kInternal: | 5614 case i::HeapGraphEdge::kInternal: |
| 5460 case i::HeapGraphEdge::kProperty: | 5615 case i::HeapGraphEdge::kProperty: |
| 5461 case i::HeapGraphEdge::kShortcut: | 5616 case i::HeapGraphEdge::kShortcut: |
| 5462 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( | 5617 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( |
| 5463 edge->name()))); | 5618 edge->name()))); |
| 5464 case i::HeapGraphEdge::kElement: | 5619 case i::HeapGraphEdge::kElement: |
| 5465 case i::HeapGraphEdge::kHidden: | 5620 case i::HeapGraphEdge::kHidden: |
| 5466 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt( | 5621 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt( |
| 5467 edge->index()))); | 5622 edge->index()))); |
| 5468 default: UNREACHABLE(); | 5623 default: UNREACHABLE(); |
| 5469 } | 5624 } |
| 5625 #endif |
| 5470 return v8::Undefined(); | 5626 return v8::Undefined(); |
| 5471 } | 5627 } |
| 5472 | 5628 |
| 5473 | 5629 |
| 5474 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { | 5630 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { |
| 5631 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5475 i::Isolate* isolate = i::Isolate::Current(); | 5632 i::Isolate* isolate = i::Isolate::Current(); |
| 5476 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); | 5633 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); |
| 5477 const i::HeapEntry* from = ToInternal(this)->From(); | 5634 const i::HeapEntry* from = ToInternal(this)->From(); |
| 5478 return reinterpret_cast<const HeapGraphNode*>(from); | 5635 return reinterpret_cast<const HeapGraphNode*>(from); |
| 5636 #else |
| 5637 return NULL; |
| 5638 #endif |
| 5479 } | 5639 } |
| 5480 | 5640 |
| 5481 | 5641 |
| 5482 const HeapGraphNode* HeapGraphEdge::GetToNode() const { | 5642 const HeapGraphNode* HeapGraphEdge::GetToNode() const { |
| 5643 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5483 i::Isolate* isolate = i::Isolate::Current(); | 5644 i::Isolate* isolate = i::Isolate::Current(); |
| 5484 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); | 5645 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); |
| 5485 const i::HeapEntry* to = ToInternal(this)->to(); | 5646 const i::HeapEntry* to = ToInternal(this)->to(); |
| 5486 return reinterpret_cast<const HeapGraphNode*>(to); | 5647 return reinterpret_cast<const HeapGraphNode*>(to); |
| 5648 #else |
| 5649 return NULL; |
| 5650 #endif |
| 5487 } | 5651 } |
| 5488 | 5652 |
| 5489 | 5653 |
| 5654 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5490 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { | 5655 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { |
| 5491 return const_cast<i::HeapEntry*>( | 5656 return const_cast<i::HeapEntry*>( |
| 5492 reinterpret_cast<const i::HeapEntry*>(entry)); | 5657 reinterpret_cast<const i::HeapEntry*>(entry)); |
| 5493 } | 5658 } |
| 5659 #endif |
| 5494 | 5660 |
| 5495 | 5661 |
| 5496 HeapGraphNode::Type HeapGraphNode::GetType() const { | 5662 HeapGraphNode::Type HeapGraphNode::GetType() const { |
| 5663 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5497 i::Isolate* isolate = i::Isolate::Current(); | 5664 i::Isolate* isolate = i::Isolate::Current(); |
| 5498 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); | 5665 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); |
| 5499 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); | 5666 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); |
| 5667 #else |
| 5668 return static_cast<HeapGraphNode::Type>(0); |
| 5669 #endif |
| 5500 } | 5670 } |
| 5501 | 5671 |
| 5502 | 5672 |
| 5503 Handle<String> HeapGraphNode::GetName() const { | 5673 Handle<String> HeapGraphNode::GetName() const { |
| 5674 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5504 i::Isolate* isolate = i::Isolate::Current(); | 5675 i::Isolate* isolate = i::Isolate::Current(); |
| 5505 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); | 5676 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); |
| 5506 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( | 5677 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( |
| 5507 ToInternal(this)->name()))); | 5678 ToInternal(this)->name()))); |
| 5679 #else |
| 5680 return v8::String::Empty(); |
| 5681 #endif |
| 5508 } | 5682 } |
| 5509 | 5683 |
| 5510 | 5684 |
| 5511 uint64_t HeapGraphNode::GetId() const { | 5685 uint64_t HeapGraphNode::GetId() const { |
| 5686 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5512 i::Isolate* isolate = i::Isolate::Current(); | 5687 i::Isolate* isolate = i::Isolate::Current(); |
| 5513 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); | 5688 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); |
| 5514 ASSERT(ToInternal(this)->snapshot()->type() != i::HeapSnapshot::kAggregated); | |
| 5515 return ToInternal(this)->id(); | 5689 return ToInternal(this)->id(); |
| 5516 } | 5690 #else |
| 5517 | 5691 return 0; |
| 5518 | 5692 #endif |
| 5519 int HeapGraphNode::GetInstancesCount() const { | |
| 5520 i::Isolate* isolate = i::Isolate::Current(); | |
| 5521 IsDeadCheck(isolate, "v8::HeapGraphNode::GetInstancesCount"); | |
| 5522 ASSERT(ToInternal(this)->snapshot()->type() == i::HeapSnapshot::kAggregated); | |
| 5523 return static_cast<int>(ToInternal(this)->id()); | |
| 5524 } | 5693 } |
| 5525 | 5694 |
| 5526 | 5695 |
| 5527 int HeapGraphNode::GetSelfSize() const { | 5696 int HeapGraphNode::GetSelfSize() const { |
| 5697 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5528 i::Isolate* isolate = i::Isolate::Current(); | 5698 i::Isolate* isolate = i::Isolate::Current(); |
| 5529 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); | 5699 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); |
| 5530 return ToInternal(this)->self_size(); | 5700 return ToInternal(this)->self_size(); |
| 5701 #else |
| 5702 return 0; |
| 5703 #endif |
| 5531 } | 5704 } |
| 5532 | 5705 |
| 5533 | 5706 |
| 5534 int HeapGraphNode::GetRetainedSize(bool exact) const { | 5707 int HeapGraphNode::GetRetainedSize(bool exact) const { |
| 5708 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5535 i::Isolate* isolate = i::Isolate::Current(); | 5709 i::Isolate* isolate = i::Isolate::Current(); |
| 5536 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize"); | 5710 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize"); |
| 5537 return ToInternal(this)->RetainedSize(exact); | 5711 return ToInternal(this)->RetainedSize(exact); |
| 5712 #else |
| 5713 return 0; |
| 5714 #endif |
| 5538 } | 5715 } |
| 5539 | 5716 |
| 5540 | 5717 |
| 5541 int HeapGraphNode::GetChildrenCount() const { | 5718 int HeapGraphNode::GetChildrenCount() const { |
| 5719 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5542 i::Isolate* isolate = i::Isolate::Current(); | 5720 i::Isolate* isolate = i::Isolate::Current(); |
| 5543 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); | 5721 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); |
| 5544 return ToInternal(this)->children().length(); | 5722 return ToInternal(this)->children().length(); |
| 5723 #else |
| 5724 return 0; |
| 5725 #endif |
| 5545 } | 5726 } |
| 5546 | 5727 |
| 5547 | 5728 |
| 5548 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { | 5729 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { |
| 5730 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5549 i::Isolate* isolate = i::Isolate::Current(); | 5731 i::Isolate* isolate = i::Isolate::Current(); |
| 5550 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); | 5732 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); |
| 5551 return reinterpret_cast<const HeapGraphEdge*>( | 5733 return reinterpret_cast<const HeapGraphEdge*>( |
| 5552 &ToInternal(this)->children()[index]); | 5734 &ToInternal(this)->children()[index]); |
| 5735 #else |
| 5736 return NULL; |
| 5737 #endif |
| 5553 } | 5738 } |
| 5554 | 5739 |
| 5555 | 5740 |
| 5556 int HeapGraphNode::GetRetainersCount() const { | 5741 int HeapGraphNode::GetRetainersCount() const { |
| 5742 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5557 i::Isolate* isolate = i::Isolate::Current(); | 5743 i::Isolate* isolate = i::Isolate::Current(); |
| 5558 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount"); | 5744 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount"); |
| 5559 return ToInternal(this)->retainers().length(); | 5745 return ToInternal(this)->retainers().length(); |
| 5746 #else |
| 5747 return 0; |
| 5748 #endif |
| 5560 } | 5749 } |
| 5561 | 5750 |
| 5562 | 5751 |
| 5563 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { | 5752 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { |
| 5753 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5564 i::Isolate* isolate = i::Isolate::Current(); | 5754 i::Isolate* isolate = i::Isolate::Current(); |
| 5565 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer"); | 5755 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer"); |
| 5566 return reinterpret_cast<const HeapGraphEdge*>( | 5756 return reinterpret_cast<const HeapGraphEdge*>( |
| 5567 ToInternal(this)->retainers()[index]); | 5757 ToInternal(this)->retainers()[index]); |
| 5758 #else |
| 5759 return NULL; |
| 5760 #endif |
| 5568 } | 5761 } |
| 5569 | 5762 |
| 5570 | 5763 |
| 5571 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { | 5764 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { |
| 5765 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5572 i::Isolate* isolate = i::Isolate::Current(); | 5766 i::Isolate* isolate = i::Isolate::Current(); |
| 5573 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); | 5767 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); |
| 5574 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator()); | 5768 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator()); |
| 5769 #else |
| 5770 return NULL; |
| 5771 #endif |
| 5575 } | 5772 } |
| 5576 | 5773 |
| 5577 | 5774 |
| 5775 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5578 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { | 5776 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { |
| 5579 return const_cast<i::HeapSnapshot*>( | 5777 return const_cast<i::HeapSnapshot*>( |
| 5580 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); | 5778 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); |
| 5581 } | 5779 } |
| 5780 #endif |
| 5582 | 5781 |
| 5583 | 5782 |
| 5584 void HeapSnapshot::Delete() { | 5783 void HeapSnapshot::Delete() { |
| 5784 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5585 i::Isolate* isolate = i::Isolate::Current(); | 5785 i::Isolate* isolate = i::Isolate::Current(); |
| 5586 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); | 5786 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); |
| 5587 if (i::HeapProfiler::GetSnapshotsCount() > 1) { | 5787 if (i::HeapProfiler::GetSnapshotsCount() > 1) { |
| 5588 ToInternal(this)->Delete(); | 5788 ToInternal(this)->Delete(); |
| 5589 } else { | 5789 } else { |
| 5590 // If this is the last snapshot, clean up all accessory data as well. | 5790 // If this is the last snapshot, clean up all accessory data as well. |
| 5591 i::HeapProfiler::DeleteAllSnapshots(); | 5791 i::HeapProfiler::DeleteAllSnapshots(); |
| 5592 } | 5792 } |
| 5793 #endif |
| 5593 } | 5794 } |
| 5594 | 5795 |
| 5595 | 5796 |
| 5596 HeapSnapshot::Type HeapSnapshot::GetType() const { | 5797 HeapSnapshot::Type HeapSnapshot::GetType() const { |
| 5798 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5597 i::Isolate* isolate = i::Isolate::Current(); | 5799 i::Isolate* isolate = i::Isolate::Current(); |
| 5598 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); | 5800 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); |
| 5599 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); | 5801 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); |
| 5802 #else |
| 5803 return static_cast<HeapSnapshot::Type>(0); |
| 5804 #endif |
| 5600 } | 5805 } |
| 5601 | 5806 |
| 5602 | 5807 |
| 5603 unsigned HeapSnapshot::GetUid() const { | 5808 unsigned HeapSnapshot::GetUid() const { |
| 5809 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5604 i::Isolate* isolate = i::Isolate::Current(); | 5810 i::Isolate* isolate = i::Isolate::Current(); |
| 5605 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); | 5811 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); |
| 5606 return ToInternal(this)->uid(); | 5812 return ToInternal(this)->uid(); |
| 5813 #else |
| 5814 return 0; |
| 5815 #endif |
| 5607 } | 5816 } |
| 5608 | 5817 |
| 5609 | 5818 |
| 5610 Handle<String> HeapSnapshot::GetTitle() const { | 5819 Handle<String> HeapSnapshot::GetTitle() const { |
| 5820 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5611 i::Isolate* isolate = i::Isolate::Current(); | 5821 i::Isolate* isolate = i::Isolate::Current(); |
| 5612 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); | 5822 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); |
| 5613 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( | 5823 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( |
| 5614 ToInternal(this)->title()))); | 5824 ToInternal(this)->title()))); |
| 5825 #else |
| 5826 return v8::String::Empty(); |
| 5827 #endif |
| 5615 } | 5828 } |
| 5616 | 5829 |
| 5617 | 5830 |
| 5618 const HeapGraphNode* HeapSnapshot::GetRoot() const { | 5831 const HeapGraphNode* HeapSnapshot::GetRoot() const { |
| 5832 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5619 i::Isolate* isolate = i::Isolate::Current(); | 5833 i::Isolate* isolate = i::Isolate::Current(); |
| 5620 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); | 5834 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); |
| 5621 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); | 5835 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); |
| 5836 #else |
| 5837 return 0; |
| 5838 #endif |
| 5622 } | 5839 } |
| 5623 | 5840 |
| 5624 | 5841 |
| 5625 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const { | 5842 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const { |
| 5843 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5626 i::Isolate* isolate = i::Isolate::Current(); | 5844 i::Isolate* isolate = i::Isolate::Current(); |
| 5627 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); | 5845 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); |
| 5628 return reinterpret_cast<const HeapGraphNode*>( | 5846 return reinterpret_cast<const HeapGraphNode*>( |
| 5629 ToInternal(this)->GetEntryById(id)); | 5847 ToInternal(this)->GetEntryById(id)); |
| 5848 #else |
| 5849 return NULL; |
| 5850 #endif |
| 5851 } |
| 5852 |
| 5853 |
| 5854 int HeapSnapshot::GetNodesCount() const { |
| 5855 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5856 i::Isolate* isolate = i::Isolate::Current(); |
| 5857 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount"); |
| 5858 return ToInternal(this)->entries()->length(); |
| 5859 #else |
| 5860 return 0; |
| 5861 #endif |
| 5862 } |
| 5863 |
| 5864 |
| 5865 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { |
| 5866 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5867 i::Isolate* isolate = i::Isolate::Current(); |
| 5868 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode"); |
| 5869 return reinterpret_cast<const HeapGraphNode*>( |
| 5870 ToInternal(this)->entries()->at(index)); |
| 5871 #else |
| 5872 return 0; |
| 5873 #endif |
| 5630 } | 5874 } |
| 5631 | 5875 |
| 5632 | 5876 |
| 5633 void HeapSnapshot::Serialize(OutputStream* stream, | 5877 void HeapSnapshot::Serialize(OutputStream* stream, |
| 5634 HeapSnapshot::SerializationFormat format) const { | 5878 HeapSnapshot::SerializationFormat format) const { |
| 5879 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5635 i::Isolate* isolate = i::Isolate::Current(); | 5880 i::Isolate* isolate = i::Isolate::Current(); |
| 5636 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); | 5881 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); |
| 5637 ApiCheck(format == kJSON, | 5882 ApiCheck(format == kJSON, |
| 5638 "v8::HeapSnapshot::Serialize", | 5883 "v8::HeapSnapshot::Serialize", |
| 5639 "Unknown serialization format"); | 5884 "Unknown serialization format"); |
| 5640 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, | 5885 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, |
| 5641 "v8::HeapSnapshot::Serialize", | 5886 "v8::HeapSnapshot::Serialize", |
| 5642 "Unsupported output encoding"); | 5887 "Unsupported output encoding"); |
| 5643 ApiCheck(stream->GetChunkSize() > 0, | 5888 ApiCheck(stream->GetChunkSize() > 0, |
| 5644 "v8::HeapSnapshot::Serialize", | 5889 "v8::HeapSnapshot::Serialize", |
| 5645 "Invalid stream chunk size"); | 5890 "Invalid stream chunk size"); |
| 5646 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); | 5891 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); |
| 5647 serializer.Serialize(stream); | 5892 serializer.Serialize(stream); |
| 5893 #endif |
| 5648 } | 5894 } |
| 5649 | 5895 |
| 5650 | 5896 |
| 5651 int HeapProfiler::GetSnapshotsCount() { | 5897 int HeapProfiler::GetSnapshotsCount() { |
| 5898 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5652 i::Isolate* isolate = i::Isolate::Current(); | 5899 i::Isolate* isolate = i::Isolate::Current(); |
| 5653 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); | 5900 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); |
| 5654 return i::HeapProfiler::GetSnapshotsCount(); | 5901 return i::HeapProfiler::GetSnapshotsCount(); |
| 5902 #else |
| 5903 return 0; |
| 5904 #endif |
| 5655 } | 5905 } |
| 5656 | 5906 |
| 5657 | 5907 |
| 5658 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { | 5908 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { |
| 5909 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5659 i::Isolate* isolate = i::Isolate::Current(); | 5910 i::Isolate* isolate = i::Isolate::Current(); |
| 5660 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); | 5911 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); |
| 5661 return reinterpret_cast<const HeapSnapshot*>( | 5912 return reinterpret_cast<const HeapSnapshot*>( |
| 5662 i::HeapProfiler::GetSnapshot(index)); | 5913 i::HeapProfiler::GetSnapshot(index)); |
| 5914 #else |
| 5915 return NULL; |
| 5916 #endif |
| 5663 } | 5917 } |
| 5664 | 5918 |
| 5665 | 5919 |
| 5666 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { | 5920 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { |
| 5921 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5667 i::Isolate* isolate = i::Isolate::Current(); | 5922 i::Isolate* isolate = i::Isolate::Current(); |
| 5668 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); | 5923 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); |
| 5669 return reinterpret_cast<const HeapSnapshot*>( | 5924 return reinterpret_cast<const HeapSnapshot*>( |
| 5670 i::HeapProfiler::FindSnapshot(uid)); | 5925 i::HeapProfiler::FindSnapshot(uid)); |
| 5926 #else |
| 5927 return NULL; |
| 5928 #endif |
| 5671 } | 5929 } |
| 5672 | 5930 |
| 5673 | 5931 |
| 5674 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, | 5932 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, |
| 5675 HeapSnapshot::Type type, | 5933 HeapSnapshot::Type type, |
| 5676 ActivityControl* control) { | 5934 ActivityControl* control) { |
| 5935 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5677 i::Isolate* isolate = i::Isolate::Current(); | 5936 i::Isolate* isolate = i::Isolate::Current(); |
| 5678 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); | 5937 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); |
| 5679 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; | 5938 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; |
| 5680 switch (type) { | 5939 switch (type) { |
| 5681 case HeapSnapshot::kFull: | 5940 case HeapSnapshot::kFull: |
| 5682 internal_type = i::HeapSnapshot::kFull; | 5941 internal_type = i::HeapSnapshot::kFull; |
| 5683 break; | 5942 break; |
| 5684 case HeapSnapshot::kAggregated: | |
| 5685 internal_type = i::HeapSnapshot::kAggregated; | |
| 5686 break; | |
| 5687 default: | 5943 default: |
| 5688 UNREACHABLE(); | 5944 UNREACHABLE(); |
| 5689 } | 5945 } |
| 5690 return reinterpret_cast<const HeapSnapshot*>( | 5946 return reinterpret_cast<const HeapSnapshot*>( |
| 5691 i::HeapProfiler::TakeSnapshot( | 5947 i::HeapProfiler::TakeSnapshot( |
| 5692 *Utils::OpenHandle(*title), internal_type, control)); | 5948 *Utils::OpenHandle(*title), internal_type, control)); |
| 5949 #else |
| 5950 return NULL; |
| 5951 #endif |
| 5693 } | 5952 } |
| 5694 | 5953 |
| 5695 | 5954 |
| 5696 void HeapProfiler::DeleteAllSnapshots() { | 5955 void HeapProfiler::DeleteAllSnapshots() { |
| 5956 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5697 i::Isolate* isolate = i::Isolate::Current(); | 5957 i::Isolate* isolate = i::Isolate::Current(); |
| 5698 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); | 5958 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); |
| 5699 i::HeapProfiler::DeleteAllSnapshots(); | 5959 i::HeapProfiler::DeleteAllSnapshots(); |
| 5960 #endif |
| 5700 } | 5961 } |
| 5701 | 5962 |
| 5702 | 5963 |
| 5703 void HeapProfiler::DefineWrapperClass(uint16_t class_id, | 5964 void HeapProfiler::DefineWrapperClass(uint16_t class_id, |
| 5704 WrapperInfoCallback callback) { | 5965 WrapperInfoCallback callback) { |
| 5966 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 5705 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, | 5967 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, |
| 5706 callback); | 5968 callback); |
| 5969 #endif |
| 5707 } | 5970 } |
| 5708 | 5971 |
| 5709 #endif // ENABLE_LOGGING_AND_PROFILING | |
| 5710 | 5972 |
| 5711 | 5973 |
| 5712 v8::Testing::StressType internal::Testing::stress_type_ = | 5974 v8::Testing::StressType internal::Testing::stress_type_ = |
| 5713 v8::Testing::kStressTypeOpt; | 5975 v8::Testing::kStressTypeOpt; |
| 5714 | 5976 |
| 5715 | 5977 |
| 5716 void Testing::SetStressRunType(Testing::StressType type) { | 5978 void Testing::SetStressRunType(Testing::StressType type) { |
| 5717 internal::Testing::set_stress_type(type); | 5979 internal::Testing::set_stress_type(type); |
| 5718 } | 5980 } |
| 5719 | 5981 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5836 | 6098 |
| 5837 | 6099 |
| 5838 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6100 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 5839 HandleScopeImplementer* scope_implementer = | 6101 HandleScopeImplementer* scope_implementer = |
| 5840 reinterpret_cast<HandleScopeImplementer*>(storage); | 6102 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 5841 scope_implementer->IterateThis(v); | 6103 scope_implementer->IterateThis(v); |
| 5842 return storage + ArchiveSpacePerThread(); | 6104 return storage + ArchiveSpacePerThread(); |
| 5843 } | 6105 } |
| 5844 | 6106 |
| 5845 } } // namespace v8::internal | 6107 } } // namespace v8::internal |
| OLD | NEW |