2011-04-01 14:38:30 +00:00
|
|
|
// Copyright 2006-2009 the V8 project authors. All rights reserved.
|
2013-03-07 11:12:26 +00:00
|
|
|
// 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.
|
2009-05-05 15:57:47 +00:00
|
|
|
//
|
|
|
|
// Tests of logging functions from log.h
|
|
|
|
|
2009-07-28 09:10:29 +00:00
|
|
|
#ifdef __linux__
|
2009-09-04 11:16:51 +00:00
|
|
|
#include <pthread.h>
|
2009-07-28 09:10:29 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#include <unistd.h>
|
2013-04-19 14:20:36 +00:00
|
|
|
#include <cmath>
|
2009-09-04 11:16:51 +00:00
|
|
|
#endif // __linux__
|
2009-05-05 15:57:47 +00:00
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
#include <unordered_set>
|
2018-05-28 08:33:07 +00:00
|
|
|
#include <vector>
|
2018-06-15 18:16:09 +00:00
|
|
|
// The C++ style guide recommends using <re2> instead of <regex>. However, the
|
|
|
|
// former isn't available in V8.
|
|
|
|
#include <regex> // NOLINT(build/c++11)
|
2018-07-23 11:42:37 +00:00
|
|
|
#include "src/api-inl.h"
|
2014-06-20 08:40:11 +00:00
|
|
|
#include "src/log-utils.h"
|
2016-09-01 12:01:33 +00:00
|
|
|
#include "src/log.h"
|
2017-01-09 13:43:28 +00:00
|
|
|
#include "src/objects-inl.h"
|
2015-09-28 19:34:08 +00:00
|
|
|
#include "src/profiler/cpu-profiler.h"
|
2015-03-27 15:28:55 +00:00
|
|
|
#include "src/snapshot/natives.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/utils.h"
|
2016-09-01 12:01:33 +00:00
|
|
|
#include "src/v8.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8threads.h"
|
2014-12-16 07:40:00 +00:00
|
|
|
#include "src/version.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/vm-state-inl.h"
|
|
|
|
#include "test/cctest/cctest.h"
|
2009-05-05 15:57:47 +00:00
|
|
|
|
2009-05-20 09:04:13 +00:00
|
|
|
using v8::internal::Address;
|
2009-05-25 08:25:36 +00:00
|
|
|
using v8::internal::EmbeddedVector;
|
2009-05-05 15:57:47 +00:00
|
|
|
using v8::internal::Logger;
|
2009-11-11 09:50:06 +00:00
|
|
|
using v8::internal::StrLength;
|
2009-05-05 15:57:47 +00:00
|
|
|
|
2010-02-17 13:23:46 +00:00
|
|
|
namespace {
|
|
|
|
|
2011-09-14 11:47:03 +00:00
|
|
|
|
2015-04-29 09:54:34 +00:00
|
|
|
#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
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
static const char* StrNStr(const char* s1, const char* s2, size_t n) {
|
|
|
|
CHECK_EQ(s1[n], '\0');
|
|
|
|
return strstr(s1, s2);
|
|
|
|
}
|
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
// Look for a log line which starts with {prefix} and ends with {suffix}.
|
2017-11-14 09:12:52 +00:00
|
|
|
static const char* FindLogLine(const char* start, const char* end,
|
|
|
|
const char* prefix,
|
2017-10-20 22:07:50 +00:00
|
|
|
const char* suffix = nullptr) {
|
2017-11-14 09:12:52 +00:00
|
|
|
CHECK_LT(start, end);
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK_EQ(end[0], '\0');
|
|
|
|
size_t prefixLength = strlen(prefix);
|
|
|
|
// Loop through the input until we find /{prefix}[^\n]+{suffix}/.
|
|
|
|
while (start < end) {
|
2017-11-28 16:12:09 +00:00
|
|
|
const char* prefixResult = strstr(start, prefix);
|
2017-10-13 07:13:19 +00:00
|
|
|
if (!prefixResult) return NULL;
|
2017-10-20 22:07:50 +00:00
|
|
|
if (suffix == nullptr) return prefixResult;
|
2017-10-13 07:13:19 +00:00
|
|
|
const char* suffixResult =
|
|
|
|
StrNStr(prefixResult, suffix, (end - prefixResult));
|
|
|
|
if (!suffixResult) return NULL;
|
|
|
|
// Check that there are no newlines in between the {prefix} and the {suffix}
|
|
|
|
// results.
|
|
|
|
const char* newlineResult =
|
|
|
|
StrNStr(prefixResult, "\n", (end - prefixResult));
|
|
|
|
if (!newlineResult) return prefixResult;
|
|
|
|
if (newlineResult > suffixResult) return prefixResult;
|
|
|
|
start = prefixResult + prefixLength;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-04-29 09:54:34 +00:00
|
|
|
|
2010-02-17 13:23:46 +00:00
|
|
|
class ScopedLoggerInitializer {
|
|
|
|
public:
|
2015-04-29 09:54:34 +00:00
|
|
|
ScopedLoggerInitializer(bool saved_log, bool saved_prof, v8::Isolate* isolate)
|
|
|
|
: saved_log_(saved_log),
|
|
|
|
saved_prof_(saved_prof),
|
2017-10-13 16:33:03 +00:00
|
|
|
temp_file_(nullptr),
|
2015-04-29 09:54:34 +00:00
|
|
|
isolate_(isolate),
|
|
|
|
isolate_scope_(isolate),
|
|
|
|
scope_(isolate),
|
|
|
|
env_(v8::Context::New(isolate)),
|
|
|
|
logger_(reinterpret_cast<i::Isolate*>(isolate)->logger()) {
|
2010-02-17 13:23:46 +00:00
|
|
|
env_->Enter();
|
|
|
|
}
|
|
|
|
|
|
|
|
~ScopedLoggerInitializer() {
|
|
|
|
env_->Exit();
|
2013-04-08 15:16:55 +00:00
|
|
|
logger_->TearDown();
|
2017-10-13 16:33:03 +00:00
|
|
|
if (temp_file_ != nullptr) fclose(temp_file_);
|
2010-02-17 13:23:46 +00:00
|
|
|
i::FLAG_prof = saved_prof_;
|
2011-07-13 11:31:22 +00:00
|
|
|
i::FLAG_log = saved_log_;
|
2017-10-13 07:13:19 +00:00
|
|
|
log_.Dispose();
|
2010-02-17 13:23:46 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Context>& env() { return env_; }
|
2010-02-17 13:23:46 +00:00
|
|
|
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate() { return isolate_; }
|
|
|
|
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
i::Isolate* i_isolate() { return reinterpret_cast<i::Isolate*>(isolate()); }
|
|
|
|
|
2013-04-08 15:16:55 +00:00
|
|
|
Logger* logger() { return logger_; }
|
|
|
|
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
void PrintLog(int requested_nof_lines = 0, const char* start = nullptr) {
|
|
|
|
if (requested_nof_lines <= 0) {
|
2017-11-14 09:12:52 +00:00
|
|
|
printf("%s", log_.start());
|
|
|
|
return;
|
|
|
|
}
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
// Try to print the last {requested_nof_lines} of the log.
|
|
|
|
if (start == nullptr) start = log_.start();
|
2017-11-14 09:12:52 +00:00
|
|
|
const char* current = log_.end();
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
int nof_lines = requested_nof_lines;
|
|
|
|
while (current > start && nof_lines > 0) {
|
2017-11-14 09:12:52 +00:00
|
|
|
current--;
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
if (*current == '\n') nof_lines--;
|
2017-11-14 09:12:52 +00:00
|
|
|
}
|
|
|
|
printf(
|
|
|
|
"======================================================\n"
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
"Last %i log lines:\n"
|
|
|
|
"======================================================\n"
|
|
|
|
"...\n%s\n"
|
2017-11-28 16:12:09 +00:00
|
|
|
"======================================================\n",
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
requested_nof_lines, current);
|
2017-11-14 09:12:52 +00:00
|
|
|
}
|
2017-10-20 22:07:50 +00:00
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
v8::Local<v8::String> GetLogString() {
|
|
|
|
return v8::String::NewFromUtf8(isolate_, log_.start(),
|
|
|
|
v8::NewStringType::kNormal, log_.length())
|
|
|
|
.ToLocalChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void StopLogging() {
|
|
|
|
bool exists = false;
|
|
|
|
log_ = i::ReadFile(StopLoggingGetTempFile(), &exists, true);
|
|
|
|
CHECK(exists);
|
|
|
|
}
|
|
|
|
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
const char* GetEndPosition() { return log_.start() + log_.length(); }
|
|
|
|
|
2017-11-14 09:12:52 +00:00
|
|
|
const char* FindLine(const char* prefix, const char* suffix = nullptr,
|
|
|
|
const char* start = nullptr) {
|
2017-10-30 10:44:59 +00:00
|
|
|
// Make sure that StopLogging() has been called before.
|
|
|
|
CHECK(log_.size());
|
2017-11-14 09:12:52 +00:00
|
|
|
if (start == nullptr) start = log_.start();
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
const char* end = GetEndPosition();
|
2017-11-14 09:12:52 +00:00
|
|
|
return FindLogLine(start, end, prefix, suffix);
|
2017-10-13 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-30 10:44:59 +00:00
|
|
|
// Find all log lines specified by the {prefix, suffix} pairs and ensure they
|
|
|
|
// occurr in the specified order.
|
2017-11-14 09:12:52 +00:00
|
|
|
void FindLogLines(const char* pairs[][2], size_t limit,
|
|
|
|
const char* start = nullptr) {
|
|
|
|
const char* prefix = pairs[0][0];
|
|
|
|
const char* suffix = pairs[0][1];
|
|
|
|
const char* last_position = FindLine(prefix, suffix, start);
|
|
|
|
if (last_position == nullptr) {
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
PrintLog(100, start);
|
2017-11-14 09:12:52 +00:00
|
|
|
V8_Fatal(__FILE__, __LINE__, "Could not find log line: %s ... %s", prefix,
|
|
|
|
suffix);
|
|
|
|
}
|
2017-10-30 10:44:59 +00:00
|
|
|
CHECK(last_position);
|
|
|
|
for (size_t i = 1; i < limit; i++) {
|
2017-11-14 09:12:52 +00:00
|
|
|
prefix = pairs[i][0];
|
|
|
|
suffix = pairs[i][1];
|
|
|
|
const char* position = FindLine(prefix, suffix, start);
|
|
|
|
if (position == nullptr) {
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
PrintLog(100, start);
|
2017-11-14 09:12:52 +00:00
|
|
|
V8_Fatal(__FILE__, __LINE__, "Could not find log line: %s ... %s",
|
|
|
|
prefix, suffix);
|
|
|
|
}
|
2017-10-30 10:44:59 +00:00
|
|
|
// Check that all string positions are in order.
|
2017-11-14 09:12:52 +00:00
|
|
|
if (position <= last_position) {
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
PrintLog(100, start);
|
2017-11-14 09:12:52 +00:00
|
|
|
V8_Fatal(__FILE__, __LINE__,
|
|
|
|
"Log statements not in expected order (prev=%p, current=%p): "
|
|
|
|
"%s ... %s",
|
|
|
|
reinterpret_cast<const void*>(last_position),
|
|
|
|
reinterpret_cast<const void*>(position), prefix, suffix);
|
|
|
|
}
|
2017-10-30 10:44:59 +00:00
|
|
|
last_position = position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
void LogCompiledFunctions() { logger_->LogCompiledFunctions(); }
|
|
|
|
|
|
|
|
void StringEvent(const char* name, const char* value) {
|
|
|
|
logger_->StringEvent(name, value);
|
|
|
|
}
|
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
void ExtractAllAddresses(std::unordered_set<uintptr_t>* map,
|
|
|
|
const char* prefix, int field_index) {
|
|
|
|
// Make sure that StopLogging() has been called before.
|
|
|
|
CHECK(log_.size());
|
|
|
|
const char* current = log_.start();
|
|
|
|
while (current != nullptr) {
|
|
|
|
current = FindLine(prefix, nullptr, current);
|
|
|
|
if (current == nullptr) return;
|
|
|
|
// Find token number {index}.
|
|
|
|
const char* previous;
|
|
|
|
for (int i = 0; i <= field_index; i++) {
|
|
|
|
previous = current;
|
|
|
|
current = strchr(current + 1, ',');
|
|
|
|
if (current == nullptr) break;
|
|
|
|
// Skip the comma.
|
|
|
|
current++;
|
|
|
|
}
|
|
|
|
if (current == nullptr) break;
|
|
|
|
uintptr_t address = strtoll(previous, nullptr, 16);
|
|
|
|
CHECK_LT(0, address);
|
|
|
|
map->insert(address);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
private:
|
2011-07-13 11:31:22 +00:00
|
|
|
FILE* StopLoggingGetTempFile() {
|
2013-04-08 15:16:55 +00:00
|
|
|
temp_file_ = logger_->TearDown();
|
2015-01-30 09:29:25 +00:00
|
|
|
CHECK(temp_file_);
|
2011-07-13 11:31:22 +00:00
|
|
|
fflush(temp_file_);
|
|
|
|
rewind(temp_file_);
|
|
|
|
return temp_file_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool saved_log_;
|
2010-02-17 13:23:46 +00:00
|
|
|
const bool saved_prof_;
|
2011-07-13 11:31:22 +00:00
|
|
|
FILE* temp_file_;
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Isolate* isolate_;
|
|
|
|
v8::Isolate::Scope isolate_scope_;
|
2010-02-17 13:23:46 +00:00
|
|
|
v8::HandleScope scope_;
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Context> env_;
|
2013-04-08 15:16:55 +00:00
|
|
|
Logger* logger_;
|
2017-10-13 07:13:19 +00:00
|
|
|
i::Vector<const char> log_;
|
2010-02-17 13:23:46 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer);
|
|
|
|
};
|
|
|
|
|
2018-05-28 08:33:07 +00:00
|
|
|
class TestCodeEventHandler : public v8::CodeEventHandler {
|
|
|
|
public:
|
|
|
|
explicit TestCodeEventHandler(v8::Isolate* isolate)
|
2018-07-16 21:01:31 +00:00
|
|
|
: v8::CodeEventHandler(isolate), isolate_(isolate) {}
|
2018-05-28 08:33:07 +00:00
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
size_t CountLines(std::string prefix, std::string suffix = std::string()) {
|
|
|
|
if (!log_.length()) return 0;
|
|
|
|
|
|
|
|
std::regex expression("(^|\\n)" + prefix + ".*" + suffix + "(?=\\n|$)");
|
|
|
|
|
|
|
|
size_t match_count(std::distance(
|
|
|
|
std::sregex_iterator(log_.begin(), log_.end(), expression),
|
|
|
|
std::sregex_iterator()));
|
|
|
|
|
|
|
|
return match_count;
|
2018-05-28 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Handle(v8::CodeEvent* code_event) override {
|
2018-06-15 18:16:09 +00:00
|
|
|
std::string log_line = "";
|
|
|
|
log_line += v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
|
|
|
|
log_line += " ";
|
|
|
|
log_line += FormatName(code_event);
|
|
|
|
log_line += "\n";
|
|
|
|
log_ += log_line;
|
2018-05-28 08:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-06-15 18:16:09 +00:00
|
|
|
std::string FormatName(v8::CodeEvent* code_event) {
|
|
|
|
std::string name = std::string(code_event->GetComment());
|
|
|
|
if (name.empty()) {
|
|
|
|
v8::Local<v8::String> functionName = code_event->GetFunctionName();
|
2018-07-16 21:01:31 +00:00
|
|
|
std::string buffer(functionName->Utf8Length(isolate_) + 1, 0);
|
2018-07-23 02:35:30 +00:00
|
|
|
functionName->WriteUtf8(isolate_, &buffer[0],
|
2018-07-16 21:01:31 +00:00
|
|
|
functionName->Utf8Length(isolate_) + 1);
|
2018-06-15 18:16:09 +00:00
|
|
|
// Sanitize name, removing unwanted \0 resulted from WriteUtf8
|
|
|
|
name = std::string(buffer.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2018-05-28 08:33:07 +00:00
|
|
|
std::string log_;
|
2018-07-16 21:01:31 +00:00
|
|
|
v8::Isolate* isolate_;
|
2018-05-28 08:33:07 +00:00
|
|
|
};
|
|
|
|
|
2010-02-17 13:23:46 +00:00
|
|
|
} // namespace
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
TEST(FindLogLine) {
|
|
|
|
const char* string =
|
|
|
|
"prefix1, stuff, suffix1\n"
|
|
|
|
"prefix2, stuff\n, suffix2\n"
|
|
|
|
"prefix3suffix3\n"
|
|
|
|
"prefix4 suffix4";
|
2017-11-14 09:12:52 +00:00
|
|
|
const char* end = string + strlen(string);
|
2017-10-13 07:13:19 +00:00
|
|
|
// Make sure the vector contains the terminating \0 character.
|
2017-11-14 09:12:52 +00:00
|
|
|
CHECK(FindLogLine(string, end, "prefix1, stuff, suffix1"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix1, stuff"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix1"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix1", "suffix1"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix1", "suffix1"));
|
|
|
|
CHECK(!FindLogLine(string, end, "prefix2", "suffix2"));
|
|
|
|
CHECK(!FindLogLine(string, end, "prefix1", "suffix2"));
|
|
|
|
CHECK(!FindLogLine(string, end, "prefix1", "suffix3"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix3", "suffix3"));
|
|
|
|
CHECK(FindLogLine(string, end, "prefix4", "suffix4"));
|
|
|
|
CHECK(!FindLogLine(string, end, "prefix4", "suffix4XXXXXXXXXXXX"));
|
|
|
|
CHECK(
|
|
|
|
!FindLogLine(string, end, "prefix4XXXXXXXXXXXXXXXXXXXXXXxxx", "suffix4"));
|
|
|
|
CHECK(!FindLogLine(string, end, "suffix", "suffix5XXXXXXXXXXXXXXXXXXXX"));
|
2009-05-25 08:25:36 +00:00
|
|
|
}
|
|
|
|
|
2010-10-26 14:51:31 +00:00
|
|
|
// BUG(913). Need to implement support for profiling multiple VM threads.
|
|
|
|
#if 0
|
2009-09-04 11:16:51 +00:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
class LoopingThread : public v8::internal::Thread {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit LoopingThread(v8::internal::Isolate* isolate)
|
|
|
|
: v8::internal::Thread(isolate),
|
2013-09-02 12:26:06 +00:00
|
|
|
semaphore_(new v8::internal::Semaphore(0)),
|
2009-09-04 11:16:51 +00:00
|
|
|
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:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit LoopingJsThread(v8::internal::Isolate* isolate)
|
|
|
|
: LoopingThread(isolate) { }
|
2009-09-04 11:16:51 +00:00
|
|
|
void RunLoop() {
|
2010-03-04 13:25:23 +00:00
|
|
|
v8::Locker locker;
|
2017-10-18 09:06:55 +00:00
|
|
|
CHECK_NOT_NULL(CcTest::i_isolate());
|
2013-09-19 09:17:13 +00:00
|
|
|
CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0);
|
2010-03-04 13:25:23 +00:00
|
|
|
SetV8ThreadId();
|
2009-09-04 11:16:51 +00:00
|
|
|
while (IsRunning()) {
|
|
|
|
v8::HandleScope scope;
|
|
|
|
v8::Persistent<v8::Context> context = v8::Context::New();
|
2010-03-04 13:25:23 +00:00
|
|
|
CHECK(!context.IsEmpty());
|
|
|
|
{
|
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
SignalRunning();
|
2011-07-13 11:31:22 +00:00
|
|
|
CompileRun(
|
2010-03-04 13:25:23 +00:00
|
|
|
"var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }");
|
|
|
|
}
|
2009-09-04 11:16:51 +00:00
|
|
|
context.Dispose();
|
2015-05-04 22:53:22 +00:00
|
|
|
i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
|
2009-09-04 11:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class LoopingNonJsThread : public LoopingThread {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit LoopingNonJsThread(v8::internal::Isolate* isolate)
|
|
|
|
: LoopingThread(isolate) { }
|
2009-09-04 11:16:51 +00:00
|
|
|
void RunLoop() {
|
|
|
|
v8::Locker locker;
|
|
|
|
v8::Unlocker unlocker;
|
|
|
|
// Now thread has V8's id, but will not run VM code.
|
2017-10-18 09:06:55 +00:00
|
|
|
CHECK_NOT_NULL(CcTest::i_isolate());
|
2013-09-19 09:17:13 +00:00
|
|
|
CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0);
|
2009-09-04 11:16:51 +00:00
|
|
|
double i = 10;
|
|
|
|
SignalRunning();
|
|
|
|
while (IsRunning()) {
|
2014-01-14 09:57:05 +00:00
|
|
|
i = std::sin(i);
|
2015-05-04 22:53:22 +00:00
|
|
|
i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
|
2009-09-04 11:16:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TestSampler : public v8::internal::Sampler {
|
|
|
|
public:
|
2011-03-18 20:35:07 +00:00
|
|
|
explicit TestSampler(v8::internal::Isolate* isolate)
|
|
|
|
: Sampler(isolate, 0, true, true),
|
2013-09-02 12:26:06 +00:00
|
|
|
semaphore_(new v8::internal::Semaphore(0)),
|
2009-09-04 11:16:51 +00:00
|
|
|
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) {
|
2017-10-13 16:33:03 +00:00
|
|
|
TestSampler* sampler = nullptr;
|
2010-12-07 11:31:57 +00:00
|
|
|
{
|
|
|
|
v8::Locker locker;
|
2013-09-19 09:17:13 +00:00
|
|
|
sampler = new TestSampler(CcTest::i_isolate());
|
2010-12-07 11:31:57 +00:00
|
|
|
sampler->Start();
|
|
|
|
CHECK(sampler->IsActive());
|
|
|
|
}
|
|
|
|
|
2013-09-19 09:17:13 +00:00
|
|
|
LoopingJsThread jsThread(CcTest::i_isolate());
|
2009-09-04 11:16:51 +00:00
|
|
|
jsThread.Start();
|
2013-09-19 09:17:13 +00:00
|
|
|
LoopingNonJsThread nonJsThread(CcTest::i_isolate());
|
2009-09-04 11:16:51 +00:00
|
|
|
nonJsThread.Start();
|
|
|
|
|
2010-12-07 11:31:57 +00:00
|
|
|
CHECK(!sampler->WasSampleStackCalled());
|
2009-09-04 11:16:51 +00:00
|
|
|
jsThread.WaitForRunning();
|
|
|
|
jsThread.SendSigProf();
|
2010-12-07 11:31:57 +00:00
|
|
|
CHECK(sampler->WaitForTick());
|
|
|
|
CHECK(sampler->WasSampleStackCalled());
|
|
|
|
sampler->Reset();
|
|
|
|
CHECK(!sampler->WasSampleStackCalled());
|
2009-09-04 11:16:51 +00:00
|
|
|
nonJsThread.WaitForRunning();
|
|
|
|
nonJsThread.SendSigProf();
|
2010-12-07 11:31:57 +00:00
|
|
|
CHECK(!sampler->WaitForTick());
|
|
|
|
CHECK(!sampler->WasSampleStackCalled());
|
|
|
|
sampler->Stop();
|
2009-09-04 11:16:51 +00:00
|
|
|
|
|
|
|
jsThread.Stop();
|
|
|
|
nonJsThread.Stop();
|
|
|
|
jsThread.Join();
|
|
|
|
nonJsThread.Join();
|
2010-12-07 11:31:57 +00:00
|
|
|
|
|
|
|
delete sampler;
|
2009-09-04 11:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __linux__
|
|
|
|
|
|
|
|
|
2009-10-07 12:20:02 +00:00
|
|
|
// 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)
|
2009-11-11 09:50:06 +00:00
|
|
|
: utf_source_(StrLength(source)) {
|
2009-10-07 12:20:02 +00:00
|
|
|
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) {
|
2013-09-19 08:54:58 +00:00
|
|
|
v8::HandleScope scope(CcTest::isolate());
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Context> env = v8::Context::New(CcTest::isolate());
|
2009-10-07 12:20:02 +00:00
|
|
|
env->Enter();
|
|
|
|
|
|
|
|
SimpleExternalString source_ext_str("(function ext() {})();");
|
2013-11-28 08:21:26 +00:00
|
|
|
v8::Local<v8::String> source =
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::String::NewExternalTwoByte(CcTest::isolate(), &source_ext_str)
|
|
|
|
.ToLocalChecked();
|
2009-10-07 12:20:02 +00:00
|
|
|
// Script needs to have a name in order to trigger InitLineEnds execution.
|
2015-11-18 08:22:07 +00:00
|
|
|
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);
|
2009-10-07 12:20:02 +00:00
|
|
|
CHECK(!evil_script.IsEmpty());
|
2015-11-18 08:22:07 +00:00
|
|
|
CHECK(!evil_script->Run(env).IsEmpty());
|
2009-10-07 12:20:02 +00:00
|
|
|
i::Handle<i::ExternalTwoByteString> i_source(
|
2018-06-26 10:14:12 +00:00
|
|
|
i::ExternalTwoByteString::cast(*v8::Utils::OpenHandle(*source)),
|
|
|
|
CcTest::i_isolate());
|
2009-10-07 12:20:02 +00:00
|
|
|
// This situation can happen if source was an external string disposed
|
|
|
|
// by its owner.
|
2018-07-13 08:27:38 +00:00
|
|
|
i_source->set_resource(nullptr);
|
2009-10-07 12:20:02 +00:00
|
|
|
|
|
|
|
// Must not crash.
|
2013-09-19 09:17:13 +00:00
|
|
|
CcTest::i_isolate()->logger()->LogCompiledFunctions();
|
2009-10-07 12:20:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 12:28:27 +00:00
|
|
|
static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
2009-11-20 12:15:46 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2013-09-20 10:52:20 +00:00
|
|
|
TEST(LogCallbacks) {
|
2015-04-29 09:54:34 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
2014-09-19 08:01:35 +00:00
|
|
|
{
|
2017-10-13 07:13:19 +00:00
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
2014-09-19 08:01:35 +00:00
|
|
|
|
|
|
|
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
|
|
|
|
isolate, v8::FunctionTemplate::New(isolate));
|
|
|
|
obj->SetClassName(v8_str("Obj"));
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::ObjectTemplate> proto = obj->PrototypeTemplate();
|
2014-09-19 08:01:35 +00:00
|
|
|
v8::Local<v8::Signature> signature = v8::Signature::New(isolate, obj);
|
|
|
|
proto->Set(v8_str("method1"),
|
|
|
|
v8::FunctionTemplate::New(isolate, ObjMethod1,
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Value>(), signature),
|
2014-09-19 08:01:35 +00:00
|
|
|
static_cast<v8::PropertyAttribute>(v8::DontDelete));
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.env()
|
2015-11-18 08:22:07 +00:00
|
|
|
->Global()
|
2017-10-13 07:13:19 +00:00
|
|
|
->Set(logger.env(), v8_str("Obj"),
|
|
|
|
obj->GetFunction(logger.env()).ToLocalChecked())
|
2015-11-18 08:22:07 +00:00
|
|
|
.FromJust();
|
2014-09-19 08:01:35 +00:00
|
|
|
CompileRun("Obj.prototype.method1.toString();");
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.LogCompiledFunctions();
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.StopLogging();
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2016-03-04 18:55:48 +00:00
|
|
|
Address ObjMethod1_entry = reinterpret_cast<Address>(ObjMethod1);
|
|
|
|
#if USES_FUNCTION_DESCRIPTORS
|
|
|
|
ObjMethod1_entry = *FUNCTION_ENTRYPOINT_ADDRESS(ObjMethod1_entry);
|
|
|
|
#endif
|
2014-09-19 08:01:35 +00:00
|
|
|
i::EmbeddedVector<char, 100> ref_data;
|
2018-04-13 22:28:05 +00:00
|
|
|
i::SNPrintF(ref_data, ",0x%" V8PRIxPTR ",1,method1", ObjMethod1_entry);
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(logger.FindLine("code-creation,Callback,-2,", ref_data.start()));
|
2014-09-19 08:01:35 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
2009-11-20 12:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-20 12:28:27 +00:00
|
|
|
static void Prop1Getter(v8::Local<v8::String> property,
|
|
|
|
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
2009-11-25 16:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Prop1Setter(v8::Local<v8::String> property,
|
2013-06-20 12:28:27 +00:00
|
|
|
v8::Local<v8::Value> value,
|
|
|
|
const v8::PropertyCallbackInfo<void>& info) {
|
2009-11-25 16:39:18 +00:00
|
|
|
}
|
|
|
|
|
2013-06-20 12:28:27 +00:00
|
|
|
static void Prop2Getter(v8::Local<v8::String> property,
|
|
|
|
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
2009-11-25 16:39:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 09:52:11 +00:00
|
|
|
|
2013-09-20 10:52:20 +00:00
|
|
|
TEST(LogAccessorCallbacks) {
|
2015-04-29 09:54:34 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
2014-09-19 08:01:35 +00:00
|
|
|
{
|
2017-10-13 07:13:19 +00:00
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
2014-09-19 08:01:35 +00:00
|
|
|
|
|
|
|
v8::Local<v8::FunctionTemplate> obj = v8::Local<v8::FunctionTemplate>::New(
|
|
|
|
isolate, v8::FunctionTemplate::New(isolate));
|
|
|
|
obj->SetClassName(v8_str("Obj"));
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::ObjectTemplate> inst = obj->InstanceTemplate();
|
2014-09-19 08:01:35 +00:00
|
|
|
inst->SetAccessor(v8_str("prop1"), Prop1Getter, Prop1Setter);
|
|
|
|
inst->SetAccessor(v8_str("prop2"), Prop2Getter);
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.logger()->LogAccessorCallbacks();
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.StopLogging();
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2016-03-04 18:55:48 +00:00
|
|
|
Address Prop1Getter_entry = reinterpret_cast<Address>(Prop1Getter);
|
|
|
|
#if USES_FUNCTION_DESCRIPTORS
|
|
|
|
Prop1Getter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop1Getter_entry);
|
|
|
|
#endif
|
2014-09-19 08:01:35 +00:00
|
|
|
EmbeddedVector<char, 100> prop1_getter_record;
|
2017-10-20 23:14:23 +00:00
|
|
|
i::SNPrintF(prop1_getter_record, ",0x%" V8PRIxPTR ",1,get prop1",
|
2018-04-13 22:28:05 +00:00
|
|
|
Prop1Getter_entry);
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(logger.FindLine("code-creation,Callback,-2,",
|
|
|
|
prop1_getter_record.start()));
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2016-03-04 18:55:48 +00:00
|
|
|
Address Prop1Setter_entry = reinterpret_cast<Address>(Prop1Setter);
|
|
|
|
#if USES_FUNCTION_DESCRIPTORS
|
|
|
|
Prop1Setter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop1Setter_entry);
|
|
|
|
#endif
|
2014-09-19 08:01:35 +00:00
|
|
|
EmbeddedVector<char, 100> prop1_setter_record;
|
2017-10-20 23:14:23 +00:00
|
|
|
i::SNPrintF(prop1_setter_record, ",0x%" V8PRIxPTR ",1,set prop1",
|
2018-04-13 22:28:05 +00:00
|
|
|
Prop1Setter_entry);
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(logger.FindLine("code-creation,Callback,-2,",
|
|
|
|
prop1_setter_record.start()));
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2016-03-04 18:55:48 +00:00
|
|
|
Address Prop2Getter_entry = reinterpret_cast<Address>(Prop2Getter);
|
|
|
|
#if USES_FUNCTION_DESCRIPTORS
|
|
|
|
Prop2Getter_entry = *FUNCTION_ENTRYPOINT_ADDRESS(Prop2Getter_entry);
|
|
|
|
#endif
|
2014-09-19 08:01:35 +00:00
|
|
|
EmbeddedVector<char, 100> prop2_getter_record;
|
2017-10-20 23:14:23 +00:00
|
|
|
i::SNPrintF(prop2_getter_record, ",0x%" V8PRIxPTR ",1,get prop2",
|
2018-04-13 22:28:05 +00:00
|
|
|
Prop2Getter_entry);
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(logger.FindLine("code-creation,Callback,-2,",
|
|
|
|
prop2_getter_record.start()));
|
2014-09-19 08:01:35 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
2010-02-17 13:23:46 +00:00
|
|
|
}
|
2009-11-25 16:39:18 +00:00
|
|
|
|
2011-09-14 11:47:03 +00:00
|
|
|
// Test that logging of code create / move events is equivalent to traversal of
|
|
|
|
// a resulting heap.
|
2013-09-20 10:52:20 +00:00
|
|
|
TEST(EquivalenceOfLoggingAndTraversal) {
|
2009-05-25 08:25:36 +00:00
|
|
|
// 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.
|
|
|
|
|
2011-07-13 11:31:22 +00:00
|
|
|
// Start with profiling to capture all code events from the beginning.
|
2015-04-29 09:54:34 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
2014-09-19 08:01:35 +00:00
|
|
|
{
|
2017-10-13 07:13:19 +00:00
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
2014-09-19 08:01:35 +00:00
|
|
|
|
|
|
|
// 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);");
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.logger()->StopProfiler();
|
2016-05-31 17:40:26 +00:00
|
|
|
reinterpret_cast<i::Isolate*>(isolate)->heap()->CollectAllGarbage(
|
2016-09-07 10:02:58 +00:00
|
|
|
i::Heap::kMakeHeapIterableMask, i::GarbageCollectionReason::kTesting);
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.StringEvent("test-logging-done", "");
|
2014-09-19 08:01:35 +00:00
|
|
|
|
|
|
|
// Iterate heap to find compiled functions, will write to log.
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.LogCompiledFunctions();
|
|
|
|
logger.StringEvent("test-traversal-done", "");
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
v8::Local<v8::String> log_str = logger.GetLogString();
|
|
|
|
logger.env()
|
2015-11-18 08:22:07 +00:00
|
|
|
->Global()
|
2017-10-13 07:13:19 +00:00
|
|
|
->Set(logger.env(), v8_str("_log"), log_str)
|
2015-11-18 08:22:07 +00:00
|
|
|
.FromJust();
|
2014-09-19 08:01:35 +00:00
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
// Load the Test snapshot's sources, see log-eq-of-logging-and-traversal.js
|
|
|
|
i::Vector<const char> source =
|
|
|
|
i::NativesCollection<i::TEST>::GetScriptsSource();
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::String> source_str =
|
|
|
|
v8::String::NewFromUtf8(isolate, source.start(),
|
|
|
|
v8::NewStringType::kNormal, source.length())
|
|
|
|
.ToLocalChecked();
|
2015-05-28 12:49:31 +00:00
|
|
|
v8::TryCatch try_catch(isolate);
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Script> script = CompileWithOrigin(source_str, "");
|
2014-09-19 08:01:35 +00:00
|
|
|
if (script.IsEmpty()) {
|
2017-08-24 21:49:48 +00:00
|
|
|
v8::String::Utf8Value exception(isolate, try_catch.Exception());
|
2017-12-18 16:19:23 +00:00
|
|
|
FATAL("compile: %s\n", *exception);
|
2014-09-19 08:01:35 +00:00
|
|
|
}
|
2015-11-18 08:22:07 +00:00
|
|
|
v8::Local<v8::Value> result;
|
2017-10-13 07:13:19 +00:00
|
|
|
if (!script->Run(logger.env()).ToLocal(&result)) {
|
2017-08-24 21:49:48 +00:00
|
|
|
v8::String::Utf8Value exception(isolate, try_catch.Exception());
|
2017-12-18 16:19:23 +00:00
|
|
|
FATAL("run: %s\n", *exception);
|
2014-09-19 08:01:35 +00:00
|
|
|
}
|
2017-10-13 07:13:19 +00:00
|
|
|
// The result either be the "true" literal or problem description.
|
2014-09-19 08:01:35 +00:00
|
|
|
if (!result->IsTrue()) {
|
2017-10-13 07:13:19 +00:00
|
|
|
v8::Local<v8::String> s = result->ToString(logger.env()).ToLocalChecked();
|
2018-07-16 21:01:31 +00:00
|
|
|
i::ScopedVector<char> data(s->Utf8Length(isolate) + 1);
|
2015-01-30 09:29:25 +00:00
|
|
|
CHECK(data.start());
|
2018-07-23 02:35:30 +00:00
|
|
|
s->WriteUtf8(isolate, data.start());
|
2017-12-18 16:19:23 +00:00
|
|
|
FATAL("%s\n", data.start());
|
2014-09-19 08:01:35 +00:00
|
|
|
}
|
2011-07-13 11:31:22 +00:00
|
|
|
}
|
2014-09-19 08:01:35 +00:00
|
|
|
isolate->Dispose();
|
2009-05-20 09:04:13 +00:00
|
|
|
}
|
2014-12-16 07:40:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
TEST(LogVersion) {
|
2015-04-29 09:54:34 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
2014-12-16 07:40:00 +00:00
|
|
|
{
|
2017-10-13 07:13:19 +00:00
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
logger.StopLogging();
|
|
|
|
|
2014-12-16 07:40:00 +00:00
|
|
|
i::EmbeddedVector<char, 100> ref_data;
|
2017-10-13 07:13:19 +00:00
|
|
|
i::SNPrintF(ref_data, "%d,%d,%d,%d,%d", i::Version::GetMajor(),
|
2014-12-16 07:40:00 +00:00
|
|
|
i::Version::GetMinor(), i::Version::GetBuild(),
|
|
|
|
i::Version::GetPatch(), i::Version::IsCandidate());
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(logger.FindLine("v8-version,", ref_data.start()));
|
2014-12-16 07:40:00 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2015-10-13 12:45:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
// https://crbug.com/539892
|
|
|
|
// CodeCreateEvents with really large names should not crash.
|
|
|
|
TEST(Issue539892) {
|
2018-07-16 21:01:31 +00:00
|
|
|
class FakeCodeEventLogger : public i::CodeEventLogger {
|
2015-10-13 12:45:15 +00:00
|
|
|
public:
|
2018-07-16 21:01:31 +00:00
|
|
|
explicit FakeCodeEventLogger(i::Isolate* isolate)
|
|
|
|
: CodeEventLogger(isolate) {}
|
|
|
|
|
2016-02-26 11:04:04 +00:00
|
|
|
void CodeMoveEvent(i::AbstractCode* from, Address to) override {}
|
|
|
|
void CodeDisableOptEvent(i::AbstractCode* code,
|
|
|
|
i::SharedFunctionInfo* shared) override {}
|
2015-10-13 12:45:15 +00:00
|
|
|
|
|
|
|
private:
|
2016-02-26 11:04:04 +00:00
|
|
|
void LogRecordedBuffer(i::AbstractCode* code, i::SharedFunctionInfo* shared,
|
|
|
|
const char* name, int length) override {}
|
2018-03-22 12:24:51 +00:00
|
|
|
void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name,
|
2018-02-19 13:36:58 +00:00
|
|
|
int length) override {}
|
2018-07-16 21:01:31 +00:00
|
|
|
} code_event_logger(CcTest::i_isolate());
|
2015-10-13 12:45:15 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
2017-10-13 07:13:19 +00:00
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
2018-04-17 23:29:24 +00:00
|
|
|
logger.logger()->AddCodeEventListener(&code_event_logger);
|
2015-10-13 12:45:15 +00:00
|
|
|
|
|
|
|
// 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.
|
2017-10-13 07:13:19 +00:00
|
|
|
logger.LogCompiledFunctions();
|
2015-10-13 12:45:15 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-20 22:07:50 +00:00
|
|
|
|
|
|
|
TEST(LogAll) {
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_log_all = true;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
|
|
|
|
// Function that will
|
|
|
|
const char* source_text =
|
|
|
|
"function testAddFn(a,b) { return a + b };"
|
|
|
|
"let result;"
|
|
|
|
"for (let i = 0; i < 100000; i++) { result = testAddFn(i, i); };"
|
|
|
|
"testAddFn('1', 1);"
|
|
|
|
"for (let i = 0; i < 100000; i++) { result = testAddFn('1', i); }";
|
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
// We should find at least one code-creation even for testAddFn();
|
|
|
|
CHECK(logger.FindLine("api,v8::Context::New"));
|
|
|
|
CHECK(logger.FindLine("timer-event-start", "V8.CompileCode"));
|
|
|
|
CHECK(logger.FindLine("timer-event-end", "V8.CompileCode"));
|
|
|
|
CHECK(logger.FindLine("code-creation,Script", ":1:1"));
|
|
|
|
CHECK(logger.FindLine("api,v8::Script::Run"));
|
|
|
|
CHECK(logger.FindLine("code-creation,LazyCompile,", "testAddFn"));
|
|
|
|
if (i::FLAG_opt && !i::FLAG_always_opt) {
|
|
|
|
CHECK(logger.FindLine("code-deopt,", "soft"));
|
|
|
|
CHECK(logger.FindLine("timer-event-start", "V8.DeoptimizeCode"));
|
|
|
|
CHECK(logger.FindLine("timer-event-end", "V8.DeoptimizeCode"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-27 03:01:08 +00:00
|
|
|
|
2018-04-10 14:31:06 +00:00
|
|
|
TEST(LogInterpretedFramesNativeStack) {
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_interpreted_frames_native_stack = true;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
|
|
|
|
const char* source_text =
|
|
|
|
"function testLogInterpretedFramesNativeStack(a,b) { return a + b };"
|
|
|
|
"testLogInterpretedFramesNativeStack('1', 1);";
|
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
CHECK(logger.FindLine("InterpretedFunction",
|
|
|
|
"testLogInterpretedFramesNativeStack"));
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2018-05-28 08:33:07 +00:00
|
|
|
TEST(ExternalCodeEventListener) {
|
|
|
|
i::FLAG_log = false;
|
|
|
|
i::FLAG_prof = false;
|
|
|
|
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
|
|
|
context->Enter();
|
|
|
|
|
|
|
|
TestCodeEventHandler code_event_handler(isolate);
|
|
|
|
|
|
|
|
const char* source_text_before_start =
|
|
|
|
"function testCodeEventListenerBeforeStart(a,b) { return a + b };"
|
|
|
|
"testCodeEventListenerBeforeStart('1', 1);";
|
|
|
|
CompileRun(source_text_before_start);
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_EQ(code_event_handler.CountLines("LazyCompile",
|
|
|
|
"testCodeEventListenerBeforeStart"),
|
|
|
|
0);
|
2018-05-28 08:33:07 +00:00
|
|
|
|
|
|
|
code_event_handler.Enable();
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_GE(code_event_handler.CountLines("LazyCompile",
|
|
|
|
"testCodeEventListenerBeforeStart"),
|
|
|
|
1);
|
2018-05-28 08:33:07 +00:00
|
|
|
|
|
|
|
const char* source_text_after_start =
|
|
|
|
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
|
|
|
|
"testCodeEventListenerAfterStart('1', 1);";
|
|
|
|
CompileRun(source_text_after_start);
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_GE(code_event_handler.CountLines("LazyCompile",
|
|
|
|
"testCodeEventListenerAfterStart"),
|
|
|
|
1);
|
2018-05-28 08:33:07 +00:00
|
|
|
|
|
|
|
context->Exit();
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2018-06-08 19:13:00 +00:00
|
|
|
TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
|
|
|
|
i::FLAG_log = false;
|
|
|
|
i::FLAG_prof = false;
|
|
|
|
i::FLAG_interpreted_frames_native_stack = true;
|
|
|
|
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
|
|
|
context->Enter();
|
|
|
|
|
|
|
|
TestCodeEventHandler code_event_handler(isolate);
|
|
|
|
|
|
|
|
const char* source_text_before_start =
|
|
|
|
"function testCodeEventListenerBeforeStart(a,b) { return a + b };"
|
|
|
|
"testCodeEventListenerBeforeStart('1', 1);";
|
|
|
|
CompileRun(source_text_before_start);
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_EQ(code_event_handler.CountLines("InterpretedFunction",
|
|
|
|
"testCodeEventListenerBeforeStart"),
|
|
|
|
0);
|
2018-06-08 19:13:00 +00:00
|
|
|
|
|
|
|
code_event_handler.Enable();
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
|
|
|
|
"testCodeEventListenerBeforeStart"),
|
|
|
|
1);
|
2018-06-08 19:13:00 +00:00
|
|
|
|
|
|
|
const char* source_text_after_start =
|
|
|
|
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
|
|
|
|
"testCodeEventListenerAfterStart('1', 1);";
|
|
|
|
CompileRun(source_text_after_start);
|
|
|
|
|
2018-06-15 18:16:09 +00:00
|
|
|
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
|
|
|
|
"testCodeEventListenerAfterStart"),
|
|
|
|
1);
|
|
|
|
|
|
|
|
CHECK_EQ(
|
|
|
|
code_event_handler.CountLines("Builtin", "InterpreterEntryTrampoline"),
|
|
|
|
1);
|
2018-06-08 19:13:00 +00:00
|
|
|
|
|
|
|
context->Exit();
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2017-10-27 03:01:08 +00:00
|
|
|
TEST(TraceMaps) {
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_trace_maps = true;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
// Try to create many different kind of maps to make sure the logging won't
|
|
|
|
// crash. More detailed tests are implemented separately.
|
|
|
|
const char* source_text =
|
|
|
|
"let a = {};"
|
|
|
|
"for (let i = 0; i < 500; i++) { a['p'+i] = i };"
|
|
|
|
"class Test { constructor(i) { this.a = 1; this['p'+i] = 1; }};"
|
|
|
|
"let t = new Test();"
|
|
|
|
"t.b = 1; t.c = 1; t.d = 3;"
|
|
|
|
"for (let i = 0; i < 100; i++) { t = new Test(i) };"
|
|
|
|
"t.b = {};";
|
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
// Mostly superficial checks.
|
|
|
|
CHECK(logger.FindLine("map,InitialMap", ",0x"));
|
|
|
|
CHECK(logger.FindLine("map,Transition", ",0x"));
|
|
|
|
CHECK(logger.FindLine("map-details", ",0x"));
|
|
|
|
}
|
|
|
|
i::FLAG_trace_maps = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-30 10:44:59 +00:00
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
TEST(LogMaps) {
|
|
|
|
// Test that all Map details from Maps in the snapshot are logged properly.
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_trace_maps = true;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
logger.StopLogging();
|
|
|
|
// Extract all the map-detail entry addresses from the log.
|
|
|
|
std::unordered_set<uintptr_t> map_addresses;
|
|
|
|
logger.ExtractAllAddresses(&map_addresses, "map-details", 2);
|
|
|
|
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
|
|
|
|
i::HeapIterator iterator(heap);
|
|
|
|
i::DisallowHeapAllocation no_gc;
|
|
|
|
|
|
|
|
// Iterate over all maps on the heap.
|
|
|
|
size_t i = 0;
|
|
|
|
for (i::HeapObject* obj = iterator.next(); obj != nullptr;
|
|
|
|
obj = iterator.next()) {
|
|
|
|
i++;
|
|
|
|
if (!obj->IsMap()) continue;
|
|
|
|
uintptr_t address = reinterpret_cast<uintptr_t>(obj);
|
|
|
|
if (map_addresses.find(address) != map_addresses.end()) continue;
|
|
|
|
logger.PrintLog(200);
|
2018-07-12 10:06:42 +00:00
|
|
|
i::Map::cast(obj)->Print();
|
2017-11-28 16:12:09 +00:00
|
|
|
V8_Fatal(__FILE__, __LINE__,
|
|
|
|
"Map (%p, #%zu) was not logged during startup with --trace-maps!"
|
|
|
|
"\n# Expected Log Line: map_details, ... %p"
|
|
|
|
"\n# Use logger::PrintLog() for more details.",
|
|
|
|
reinterpret_cast<void*>(obj), i, reinterpret_cast<void*>(obj));
|
|
|
|
}
|
|
|
|
logger.PrintLog(200);
|
|
|
|
}
|
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2017-10-30 10:44:59 +00:00
|
|
|
TEST(ConsoleTimeEvents) {
|
|
|
|
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 logger(saved_log, saved_prof, isolate);
|
|
|
|
// Test that console time events are properly logged
|
|
|
|
const char* source_text =
|
|
|
|
"console.time();"
|
|
|
|
"console.timeEnd();"
|
|
|
|
"console.timeStamp();"
|
|
|
|
"console.time('timerEvent1');"
|
|
|
|
"console.timeEnd('timerEvent1');"
|
|
|
|
"console.timeStamp('timerEvent2');"
|
|
|
|
"console.timeStamp('timerEvent3');";
|
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
const char* pairs[][2] = {{"timer-event-start,default,", nullptr},
|
|
|
|
{"timer-event-end,default,", nullptr},
|
|
|
|
{"timer-event,default,", nullptr},
|
|
|
|
{"timer-event-start,timerEvent1,", nullptr},
|
|
|
|
{"timer-event-end,timerEvent1,", nullptr},
|
|
|
|
{"timer-event,timerEvent2,", nullptr},
|
|
|
|
{"timer-event,timerEvent3,", nullptr}};
|
|
|
|
logger.FindLogLines(pairs, arraysize(pairs));
|
|
|
|
}
|
|
|
|
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-30 13:18:12 +00:00
|
|
|
|
|
|
|
TEST(LogFunctionEvents) {
|
2017-11-30 15:23:42 +00:00
|
|
|
// Always opt and stress opt will break the fine-grained log order.
|
|
|
|
if (i::FLAG_always_opt) return;
|
|
|
|
|
2017-10-30 13:18:12 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_log_function_events = true;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
|
2017-10-30 13:18:12 +00:00
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
|
|
|
|
// Run some warmup code to help ignoring existing log entries.
|
|
|
|
CompileRun(
|
|
|
|
"function warmUp(a) {"
|
|
|
|
" let b = () => 1;"
|
|
|
|
" return function(c) { return a+b+c; };"
|
|
|
|
"};"
|
|
|
|
"warmUp(1)(2);"
|
|
|
|
"(function warmUpEndMarkerFunction(){})();");
|
|
|
|
|
2017-10-30 13:18:12 +00:00
|
|
|
const char* source_text =
|
|
|
|
"function lazyNotExecutedFunction() { return 'lazy' };"
|
2017-11-14 09:12:52 +00:00
|
|
|
"function lazyFunction() { "
|
|
|
|
" function lazyInnerFunction() { return 'lazy' };"
|
|
|
|
" return lazyInnerFunction;"
|
|
|
|
"};"
|
|
|
|
"let innerFn = lazyFunction();"
|
|
|
|
"innerFn();"
|
|
|
|
"(function eagerFunction(){ return 'eager' })();"
|
|
|
|
"function Foo() { this.foo = function(){}; };"
|
|
|
|
"let i = new Foo(); i.foo();";
|
2017-10-30 13:18:12 +00:00
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
// Ignore all the log entries that happened before warmup
|
2017-11-14 09:12:52 +00:00
|
|
|
const char* start =
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
logger.FindLine("function,first-execution", "warmUpEndMarkerFunction");
|
|
|
|
CHECK_NOT_NULL(start);
|
2017-11-14 09:12:52 +00:00
|
|
|
const char* pairs[][2] = {
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
// Create a new script
|
|
|
|
{"script,create", nullptr},
|
|
|
|
{"script-details", nullptr},
|
2017-11-14 09:12:52 +00:00
|
|
|
// Step 1: parsing top-level script, preparsing functions
|
|
|
|
{"function,preparse-", ",lazyNotExecutedFunction"},
|
|
|
|
// Missing name for preparsing lazyInnerFunction
|
|
|
|
// {"function,preparse-", nullptr},
|
|
|
|
{"function,preparse-", ",lazyFunction"},
|
|
|
|
{"function,full-parse,", ",eagerFunction"},
|
|
|
|
{"function,preparse-", ",Foo"},
|
|
|
|
// Missing name for inner preparsing of Foo.foo
|
|
|
|
// {"function,preparse-", nullptr},
|
|
|
|
// Missing name for top-level script.
|
|
|
|
{"function,parse-script,", nullptr},
|
|
|
|
|
|
|
|
// Step 2: compiling top-level script and eager functions
|
|
|
|
// - Compiling script without name.
|
Reland "[parser][log] Log script id during background compilation"
This reverts commit a800e05007d42c84cd5627e5dfb305dfb9912844.
Original change's description:
> Revert "[parser][log] Log script id during background compilation"
>
> This reverts commit aafd5c52ab98608e37284a5a944a4c63045625b9.
>
> Reason for revert: Tentative revert for
>
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64/24825
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Win64%20-%20msvc/3242
>
> Original change's description:
> > [parser][log] Log script id during background compilation
> >
> > - Add separate script-create, script-reserve-id and script-details log events
> > - Add log events for CompilationCache hits and puts
> > - Simplify function event logging by only pass along the script id
> > - Explicitly create Scripts in parse-processor.js on script events only
> > - Create a temporary script id in the ParseInfo for use during background
> > parsing and compilation
> > - Clean up ParseInfo initialization to centralize creation and use of
> > script ids
> > - Allow creating Scripts with predefined script ids
> >
> > Bug: chromium:757467, chromium:850038
> > Change-Id: I02dfd1d5725795b9fe0ea94ef57b287b934a1efe
> > Reviewed-on: https://chromium-review.googlesource.com/1097131
> > Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
> > Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> > Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> > Commit-Queue: Camillo Bruni <cbruni@chromium.org>
> > Cr-Commit-Position: refs/heads/master@{#53978}
>
> TBR=ulan@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
>
> Change-Id: I629f72f51d5e086e2b54658c1fdd18cec268aab2
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: chromium:757467, chromium:850038
> Reviewed-on: https://chromium-review.googlesource.com/1112538
> Reviewed-by: Yang Guo <yangguo@chromium.org>
> Commit-Queue: Yang Guo <yangguo@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#53984}
TBR=ulan@chromium.org,yangguo@chromium.org,cbruni@chromium.org,gsathya@chromium.org,leszeks@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: chromium:757467, chromium:850038
Change-Id: I3088c86362c06ee50464f1f14e25350b1b8048ad
Reviewed-on: https://chromium-review.googlesource.com/1112539
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53994}
2018-06-25 09:00:21 +00:00
|
|
|
{"function,compile,", nullptr},
|
2017-11-14 09:12:52 +00:00
|
|
|
{"function,compile,", ",eagerFunction"},
|
|
|
|
|
|
|
|
// Step 3: start executing script
|
|
|
|
// Step 4. - lazy parse, lazy compiling and execute skipped functions
|
|
|
|
// - execute eager functions.
|
|
|
|
{"function,parse-function,", ",lazyFunction"},
|
|
|
|
{"function,compile-lazy,", ",lazyFunction"},
|
2017-11-30 15:23:42 +00:00
|
|
|
{"function,first-execution,", ",lazyFunction"},
|
2017-11-14 09:12:52 +00:00
|
|
|
|
|
|
|
{"function,parse-function,", ",lazyInnerFunction"},
|
|
|
|
{"function,compile-lazy,", ",lazyInnerFunction"},
|
2017-11-30 15:23:42 +00:00
|
|
|
{"function,first-execution,", ",lazyInnerFunction"},
|
|
|
|
|
|
|
|
{"function,first-execution,", ",eagerFunction"},
|
2017-11-14 09:12:52 +00:00
|
|
|
|
|
|
|
{"function,parse-function,", ",Foo"},
|
|
|
|
{"function,compile-lazy,", ",Foo"},
|
2017-11-30 15:23:42 +00:00
|
|
|
{"function,first-execution,", ",Foo"},
|
|
|
|
|
2017-11-14 09:12:52 +00:00
|
|
|
{"function,parse-function,", ",Foo.foo"},
|
|
|
|
{"function,compile-lazy,", ",Foo.foo"},
|
2017-11-30 15:23:42 +00:00
|
|
|
{"function,first-execution,", ",Foo.foo"},
|
2017-11-14 09:12:52 +00:00
|
|
|
};
|
|
|
|
logger.FindLogLines(pairs, arraysize(pairs), start);
|
2017-10-30 13:18:12 +00:00
|
|
|
}
|
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|