test-log.cc 20.6 KB
Newer Older
1
// Copyright 2006-2009 the V8 project authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
//     * Neither the name of Google Inc. nor the names of its
//       contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 28 29
//
// Tests of logging functions from log.h

30
#ifdef __linux__
31
#include <pthread.h>
32 33
#include <signal.h>
#include <unistd.h>
34
#include <cmath>
35
#endif  // __linux__
36

37
#include "src/api.h"
38
#include "src/log-utils.h"
39
#include "src/log.h"
40
#include "src/objects-inl.h"
41
#include "src/profiler/cpu-profiler.h"
42
#include "src/snapshot/natives.h"
43
#include "src/utils.h"
44
#include "src/v8.h"
45
#include "src/v8threads.h"
46
#include "src/version.h"
47 48
#include "src/vm-state-inl.h"
#include "test/cctest/cctest.h"
49

50
using v8::internal::Address;
51
using v8::internal::EmbeddedVector;
52
using v8::internal::Logger;
53
using v8::internal::StrLength;
54

55 56
namespace {

57

58 59 60 61 62 63 64 65 66
#define SETUP_FLAGS()                            \
  bool saved_log = i::FLAG_log;                  \
  bool saved_prof = i::FLAG_prof;                \
  i::FLAG_log = true;                            \
  i::FLAG_prof = true;                           \
  i::FLAG_logfile = i::Log::kLogToTemporaryFile; \
  i::FLAG_logfile_per_isolate = false


67 68
class ScopedLoggerInitializer {
 public:
69 70 71
  ScopedLoggerInitializer(bool saved_log, bool saved_prof, v8::Isolate* isolate)
      : saved_log_(saved_log),
        saved_prof_(saved_prof),
72
        temp_file_(NULL),
73 74 75 76 77
        isolate_(isolate),
        isolate_scope_(isolate),
        scope_(isolate),
        env_(v8::Context::New(isolate)),
        logger_(reinterpret_cast<i::Isolate*>(isolate)->logger()) {
78 79 80 81 82
    env_->Enter();
  }

  ~ScopedLoggerInitializer() {
    env_->Exit();
yurys@chromium.org's avatar
yurys@chromium.org committed
83
    logger_->TearDown();
84
    if (temp_file_ != NULL) fclose(temp_file_);
85
    i::FLAG_prof = saved_prof_;
86
    i::FLAG_log = saved_log_;
87 88
  }

89
  v8::Local<v8::Context>& env() { return env_; }
90

91 92
  v8::Isolate* isolate() { return isolate_; }

yurys@chromium.org's avatar
yurys@chromium.org committed
93 94
  Logger* logger() { return logger_; }

95
  FILE* StopLoggingGetTempFile() {
yurys@chromium.org's avatar
yurys@chromium.org committed
96
    temp_file_ = logger_->TearDown();
97
    CHECK(temp_file_);
98 99 100 101 102
    fflush(temp_file_);
    rewind(temp_file_);
    return temp_file_;
  }

103
 private:
104
  const bool saved_log_;
105
  const bool saved_prof_;
106
  FILE* temp_file_;
107 108
  v8::Isolate* isolate_;
  v8::Isolate::Scope isolate_scope_;
109
  v8::HandleScope scope_;
110
  v8::Local<v8::Context> env_;
yurys@chromium.org's avatar
yurys@chromium.org committed
111
  Logger* logger_;
112 113 114 115 116 117 118

  DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer);
};

}  // namespace


119 120 121
static const char* StrNStr(const char* s1, const char* s2, int n) {
  if (s1[n] == '\0') return strstr(s1, s2);
  i::ScopedVector<char> str(n + 1);
122
  i::StrNCpy(str, s1, static_cast<size_t>(n));
123 124 125
  str[n] = '\0';
  char* found = strstr(str.start(), s2);
  return found != NULL ? s1 + (found - str.start()) : NULL;
126 127 128
}


129 130
// BUG(913). Need to implement support for profiling multiple VM threads.
#if 0
131 132 133 134 135

namespace {

class LoopingThread : public v8::internal::Thread {
 public:
136 137
  explicit LoopingThread(v8::internal::Isolate* isolate)
      : v8::internal::Thread(isolate),
138
        semaphore_(new v8::internal::Semaphore(0)),
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
        run_(true) {
  }

  virtual ~LoopingThread() { delete semaphore_; }

  void Run() {
    self_ = pthread_self();
    RunLoop();
  }

  void SendSigProf() { pthread_kill(self_, SIGPROF); }

  void Stop() { run_ = false; }

  bool WaitForRunning() { return semaphore_->Wait(1000000); }

 protected:
  bool IsRunning() { return run_; }

  virtual void RunLoop() = 0;

  void SetV8ThreadId() {
    v8_thread_id_ = v8::V8::GetCurrentThreadId();
  }

  void SignalRunning() { semaphore_->Signal(); }

 private:
  v8::internal::Semaphore* semaphore_;
  bool run_;
  pthread_t self_;
  int v8_thread_id_;
};


class LoopingJsThread : public LoopingThread {
 public:
176 177
  explicit LoopingJsThread(v8::internal::Isolate* isolate)
      : LoopingThread(isolate) { }
178
  void RunLoop() {
179
    v8::Locker locker;
180 181
    CHECK(CcTest::i_isolate() != NULL);
    CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0);
182
    SetV8ThreadId();
183 184 185
    while (IsRunning()) {
      v8::HandleScope scope;
      v8::Persistent<v8::Context> context = v8::Context::New();
186 187 188 189
      CHECK(!context.IsEmpty());
      {
        v8::Context::Scope context_scope(context);
        SignalRunning();
190
        CompileRun(
191 192
            "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }");
      }
193
      context.Dispose();
194
      i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
195 196 197 198 199 200 201
    }
  }
};


class LoopingNonJsThread : public LoopingThread {
 public:
202 203
  explicit LoopingNonJsThread(v8::internal::Isolate* isolate)
      : LoopingThread(isolate) { }
204 205 206 207
  void RunLoop() {
    v8::Locker locker;
    v8::Unlocker unlocker;
    // Now thread has V8's id, but will not run VM code.
208 209
    CHECK(CcTest::i_isolate() != NULL);
    CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0);
210 211 212
    double i = 10;
    SignalRunning();
    while (IsRunning()) {
213
      i = std::sin(i);
214
      i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
215 216 217 218 219 220 221
    }
  }
};


class TestSampler : public v8::internal::Sampler {
 public:
222 223
  explicit TestSampler(v8::internal::Isolate* isolate)
      : Sampler(isolate, 0, true, true),
224
        semaphore_(new v8::internal::Semaphore(0)),
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
        was_sample_stack_called_(false) {
  }

  ~TestSampler() { delete semaphore_; }

  void SampleStack(v8::internal::TickSample*) {
    was_sample_stack_called_ = true;
  }

  void Tick(v8::internal::TickSample*) { semaphore_->Signal(); }

  bool WaitForTick() { return semaphore_->Wait(1000000); }

  void Reset() { was_sample_stack_called_ = false; }

  bool WasSampleStackCalled() { return was_sample_stack_called_; }

 private:
  v8::internal::Semaphore* semaphore_;
  bool was_sample_stack_called_;
};


}  // namespace

TEST(ProfMultipleThreads) {
251 252 253
  TestSampler* sampler = NULL;
  {
    v8::Locker locker;
254
    sampler = new TestSampler(CcTest::i_isolate());
255 256 257 258
    sampler->Start();
    CHECK(sampler->IsActive());
  }

259
  LoopingJsThread jsThread(CcTest::i_isolate());
260
  jsThread.Start();
261
  LoopingNonJsThread nonJsThread(CcTest::i_isolate());
262 263
  nonJsThread.Start();

264
  CHECK(!sampler->WasSampleStackCalled());
265 266
  jsThread.WaitForRunning();
  jsThread.SendSigProf();
267 268 269 270
  CHECK(sampler->WaitForTick());
  CHECK(sampler->WasSampleStackCalled());
  sampler->Reset();
  CHECK(!sampler->WasSampleStackCalled());
271 272
  nonJsThread.WaitForRunning();
  nonJsThread.SendSigProf();
273 274 275
  CHECK(!sampler->WaitForTick());
  CHECK(!sampler->WasSampleStackCalled());
  sampler->Stop();
276 277 278 279 280

  jsThread.Stop();
  nonJsThread.Stop();
  jsThread.Join();
  nonJsThread.Join();
281 282

  delete sampler;
283 284 285 286 287
}

#endif  // __linux__


288 289 290 291 292 293 294 295
// Test for issue http://crbug.com/23768 in Chromium.
// Heap can contain scripts with already disposed external sources.
// We need to verify that LogCompiledFunctions doesn't crash on them.
namespace {

class SimpleExternalString : public v8::String::ExternalStringResource {
 public:
  explicit SimpleExternalString(const char* source)
296
      : utf_source_(StrLength(source)) {
297 298 299 300 301 302 303 304 305 306 307 308 309
    for (int i = 0; i < utf_source_.length(); ++i)
      utf_source_[i] = source[i];
  }
  virtual ~SimpleExternalString() {}
  virtual size_t length() const { return utf_source_.length(); }
  virtual const uint16_t* data() const { return utf_source_.start(); }
 private:
  i::ScopedVector<uint16_t> utf_source_;
};

}  // namespace

TEST(Issue23768) {
310
  v8::HandleScope scope(CcTest::isolate());
311
  v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
312 313 314
  env->Enter();

  SimpleExternalString source_ext_str("(function ext() {})();");
315
  v8::Local<v8::String> source =
316 317
      v8::String::NewExternalTwoByte(CcTest::isolate(), &source_ext_str)
          .ToLocalChecked();
318
  // Script needs to have a name in order to trigger InitLineEnds execution.
319 320 321 322 323
  v8::Local<v8::String> origin =
      v8::String::NewFromUtf8(CcTest::isolate(), "issue-23768-test",
                              v8::NewStringType::kNormal)
          .ToLocalChecked();
  v8::Local<v8::Script> evil_script = CompileWithOrigin(source, origin);
324
  CHECK(!evil_script.IsEmpty());
325
  CHECK(!evil_script->Run(env).IsEmpty());
326 327 328 329 330 331 332
  i::Handle<i::ExternalTwoByteString> i_source(
      i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)));
  // This situation can happen if source was an external string disposed
  // by its owner.
  i_source->set_resource(NULL);

  // Must not crash.
333
  CcTest::i_isolate()->logger()->LogCompiledFunctions();
334 335 336
}


337
static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) {
338 339
}

340

341
TEST(LogCallbacks) {
342 343 344 345
  SETUP_FLAGS();
  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
  v8::Isolate* isolate = v8::Isolate::New(create_params);
346
  {
347
    ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
348 349 350 351 352
    Logger* logger = initialize_logger.logger();

    v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
        isolate, v8::FunctionTemplate::New(isolate));
    obj->SetClassName(v8_str("Obj"));
353
    v8::Local<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
354 355 356
    v8::Local<v8::Signature> signature = v8::Signature::New(isolate, obj);
    proto->Set(v8_str("method1"),
               v8::FunctionTemplate::New(isolate, ObjMethod1,
357
                                         v8::Local<v8::Value>(), signature),
358 359
               static_cast<v8::PropertyAttribute>(v8::DontDelete));

360 361 362 363 364
    initialize_logger.env()
        ->Global()
        ->Set(initialize_logger.env(), v8_str("Obj"),
              obj->GetFunction(initialize_logger.env()).ToLocalChecked())
        .FromJust();
365 366 367 368 369 370 371 372 373
    CompileRun("Obj.prototype.method1.toString();");

    logger->LogCompiledFunctions();

    bool exists = false;
    i::Vector<const char> log(
        i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
    CHECK(exists);

374 375 376 377
    Address ObjMethod1_entry = reinterpret_cast<Address>(ObjMethod1);
#if USES_FUNCTION_DESCRIPTORS
    ObjMethod1_entry = *FUNCTION_ENTRYPOINT_ADDRESS(ObjMethod1_entry);
#endif
378
    i::EmbeddedVector<char, 100> ref_data;
jfb's avatar
jfb committed
379
    i::SNPrintF(ref_data, "code-creation,Callback,-2,%p,1,\"method1\"",
380
                static_cast<void*>(ObjMethod1_entry));
381

382
    CHECK(StrNStr(log.start(), ref_data.start(), log.length()));
383 384 385
    log.Dispose();
  }
  isolate->Dispose();
386 387 388
}


389 390
static void Prop1Getter(v8::Local<v8::String> property,
                        const v8::PropertyCallbackInfo<v8::Value>& info) {
391 392 393
}

static void Prop1Setter(v8::Local<v8::String> property,
394 395
                        v8::Local<v8::Value> value,
                        const v8::PropertyCallbackInfo<void>& info) {
396 397
}

398 399
static void Prop2Getter(v8::Local<v8::String> property,
                        const v8::PropertyCallbackInfo<v8::Value>& info) {
400 401
}

402

403
TEST(LogAccessorCallbacks) {
404 405 406 407
  SETUP_FLAGS();
  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
  v8::Isolate* isolate = v8::Isolate::New(create_params);
408
  {
409
    ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
410 411 412 413 414
    Logger* logger = initialize_logger.logger();

    v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
        isolate, v8::FunctionTemplate::New(isolate));
    obj->SetClassName(v8_str("Obj"));
415
    v8::Local<v8::ObjectTemplate> inst = obj->InstanceTemplate();
416 417 418 419 420 421 422 423 424 425
    inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
    inst->SetAccessor(v8_str("prop2"), Prop2Getter);

    logger->LogAccessorCallbacks();

    bool exists = false;
    i::Vector<const char> log(
        i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
    CHECK(exists);

426 427 428 429
    Address Prop1Getter_entry = reinterpret_cast<Address>(Prop1Getter);
#if USES_FUNCTION_DESCRIPTORS
    Prop1Getter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop1Getter_entry);
#endif
430 431
    EmbeddedVector<char, 100> prop1_getter_record;
    i::SNPrintF(prop1_getter_record,
jfb's avatar
jfb committed
432
                "code-creation,Callback,-2,%p,1,\"get prop1\"",
433
                static_cast<void*>(Prop1Getter_entry));
434
    CHECK(StrNStr(log.start(), prop1_getter_record.start(), log.length()));
435

436 437 438 439
    Address Prop1Setter_entry = reinterpret_cast<Address>(Prop1Setter);
#if USES_FUNCTION_DESCRIPTORS
    Prop1Setter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop1Setter_entry);
#endif
440 441
    EmbeddedVector<char, 100> prop1_setter_record;
    i::SNPrintF(prop1_setter_record,
jfb's avatar
jfb committed
442
                "code-creation,Callback,-2,%p,1,\"set prop1\"",
443
                static_cast<void*>(Prop1Setter_entry));
444
    CHECK(StrNStr(log.start(), prop1_setter_record.start(), log.length()));
445

446 447 448 449
    Address Prop2Getter_entry = reinterpret_cast<Address>(Prop2Getter);
#if USES_FUNCTION_DESCRIPTORS
    Prop2Getter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop2Getter_entry);
#endif
450 451
    EmbeddedVector<char, 100> prop2_getter_record;
    i::SNPrintF(prop2_getter_record,
jfb's avatar
jfb committed
452
                "code-creation,Callback,-2,%p,1,\"get prop2\"",
453
                static_cast<void*>(Prop2Getter_entry));
454
    CHECK(StrNStr(log.start(), prop2_getter_record.start(), log.length()));
455 456 457
    log.Dispose();
  }
  isolate->Dispose();
458
}
459

460

461 462
typedef i::NativesCollection<i::TEST> TestSources;

463 464 465

// Test that logging of code create / move events is equivalent to traversal of
// a resulting heap.
466
TEST(EquivalenceOfLoggingAndTraversal) {
467 468 469 470 471 472
  // This test needs to be run on a "clean" V8 to ensure that snapshot log
  // is loaded. This is always true when running using tools/test.py because
  // it launches a new cctest instance for every test. To be sure that launching
  // cctest manually also works, please be sure that no tests below
  // are using V8.

473
  // Start with profiling to capture all code events from the beginning.
474 475 476 477
  SETUP_FLAGS();
  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
  v8::Isolate* isolate = v8::Isolate::New(create_params);
478
  {
479
    ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
480 481 482 483 484 485 486 487 488
    Logger* logger = initialize_logger.logger();

    // Compile and run a function that creates other functions.
    CompileRun(
        "(function f(obj) {\n"
        "  obj.test =\n"
        "    (function a(j) { return function b() { return j; } })(100);\n"
        "})(this);");
    logger->StopProfiler();
489
    reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
490
        i::Heap::kMakeHeapIterableMask, i::GarbageCollectionReason::kTesting);
491 492 493 494 495 496 497 498 499 500
    logger->StringEvent("test-logging-done", "");

    // Iterate heap to find compiled functions, will write to log.
    logger->LogCompiledFunctions();
    logger->StringEvent("test-traversal-done", "");

    bool exists = false;
    i::Vector<const char> log(
        i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
    CHECK(exists);
501 502 503 504 505 506 507 508
    v8::Local<v8::String> log_str =
        v8::String::NewFromUtf8(isolate, log.start(),
                                v8::NewStringType::kNormal, log.length())
            .ToLocalChecked();
    initialize_logger.env()
        ->Global()
        ->Set(initialize_logger.env(), v8_str("_log"), log_str)
        .FromJust();
509

510
    i::Vector<const char> source = TestSources::GetScriptsSource();
511 512 513 514
    v8::Local<v8::String> source_str =
        v8::String::NewFromUtf8(isolate, source.start(),
                                v8::NewStringType::kNormal, source.length())
            .ToLocalChecked();
515
    v8::TryCatch try_catch(isolate);
516
    v8::Local<v8::Script> script = CompileWithOrigin(source_str, "");
517 518 519 520 521
    if (script.IsEmpty()) {
      v8::String::Utf8Value exception(try_catch.Exception());
      printf("compile: %s\n", *exception);
      CHECK(false);
    }
522 523
    v8::Local<v8::Value> result;
    if (!script->Run(initialize_logger.env()).ToLocal(&result)) {
524 525 526 527 528 529
      v8::String::Utf8Value exception(try_catch.Exception());
      printf("run: %s\n", *exception);
      CHECK(false);
    }
    // The result either be a "true" literal or problem description.
    if (!result->IsTrue()) {
530 531
      v8::Local<v8::String> s =
          result->ToString(initialize_logger.env()).ToLocalChecked();
532
      i::ScopedVector<char> data(s->Utf8Length() + 1);
533
      CHECK(data.start());
534 535 536 537 538 539
      s->WriteUtf8(data.start());
      printf("%s\n", data.start());
      // Make sure that our output is written prior crash due to CHECK failure.
      fflush(stdout);
      CHECK(false);
    }
540
  }
541
  isolate->Dispose();
542
}
543 544 545


TEST(LogVersion) {
546 547 548 549
  SETUP_FLAGS();
  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
  v8::Isolate* isolate = v8::Isolate::New(create_params);
550
  {
551
    ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
552 553 554 555 556 557 558 559
    bool exists = false;
    i::Vector<const char> log(
        i::ReadFile(initialize_logger.StopLoggingGetTempFile(), &exists, true));
    CHECK(exists);
    i::EmbeddedVector<char, 100> ref_data;
    i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(),
                i::Version::GetMinor(), i::Version::GetBuild(),
                i::Version::GetPatch(), i::Version::IsCandidate());
560
    CHECK(StrNStr(log.start(), ref_data.start(), log.length()));
561 562 563 564
    log.Dispose();
  }
  isolate->Dispose();
}
565 566 567 568 569 570 571


// https://crbug.com/539892
// CodeCreateEvents with really large names should not crash.
TEST(Issue539892) {
  class : public i::CodeEventLogger {
   public:
572 573 574
    void CodeMoveEvent(i::AbstractCode* from, Address to) override {}
    void CodeDisableOptEvent(i::AbstractCode* code,
                             i::SharedFunctionInfo* shared) override {}
575 576

   private:
577 578
    void LogRecordedBuffer(i::AbstractCode* code, i::SharedFunctionInfo* shared,
                           const char* name, int length) override {}
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
  } code_event_logger;
  SETUP_FLAGS();
  v8::Isolate::CreateParams create_params;
  create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
  v8::Isolate* isolate = v8::Isolate::New(create_params);

  {
    ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
    Logger* logger = initialize_logger.logger();
    logger->addCodeEventListener(&code_event_logger);

    // Function with a really large name.
    const char* source_text =
        "(function "
        "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac"
        "(){})();";

    CompileRun(source_text);

    // Must not crash.
    logger->LogCompiledFunctions();
  }
  isolate->Dispose();
}