Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: src/api.cc

Issue 7353017: 2011-07-13: Version 3.4.12 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/SConscript ('k') | src/arm/code-stubs-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "snapshot.h" 47 #include "snapshot.h"
48 #include "v8threads.h" 48 #include "v8threads.h"
49 #include "version.h" 49 #include "version.h"
50 #include "vm-state-inl.h" 50 #include "vm-state-inl.h"
51 51
52 #include "../include/v8-profiler.h" 52 #include "../include/v8-profiler.h"
53 #include "../include/v8-testing.h" 53 #include "../include/v8-testing.h"
54 54
55 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 55 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
56 56
57 #ifdef ENABLE_VMSTATE_TRACKING
58 #define ENTER_V8(isolate) \ 57 #define ENTER_V8(isolate) \
59 ASSERT((isolate)->IsInitialized()); \ 58 ASSERT((isolate)->IsInitialized()); \
60 i::VMState __state__((isolate), i::OTHER) 59 i::VMState __state__((isolate), i::OTHER)
61 #define LEAVE_V8(isolate) \ 60 #define LEAVE_V8(isolate) \
62 i::VMState __state__((isolate), i::EXTERNAL) 61 i::VMState __state__((isolate), i::EXTERNAL)
63 #else
64 #define ENTER_V8(isolate) ((void) 0)
65 #define LEAVE_V8(isolate) ((void) 0)
66 #endif
67 62
68 namespace v8 { 63 namespace v8 {
69 64
70 #define ON_BAILOUT(isolate, location, code) \ 65 #define ON_BAILOUT(isolate, location, code) \
71 if (IsDeadCheck(isolate, location) || \ 66 if (IsDeadCheck(isolate, location) || \
72 IsExecutionTerminatingCheck(isolate)) { \ 67 IsExecutionTerminatingCheck(isolate)) { \
73 code; \ 68 code; \
74 UNREACHABLE(); \ 69 UNREACHABLE(); \
75 } 70 }
76 71
(...skipping 30 matching lines...) Expand all
107 "Entering the V8 API without proper locking in place"); \ 102 "Entering the V8 API without proper locking in place"); \
108 } \ 103 } \
109 } while (false) 104 } while (false)
110 105
111 106
112 // --- E x c e p t i o n B e h a v i o r --- 107 // --- E x c e p t i o n B e h a v i o r ---
113 108
114 109
115 static void DefaultFatalErrorHandler(const char* location, 110 static void DefaultFatalErrorHandler(const char* location,
116 const char* message) { 111 const char* message) {
117 #ifdef ENABLE_VMSTATE_TRACKING
118 i::VMState __state__(i::Isolate::Current(), i::OTHER); 112 i::VMState __state__(i::Isolate::Current(), i::OTHER);
119 #endif
120 API_Fatal(location, message); 113 API_Fatal(location, message);
121 } 114 }
122 115
123 116
124 static FatalErrorCallback GetFatalErrorHandler() { 117 static FatalErrorCallback GetFatalErrorHandler() {
125 i::Isolate* isolate = i::Isolate::Current(); 118 i::Isolate* isolate = i::Isolate::Current();
126 if (isolate->exception_behavior() == NULL) { 119 if (isolate->exception_behavior() == NULL) {
127 isolate->set_exception_behavior(DefaultFatalErrorHandler); 120 isolate->set_exception_behavior(DefaultFatalErrorHandler);
128 } 121 }
129 return isolate->exception_behavior(); 122 return isolate->exception_behavior();
(...skipping 4695 matching lines...) Expand 10 before | Expand all | Expand 10 after
4825 4818
4826 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) { 4819 void V8::RemoveMemoryAllocationCallback(MemoryAllocationCallback callback) {
4827 i::Isolate* isolate = i::Isolate::Current(); 4820 i::Isolate* isolate = i::Isolate::Current();
4828 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return; 4821 if (IsDeadCheck(isolate, "v8::V8::RemoveMemoryAllocationCallback()")) return;
4829 isolate->memory_allocator()->RemoveMemoryAllocationCallback( 4822 isolate->memory_allocator()->RemoveMemoryAllocationCallback(
4830 callback); 4823 callback);
4831 } 4824 }
4832 4825
4833 4826
4834 void V8::PauseProfiler() { 4827 void V8::PauseProfiler() {
4835 #ifdef ENABLE_LOGGING_AND_PROFILING
4836 i::Isolate* isolate = i::Isolate::Current(); 4828 i::Isolate* isolate = i::Isolate::Current();
4837 isolate->logger()->PauseProfiler(); 4829 isolate->logger()->PauseProfiler();
4838 #endif
4839 } 4830 }
4840 4831
4841 4832
4842 void V8::ResumeProfiler() { 4833 void V8::ResumeProfiler() {
4843 #ifdef ENABLE_LOGGING_AND_PROFILING
4844 i::Isolate* isolate = i::Isolate::Current(); 4834 i::Isolate* isolate = i::Isolate::Current();
4845 isolate->logger()->ResumeProfiler(); 4835 isolate->logger()->ResumeProfiler();
4846 #endif
4847 } 4836 }
4848 4837
4849 4838
4850 bool V8::IsProfilerPaused() { 4839 bool V8::IsProfilerPaused() {
4851 #ifdef ENABLE_LOGGING_AND_PROFILING
4852 i::Isolate* isolate = i::Isolate::Current(); 4840 i::Isolate* isolate = i::Isolate::Current();
4853 return isolate->logger()->IsProfilerPaused(); 4841 return isolate->logger()->IsProfilerPaused();
4854 #else
4855 return true;
4856 #endif
4857 }
4858
4859
4860 int V8::GetLogLines(int from_pos, char* dest_buf, int max_size) {
4861 #ifdef ENABLE_LOGGING_AND_PROFILING
4862 ASSERT(max_size >= kMinimumSizeForLogLinesBuffer);
4863 return LOGGER->GetLogLines(from_pos, dest_buf, max_size);
4864 #endif
4865 return 0;
4866 } 4842 }
4867 4843
4868 4844
4869 int V8::GetCurrentThreadId() { 4845 int V8::GetCurrentThreadId() {
4870 i::Isolate* isolate = i::Isolate::Current(); 4846 i::Isolate* isolate = i::Isolate::Current();
4871 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()"); 4847 EnsureInitializedForIsolate(isolate, "V8::GetCurrentThreadId()");
4872 return isolate->thread_id().ToInteger(); 4848 return isolate->thread_id().ToInteger();
4873 } 4849 }
4874 4850
4875 4851
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 i::Isolate* isolate = i::Isolate::Current(); 5296 i::Isolate* isolate = i::Isolate::Current();
5321 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()"); 5297 EnsureInitializedForIsolate(isolate, "v8::Debug::GetDebugContext()");
5322 ENTER_V8(isolate); 5298 ENTER_V8(isolate);
5323 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext()); 5299 return Utils::ToLocal(i::Isolate::Current()->debugger()->GetDebugContext());
5324 } 5300 }
5325 5301
5326 #endif // ENABLE_DEBUGGER_SUPPORT 5302 #endif // ENABLE_DEBUGGER_SUPPORT
5327 5303
5328 5304
5329 Handle<String> CpuProfileNode::GetFunctionName() const { 5305 Handle<String> CpuProfileNode::GetFunctionName() const {
5330 #ifdef ENABLE_LOGGING_AND_PROFILING
5331 i::Isolate* isolate = i::Isolate::Current(); 5306 i::Isolate* isolate = i::Isolate::Current();
5332 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); 5307 IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName");
5333 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 5308 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5334 const i::CodeEntry* entry = node->entry(); 5309 const i::CodeEntry* entry = node->entry();
5335 if (!entry->has_name_prefix()) { 5310 if (!entry->has_name_prefix()) {
5336 return Handle<String>(ToApi<String>( 5311 return Handle<String>(ToApi<String>(
5337 isolate->factory()->LookupAsciiSymbol(entry->name()))); 5312 isolate->factory()->LookupAsciiSymbol(entry->name())));
5338 } else { 5313 } else {
5339 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString( 5314 return Handle<String>(ToApi<String>(isolate->factory()->NewConsString(
5340 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()), 5315 isolate->factory()->LookupAsciiSymbol(entry->name_prefix()),
5341 isolate->factory()->LookupAsciiSymbol(entry->name())))); 5316 isolate->factory()->LookupAsciiSymbol(entry->name()))));
5342 } 5317 }
5343 #else
5344 return v8::String::Empty();
5345 #endif
5346 } 5318 }
5347 5319
5348 5320
5349 Handle<String> CpuProfileNode::GetScriptResourceName() const { 5321 Handle<String> CpuProfileNode::GetScriptResourceName() const {
5350 #ifdef ENABLE_LOGGING_AND_PROFILING
5351 i::Isolate* isolate = i::Isolate::Current(); 5322 i::Isolate* isolate = i::Isolate::Current();
5352 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); 5323 IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName");
5353 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); 5324 const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
5354 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5325 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5355 node->entry()->resource_name()))); 5326 node->entry()->resource_name())));
5356 #else
5357 return v8::String::Empty();
5358 #endif
5359 } 5327 }
5360 5328
5361 5329
5362 int CpuProfileNode::GetLineNumber() const { 5330 int CpuProfileNode::GetLineNumber() const {
5363 #ifdef ENABLE_LOGGING_AND_PROFILING
5364 i::Isolate* isolate = i::Isolate::Current(); 5331 i::Isolate* isolate = i::Isolate::Current();
5365 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber"); 5332 IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber");
5366 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); 5333 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
5367 #else
5368 return 0;
5369 #endif
5370 } 5334 }
5371 5335
5372 5336
5373 double CpuProfileNode::GetTotalTime() const { 5337 double CpuProfileNode::GetTotalTime() const {
5374 #ifdef ENABLE_LOGGING_AND_PROFILING
5375 i::Isolate* isolate = i::Isolate::Current(); 5338 i::Isolate* isolate = i::Isolate::Current();
5376 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime"); 5339 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime");
5377 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis(); 5340 return reinterpret_cast<const i::ProfileNode*>(this)->GetTotalMillis();
5378 #else
5379 return 0.0;
5380 #endif
5381 } 5341 }
5382 5342
5383 5343
5384 double CpuProfileNode::GetSelfTime() const { 5344 double CpuProfileNode::GetSelfTime() const {
5385 #ifdef ENABLE_LOGGING_AND_PROFILING
5386 i::Isolate* isolate = i::Isolate::Current(); 5345 i::Isolate* isolate = i::Isolate::Current();
5387 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime"); 5346 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime");
5388 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis(); 5347 return reinterpret_cast<const i::ProfileNode*>(this)->GetSelfMillis();
5389 #else
5390 return 0.0;
5391 #endif
5392 } 5348 }
5393 5349
5394 5350
5395 double CpuProfileNode::GetTotalSamplesCount() const { 5351 double CpuProfileNode::GetTotalSamplesCount() const {
5396 #ifdef ENABLE_LOGGING_AND_PROFILING
5397 i::Isolate* isolate = i::Isolate::Current(); 5352 i::Isolate* isolate = i::Isolate::Current();
5398 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount"); 5353 IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount");
5399 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks(); 5354 return reinterpret_cast<const i::ProfileNode*>(this)->total_ticks();
5400 #else
5401 return 0.0;
5402 #endif
5403 } 5355 }
5404 5356
5405 5357
5406 double CpuProfileNode::GetSelfSamplesCount() const { 5358 double CpuProfileNode::GetSelfSamplesCount() const {
5407 #ifdef ENABLE_LOGGING_AND_PROFILING
5408 i::Isolate* isolate = i::Isolate::Current(); 5359 i::Isolate* isolate = i::Isolate::Current();
5409 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); 5360 IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount");
5410 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks(); 5361 return reinterpret_cast<const i::ProfileNode*>(this)->self_ticks();
5411 #else
5412 return 0.0;
5413 #endif
5414 } 5362 }
5415 5363
5416 5364
5417 unsigned CpuProfileNode::GetCallUid() const { 5365 unsigned CpuProfileNode::GetCallUid() const {
5418 #ifdef ENABLE_LOGGING_AND_PROFILING
5419 i::Isolate* isolate = i::Isolate::Current(); 5366 i::Isolate* isolate = i::Isolate::Current();
5420 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid"); 5367 IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid");
5421 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid(); 5368 return reinterpret_cast<const i::ProfileNode*>(this)->entry()->GetCallUid();
5422 #else
5423 return 0;
5424 #endif
5425 } 5369 }
5426 5370
5427 5371
5428 int CpuProfileNode::GetChildrenCount() const { 5372 int CpuProfileNode::GetChildrenCount() const {
5429 #ifdef ENABLE_LOGGING_AND_PROFILING
5430 i::Isolate* isolate = i::Isolate::Current(); 5373 i::Isolate* isolate = i::Isolate::Current();
5431 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); 5374 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount");
5432 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length(); 5375 return reinterpret_cast<const i::ProfileNode*>(this)->children()->length();
5433 #else
5434 return 0;
5435 #endif
5436 } 5376 }
5437 5377
5438 5378
5439 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { 5379 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
5440 #ifdef ENABLE_LOGGING_AND_PROFILING
5441 i::Isolate* isolate = i::Isolate::Current(); 5380 i::Isolate* isolate = i::Isolate::Current();
5442 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); 5381 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild");
5443 const i::ProfileNode* child = 5382 const i::ProfileNode* child =
5444 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); 5383 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
5445 return reinterpret_cast<const CpuProfileNode*>(child); 5384 return reinterpret_cast<const CpuProfileNode*>(child);
5446 #else
5447 return NULL;
5448 #endif
5449 } 5385 }
5450 5386
5451 5387
5452 void CpuProfile::Delete() { 5388 void CpuProfile::Delete() {
5453 #ifdef ENABLE_LOGGING_AND_PROFILING
5454 i::Isolate* isolate = i::Isolate::Current(); 5389 i::Isolate* isolate = i::Isolate::Current();
5455 IsDeadCheck(isolate, "v8::CpuProfile::Delete"); 5390 IsDeadCheck(isolate, "v8::CpuProfile::Delete");
5456 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this)); 5391 i::CpuProfiler::DeleteProfile(reinterpret_cast<i::CpuProfile*>(this));
5457 if (i::CpuProfiler::GetProfilesCount() == 0 && 5392 if (i::CpuProfiler::GetProfilesCount() == 0 &&
5458 !i::CpuProfiler::HasDetachedProfiles()) { 5393 !i::CpuProfiler::HasDetachedProfiles()) {
5459 // If this was the last profile, clean up all accessory data as well. 5394 // If this was the last profile, clean up all accessory data as well.
5460 i::CpuProfiler::DeleteAllProfiles(); 5395 i::CpuProfiler::DeleteAllProfiles();
5461 } 5396 }
5462 #endif
5463 } 5397 }
5464 5398
5465 5399
5466 unsigned CpuProfile::GetUid() const { 5400 unsigned CpuProfile::GetUid() const {
5467 #ifdef ENABLE_LOGGING_AND_PROFILING
5468 i::Isolate* isolate = i::Isolate::Current(); 5401 i::Isolate* isolate = i::Isolate::Current();
5469 IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); 5402 IsDeadCheck(isolate, "v8::CpuProfile::GetUid");
5470 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); 5403 return reinterpret_cast<const i::CpuProfile*>(this)->uid();
5471 #else
5472 return 0;
5473 #endif
5474 } 5404 }
5475 5405
5476 5406
5477 Handle<String> CpuProfile::GetTitle() const { 5407 Handle<String> CpuProfile::GetTitle() const {
5478 #ifdef ENABLE_LOGGING_AND_PROFILING
5479 i::Isolate* isolate = i::Isolate::Current(); 5408 i::Isolate* isolate = i::Isolate::Current();
5480 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); 5409 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
5481 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5410 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5482 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5411 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5483 profile->title()))); 5412 profile->title())));
5484 #else
5485 return v8::String::Empty();
5486 #endif
5487 } 5413 }
5488 5414
5489 5415
5490 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { 5416 const CpuProfileNode* CpuProfile::GetBottomUpRoot() const {
5491 #ifdef ENABLE_LOGGING_AND_PROFILING
5492 i::Isolate* isolate = i::Isolate::Current(); 5417 i::Isolate* isolate = i::Isolate::Current();
5493 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot"); 5418 IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot");
5494 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5419 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5495 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root()); 5420 return reinterpret_cast<const CpuProfileNode*>(profile->bottom_up()->root());
5496 #else
5497 return NULL;
5498 #endif
5499 } 5421 }
5500 5422
5501 5423
5502 const CpuProfileNode* CpuProfile::GetTopDownRoot() const { 5424 const CpuProfileNode* CpuProfile::GetTopDownRoot() const {
5503 #ifdef ENABLE_LOGGING_AND_PROFILING
5504 i::Isolate* isolate = i::Isolate::Current(); 5425 i::Isolate* isolate = i::Isolate::Current();
5505 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot"); 5426 IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot");
5506 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); 5427 const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
5507 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root()); 5428 return reinterpret_cast<const CpuProfileNode*>(profile->top_down()->root());
5508 #else
5509 return NULL;
5510 #endif
5511 } 5429 }
5512 5430
5513 5431
5514 int CpuProfiler::GetProfilesCount() { 5432 int CpuProfiler::GetProfilesCount() {
5515 #ifdef ENABLE_LOGGING_AND_PROFILING
5516 i::Isolate* isolate = i::Isolate::Current(); 5433 i::Isolate* isolate = i::Isolate::Current();
5517 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); 5434 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount");
5518 return i::CpuProfiler::GetProfilesCount(); 5435 return i::CpuProfiler::GetProfilesCount();
5519 #else
5520 return 0;
5521 #endif
5522 } 5436 }
5523 5437
5524 5438
5525 const CpuProfile* CpuProfiler::GetProfile(int index, 5439 const CpuProfile* CpuProfiler::GetProfile(int index,
5526 Handle<Value> security_token) { 5440 Handle<Value> security_token) {
5527 #ifdef ENABLE_LOGGING_AND_PROFILING
5528 i::Isolate* isolate = i::Isolate::Current(); 5441 i::Isolate* isolate = i::Isolate::Current();
5529 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); 5442 IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile");
5530 return reinterpret_cast<const CpuProfile*>( 5443 return reinterpret_cast<const CpuProfile*>(
5531 i::CpuProfiler::GetProfile( 5444 i::CpuProfiler::GetProfile(
5532 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5445 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5533 index)); 5446 index));
5534 #else
5535 return NULL;
5536 #endif
5537 } 5447 }
5538 5448
5539 5449
5540 const CpuProfile* CpuProfiler::FindProfile(unsigned uid, 5450 const CpuProfile* CpuProfiler::FindProfile(unsigned uid,
5541 Handle<Value> security_token) { 5451 Handle<Value> security_token) {
5542 #ifdef ENABLE_LOGGING_AND_PROFILING
5543 i::Isolate* isolate = i::Isolate::Current(); 5452 i::Isolate* isolate = i::Isolate::Current();
5544 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); 5453 IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile");
5545 return reinterpret_cast<const CpuProfile*>( 5454 return reinterpret_cast<const CpuProfile*>(
5546 i::CpuProfiler::FindProfile( 5455 i::CpuProfiler::FindProfile(
5547 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5456 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5548 uid)); 5457 uid));
5549 #else
5550 return NULL;
5551 #endif
5552 } 5458 }
5553 5459
5554 5460
5555 void CpuProfiler::StartProfiling(Handle<String> title) { 5461 void CpuProfiler::StartProfiling(Handle<String> title) {
5556 #ifdef ENABLE_LOGGING_AND_PROFILING
5557 i::Isolate* isolate = i::Isolate::Current(); 5462 i::Isolate* isolate = i::Isolate::Current();
5558 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); 5463 IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling");
5559 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); 5464 i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title));
5560 #endif
5561 } 5465 }
5562 5466
5563 5467
5564 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title, 5468 const CpuProfile* CpuProfiler::StopProfiling(Handle<String> title,
5565 Handle<Value> security_token) { 5469 Handle<Value> security_token) {
5566 #ifdef ENABLE_LOGGING_AND_PROFILING
5567 i::Isolate* isolate = i::Isolate::Current(); 5470 i::Isolate* isolate = i::Isolate::Current();
5568 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); 5471 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
5569 return reinterpret_cast<const CpuProfile*>( 5472 return reinterpret_cast<const CpuProfile*>(
5570 i::CpuProfiler::StopProfiling( 5473 i::CpuProfiler::StopProfiling(
5571 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5474 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5572 *Utils::OpenHandle(*title))); 5475 *Utils::OpenHandle(*title)));
5573 #else
5574 return NULL;
5575 #endif
5576 } 5476 }
5577 5477
5578 5478
5579 void CpuProfiler::DeleteAllProfiles() { 5479 void CpuProfiler::DeleteAllProfiles() {
5580 #ifdef ENABLE_LOGGING_AND_PROFILING
5581 i::Isolate* isolate = i::Isolate::Current(); 5480 i::Isolate* isolate = i::Isolate::Current();
5582 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); 5481 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
5583 i::CpuProfiler::DeleteAllProfiles(); 5482 i::CpuProfiler::DeleteAllProfiles();
5584 #endif
5585 } 5483 }
5586 5484
5587 5485
5588 #ifdef ENABLE_LOGGING_AND_PROFILING
5589 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 5486 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
5590 return const_cast<i::HeapGraphEdge*>( 5487 return const_cast<i::HeapGraphEdge*>(
5591 reinterpret_cast<const i::HeapGraphEdge*>(edge)); 5488 reinterpret_cast<const i::HeapGraphEdge*>(edge));
5592 } 5489 }
5593 #endif
5594 5490
5595 5491
5596 HeapGraphEdge::Type HeapGraphEdge::GetType() const { 5492 HeapGraphEdge::Type HeapGraphEdge::GetType() const {
5597 #ifdef ENABLE_LOGGING_AND_PROFILING
5598 i::Isolate* isolate = i::Isolate::Current(); 5493 i::Isolate* isolate = i::Isolate::Current();
5599 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); 5494 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType");
5600 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); 5495 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
5601 #else
5602 return static_cast<HeapGraphEdge::Type>(0);
5603 #endif
5604 } 5496 }
5605 5497
5606 5498
5607 Handle<Value> HeapGraphEdge::GetName() const { 5499 Handle<Value> HeapGraphEdge::GetName() const {
5608 #ifdef ENABLE_LOGGING_AND_PROFILING
5609 i::Isolate* isolate = i::Isolate::Current(); 5500 i::Isolate* isolate = i::Isolate::Current();
5610 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); 5501 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName");
5611 i::HeapGraphEdge* edge = ToInternal(this); 5502 i::HeapGraphEdge* edge = ToInternal(this);
5612 switch (edge->type()) { 5503 switch (edge->type()) {
5613 case i::HeapGraphEdge::kContextVariable: 5504 case i::HeapGraphEdge::kContextVariable:
5614 case i::HeapGraphEdge::kInternal: 5505 case i::HeapGraphEdge::kInternal:
5615 case i::HeapGraphEdge::kProperty: 5506 case i::HeapGraphEdge::kProperty:
5616 case i::HeapGraphEdge::kShortcut: 5507 case i::HeapGraphEdge::kShortcut:
5617 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5508 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5618 edge->name()))); 5509 edge->name())));
5619 case i::HeapGraphEdge::kElement: 5510 case i::HeapGraphEdge::kElement:
5620 case i::HeapGraphEdge::kHidden: 5511 case i::HeapGraphEdge::kHidden:
5621 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt( 5512 return Handle<Number>(ToApi<Number>(isolate->factory()->NewNumberFromInt(
5622 edge->index()))); 5513 edge->index())));
5623 default: UNREACHABLE(); 5514 default: UNREACHABLE();
5624 } 5515 }
5625 #endif
5626 return v8::Undefined(); 5516 return v8::Undefined();
5627 } 5517 }
5628 5518
5629 5519
5630 const HeapGraphNode* HeapGraphEdge::GetFromNode() const { 5520 const HeapGraphNode* HeapGraphEdge::GetFromNode() const {
5631 #ifdef ENABLE_LOGGING_AND_PROFILING
5632 i::Isolate* isolate = i::Isolate::Current(); 5521 i::Isolate* isolate = i::Isolate::Current();
5633 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); 5522 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode");
5634 const i::HeapEntry* from = ToInternal(this)->From(); 5523 const i::HeapEntry* from = ToInternal(this)->From();
5635 return reinterpret_cast<const HeapGraphNode*>(from); 5524 return reinterpret_cast<const HeapGraphNode*>(from);
5636 #else
5637 return NULL;
5638 #endif
5639 } 5525 }
5640 5526
5641 5527
5642 const HeapGraphNode* HeapGraphEdge::GetToNode() const { 5528 const HeapGraphNode* HeapGraphEdge::GetToNode() const {
5643 #ifdef ENABLE_LOGGING_AND_PROFILING
5644 i::Isolate* isolate = i::Isolate::Current(); 5529 i::Isolate* isolate = i::Isolate::Current();
5645 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); 5530 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode");
5646 const i::HeapEntry* to = ToInternal(this)->to(); 5531 const i::HeapEntry* to = ToInternal(this)->to();
5647 return reinterpret_cast<const HeapGraphNode*>(to); 5532 return reinterpret_cast<const HeapGraphNode*>(to);
5648 #else
5649 return NULL;
5650 #endif
5651 } 5533 }
5652 5534
5653 5535
5654 #ifdef ENABLE_LOGGING_AND_PROFILING
5655 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { 5536 static i::HeapEntry* ToInternal(const HeapGraphNode* entry) {
5656 return const_cast<i::HeapEntry*>( 5537 return const_cast<i::HeapEntry*>(
5657 reinterpret_cast<const i::HeapEntry*>(entry)); 5538 reinterpret_cast<const i::HeapEntry*>(entry));
5658 } 5539 }
5659 #endif
5660 5540
5661 5541
5662 HeapGraphNode::Type HeapGraphNode::GetType() const { 5542 HeapGraphNode::Type HeapGraphNode::GetType() const {
5663 #ifdef ENABLE_LOGGING_AND_PROFILING
5664 i::Isolate* isolate = i::Isolate::Current(); 5543 i::Isolate* isolate = i::Isolate::Current();
5665 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); 5544 IsDeadCheck(isolate, "v8::HeapGraphNode::GetType");
5666 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type()); 5545 return static_cast<HeapGraphNode::Type>(ToInternal(this)->type());
5667 #else
5668 return static_cast<HeapGraphNode::Type>(0);
5669 #endif
5670 } 5546 }
5671 5547
5672 5548
5673 Handle<String> HeapGraphNode::GetName() const { 5549 Handle<String> HeapGraphNode::GetName() const {
5674 #ifdef ENABLE_LOGGING_AND_PROFILING
5675 i::Isolate* isolate = i::Isolate::Current(); 5550 i::Isolate* isolate = i::Isolate::Current();
5676 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); 5551 IsDeadCheck(isolate, "v8::HeapGraphNode::GetName");
5677 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5552 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5678 ToInternal(this)->name()))); 5553 ToInternal(this)->name())));
5679 #else
5680 return v8::String::Empty();
5681 #endif
5682 } 5554 }
5683 5555
5684 5556
5685 uint64_t HeapGraphNode::GetId() const { 5557 uint64_t HeapGraphNode::GetId() const {
5686 #ifdef ENABLE_LOGGING_AND_PROFILING
5687 i::Isolate* isolate = i::Isolate::Current(); 5558 i::Isolate* isolate = i::Isolate::Current();
5688 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); 5559 IsDeadCheck(isolate, "v8::HeapGraphNode::GetId");
5689 return ToInternal(this)->id(); 5560 return ToInternal(this)->id();
5690 #else
5691 return 0;
5692 #endif
5693 } 5561 }
5694 5562
5695 5563
5696 int HeapGraphNode::GetSelfSize() const { 5564 int HeapGraphNode::GetSelfSize() const {
5697 #ifdef ENABLE_LOGGING_AND_PROFILING
5698 i::Isolate* isolate = i::Isolate::Current(); 5565 i::Isolate* isolate = i::Isolate::Current();
5699 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); 5566 IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize");
5700 return ToInternal(this)->self_size(); 5567 return ToInternal(this)->self_size();
5701 #else
5702 return 0;
5703 #endif
5704 } 5568 }
5705 5569
5706 5570
5707 int HeapGraphNode::GetRetainedSize(bool exact) const { 5571 int HeapGraphNode::GetRetainedSize(bool exact) const {
5708 #ifdef ENABLE_LOGGING_AND_PROFILING
5709 i::Isolate* isolate = i::Isolate::Current(); 5572 i::Isolate* isolate = i::Isolate::Current();
5710 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize"); 5573 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize");
5711 return ToInternal(this)->RetainedSize(exact); 5574 return ToInternal(this)->RetainedSize(exact);
5712 #else
5713 return 0;
5714 #endif
5715 } 5575 }
5716 5576
5717 5577
5718 int HeapGraphNode::GetChildrenCount() const { 5578 int HeapGraphNode::GetChildrenCount() const {
5719 #ifdef ENABLE_LOGGING_AND_PROFILING
5720 i::Isolate* isolate = i::Isolate::Current(); 5579 i::Isolate* isolate = i::Isolate::Current();
5721 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); 5580 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount");
5722 return ToInternal(this)->children().length(); 5581 return ToInternal(this)->children().length();
5723 #else
5724 return 0;
5725 #endif
5726 } 5582 }
5727 5583
5728 5584
5729 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { 5585 const HeapGraphEdge* HeapGraphNode::GetChild(int index) const {
5730 #ifdef ENABLE_LOGGING_AND_PROFILING
5731 i::Isolate* isolate = i::Isolate::Current(); 5586 i::Isolate* isolate = i::Isolate::Current();
5732 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); 5587 IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild");
5733 return reinterpret_cast<const HeapGraphEdge*>( 5588 return reinterpret_cast<const HeapGraphEdge*>(
5734 &ToInternal(this)->children()[index]); 5589 &ToInternal(this)->children()[index]);
5735 #else
5736 return NULL;
5737 #endif
5738 } 5590 }
5739 5591
5740 5592
5741 int HeapGraphNode::GetRetainersCount() const { 5593 int HeapGraphNode::GetRetainersCount() const {
5742 #ifdef ENABLE_LOGGING_AND_PROFILING
5743 i::Isolate* isolate = i::Isolate::Current(); 5594 i::Isolate* isolate = i::Isolate::Current();
5744 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount"); 5595 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount");
5745 return ToInternal(this)->retainers().length(); 5596 return ToInternal(this)->retainers().length();
5746 #else
5747 return 0;
5748 #endif
5749 } 5597 }
5750 5598
5751 5599
5752 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { 5600 const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const {
5753 #ifdef ENABLE_LOGGING_AND_PROFILING
5754 i::Isolate* isolate = i::Isolate::Current(); 5601 i::Isolate* isolate = i::Isolate::Current();
5755 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer"); 5602 IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer");
5756 return reinterpret_cast<const HeapGraphEdge*>( 5603 return reinterpret_cast<const HeapGraphEdge*>(
5757 ToInternal(this)->retainers()[index]); 5604 ToInternal(this)->retainers()[index]);
5758 #else
5759 return NULL;
5760 #endif
5761 } 5605 }
5762 5606
5763 5607
5764 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { 5608 const HeapGraphNode* HeapGraphNode::GetDominatorNode() const {
5765 #ifdef ENABLE_LOGGING_AND_PROFILING
5766 i::Isolate* isolate = i::Isolate::Current(); 5609 i::Isolate* isolate = i::Isolate::Current();
5767 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); 5610 IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode");
5768 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator()); 5611 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->dominator());
5769 #else
5770 return NULL;
5771 #endif
5772 } 5612 }
5773 5613
5774 5614
5775 #ifdef ENABLE_LOGGING_AND_PROFILING
5776 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 5615 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
5777 return const_cast<i::HeapSnapshot*>( 5616 return const_cast<i::HeapSnapshot*>(
5778 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 5617 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
5779 } 5618 }
5780 #endif
5781 5619
5782 5620
5783 void HeapSnapshot::Delete() { 5621 void HeapSnapshot::Delete() {
5784 #ifdef ENABLE_LOGGING_AND_PROFILING
5785 i::Isolate* isolate = i::Isolate::Current(); 5622 i::Isolate* isolate = i::Isolate::Current();
5786 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); 5623 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
5787 if (i::HeapProfiler::GetSnapshotsCount() > 1) { 5624 if (i::HeapProfiler::GetSnapshotsCount() > 1) {
5788 ToInternal(this)->Delete(); 5625 ToInternal(this)->Delete();
5789 } else { 5626 } else {
5790 // If this is the last snapshot, clean up all accessory data as well. 5627 // If this is the last snapshot, clean up all accessory data as well.
5791 i::HeapProfiler::DeleteAllSnapshots(); 5628 i::HeapProfiler::DeleteAllSnapshots();
5792 } 5629 }
5793 #endif
5794 } 5630 }
5795 5631
5796 5632
5797 HeapSnapshot::Type HeapSnapshot::GetType() const { 5633 HeapSnapshot::Type HeapSnapshot::GetType() const {
5798 #ifdef ENABLE_LOGGING_AND_PROFILING
5799 i::Isolate* isolate = i::Isolate::Current(); 5634 i::Isolate* isolate = i::Isolate::Current();
5800 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); 5635 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
5801 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); 5636 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
5802 #else
5803 return static_cast<HeapSnapshot::Type>(0);
5804 #endif
5805 } 5637 }
5806 5638
5807 5639
5808 unsigned HeapSnapshot::GetUid() const { 5640 unsigned HeapSnapshot::GetUid() const {
5809 #ifdef ENABLE_LOGGING_AND_PROFILING
5810 i::Isolate* isolate = i::Isolate::Current(); 5641 i::Isolate* isolate = i::Isolate::Current();
5811 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); 5642 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
5812 return ToInternal(this)->uid(); 5643 return ToInternal(this)->uid();
5813 #else
5814 return 0;
5815 #endif
5816 } 5644 }
5817 5645
5818 5646
5819 Handle<String> HeapSnapshot::GetTitle() const { 5647 Handle<String> HeapSnapshot::GetTitle() const {
5820 #ifdef ENABLE_LOGGING_AND_PROFILING
5821 i::Isolate* isolate = i::Isolate::Current(); 5648 i::Isolate* isolate = i::Isolate::Current();
5822 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); 5649 IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle");
5823 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol( 5650 return Handle<String>(ToApi<String>(isolate->factory()->LookupAsciiSymbol(
5824 ToInternal(this)->title()))); 5651 ToInternal(this)->title())));
5825 #else
5826 return v8::String::Empty();
5827 #endif
5828 } 5652 }
5829 5653
5830 5654
5831 const HeapGraphNode* HeapSnapshot::GetRoot() const { 5655 const HeapGraphNode* HeapSnapshot::GetRoot() const {
5832 #ifdef ENABLE_LOGGING_AND_PROFILING
5833 i::Isolate* isolate = i::Isolate::Current(); 5656 i::Isolate* isolate = i::Isolate::Current();
5834 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); 5657 IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead");
5835 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root()); 5658 return reinterpret_cast<const HeapGraphNode*>(ToInternal(this)->root());
5836 #else
5837 return 0;
5838 #endif
5839 } 5659 }
5840 5660
5841 5661
5842 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const { 5662 const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const {
5843 #ifdef ENABLE_LOGGING_AND_PROFILING
5844 i::Isolate* isolate = i::Isolate::Current(); 5663 i::Isolate* isolate = i::Isolate::Current();
5845 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); 5664 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById");
5846 return reinterpret_cast<const HeapGraphNode*>( 5665 return reinterpret_cast<const HeapGraphNode*>(
5847 ToInternal(this)->GetEntryById(id)); 5666 ToInternal(this)->GetEntryById(id));
5848 #else
5849 return NULL;
5850 #endif
5851 } 5667 }
5852 5668
5853 5669
5854 int HeapSnapshot::GetNodesCount() const { 5670 int HeapSnapshot::GetNodesCount() const {
5855 #ifdef ENABLE_LOGGING_AND_PROFILING
5856 i::Isolate* isolate = i::Isolate::Current(); 5671 i::Isolate* isolate = i::Isolate::Current();
5857 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount"); 5672 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodesCount");
5858 return ToInternal(this)->entries()->length(); 5673 return ToInternal(this)->entries()->length();
5859 #else
5860 return 0;
5861 #endif
5862 } 5674 }
5863 5675
5864 5676
5865 const HeapGraphNode* HeapSnapshot::GetNode(int index) const { 5677 const HeapGraphNode* HeapSnapshot::GetNode(int index) const {
5866 #ifdef ENABLE_LOGGING_AND_PROFILING
5867 i::Isolate* isolate = i::Isolate::Current(); 5678 i::Isolate* isolate = i::Isolate::Current();
5868 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode"); 5679 IsDeadCheck(isolate, "v8::HeapSnapshot::GetNode");
5869 return reinterpret_cast<const HeapGraphNode*>( 5680 return reinterpret_cast<const HeapGraphNode*>(
5870 ToInternal(this)->entries()->at(index)); 5681 ToInternal(this)->entries()->at(index));
5871 #else
5872 return 0;
5873 #endif
5874 } 5682 }
5875 5683
5876 5684
5877 void HeapSnapshot::Serialize(OutputStream* stream, 5685 void HeapSnapshot::Serialize(OutputStream* stream,
5878 HeapSnapshot::SerializationFormat format) const { 5686 HeapSnapshot::SerializationFormat format) const {
5879 #ifdef ENABLE_LOGGING_AND_PROFILING
5880 i::Isolate* isolate = i::Isolate::Current(); 5687 i::Isolate* isolate = i::Isolate::Current();
5881 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); 5688 IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize");
5882 ApiCheck(format == kJSON, 5689 ApiCheck(format == kJSON,
5883 "v8::HeapSnapshot::Serialize", 5690 "v8::HeapSnapshot::Serialize",
5884 "Unknown serialization format"); 5691 "Unknown serialization format");
5885 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii, 5692 ApiCheck(stream->GetOutputEncoding() == OutputStream::kAscii,
5886 "v8::HeapSnapshot::Serialize", 5693 "v8::HeapSnapshot::Serialize",
5887 "Unsupported output encoding"); 5694 "Unsupported output encoding");
5888 ApiCheck(stream->GetChunkSize() > 0, 5695 ApiCheck(stream->GetChunkSize() > 0,
5889 "v8::HeapSnapshot::Serialize", 5696 "v8::HeapSnapshot::Serialize",
5890 "Invalid stream chunk size"); 5697 "Invalid stream chunk size");
5891 i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); 5698 i::HeapSnapshotJSONSerializer serializer(ToInternal(this));
5892 serializer.Serialize(stream); 5699 serializer.Serialize(stream);
5893 #endif
5894 } 5700 }
5895 5701
5896 5702
5897 int HeapProfiler::GetSnapshotsCount() { 5703 int HeapProfiler::GetSnapshotsCount() {
5898 #ifdef ENABLE_LOGGING_AND_PROFILING
5899 i::Isolate* isolate = i::Isolate::Current(); 5704 i::Isolate* isolate = i::Isolate::Current();
5900 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); 5705 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount");
5901 return i::HeapProfiler::GetSnapshotsCount(); 5706 return i::HeapProfiler::GetSnapshotsCount();
5902 #else
5903 return 0;
5904 #endif
5905 } 5707 }
5906 5708
5907 5709
5908 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { 5710 const HeapSnapshot* HeapProfiler::GetSnapshot(int index) {
5909 #ifdef ENABLE_LOGGING_AND_PROFILING
5910 i::Isolate* isolate = i::Isolate::Current(); 5711 i::Isolate* isolate = i::Isolate::Current();
5911 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); 5712 IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot");
5912 return reinterpret_cast<const HeapSnapshot*>( 5713 return reinterpret_cast<const HeapSnapshot*>(
5913 i::HeapProfiler::GetSnapshot(index)); 5714 i::HeapProfiler::GetSnapshot(index));
5914 #else
5915 return NULL;
5916 #endif
5917 } 5715 }
5918 5716
5919 5717
5920 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { 5718 const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) {
5921 #ifdef ENABLE_LOGGING_AND_PROFILING
5922 i::Isolate* isolate = i::Isolate::Current(); 5719 i::Isolate* isolate = i::Isolate::Current();
5923 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); 5720 IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot");
5924 return reinterpret_cast<const HeapSnapshot*>( 5721 return reinterpret_cast<const HeapSnapshot*>(
5925 i::HeapProfiler::FindSnapshot(uid)); 5722 i::HeapProfiler::FindSnapshot(uid));
5926 #else
5927 return NULL;
5928 #endif
5929 } 5723 }
5930 5724
5931 5725
5932 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title, 5726 const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle<String> title,
5933 HeapSnapshot::Type type, 5727 HeapSnapshot::Type type,
5934 ActivityControl* control) { 5728 ActivityControl* control) {
5935 #ifdef ENABLE_LOGGING_AND_PROFILING
5936 i::Isolate* isolate = i::Isolate::Current(); 5729 i::Isolate* isolate = i::Isolate::Current();
5937 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); 5730 IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot");
5938 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; 5731 i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull;
5939 switch (type) { 5732 switch (type) {
5940 case HeapSnapshot::kFull: 5733 case HeapSnapshot::kFull:
5941 internal_type = i::HeapSnapshot::kFull; 5734 internal_type = i::HeapSnapshot::kFull;
5942 break; 5735 break;
5943 default: 5736 default:
5944 UNREACHABLE(); 5737 UNREACHABLE();
5945 } 5738 }
5946 return reinterpret_cast<const HeapSnapshot*>( 5739 return reinterpret_cast<const HeapSnapshot*>(
5947 i::HeapProfiler::TakeSnapshot( 5740 i::HeapProfiler::TakeSnapshot(
5948 *Utils::OpenHandle(*title), internal_type, control)); 5741 *Utils::OpenHandle(*title), internal_type, control));
5949 #else
5950 return NULL;
5951 #endif
5952 } 5742 }
5953 5743
5954 5744
5955 void HeapProfiler::DeleteAllSnapshots() { 5745 void HeapProfiler::DeleteAllSnapshots() {
5956 #ifdef ENABLE_LOGGING_AND_PROFILING
5957 i::Isolate* isolate = i::Isolate::Current(); 5746 i::Isolate* isolate = i::Isolate::Current();
5958 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); 5747 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
5959 i::HeapProfiler::DeleteAllSnapshots(); 5748 i::HeapProfiler::DeleteAllSnapshots();
5960 #endif
5961 } 5749 }
5962 5750
5963 5751
5964 void HeapProfiler::DefineWrapperClass(uint16_t class_id, 5752 void HeapProfiler::DefineWrapperClass(uint16_t class_id,
5965 WrapperInfoCallback callback) { 5753 WrapperInfoCallback callback) {
5966 #ifdef ENABLE_LOGGING_AND_PROFILING
5967 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, 5754 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
5968 callback); 5755 callback);
5969 #endif
5970 } 5756 }
5971 5757
5972 5758
5973 5759
5974 v8::Testing::StressType internal::Testing::stress_type_ = 5760 v8::Testing::StressType internal::Testing::stress_type_ =
5975 v8::Testing::kStressTypeOpt; 5761 v8::Testing::kStressTypeOpt;
5976 5762
5977 5763
5978 void Testing::SetStressRunType(Testing::StressType type) { 5764 void Testing::SetStressRunType(Testing::StressType type) {
5979 internal::Testing::set_stress_type(type); 5765 internal::Testing::set_stress_type(type);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
6098 5884
6099 5885
6100 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5886 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
6101 HandleScopeImplementer* scope_implementer = 5887 HandleScopeImplementer* scope_implementer =
6102 reinterpret_cast<HandleScopeImplementer*>(storage); 5888 reinterpret_cast<HandleScopeImplementer*>(storage);
6103 scope_implementer->IterateThis(v); 5889 scope_implementer->IterateThis(v);
6104 return storage + ArchiveSpacePerThread(); 5890 return storage + ArchiveSpacePerThread();
6105 } 5891 }
6106 5892
6107 } } // namespace v8::internal 5893 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/SConscript ('k') | src/arm/code-stubs-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698