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

Side by Side Diff: test/cctest/test-log.cc

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 9 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 | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-log-stack-tracer.cc » ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of logging functions from log.h 3 // Tests of logging functions from log.h
4 4
5 #ifdef ENABLE_LOGGING_AND_PROFILING 5 #ifdef ENABLE_LOGGING_AND_PROFILING
6 6
7 #ifdef __linux__ 7 #ifdef __linux__
8 #include <math.h> 8 #include <math.h>
9 #include <pthread.h> 9 #include <pthread.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 11 matching lines...) Expand all
22 using v8::internal::EmbeddedVector; 22 using v8::internal::EmbeddedVector;
23 using v8::internal::Logger; 23 using v8::internal::Logger;
24 using v8::internal::StrLength; 24 using v8::internal::StrLength;
25 25
26 namespace i = v8::internal; 26 namespace i = v8::internal;
27 27
28 static void SetUp() { 28 static void SetUp() {
29 // Log to memory buffer. 29 // Log to memory buffer.
30 i::FLAG_logfile = "*"; 30 i::FLAG_logfile = "*";
31 i::FLAG_log = true; 31 i::FLAG_log = true;
32 Logger::Setup(); 32 LOGGER->Setup();
33 } 33 }
34 34
35 static void TearDown() { 35 static void TearDown() {
36 Logger::TearDown(); 36 LOGGER->TearDown();
37 } 37 }
38 38
39 39
40 TEST(EmptyLog) { 40 TEST(EmptyLog) {
41 SetUp(); 41 SetUp();
42 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); 42 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0));
43 CHECK_EQ(0, Logger::GetLogLines(100, NULL, 0)); 43 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0));
44 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 100)); 44 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100));
45 CHECK_EQ(0, Logger::GetLogLines(100, NULL, 100)); 45 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100));
46 TearDown(); 46 TearDown();
47 } 47 }
48 48
49 49
50 TEST(GetMessages) { 50 TEST(GetMessages) {
51 SetUp(); 51 SetUp();
52 Logger::StringEvent("aaa", "bbb"); 52 LOGGER->StringEvent("aaa", "bbb");
53 Logger::StringEvent("cccc", "dddd"); 53 LOGGER->StringEvent("cccc", "dddd");
54 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); 54 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0));
55 char log_lines[100]; 55 char log_lines[100];
56 memset(log_lines, 0, sizeof(log_lines)); 56 memset(log_lines, 0, sizeof(log_lines));
57 // See Logger::StringEvent. 57 // See Logger::StringEvent.
58 const char* line_1 = "aaa,\"bbb\"\n"; 58 const char* line_1 = "aaa,\"bbb\"\n";
59 const int line_1_len = StrLength(line_1); 59 const int line_1_len = StrLength(line_1);
60 // The exact size. 60 // The exact size.
61 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len)); 61 CHECK_EQ(line_1_len, LOGGER->GetLogLines(0, log_lines, line_1_len));
62 CHECK_EQ(line_1, log_lines); 62 CHECK_EQ(line_1, log_lines);
63 memset(log_lines, 0, sizeof(log_lines)); 63 memset(log_lines, 0, sizeof(log_lines));
64 // A bit more than the first line length. 64 // A bit more than the first line length.
65 CHECK_EQ(line_1_len, Logger::GetLogLines(0, log_lines, line_1_len + 3)); 65 CHECK_EQ(line_1_len, LOGGER->GetLogLines(0, log_lines, line_1_len + 3));
66 log_lines[line_1_len] = '\0'; 66 log_lines[line_1_len] = '\0';
67 CHECK_EQ(line_1, log_lines); 67 CHECK_EQ(line_1, log_lines);
68 memset(log_lines, 0, sizeof(log_lines)); 68 memset(log_lines, 0, sizeof(log_lines));
69 const char* line_2 = "cccc,\"dddd\"\n"; 69 const char* line_2 = "cccc,\"dddd\"\n";
70 const int line_2_len = StrLength(line_2); 70 const int line_2_len = StrLength(line_2);
71 // Now start with line_2 beginning. 71 // Now start with line_2 beginning.
72 CHECK_EQ(0, Logger::GetLogLines(line_1_len, log_lines, 0)); 72 CHECK_EQ(0, LOGGER->GetLogLines(line_1_len, log_lines, 0));
73 CHECK_EQ(line_2_len, Logger::GetLogLines(line_1_len, log_lines, line_2_len)); 73 CHECK_EQ(line_2_len, LOGGER->GetLogLines(line_1_len, log_lines, line_2_len));
74 CHECK_EQ(line_2, log_lines); 74 CHECK_EQ(line_2, log_lines);
75 memset(log_lines, 0, sizeof(log_lines)); 75 memset(log_lines, 0, sizeof(log_lines));
76 CHECK_EQ(line_2_len, 76 CHECK_EQ(line_2_len,
77 Logger::GetLogLines(line_1_len, log_lines, line_2_len + 3)); 77 LOGGER->GetLogLines(line_1_len, log_lines, line_2_len + 3));
78 CHECK_EQ(line_2, log_lines); 78 CHECK_EQ(line_2, log_lines);
79 memset(log_lines, 0, sizeof(log_lines)); 79 memset(log_lines, 0, sizeof(log_lines));
80 // Now get entire buffer contents. 80 // Now get entire buffer contents.
81 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n"; 81 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n";
82 const int all_lines_len = StrLength(all_lines); 82 const int all_lines_len = StrLength(all_lines);
83 CHECK_EQ(all_lines_len, Logger::GetLogLines(0, log_lines, all_lines_len)); 83 CHECK_EQ(all_lines_len, LOGGER->GetLogLines(0, log_lines, all_lines_len));
84 CHECK_EQ(all_lines, log_lines); 84 CHECK_EQ(all_lines, log_lines);
85 memset(log_lines, 0, sizeof(log_lines)); 85 memset(log_lines, 0, sizeof(log_lines));
86 CHECK_EQ(all_lines_len, Logger::GetLogLines(0, log_lines, all_lines_len + 3)); 86 CHECK_EQ(all_lines_len, LOGGER->GetLogLines(0, log_lines, all_lines_len + 3));
87 CHECK_EQ(all_lines, log_lines); 87 CHECK_EQ(all_lines, log_lines);
88 memset(log_lines, 0, sizeof(log_lines)); 88 memset(log_lines, 0, sizeof(log_lines));
89 TearDown(); 89 TearDown();
90 } 90 }
91 91
92 92
93 static int GetLogLines(int start_pos, i::Vector<char>* buffer) { 93 static int GetLogLines(int start_pos, i::Vector<char>* buffer) {
94 return Logger::GetLogLines(start_pos, buffer->start(), buffer->length()); 94 return LOGGER->GetLogLines(start_pos, buffer->start(), buffer->length());
95 } 95 }
96 96
97 97
98 TEST(BeyondWritePosition) { 98 TEST(BeyondWritePosition) {
99 SetUp(); 99 SetUp();
100 Logger::StringEvent("aaa", "bbb"); 100 LOGGER->StringEvent("aaa", "bbb");
101 Logger::StringEvent("cccc", "dddd"); 101 LOGGER->StringEvent("cccc", "dddd");
102 // See Logger::StringEvent. 102 // See Logger::StringEvent.
103 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n"; 103 const char* all_lines = "aaa,\"bbb\"\ncccc,\"dddd\"\n";
104 const int all_lines_len = StrLength(all_lines); 104 const int all_lines_len = StrLength(all_lines);
105 EmbeddedVector<char, 100> buffer; 105 EmbeddedVector<char, 100> buffer;
106 const int beyond_write_pos = all_lines_len; 106 const int beyond_write_pos = all_lines_len;
107 CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos, buffer.start(), 1)); 107 CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos, buffer.start(), 1));
108 CHECK_EQ(0, GetLogLines(beyond_write_pos, &buffer)); 108 CHECK_EQ(0, GetLogLines(beyond_write_pos, &buffer));
109 CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos + 1, buffer.start(), 1)); 109 CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos + 1, buffer.start(), 1));
110 CHECK_EQ(0, GetLogLines(beyond_write_pos + 1, &buffer)); 110 CHECK_EQ(0, GetLogLines(beyond_write_pos + 1, &buffer));
111 CHECK_EQ(0, Logger::GetLogLines(beyond_write_pos + 100, buffer.start(), 1)); 111 CHECK_EQ(0, LOGGER->GetLogLines(beyond_write_pos + 100, buffer.start(), 1));
112 CHECK_EQ(0, GetLogLines(beyond_write_pos + 100, &buffer)); 112 CHECK_EQ(0, GetLogLines(beyond_write_pos + 100, &buffer));
113 CHECK_EQ(0, Logger::GetLogLines(10 * 1024 * 1024, buffer.start(), 1)); 113 CHECK_EQ(0, LOGGER->GetLogLines(10 * 1024 * 1024, buffer.start(), 1));
114 CHECK_EQ(0, GetLogLines(10 * 1024 * 1024, &buffer)); 114 CHECK_EQ(0, GetLogLines(10 * 1024 * 1024, &buffer));
115 TearDown(); 115 TearDown();
116 } 116 }
117 117
118 118
119 TEST(MemoryLoggingTurnedOff) { 119 TEST(MemoryLoggingTurnedOff) {
120 // Log to stdout 120 // Log to stdout
121 i::FLAG_logfile = "-"; 121 i::FLAG_logfile = "-";
122 i::FLAG_log = true; 122 i::FLAG_log = true;
123 Logger::Setup(); 123 LOGGER->Setup();
124 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 0)); 124 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 0));
125 CHECK_EQ(0, Logger::GetLogLines(100, NULL, 0)); 125 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 0));
126 CHECK_EQ(0, Logger::GetLogLines(0, NULL, 100)); 126 CHECK_EQ(0, LOGGER->GetLogLines(0, NULL, 100));
127 CHECK_EQ(0, Logger::GetLogLines(100, NULL, 100)); 127 CHECK_EQ(0, LOGGER->GetLogLines(100, NULL, 100));
128 Logger::TearDown(); 128 LOGGER->TearDown();
129 } 129 }
130 130
131 131
132 static void CompileAndRunScript(const char *src) { 132 static void CompileAndRunScript(const char *src) {
133 v8::Script::Compile(v8::String::New(src))->Run(); 133 v8::Script::Compile(v8::String::New(src))->Run();
134 } 134 }
135 135
136 136
137 namespace v8 { 137 namespace v8 {
138 namespace internal { 138 namespace internal {
139 139
140 class LoggerTestHelper : public AllStatic { 140 class LoggerTestHelper : public AllStatic {
141 public: 141 public:
142 static bool IsSamplerActive() { return Logger::IsProfilerSamplerActive(); } 142 static bool IsSamplerActive() { return LOGGER->IsProfilerSamplerActive(); }
143 static void ResetSamplesTaken() { 143 static void ResetSamplesTaken() {
144 reinterpret_cast<Sampler*>(Logger::ticker_)->ResetSamplesTaken(); 144 reinterpret_cast<Sampler*>(LOGGER->ticker_)->ResetSamplesTaken();
145 } 145 }
146 static bool has_samples_taken() { 146 static bool has_samples_taken() {
147 return reinterpret_cast<Sampler*>(Logger::ticker_)->samples_taken() > 0; 147 return reinterpret_cast<Sampler*>(LOGGER->ticker_)->samples_taken() > 0;
148 } 148 }
149 }; 149 };
150 150
151 } // namespace v8::internal 151 } // namespace v8::internal
152 } // namespace v8 152 } // namespace v8
153 153
154 using v8::internal::LoggerTestHelper; 154 using v8::internal::LoggerTestHelper;
155 155
156 156
157 namespace { 157 namespace {
158 158
159 class ScopedLoggerInitializer { 159 class ScopedLoggerInitializer {
160 public: 160 public:
161 explicit ScopedLoggerInitializer(bool prof_lazy) 161 explicit ScopedLoggerInitializer(bool prof_lazy)
162 : saved_prof_lazy_(i::FLAG_prof_lazy), 162 : saved_prof_lazy_(i::FLAG_prof_lazy),
163 saved_prof_(i::FLAG_prof), 163 saved_prof_(i::FLAG_prof),
164 saved_prof_auto_(i::FLAG_prof_auto), 164 saved_prof_auto_(i::FLAG_prof_auto),
165 trick_to_run_init_flags_(init_flags_(prof_lazy)), 165 trick_to_run_init_flags_(init_flags_(prof_lazy)),
166 need_to_set_up_logger_(i::V8::IsRunning()), 166 need_to_set_up_logger_(i::V8::IsRunning()),
167 scope_(), 167 scope_(),
168 env_(v8::Context::New()) { 168 env_(v8::Context::New()) {
169 if (need_to_set_up_logger_) Logger::Setup(); 169 if (need_to_set_up_logger_) LOGGER->Setup();
170 env_->Enter(); 170 env_->Enter();
171 } 171 }
172 172
173 ~ScopedLoggerInitializer() { 173 ~ScopedLoggerInitializer() {
174 env_->Exit(); 174 env_->Exit();
175 Logger::TearDown(); 175 LOGGER->TearDown();
176 i::FLAG_prof_lazy = saved_prof_lazy_; 176 i::FLAG_prof_lazy = saved_prof_lazy_;
177 i::FLAG_prof = saved_prof_; 177 i::FLAG_prof = saved_prof_;
178 i::FLAG_prof_auto = saved_prof_auto_; 178 i::FLAG_prof_auto = saved_prof_auto_;
179 } 179 }
180 180
181 v8::Handle<v8::Context>& env() { return env_; } 181 v8::Handle<v8::Context>& env() { return env_; }
182 182
183 private: 183 private:
184 static bool init_flags_(bool prof_lazy) { 184 static bool init_flags_(bool prof_lazy) {
185 i::FLAG_prof = true; 185 i::FLAG_prof = true;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 }; 244 };
245 245
246 } // namespace 246 } // namespace
247 247
248 248
249 static void CheckThatProfilerWorks(LogBufferMatcher* matcher) { 249 static void CheckThatProfilerWorks(LogBufferMatcher* matcher) {
250 CHECK(i::RuntimeProfiler::IsEnabled() || 250 CHECK(i::RuntimeProfiler::IsEnabled() ||
251 !LoggerTestHelper::IsSamplerActive()); 251 !LoggerTestHelper::IsSamplerActive());
252 LoggerTestHelper::ResetSamplesTaken(); 252 LoggerTestHelper::ResetSamplesTaken();
253 253
254 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); 254 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 0);
255 CHECK(LoggerTestHelper::IsSamplerActive()); 255 CHECK(LoggerTestHelper::IsSamplerActive());
256 256
257 // Verify that the current map of compiled functions has been logged. 257 // Verify that the current map of compiled functions has been logged.
258 CHECK_GT(matcher->GetNextChunk(), 0); 258 CHECK_GT(matcher->GetNextChunk(), 0);
259 const char* code_creation = "\ncode-creation,"; // eq. to /^code-creation,/ 259 const char* code_creation = "\ncode-creation,"; // eq. to /^code-creation,/
260 CHECK_NE(NULL, matcher->Find(code_creation)); 260 CHECK_NE(NULL, matcher->Find(code_creation));
261 261
262 // Force compiler to generate new code by parametrizing source. 262 // Force compiler to generate new code by parametrizing source.
263 EmbeddedVector<char, 100> script_src; 263 EmbeddedVector<char, 100> script_src;
264 i::OS::SNPrintF(script_src, 264 i::OS::SNPrintF(script_src,
265 "function f%d(x) { return %d * x; }" 265 "function f%d(x) { return %d * x; }"
266 "for (var i = 0; i < 10000; ++i) { f%d(i); }", 266 "for (var i = 0; i < 10000; ++i) { f%d(i); }",
267 matcher->log_pos(), matcher->log_pos(), matcher->log_pos()); 267 matcher->log_pos(), matcher->log_pos(), matcher->log_pos());
268 // Run code for 200 msecs to get some ticks. 268 // Run code for 200 msecs to get some ticks.
269 const double end_time = i::OS::TimeCurrentMillis() + 200; 269 const double end_time = i::OS::TimeCurrentMillis() + 200;
270 while (i::OS::TimeCurrentMillis() < end_time) { 270 while (i::OS::TimeCurrentMillis() < end_time) {
271 CompileAndRunScript(script_src.start()); 271 CompileAndRunScript(script_src.start());
272 // Yield CPU to give Profiler thread a chance to process ticks. 272 // Yield CPU to give Profiler thread a chance to process ticks.
273 i::OS::Sleep(1); 273 i::OS::Sleep(1);
274 } 274 }
275 275
276 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 0); 276 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 0);
277 CHECK(i::RuntimeProfiler::IsEnabled() || 277 CHECK(i::RuntimeProfiler::IsEnabled() ||
278 !LoggerTestHelper::IsSamplerActive()); 278 !LoggerTestHelper::IsSamplerActive());
279 279
280 // Wait 50 msecs to allow Profiler thread to process the last 280 // Wait 50 msecs to allow Profiler thread to process the last
281 // tick sample it has got. 281 // tick sample it has got.
282 i::OS::Sleep(50); 282 i::OS::Sleep(50);
283 283
284 // Now we must have compiler and tick records. 284 // Now we must have compiler and tick records.
285 CHECK_GT(matcher->GetNextChunk(), 0); 285 CHECK_GT(matcher->GetNextChunk(), 0);
286 matcher->PrintBuffer(); 286 matcher->PrintBuffer();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 } 322 }
323 323
324 324
325 // BUG(913). Need to implement support for profiling multiple VM threads. 325 // BUG(913). Need to implement support for profiling multiple VM threads.
326 #if 0 326 #if 0
327 327
328 namespace { 328 namespace {
329 329
330 class LoopingThread : public v8::internal::Thread { 330 class LoopingThread : public v8::internal::Thread {
331 public: 331 public:
332 LoopingThread() 332 explicit LoopingThread(v8::internal::Isolate* isolate)
333 : v8::internal::Thread(), 333 : v8::internal::Thread(isolate),
334 semaphore_(v8::internal::OS::CreateSemaphore(0)), 334 semaphore_(v8::internal::OS::CreateSemaphore(0)),
335 run_(true) { 335 run_(true) {
336 } 336 }
337 337
338 virtual ~LoopingThread() { delete semaphore_; } 338 virtual ~LoopingThread() { delete semaphore_; }
339 339
340 void Run() { 340 void Run() {
341 self_ = pthread_self(); 341 self_ = pthread_self();
342 RunLoop(); 342 RunLoop();
343 } 343 }
(...skipping 18 matching lines...) Expand all
362 private: 362 private:
363 v8::internal::Semaphore* semaphore_; 363 v8::internal::Semaphore* semaphore_;
364 bool run_; 364 bool run_;
365 pthread_t self_; 365 pthread_t self_;
366 int v8_thread_id_; 366 int v8_thread_id_;
367 }; 367 };
368 368
369 369
370 class LoopingJsThread : public LoopingThread { 370 class LoopingJsThread : public LoopingThread {
371 public: 371 public:
372 explicit LoopingJsThread(v8::internal::Isolate* isolate)
373 : LoopingThread(isolate) { }
372 void RunLoop() { 374 void RunLoop() {
373 v8::Locker locker; 375 v8::Locker locker;
374 CHECK(v8::internal::ThreadManager::HasId()); 376 CHECK(i::Isolate::Current() != NULL);
377 CHECK_GT(i::Isolate::Current()->thread_manager()->CurrentId(), 0);
375 SetV8ThreadId(); 378 SetV8ThreadId();
376 while (IsRunning()) { 379 while (IsRunning()) {
377 v8::HandleScope scope; 380 v8::HandleScope scope;
378 v8::Persistent<v8::Context> context = v8::Context::New(); 381 v8::Persistent<v8::Context> context = v8::Context::New();
379 CHECK(!context.IsEmpty()); 382 CHECK(!context.IsEmpty());
380 { 383 {
381 v8::Context::Scope context_scope(context); 384 v8::Context::Scope context_scope(context);
382 SignalRunning(); 385 SignalRunning();
383 CompileAndRunScript( 386 CompileAndRunScript(
384 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }"); 387 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }");
385 } 388 }
386 context.Dispose(); 389 context.Dispose();
387 i::OS::Sleep(1); 390 i::OS::Sleep(1);
388 } 391 }
389 } 392 }
390 }; 393 };
391 394
392 395
393 class LoopingNonJsThread : public LoopingThread { 396 class LoopingNonJsThread : public LoopingThread {
394 public: 397 public:
398 explicit LoopingNonJsThread(v8::internal::Isolate* isolate)
399 : LoopingThread(isolate) { }
395 void RunLoop() { 400 void RunLoop() {
396 v8::Locker locker; 401 v8::Locker locker;
397 v8::Unlocker unlocker; 402 v8::Unlocker unlocker;
398 // Now thread has V8's id, but will not run VM code. 403 // Now thread has V8's id, but will not run VM code.
399 CHECK(v8::internal::ThreadManager::HasId()); 404 CHECK(i::Isolate::Current() != NULL);
405 CHECK_GT(i::Isolate::Current()->thread_manager()->CurrentId(), 0);
400 double i = 10; 406 double i = 10;
401 SignalRunning(); 407 SignalRunning();
402 while (IsRunning()) { 408 while (IsRunning()) {
403 i = sin(i); 409 i = sin(i);
404 i::OS::Sleep(1); 410 i::OS::Sleep(1);
405 } 411 }
406 } 412 }
407 }; 413 };
408 414
409 415
410 class TestSampler : public v8::internal::Sampler { 416 class TestSampler : public v8::internal::Sampler {
411 public: 417 public:
412 TestSampler() 418 explicit TestSampler(v8::internal::Isolate* isolate)
413 : Sampler(0, true, true), 419 : Sampler(isolate, 0, true, true),
414 semaphore_(v8::internal::OS::CreateSemaphore(0)), 420 semaphore_(v8::internal::OS::CreateSemaphore(0)),
415 was_sample_stack_called_(false) { 421 was_sample_stack_called_(false) {
416 } 422 }
417 423
418 ~TestSampler() { delete semaphore_; } 424 ~TestSampler() { delete semaphore_; }
419 425
420 void SampleStack(v8::internal::TickSample*) { 426 void SampleStack(v8::internal::TickSample*) {
421 was_sample_stack_called_ = true; 427 was_sample_stack_called_ = true;
422 } 428 }
423 429
(...skipping 10 matching lines...) Expand all
434 bool was_sample_stack_called_; 440 bool was_sample_stack_called_;
435 }; 441 };
436 442
437 443
438 } // namespace 444 } // namespace
439 445
440 TEST(ProfMultipleThreads) { 446 TEST(ProfMultipleThreads) {
441 TestSampler* sampler = NULL; 447 TestSampler* sampler = NULL;
442 { 448 {
443 v8::Locker locker; 449 v8::Locker locker;
444 sampler = new TestSampler(); 450 sampler = new TestSampler(v8::internal::Isolate::Current());
445 sampler->Start(); 451 sampler->Start();
446 CHECK(sampler->IsActive()); 452 CHECK(sampler->IsActive());
447 } 453 }
448 454
449 LoopingJsThread jsThread; 455 LoopingJsThread jsThread(v8::internal::Isolate::Current());
450 jsThread.Start(); 456 jsThread.Start();
451 LoopingNonJsThread nonJsThread; 457 LoopingNonJsThread nonJsThread(v8::internal::Isolate::Current());
452 nonJsThread.Start(); 458 nonJsThread.Start();
453 459
454 CHECK(!sampler->WasSampleStackCalled()); 460 CHECK(!sampler->WasSampleStackCalled());
455 jsThread.WaitForRunning(); 461 jsThread.WaitForRunning();
456 jsThread.SendSigProf(); 462 jsThread.SendSigProf();
457 CHECK(sampler->WaitForTick()); 463 CHECK(sampler->WaitForTick());
458 CHECK(sampler->WasSampleStackCalled()); 464 CHECK(sampler->WasSampleStackCalled());
459 sampler->Reset(); 465 sampler->Reset();
460 CHECK(!sampler->WasSampleStackCalled()); 466 CHECK(!sampler->WasSampleStackCalled());
461 nonJsThread.WaitForRunning(); 467 nonJsThread.WaitForRunning();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin); 514 v8::Handle<v8::Script> evil_script = v8::Script::Compile(source, origin);
509 CHECK(!evil_script.IsEmpty()); 515 CHECK(!evil_script.IsEmpty());
510 CHECK(!evil_script->Run().IsEmpty()); 516 CHECK(!evil_script->Run().IsEmpty());
511 i::Handle<i::ExternalTwoByteString> i_source( 517 i::Handle<i::ExternalTwoByteString> i_source(
512 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source))); 518 i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
513 // This situation can happen if source was an external string disposed 519 // This situation can happen if source was an external string disposed
514 // by its owner. 520 // by its owner.
515 i_source->set_resource(NULL); 521 i_source->set_resource(NULL);
516 522
517 // Must not crash. 523 // Must not crash.
518 i::Logger::LogCompiledFunctions(); 524 LOGGER->LogCompiledFunctions();
519 } 525 }
520 526
521 527
522 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) { 528 static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) {
523 return v8::Handle<v8::Value>(); 529 return v8::Handle<v8::Value>();
524 } 530 }
525 531
526 TEST(LogCallbacks) { 532 TEST(LogCallbacks) {
527 ScopedLoggerInitializer initialize_logger(false); 533 ScopedLoggerInitializer initialize_logger(false);
528 LogBufferMatcher matcher; 534 LogBufferMatcher matcher;
529 535
530 v8::Persistent<v8::FunctionTemplate> obj = 536 v8::Persistent<v8::FunctionTemplate> obj =
531 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New()); 537 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
532 obj->SetClassName(v8::String::New("Obj")); 538 obj->SetClassName(v8::String::New("Obj"));
533 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate(); 539 v8::Handle<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
534 v8::Local<v8::Signature> signature = v8::Signature::New(obj); 540 v8::Local<v8::Signature> signature = v8::Signature::New(obj);
535 proto->Set(v8::String::New("method1"), 541 proto->Set(v8::String::New("method1"),
536 v8::FunctionTemplate::New(ObjMethod1, 542 v8::FunctionTemplate::New(ObjMethod1,
537 v8::Handle<v8::Value>(), 543 v8::Handle<v8::Value>(),
538 signature), 544 signature),
539 static_cast<v8::PropertyAttribute>(v8::DontDelete)); 545 static_cast<v8::PropertyAttribute>(v8::DontDelete));
540 546
541 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction()); 547 initialize_logger.env()->Global()->Set(v8_str("Obj"), obj->GetFunction());
542 CompileAndRunScript("Obj.prototype.method1.toString();"); 548 CompileAndRunScript("Obj.prototype.method1.toString();");
543 549
544 i::Logger::LogCompiledFunctions(); 550 LOGGER->LogCompiledFunctions();
545 CHECK_GT(matcher.GetNextChunk(), 0); 551 CHECK_GT(matcher.GetNextChunk(), 0);
546 552
547 const char* callback_rec = "code-creation,Callback,"; 553 const char* callback_rec = "code-creation,Callback,";
548 char* pos = const_cast<char*>(matcher.Find(callback_rec)); 554 char* pos = const_cast<char*>(matcher.Find(callback_rec));
549 CHECK_NE(NULL, pos); 555 CHECK_NE(NULL, pos);
550 pos += strlen(callback_rec); 556 pos += strlen(callback_rec);
551 EmbeddedVector<char, 100> ref_data; 557 EmbeddedVector<char, 100> ref_data;
552 i::OS::SNPrintF(ref_data, 558 i::OS::SNPrintF(ref_data,
553 "0x%" V8PRIxPTR ",1,\"method1\"", ObjMethod1); 559 "0x%" V8PRIxPTR ",1,\"method1\"", ObjMethod1);
554 *(pos + strlen(ref_data.start())) = '\0'; 560 *(pos + strlen(ref_data.start())) = '\0';
(...skipping 22 matching lines...) Expand all
577 ScopedLoggerInitializer initialize_logger(false); 583 ScopedLoggerInitializer initialize_logger(false);
578 LogBufferMatcher matcher; 584 LogBufferMatcher matcher;
579 585
580 v8::Persistent<v8::FunctionTemplate> obj = 586 v8::Persistent<v8::FunctionTemplate> obj =
581 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New()); 587 v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New());
582 obj->SetClassName(v8::String::New("Obj")); 588 obj->SetClassName(v8::String::New("Obj"));
583 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate(); 589 v8::Handle<v8::ObjectTemplate> inst = obj->InstanceTemplate();
584 inst->SetAccessor(v8::String::New("prop1"), Prop1Getter, Prop1Setter); 590 inst->SetAccessor(v8::String::New("prop1"), Prop1Getter, Prop1Setter);
585 inst->SetAccessor(v8::String::New("prop2"), Prop2Getter); 591 inst->SetAccessor(v8::String::New("prop2"), Prop2Getter);
586 592
587 i::Logger::LogAccessorCallbacks(); 593 LOGGER->LogAccessorCallbacks();
588 CHECK_GT(matcher.GetNextChunk(), 0); 594 CHECK_GT(matcher.GetNextChunk(), 0);
589 matcher.PrintBuffer(); 595 matcher.PrintBuffer();
590 596
591 EmbeddedVector<char, 100> prop1_getter_record; 597 EmbeddedVector<char, 100> prop1_getter_record;
592 i::OS::SNPrintF(prop1_getter_record, 598 i::OS::SNPrintF(prop1_getter_record,
593 "code-creation,Callback,0x%" V8PRIxPTR ",1,\"get prop1\"", 599 "code-creation,Callback,0x%" V8PRIxPTR ",1,\"get prop1\"",
594 Prop1Getter); 600 Prop1Getter);
595 CHECK_NE(NULL, matcher.Find(prop1_getter_record)); 601 CHECK_NE(NULL, matcher.Find(prop1_getter_record));
596 EmbeddedVector<char, 100> prop1_setter_record; 602 EmbeddedVector<char, 100> prop1_setter_record;
597 i::OS::SNPrintF(prop1_setter_record, 603 i::OS::SNPrintF(prop1_setter_record,
(...skipping 11 matching lines...) Expand all
609 615
610 616
611 TEST(LogTags) { 617 TEST(LogTags) {
612 ScopedLoggerInitializer initialize_logger(false); 618 ScopedLoggerInitializer initialize_logger(false);
613 LogBufferMatcher matcher; 619 LogBufferMatcher matcher;
614 620
615 const char* open_tag = "open-tag,"; 621 const char* open_tag = "open-tag,";
616 const char* close_tag = "close-tag,"; 622 const char* close_tag = "close-tag,";
617 623
618 // Check compatibility with the old style behavior. 624 // Check compatibility with the old style behavior.
619 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 625 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
620 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 0); 626 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 0);
621 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 627 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
622 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 0); 628 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 0);
623 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 629 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
624 CHECK_EQ(NULL, matcher.Find(open_tag)); 630 CHECK_EQ(NULL, matcher.Find(open_tag));
625 CHECK_EQ(NULL, matcher.Find(close_tag)); 631 CHECK_EQ(NULL, matcher.Find(close_tag));
626 632
627 const char* open_tag1 = "open-tag,1\n"; 633 const char* open_tag1 = "open-tag,1\n";
628 const char* close_tag1 = "close-tag,1\n"; 634 const char* close_tag1 = "close-tag,1\n";
629 635
630 // Check non-nested tag case. 636 // Check non-nested tag case.
631 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 637 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
632 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); 638 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1);
633 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 639 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
634 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); 640 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1);
635 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 641 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
636 CHECK_GT(matcher.GetNextChunk(), 0); 642 CHECK_GT(matcher.GetNextChunk(), 0);
637 CHECK(matcher.IsInSequence(open_tag1, close_tag1)); 643 CHECK(matcher.IsInSequence(open_tag1, close_tag1));
638 644
639 const char* open_tag2 = "open-tag,2\n"; 645 const char* open_tag2 = "open-tag,2\n";
640 const char* close_tag2 = "close-tag,2\n"; 646 const char* close_tag2 = "close-tag,2\n";
641 647
642 // Check nested tags case. 648 // Check nested tags case.
643 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 649 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
644 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); 650 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1);
645 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 651 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
646 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); 652 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2);
647 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 653 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
648 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); 654 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2);
649 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 655 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
650 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); 656 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1);
651 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 657 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
652 CHECK_GT(matcher.GetNextChunk(), 0); 658 CHECK_GT(matcher.GetNextChunk(), 0);
653 // open_tag1 < open_tag2 < close_tag2 < close_tag1 659 // open_tag1 < open_tag2 < close_tag2 < close_tag1
654 CHECK(matcher.IsInSequence(open_tag1, open_tag2)); 660 CHECK(matcher.IsInSequence(open_tag1, open_tag2));
655 CHECK(matcher.IsInSequence(open_tag2, close_tag2)); 661 CHECK(matcher.IsInSequence(open_tag2, close_tag2));
656 CHECK(matcher.IsInSequence(close_tag2, close_tag1)); 662 CHECK(matcher.IsInSequence(close_tag2, close_tag1));
657 663
658 // Check overlapped tags case. 664 // Check overlapped tags case.
659 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 665 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
660 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); 666 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1);
661 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 667 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
662 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); 668 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2);
663 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 669 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
664 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); 670 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1);
665 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 671 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
666 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); 672 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2);
667 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 673 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
668 CHECK_GT(matcher.GetNextChunk(), 0); 674 CHECK_GT(matcher.GetNextChunk(), 0);
669 // open_tag1 < open_tag2 < close_tag1 < close_tag2 675 // open_tag1 < open_tag2 < close_tag1 < close_tag2
670 CHECK(matcher.IsInSequence(open_tag1, open_tag2)); 676 CHECK(matcher.IsInSequence(open_tag1, open_tag2));
671 CHECK(matcher.IsInSequence(open_tag2, close_tag1)); 677 CHECK(matcher.IsInSequence(open_tag2, close_tag1));
672 CHECK(matcher.IsInSequence(close_tag1, close_tag2)); 678 CHECK(matcher.IsInSequence(close_tag1, close_tag2));
673 679
674 const char* open_tag3 = "open-tag,3\n"; 680 const char* open_tag3 = "open-tag,3\n";
675 const char* close_tag3 = "close-tag,3\n"; 681 const char* close_tag3 = "close-tag,3\n";
676 682
677 // Check pausing overflow case. 683 // Check pausing overflow case.
678 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 684 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
679 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); 685 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1);
680 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 686 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
681 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 2); 687 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 2);
682 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 688 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
683 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 2); 689 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 2);
684 CHECK_EQ(v8::PROFILER_MODULE_CPU, Logger::GetActiveProfilerModules()); 690 CHECK_EQ(v8::PROFILER_MODULE_CPU, LOGGER->GetActiveProfilerModules());
685 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); 691 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1);
686 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 692 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
687 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 3); 693 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 3);
688 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 694 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
689 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 3); 695 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 3);
690 CHECK_EQ(v8::PROFILER_MODULE_NONE, Logger::GetActiveProfilerModules()); 696 CHECK_EQ(v8::PROFILER_MODULE_NONE, LOGGER->GetActiveProfilerModules());
691 // Must be no tags, because logging must be disabled. 697 // Must be no tags, because logging must be disabled.
692 CHECK_EQ(NULL, matcher.Find(open_tag3)); 698 CHECK_EQ(NULL, matcher.Find(open_tag3));
693 CHECK_EQ(NULL, matcher.Find(close_tag3)); 699 CHECK_EQ(NULL, matcher.Find(close_tag3));
694 } 700 }
695 701
696 702
697 TEST(IsLoggingPreserved) { 703 TEST(IsLoggingPreserved) {
698 ScopedLoggerInitializer initialize_logger(false); 704 ScopedLoggerInitializer initialize_logger(false);
699 705
700 CHECK(Logger::is_logging()); 706 CHECK(LOGGER->is_logging());
701 Logger::ResumeProfiler(v8::PROFILER_MODULE_CPU, 1); 707 LOGGER->ResumeProfiler(v8::PROFILER_MODULE_CPU, 1);
702 CHECK(Logger::is_logging()); 708 CHECK(LOGGER->is_logging());
703 Logger::PauseProfiler(v8::PROFILER_MODULE_CPU, 1); 709 LOGGER->PauseProfiler(v8::PROFILER_MODULE_CPU, 1);
704 CHECK(Logger::is_logging()); 710 CHECK(LOGGER->is_logging());
705 711
706 CHECK(Logger::is_logging()); 712 CHECK(LOGGER->is_logging());
707 Logger::ResumeProfiler( 713 LOGGER->ResumeProfiler(
708 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); 714 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1);
709 CHECK(Logger::is_logging()); 715 CHECK(LOGGER->is_logging());
710 Logger::PauseProfiler( 716 LOGGER->PauseProfiler(
711 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); 717 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1);
712 CHECK(Logger::is_logging()); 718 CHECK(LOGGER->is_logging());
713 719
714 CHECK(Logger::is_logging()); 720 CHECK(LOGGER->is_logging());
715 Logger::ResumeProfiler( 721 LOGGER->ResumeProfiler(
716 v8::PROFILER_MODULE_CPU | 722 v8::PROFILER_MODULE_CPU |
717 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); 723 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1);
718 CHECK(Logger::is_logging()); 724 CHECK(LOGGER->is_logging());
719 Logger::PauseProfiler( 725 LOGGER->PauseProfiler(
720 v8::PROFILER_MODULE_CPU | 726 v8::PROFILER_MODULE_CPU |
721 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1); 727 v8::PROFILER_MODULE_HEAP_STATS | v8::PROFILER_MODULE_JS_CONSTRUCTORS, 1);
722 CHECK(Logger::is_logging()); 728 CHECK(LOGGER->is_logging());
723 } 729 }
724 730
725 731
726 static inline bool IsStringEqualTo(const char* r, const char* s) { 732 static inline bool IsStringEqualTo(const char* r, const char* s) {
727 return strncmp(r, s, strlen(r)) == 0; 733 return strncmp(r, s, strlen(r)) == 0;
728 } 734 }
729 735
730 736
731 static bool Consume(const char* str, char** buf) { 737 static bool Consume(const char* str, char** buf) {
732 if (IsStringEqualTo(str, *buf)) { 738 if (IsStringEqualTo(str, *buf)) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 v8::Handle<v8::Context> env = v8::Context::New( 1127 v8::Handle<v8::Context> env = v8::Context::New(
1122 0, v8::Handle<v8::ObjectTemplate>(), global_object); 1128 0, v8::Handle<v8::ObjectTemplate>(), global_object);
1123 env->Enter(); 1129 env->Enter();
1124 1130
1125 // Compile and run a function that creates other functions. 1131 // Compile and run a function that creates other functions.
1126 CompileAndRunScript( 1132 CompileAndRunScript(
1127 "(function f(obj) {\n" 1133 "(function f(obj) {\n"
1128 " obj.test =\n" 1134 " obj.test =\n"
1129 " (function a(j) { return function b() { return j; } })(100);\n" 1135 " (function a(j) { return function b() { return j; } })(100);\n"
1130 "})(this);"); 1136 "})(this);");
1131 i::Heap::CollectAllGarbage(false); 1137 HEAP->CollectAllGarbage(false);
1132 1138
1133 EmbeddedVector<char, 204800> buffer; 1139 EmbeddedVector<char, 204800> buffer;
1134 int log_size; 1140 int log_size;
1135 ParseLogResult ref_result; 1141 ParseLogResult ref_result;
1136 1142
1137 // Retrieve the log. 1143 // Retrieve the log.
1138 { 1144 {
1139 // Make sure that no GCs occur prior to LogCompiledFunctions call. 1145 // Make sure that no GCs occur prior to LogCompiledFunctions call.
1140 i::AssertNoAllocation no_alloc; 1146 i::AssertNoAllocation no_alloc;
1141 1147
1142 log_size = GetLogLines(0, &buffer); 1148 log_size = GetLogLines(0, &buffer);
1143 CHECK_GT(log_size, 0); 1149 CHECK_GT(log_size, 0);
1144 CHECK_GT(buffer.length(), log_size); 1150 CHECK_GT(buffer.length(), log_size);
1145 1151
1146 // Fill a map of compiled code objects. 1152 // Fill a map of compiled code objects.
1147 ParseLog(buffer.start(), buffer.start() + log_size, &ref_result); 1153 ParseLog(buffer.start(), buffer.start() + log_size, &ref_result);
1148 } 1154 }
1149 1155
1150 // Iterate heap to find compiled functions, will write to log. 1156 // Iterate heap to find compiled functions, will write to log.
1151 i::Logger::LogCompiledFunctions(); 1157 LOGGER->LogCompiledFunctions();
1152 char* new_log_start = buffer.start() + log_size; 1158 char* new_log_start = buffer.start() + log_size;
1153 const int new_log_size = Logger::GetLogLines( 1159 const int new_log_size = LOGGER->GetLogLines(
1154 log_size, new_log_start, buffer.length() - log_size); 1160 log_size, new_log_start, buffer.length() - log_size);
1155 CHECK_GT(new_log_size, 0); 1161 CHECK_GT(new_log_size, 0);
1156 CHECK_GT(buffer.length(), log_size + new_log_size); 1162 CHECK_GT(buffer.length(), log_size + new_log_size);
1157 1163
1158 // Fill an equivalent map of compiled code objects. 1164 // Fill an equivalent map of compiled code objects.
1159 ParseLogResult new_result; 1165 ParseLogResult new_result;
1160 ParseLog(new_log_start, new_log_start + new_log_size, &new_result); 1166 ParseLog(new_log_start, new_log_start + new_log_size, &new_result);
1161 1167
1162 // Test their actual equivalence. 1168 // Test their actual equivalence.
1163 Interval combined; 1169 Interval combined;
(...skipping 13 matching lines...) Expand all
1177 PrintCodeEntitiesInfo(equal, addr, ref_entity, new_entity); 1183 PrintCodeEntitiesInfo(equal, addr, ref_entity, new_entity);
1178 } 1184 }
1179 } 1185 }
1180 iter = iter->get_next(); 1186 iter = iter->get_next();
1181 } 1187 }
1182 // Make sure that all log data is written prior crash due to CHECK failure. 1188 // Make sure that all log data is written prior crash due to CHECK failure.
1183 fflush(stdout); 1189 fflush(stdout);
1184 CHECK(results_equal); 1190 CHECK(results_equal);
1185 1191
1186 env->Exit(); 1192 env->Exit();
1187 Logger::TearDown(); 1193 LOGGER->TearDown();
1188 i::FLAG_always_compact = saved_always_compact; 1194 i::FLAG_always_compact = saved_always_compact;
1189 } 1195 }
1190 1196
1191 #endif // ENABLE_LOGGING_AND_PROFILING 1197 #endif // ENABLE_LOGGING_AND_PROFILING
OLDNEW
« no previous file with comments | « test/cctest/test-liveedit.cc ('k') | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698