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
|
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
#include <unordered_set>
|
2018-05-28 08:33:07 +00:00
|
|
|
#include <vector>
|
2019-05-17 12:13:44 +00:00
|
|
|
#include "src/api/api-inl.h"
|
2018-08-22 13:57:49 +00:00
|
|
|
#include "src/builtins/builtins.h"
|
2019-05-21 09:30:15 +00:00
|
|
|
#include "src/codegen/compilation-cache.h"
|
2019-05-22 07:55:37 +00:00
|
|
|
#include "src/execution/vm-state-inl.h"
|
2019-05-24 13:51:59 +00:00
|
|
|
#include "src/init/v8.h"
|
2019-05-20 09:15:06 +00:00
|
|
|
#include "src/logging/log-utils.h"
|
|
|
|
#include "src/logging/log.h"
|
2019-05-23 08:51:46 +00:00
|
|
|
#include "src/objects/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"
|
2019-05-23 13:27:57 +00:00
|
|
|
#include "src/utils/ostreams.h"
|
|
|
|
#include "src/utils/version.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#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;
|
|
|
|
|
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
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
static std::vector<std::string> Split(const std::string& s, char delimiter) {
|
|
|
|
std::vector<std::string> result;
|
|
|
|
std::string line;
|
|
|
|
std::istringstream stream(s);
|
|
|
|
while (std::getline(stream, line, delimiter)) {
|
|
|
|
result.push_back(line);
|
2017-10-13 07:13:19 +00:00
|
|
|
}
|
2018-08-21 14:33:00 +00:00
|
|
|
return result;
|
2017-10-13 07:13:19 +00:00
|
|
|
}
|
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_;
|
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_; }
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
v8::Local<v8::String> GetLogString() {
|
2018-08-21 14:33:00 +00:00
|
|
|
int length = static_cast<int>(raw_log_.size());
|
|
|
|
return v8::String::NewFromUtf8(isolate_, raw_log_.c_str(),
|
2018-07-30 16:24:40 +00:00
|
|
|
v8::NewStringType::kNormal, length)
|
2017-10-13 07:13:19 +00:00
|
|
|
.ToLocalChecked();
|
|
|
|
}
|
|
|
|
|
2018-11-27 08:08:59 +00:00
|
|
|
void PrintLog() {
|
|
|
|
i::StdoutStream os;
|
|
|
|
os << raw_log_ << std::flush;
|
|
|
|
}
|
|
|
|
|
2017-10-13 07:13:19 +00:00
|
|
|
void StopLogging() {
|
|
|
|
bool exists = false;
|
2018-08-21 14:33:00 +00:00
|
|
|
raw_log_ = i::ReadFile(StopLoggingGetTempFile(), &exists, true);
|
|
|
|
log_ = Split(raw_log_, '\n');
|
2017-10-13 07:13:19 +00:00
|
|
|
CHECK(exists);
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
// Searches |log_| for a line which contains all the strings in |search_terms|
|
|
|
|
// as substrings, starting from the index |start|, and returns the index of
|
|
|
|
// the found line. Returns std::string::npos if no line is found.
|
|
|
|
size_t IndexOfLine(const std::vector<std::string>& search_terms,
|
|
|
|
size_t start = 0) {
|
|
|
|
for (size_t i = start; i < log_.size(); ++i) {
|
|
|
|
const std::string& line = log_.at(i);
|
|
|
|
bool all_terms_found = true;
|
|
|
|
for (const std::string& term : search_terms) {
|
|
|
|
all_terms_found &= line.find(term) != std::string::npos;
|
|
|
|
}
|
|
|
|
if (all_terms_found) return i;
|
|
|
|
}
|
|
|
|
return std::string::npos;
|
|
|
|
}
|
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
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
bool ContainsLine(const std::vector<std::string>& search_terms,
|
|
|
|
size_t start = 0) {
|
|
|
|
return IndexOfLine(search_terms, start) != std::string::npos;
|
2017-10-13 07:13:19 +00:00
|
|
|
}
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
// Calls IndexOfLine for each set of substring terms in
|
|
|
|
// |all_line_search_terms|, in order. Returns true if they're all found.
|
|
|
|
bool ContainsLinesInOrder(
|
|
|
|
const std::vector<std::vector<std::string>>& all_line_search_terms,
|
|
|
|
size_t start = 0) {
|
|
|
|
CHECK_GT(log_.size(), 0);
|
|
|
|
for (auto& search_terms : all_line_search_terms) {
|
|
|
|
start = IndexOfLine(search_terms, start);
|
|
|
|
if (start == std::string::npos) return false;
|
|
|
|
++start; // Skip the found line.
|
2017-11-14 09:12:52 +00:00
|
|
|
}
|
2018-08-21 14:33:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-11-27 08:08:59 +00:00
|
|
|
std::unordered_set<uintptr_t> ExtractLogAddresses(std::string search_term,
|
|
|
|
size_t address_column,
|
|
|
|
bool allow_duplicates) {
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK_GT(log_.size(), 0);
|
2018-11-27 08:08:59 +00:00
|
|
|
// Map addresses of Maps to log_lines.
|
|
|
|
std::unordered_map<uintptr_t, std::string> map;
|
|
|
|
size_t current = 0;
|
2018-08-21 14:33:00 +00:00
|
|
|
while (true) {
|
2018-11-27 08:08:59 +00:00
|
|
|
current = IndexOfLine({search_term}, current);
|
|
|
|
if (current == std::string::npos) break;
|
|
|
|
std::string current_line = log_.at(current);
|
|
|
|
std::vector<std::string> columns = Split(current_line, ',');
|
|
|
|
++current; // Skip the found line.
|
2018-08-27 09:17:21 +00:00
|
|
|
// TODO(crbug.com/v8/8084): These two continue lines should really be
|
|
|
|
// errors. But on Windows the log is sometimes mysteriously cut off at the
|
|
|
|
// end. If the cut-off point happens to fall in the address field, the
|
|
|
|
// conditions will be triggered.
|
|
|
|
if (address_column >= columns.size()) continue;
|
2018-08-21 14:33:00 +00:00
|
|
|
uintptr_t address =
|
|
|
|
strtoll(columns.at(address_column).c_str(), nullptr, 16);
|
2018-08-27 09:17:21 +00:00
|
|
|
if (address == 0) continue;
|
2018-11-27 08:08:59 +00:00
|
|
|
if (!allow_duplicates) {
|
|
|
|
auto match = map.find(address);
|
|
|
|
// Ignore same address but different log line.
|
|
|
|
if (match != map.end() && match->second.compare(current_line) == 0) {
|
|
|
|
for (size_t i = 0; i < current; i++) {
|
|
|
|
printf("%s\n", log_.at(i).c_str());
|
|
|
|
}
|
|
|
|
printf("%zu\n", current);
|
2019-05-10 18:55:22 +00:00
|
|
|
FATAL("%s, ... %p apperead twice:\n %s", search_term.c_str(),
|
|
|
|
reinterpret_cast<void*>(address), current_line.c_str());
|
2018-11-27 08:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
map.insert({address, current_line});
|
|
|
|
}
|
|
|
|
// Extract all keys.
|
|
|
|
std::unordered_set<uintptr_t> result;
|
|
|
|
for (auto key_value : map) {
|
|
|
|
result.insert(key_value.first);
|
2017-10-30 10:44:59 +00:00
|
|
|
}
|
2018-08-21 14:33:00 +00:00
|
|
|
return result;
|
2017-10-30 10:44:59 +00:00
|
|
|
}
|
|
|
|
|
2018-08-22 13:57:49 +00:00
|
|
|
void LogCodeObjects() { logger_->LogCodeObjects(); }
|
2017-10-13 07:13:19 +00:00
|
|
|
void LogCompiledFunctions() { logger_->LogCompiledFunctions(); }
|
|
|
|
|
|
|
|
void StringEvent(const char* name, const char* value) {
|
|
|
|
logger_->StringEvent(name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
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_;
|
2018-08-21 14:33:00 +00:00
|
|
|
|
|
|
|
std::string raw_log_;
|
|
|
|
std::vector<std::string> 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()) {
|
2018-08-21 14:33:00 +00:00
|
|
|
if (event_log_.empty()) return 0;
|
2018-08-07 10:35:45 +00:00
|
|
|
|
|
|
|
size_t match = 0;
|
2018-08-21 14:33:00 +00:00
|
|
|
for (const std::string& line : event_log_) {
|
2018-08-07 10:35:45 +00:00
|
|
|
size_t prefix_pos = line.find(prefix);
|
|
|
|
if (prefix_pos == std::string::npos) continue;
|
|
|
|
size_t suffix_pos = line.rfind(suffix);
|
|
|
|
if (suffix_pos == std::string::npos) continue;
|
|
|
|
if (suffix_pos != line.length() - suffix.length()) continue;
|
|
|
|
if (prefix_pos >= suffix_pos) continue;
|
|
|
|
match++;
|
|
|
|
}
|
2018-06-15 18:16:09 +00:00
|
|
|
|
2018-08-07 10:35:45 +00:00
|
|
|
return match;
|
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);
|
2018-08-21 14:33:00 +00:00
|
|
|
event_log_.push_back(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-08-21 14:33:00 +00:00
|
|
|
std::vector<std::string> event_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
|
|
|
|
|
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)
|
2019-04-29 14:56:08 +00:00
|
|
|
: utf_source_(i::OwnedVector<uint16_t>::Of(i::CStrVector(source))) {}
|
2018-09-14 15:34:02 +00:00
|
|
|
~SimpleExternalString() override = default;
|
2019-04-29 14:56:08 +00:00
|
|
|
size_t length() const override { return utf_source_.size(); }
|
2019-04-29 11:06:49 +00:00
|
|
|
const uint16_t* data() const override { return utf_source_.begin(); }
|
|
|
|
|
2009-10-07 12:20:02 +00:00
|
|
|
private:
|
2019-04-29 14:56:08 +00:00
|
|
|
i::OwnedVector<uint16_t> utf_source_;
|
2009-10-07 12:20:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // 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();
|
2019-03-07 18:54:37 +00:00
|
|
|
v8::Local<v8::Script> evil_script =
|
|
|
|
CompileWithOrigin(source, origin, v8_bool(false));
|
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-26 06:42:03 +00:00
|
|
|
i_source->SetResource(CcTest::i_isolate(), 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
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_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();
|
|
|
|
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
|
2018-08-21 14:33:00 +00:00
|
|
|
i::EmbeddedVector<char, 100> suffix_buffer;
|
|
|
|
i::SNPrintF(suffix_buffer, ",0x%" V8PRIxPTR ",1,method1", ObjMethod1_entry);
|
|
|
|
CHECK(logger.ContainsLine(
|
2019-04-29 11:06:49 +00:00
|
|
|
{"code-creation,Callback,-2,", std::string(suffix_buffer.begin())}));
|
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
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_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);
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"code-creation,Callback,-2,",
|
2019-04-29 11:06:49 +00:00
|
|
|
std::string(prop1_getter_record.begin())}));
|
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);
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"code-creation,Callback,-2,",
|
2019-04-29 11:06:49 +00:00
|
|
|
std::string(prop1_setter_record.begin())}));
|
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);
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"code-creation,Callback,-2,",
|
2019-04-29 11:06:49 +00:00
|
|
|
std::string(prop2_getter_record.begin())}));
|
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
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_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();
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
i::EmbeddedVector<char, 100> line_buffer;
|
|
|
|
i::SNPrintF(line_buffer, "%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());
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(
|
2019-04-29 11:06:49 +00:00
|
|
|
logger.ContainsLine({"v8-version,", std::string(line_buffer.begin())}));
|
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.
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_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) {}
|
|
|
|
|
2018-11-25 03:47:59 +00:00
|
|
|
void CodeMoveEvent(i::AbstractCode from, i::AbstractCode to) override {}
|
|
|
|
void CodeDisableOptEvent(i::AbstractCode code,
|
2018-11-28 19:57:30 +00:00
|
|
|
i::SharedFunctionInfo shared) override {}
|
2015-10-13 12:45:15 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-28 19:57:30 +00:00
|
|
|
void LogRecordedBuffer(i::AbstractCode code, i::SharedFunctionInfo shared,
|
2016-02-26 11:04:04 +00:00
|
|
|
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 {}
|
2019-03-07 12:06:36 +00:00
|
|
|
};
|
|
|
|
|
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);
|
2019-03-07 12:06:36 +00:00
|
|
|
FakeCodeEventLogger code_event_logger(reinterpret_cast<i::Isolate*>(isolate));
|
2015-10-13 12:45:15 +00:00
|
|
|
|
|
|
|
{
|
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
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(LogAll) {
|
2017-10-20 22:07:50 +00:00
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_log_all = true;
|
2018-09-17 08:44:19 +00:00
|
|
|
i::FLAG_turbo_inlining = false;
|
2018-11-30 10:18:20 +00:00
|
|
|
i::FLAG_allow_natives_syntax = true;
|
2017-10-20 22:07:50 +00:00
|
|
|
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);
|
|
|
|
|
2018-11-30 10:18:20 +00:00
|
|
|
const char* source_text = R"(
|
|
|
|
function testAddFn(a,b) {
|
|
|
|
return a + b
|
|
|
|
};
|
|
|
|
let result;
|
|
|
|
|
|
|
|
// Warm up the ICs.
|
2019-04-30 11:04:41 +00:00
|
|
|
%PrepareFunctionForOptimization(testAddFn);
|
2018-11-30 10:18:20 +00:00
|
|
|
for (let i = 0; i < 100000; i++) {
|
|
|
|
result = testAddFn(i, i);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Enforce optimization.
|
|
|
|
%OptimizeFunctionOnNextCall(testAddFn);
|
|
|
|
result = testAddFn(1, 1);
|
|
|
|
|
|
|
|
// Cause deopt.
|
|
|
|
testAddFn('1', 1)
|
|
|
|
for (let i = 0; i < 100000; i++) {
|
|
|
|
result = testAddFn('1', i);
|
|
|
|
}
|
|
|
|
)";
|
2017-10-20 22:07:50 +00:00
|
|
|
CompileRun(source_text);
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
// We should find at least one code-creation even for testAddFn();
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"api,v8::Context::New"}));
|
|
|
|
CHECK(logger.ContainsLine({"timer-event-start", "V8.CompileCode"}));
|
|
|
|
CHECK(logger.ContainsLine({"timer-event-end", "V8.CompileCode"}));
|
|
|
|
CHECK(logger.ContainsLine({"code-creation,Script", ":1:1"}));
|
|
|
|
CHECK(logger.ContainsLine({"api,v8::Script::Run"}));
|
|
|
|
CHECK(logger.ContainsLine({"code-creation,LazyCompile,", "testAddFn"}));
|
2018-11-30 10:18:20 +00:00
|
|
|
|
2017-10-20 22:07:50 +00:00
|
|
|
if (i::FLAG_opt && !i::FLAG_always_opt) {
|
2018-10-06 19:32:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"code-deopt,", "not a Smi"}));
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"timer-event-start", "V8.DeoptimizeCode"}));
|
|
|
|
CHECK(logger.ContainsLine({"timer-event-end", "V8.DeoptimizeCode"}));
|
2017-10-20 22:07:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-27 03:01:08 +00:00
|
|
|
|
2019-01-22 14:45:10 +00:00
|
|
|
#ifndef V8_TARGET_ARCH_ARM
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(LogInterpretedFramesNativeStack) {
|
2018-04-10 14:31:06 +00:00
|
|
|
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();
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine(
|
|
|
|
{"InterpretedFunction", "testLogInterpretedFramesNativeStack"}));
|
2018-04-10 14:31:06 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2019-04-22 23:39:50 +00:00
|
|
|
|
|
|
|
UNINITIALIZED_TEST(LogInterpretedFramesNativeStackWithSerialization) {
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_interpreted_frames_native_stack = true;
|
|
|
|
i::FLAG_always_opt = false;
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
|
|
|
|
v8::ScriptCompiler::CachedData* cache = nullptr;
|
|
|
|
|
|
|
|
bool has_cache = cache != nullptr;
|
|
|
|
// NOTE(mmarchini): Runs the test two times. The first time it will compile
|
|
|
|
// our script and will create a code cache for it. The second time we'll
|
|
|
|
// deserialize the cache and check if our function was logged correctly.
|
|
|
|
// We disallow compilation on the second run to ensure we're loading from
|
|
|
|
// cache.
|
|
|
|
do {
|
|
|
|
v8::Isolate* isolate = v8::Isolate::New(create_params);
|
|
|
|
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
|
|
|
|
has_cache = cache != nullptr;
|
|
|
|
v8::ScriptCompiler::CompileOptions options =
|
|
|
|
has_cache ? v8::ScriptCompiler::kConsumeCodeCache
|
|
|
|
: v8::ScriptCompiler::kEagerCompile;
|
|
|
|
|
|
|
|
v8::HandleScope scope(isolate);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
|
|
|
v8::Local<v8::String> source = v8_str(
|
|
|
|
"function eyecatcher() { return a * a; } return eyecatcher();");
|
|
|
|
v8::Local<v8::String> arg_str = v8_str("a");
|
|
|
|
v8::ScriptOrigin origin(v8_str("filename"));
|
|
|
|
|
|
|
|
i::DisallowCompilation* no_compile_expected =
|
|
|
|
has_cache ? new i::DisallowCompilation(
|
|
|
|
reinterpret_cast<i::Isolate*>(isolate))
|
|
|
|
: nullptr;
|
|
|
|
|
|
|
|
v8::ScriptCompiler::Source script_source(source, origin, cache);
|
|
|
|
v8::Local<v8::Function> fun =
|
|
|
|
v8::ScriptCompiler::CompileFunctionInContext(
|
|
|
|
context, &script_source, 1, &arg_str, 0, nullptr, options)
|
|
|
|
.ToLocalChecked();
|
|
|
|
if (has_cache) {
|
|
|
|
logger.StopLogging();
|
|
|
|
CHECK(logger.ContainsLine({"InterpretedFunction", "eyecatcher"}));
|
|
|
|
}
|
|
|
|
v8::Local<v8::Value> arg = v8_num(3);
|
|
|
|
v8::Local<v8::Value> result =
|
|
|
|
fun->Call(context, v8::Undefined(isolate), 1, &arg).ToLocalChecked();
|
|
|
|
CHECK_EQ(9, result->Int32Value(context).FromJust());
|
|
|
|
cache = v8::ScriptCompiler::CreateCodeCacheForFunction(fun);
|
|
|
|
|
|
|
|
if (no_compile_expected != nullptr) delete no_compile_expected;
|
|
|
|
}
|
|
|
|
|
|
|
|
isolate->Dispose();
|
|
|
|
} while (!has_cache);
|
|
|
|
delete cache;
|
|
|
|
}
|
2019-01-22 14:45:10 +00:00
|
|
|
#endif // V8_TARGET_ARCH_ARM
|
2018-04-10 14:31:06 +00:00
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(ExternalCodeEventListener) {
|
2018-05-28 08:33:07 +00:00
|
|
|
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);
|
2019-01-11 11:52:27 +00:00
|
|
|
v8::Context::Scope context_scope(context);
|
2018-05-28 08:33:07 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(ExternalCodeEventListenerInnerFunctions) {
|
2019-01-11 11:52:27 +00:00
|
|
|
i::FLAG_log = false;
|
|
|
|
i::FLAG_prof = false;
|
|
|
|
|
|
|
|
v8::ScriptCompiler::CachedData* cache;
|
|
|
|
static const char* source_cstring =
|
|
|
|
"(function f1() { return (function f2() {}); })()";
|
|
|
|
|
|
|
|
v8::Isolate::CreateParams create_params;
|
|
|
|
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
|
|
|
|
v8::Isolate* isolate1 = v8::Isolate::New(create_params);
|
|
|
|
{ // Test that we emit the correct code events from eagerly compiling.
|
|
|
|
v8::HandleScope scope(isolate1);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate1);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate1);
|
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
TestCodeEventHandler code_event_handler(isolate1);
|
|
|
|
code_event_handler.Enable();
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_string = v8_str(source_cstring);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_string, origin);
|
|
|
|
v8::Local<v8::UnboundScript> script =
|
|
|
|
v8::ScriptCompiler::CompileUnboundScript(isolate1, &source)
|
|
|
|
.ToLocalChecked();
|
|
|
|
CHECK_EQ(code_event_handler.CountLines("Script", "f1"), 1);
|
|
|
|
CHECK_EQ(code_event_handler.CountLines("Script", "f2"), 1);
|
|
|
|
cache = v8::ScriptCompiler::CreateCodeCache(script);
|
|
|
|
}
|
|
|
|
isolate1->Dispose();
|
|
|
|
|
|
|
|
v8::Isolate* isolate2 = v8::Isolate::New(create_params);
|
|
|
|
{ // Test that we emit the correct code events from deserialization.
|
|
|
|
v8::HandleScope scope(isolate2);
|
|
|
|
v8::Isolate::Scope isolate_scope(isolate2);
|
|
|
|
v8::Local<v8::Context> context = v8::Context::New(isolate2);
|
|
|
|
v8::Context::Scope context_scope(context);
|
|
|
|
|
|
|
|
TestCodeEventHandler code_event_handler(isolate2);
|
|
|
|
code_event_handler.Enable();
|
|
|
|
|
|
|
|
v8::Local<v8::String> source_string = v8_str(source_cstring);
|
|
|
|
v8::ScriptOrigin origin(v8_str("test"));
|
|
|
|
v8::ScriptCompiler::Source source(source_string, origin, cache);
|
|
|
|
{
|
|
|
|
i::DisallowCompilation no_compile_expected(
|
|
|
|
reinterpret_cast<i::Isolate*>(isolate2));
|
|
|
|
v8::ScriptCompiler::CompileUnboundScript(
|
|
|
|
isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache)
|
|
|
|
.ToLocalChecked();
|
|
|
|
}
|
|
|
|
CHECK_EQ(code_event_handler.CountLines("Script", "f1"), 1);
|
|
|
|
CHECK_EQ(code_event_handler.CountLines("Script", "f2"), 1);
|
|
|
|
}
|
|
|
|
isolate2->Dispose();
|
|
|
|
}
|
|
|
|
|
2019-01-22 14:45:10 +00:00
|
|
|
#ifndef V8_TARGET_ARCH_ARM
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
|
2018-06-08 19:13:00 +00:00
|
|
|
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();
|
|
|
|
}
|
2019-01-22 14:45:10 +00:00
|
|
|
#endif // V8_TARGET_ARCH_ARM
|
2018-06-08 19:13:00 +00:00
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(TraceMaps) {
|
2017-10-27 03:01:08 +00:00
|
|
|
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.
|
2018-11-27 08:08:59 +00:00
|
|
|
const char* source_text = R"(
|
|
|
|
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 = {};
|
|
|
|
)";
|
|
|
|
CompileRunChecked(isolate, source_text);
|
2017-10-27 03:01:08 +00:00
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
// Mostly superficial checks.
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLine({"map,InitialMap", ",0x"}));
|
|
|
|
CHECK(logger.ContainsLine({"map,Transition", ",0x"}));
|
|
|
|
CHECK(logger.ContainsLine({"map-details", ",0x"}));
|
2017-10-27 03:01:08 +00:00
|
|
|
}
|
|
|
|
i::FLAG_trace_maps = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-30 10:44:59 +00:00
|
|
|
|
2018-11-27 08:08:59 +00:00
|
|
|
namespace {
|
|
|
|
// Ensure that all Maps found on the heap have a single corresponding map-create
|
|
|
|
// and map-details entry in the v8.log.
|
|
|
|
void ValidateMapDetailsLogging(v8::Isolate* isolate,
|
|
|
|
ScopedLoggerInitializer* logger) {
|
|
|
|
// map-create might have duplicates if a Map address is reused after a gc.
|
|
|
|
std::unordered_set<uintptr_t> map_create_addresses =
|
|
|
|
logger->ExtractLogAddresses("map-create", 2, true);
|
|
|
|
std::unordered_set<uintptr_t> map_details_addresses =
|
|
|
|
logger->ExtractLogAddresses("map-details", 2, false);
|
|
|
|
|
|
|
|
// Iterate over all maps on the heap.
|
|
|
|
i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap();
|
2019-06-13 10:51:22 +00:00
|
|
|
i::HeapObjectIterator iterator(heap);
|
2018-11-27 08:08:59 +00:00
|
|
|
i::DisallowHeapAllocation no_gc;
|
|
|
|
size_t i = 0;
|
2019-05-31 10:59:12 +00:00
|
|
|
for (i::HeapObject obj = iterator.Next(); !obj.is_null();
|
|
|
|
obj = iterator.Next()) {
|
2019-05-23 07:47:44 +00:00
|
|
|
if (!obj.IsMap()) continue;
|
2018-11-27 08:08:59 +00:00
|
|
|
i++;
|
2019-05-23 07:47:44 +00:00
|
|
|
uintptr_t address = obj.ptr();
|
2018-11-27 08:08:59 +00:00
|
|
|
if (map_create_addresses.find(address) == map_create_addresses.end()) {
|
|
|
|
// logger->PrintLog();
|
2019-05-23 07:47:44 +00:00
|
|
|
i::Map::cast(obj).Print();
|
2019-05-10 18:55:22 +00:00
|
|
|
FATAL(
|
|
|
|
"Map (%p, #%zu) creation not logged during startup with "
|
|
|
|
"--trace-maps!"
|
|
|
|
"\n# Expected Log Line: map-create, ... %p",
|
2019-05-23 07:47:44 +00:00
|
|
|
reinterpret_cast<void*>(obj.ptr()), i,
|
|
|
|
reinterpret_cast<void*>(obj.ptr()));
|
2018-11-27 08:08:59 +00:00
|
|
|
} else if (map_details_addresses.find(address) ==
|
|
|
|
map_details_addresses.end()) {
|
|
|
|
// logger->PrintLog();
|
2019-05-23 07:47:44 +00:00
|
|
|
i::Map::cast(obj).Print();
|
2019-05-10 18:55:22 +00:00
|
|
|
FATAL(
|
|
|
|
"Map (%p, #%zu) details not logged during startup with "
|
|
|
|
"--trace-maps!"
|
|
|
|
"\n# Expected Log Line: map-details, ... %p",
|
2019-05-23 07:47:44 +00:00
|
|
|
reinterpret_cast<void*>(obj.ptr()), i,
|
|
|
|
reinterpret_cast<void*>(obj.ptr()));
|
2018-11-27 08:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(LogMapsDetailsStartup) {
|
2018-11-27 08:08:59 +00:00
|
|
|
// Reusing map addresses might cause these tests to fail.
|
|
|
|
if (i::FLAG_gc_global || i::FLAG_stress_compaction ||
|
|
|
|
i::FLAG_stress_incremental_marking) {
|
|
|
|
return;
|
|
|
|
}
|
2017-11-28 16:12:09 +00:00
|
|
|
// 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();
|
2018-11-27 08:08:59 +00:00
|
|
|
ValidateMapDetailsLogging(isolate, &logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(LogMapsDetailsCode) {
|
2018-11-27 08:08:59 +00:00
|
|
|
// Reusing map addresses might cause these tests to fail.
|
|
|
|
if (i::FLAG_gc_global || i::FLAG_stress_compaction ||
|
|
|
|
i::FLAG_stress_incremental_marking) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SETUP_FLAGS();
|
|
|
|
i::FLAG_retain_maps_for_n_gc = 0xFFFFFFF;
|
|
|
|
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);
|
|
|
|
const char* source = R"(
|
|
|
|
// Normal properties overflowing into dict-mode.
|
|
|
|
let a = {};
|
|
|
|
for (let i = 0; i < 500; i++) {
|
|
|
|
a['p'+i] = i
|
|
|
|
};
|
|
|
|
// Constructor / initial maps
|
|
|
|
function Constructor(dictElements=false) {
|
|
|
|
this.a = 1;
|
|
|
|
this.b = 2;
|
|
|
|
this.c = 3;
|
|
|
|
if (dictElements) {
|
|
|
|
this[0xFFFFF] = 1;
|
|
|
|
}
|
|
|
|
this.d = 4;
|
|
|
|
this.e = 5;
|
|
|
|
this.f = 5;
|
|
|
|
}
|
|
|
|
// Keep objects and their maps alive to avoid reusing map addresses.
|
|
|
|
let instances = [];
|
|
|
|
let instance;
|
|
|
|
for (let i =0; i < 500; i++) {
|
|
|
|
instances.push(new Constructor());
|
2017-11-28 16:12:09 +00:00
|
|
|
}
|
2018-11-27 08:08:59 +00:00
|
|
|
// Map deprecation.
|
|
|
|
for (let i =0; i < 500; i++) {
|
|
|
|
instance = new Constructor();
|
|
|
|
instance.d = 1.1;
|
|
|
|
instances.push(instance);
|
|
|
|
}
|
|
|
|
for (let i =0; i < 500; i++) {
|
|
|
|
instance = new Constructor();
|
|
|
|
instance.b = 1.1;
|
|
|
|
instances.push(instance);
|
|
|
|
}
|
|
|
|
for (let i =0; i < 500; i++) {
|
|
|
|
instance = new Constructor();
|
|
|
|
instance.c = Object;
|
|
|
|
instances.push(instance);
|
|
|
|
}
|
|
|
|
// Create instance with dict-elements.
|
|
|
|
instances.push(new Constructor(true));
|
|
|
|
|
|
|
|
// Class
|
|
|
|
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);
|
|
|
|
instances.push(t);
|
|
|
|
}
|
|
|
|
t.b = {};
|
|
|
|
|
|
|
|
// Anonymous classes
|
|
|
|
function create(value) {
|
|
|
|
return new class {
|
|
|
|
constructor() {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
instances.push(create(i));
|
|
|
|
};
|
|
|
|
|
|
|
|
// Modifying some protoypes.
|
|
|
|
Array.prototype.helper = () => 1;
|
|
|
|
[1,2,3].helper();
|
|
|
|
)";
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
CompileRunChecked(isolate, source);
|
|
|
|
logger.StopLogging();
|
|
|
|
ValidateMapDetailsLogging(isolate, &logger);
|
|
|
|
}
|
|
|
|
|
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(LogMapsDetailsContexts) {
|
2018-11-27 08:08:59 +00:00
|
|
|
// Reusing map addresses might cause these tests to fail.
|
|
|
|
if (i::FLAG_gc_global || i::FLAG_stress_compaction ||
|
|
|
|
i::FLAG_stress_incremental_marking) {
|
|
|
|
return;
|
2017-11-28 16:12:09 +00:00
|
|
|
}
|
2018-11-27 08:08:59 +00:00
|
|
|
// 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);
|
|
|
|
// Use the default context.
|
|
|
|
CompileRunChecked(isolate, "{a:1}");
|
|
|
|
// Create additional contexts.
|
|
|
|
v8::Local<v8::Context> env1 = v8::Context::New(isolate);
|
|
|
|
env1->Enter();
|
|
|
|
CompileRun(env1, "{b:1}").ToLocalChecked();
|
|
|
|
|
|
|
|
v8::Local<v8::Context> env2 = v8::Context::New(isolate);
|
|
|
|
env2->Enter();
|
|
|
|
CompileRun(env2, "{c:1}").ToLocalChecked();
|
|
|
|
env2->Exit();
|
|
|
|
env1->Exit();
|
|
|
|
|
|
|
|
logger.StopLogging();
|
|
|
|
ValidateMapDetailsLogging(isolate, &logger);
|
|
|
|
}
|
|
|
|
|
2017-11-28 16:12:09 +00:00
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(ConsoleTimeEvents) {
|
2017-10-30 10:44:59 +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);
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2018-08-21 14:33:00 +00:00
|
|
|
std::vector<std::vector<std::string>> lines = {
|
|
|
|
{"timer-event-start,default,"}, {"timer-event-end,default,"},
|
|
|
|
{"timer-event,default,"}, {"timer-event-start,timerEvent1,"},
|
|
|
|
{"timer-event-end,timerEvent1,"}, {"timer-event,timerEvent2,"},
|
|
|
|
{"timer-event,timerEvent3,"}};
|
|
|
|
CHECK(logger.ContainsLinesInOrder(lines));
|
2017-10-30 10:44:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2017-10-30 13:18:12 +00:00
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_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
|
2018-08-21 14:33:00 +00:00
|
|
|
size_t start = logger.IndexOfLine(
|
|
|
|
{"function,first-execution", "warmUpEndMarkerFunction"});
|
|
|
|
CHECK(start != std::string::npos);
|
|
|
|
std::vector<std::vector<std::string>> lines = {
|
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
|
2018-08-21 14:33:00 +00:00
|
|
|
{"script,create"},
|
|
|
|
{"script-details"},
|
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.
|
2018-08-21 14:33:00 +00:00
|
|
|
{"function,parse-script,"},
|
2017-11-14 09:12:52 +00:00
|
|
|
|
|
|
|
// Step 2: compiling top-level script and eager functions
|
|
|
|
// - Compiling script without name.
|
2018-08-21 14:33:00 +00:00
|
|
|
{"function,compile,"},
|
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
|
|
|
};
|
2018-08-21 14:33:00 +00:00
|
|
|
CHECK(logger.ContainsLinesInOrder(lines, start));
|
2017-10-30 13:18:12 +00:00
|
|
|
}
|
|
|
|
i::FLAG_log_function_events = false;
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|
2018-08-22 13:57:49 +00:00
|
|
|
|
2019-03-07 12:06:36 +00:00
|
|
|
UNINITIALIZED_TEST(BuiltinsNotLoggedAsLazyCompile) {
|
2018-08-22 13:57:49 +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);
|
|
|
|
{
|
|
|
|
ScopedLoggerInitializer logger(saved_log, saved_prof, isolate);
|
|
|
|
|
|
|
|
logger.LogCodeObjects();
|
|
|
|
logger.LogCompiledFunctions();
|
|
|
|
logger.StopLogging();
|
|
|
|
|
|
|
|
i::Handle<i::Code> builtin = logger.i_isolate()->builtins()->builtin_handle(
|
|
|
|
i::Builtins::kBooleanConstructor);
|
|
|
|
i::EmbeddedVector<char, 100> buffer;
|
|
|
|
|
|
|
|
// Should only be logged as "Builtin" with a name, never as "LazyCompile".
|
|
|
|
i::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,BooleanConstructor",
|
|
|
|
builtin->InstructionStart(), builtin->InstructionSize());
|
|
|
|
CHECK(logger.ContainsLine(
|
2019-04-29 11:06:49 +00:00
|
|
|
{"code-creation,Builtin,3,", std::string(buffer.begin())}));
|
2018-08-22 13:57:49 +00:00
|
|
|
|
|
|
|
i::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,", builtin->InstructionStart(),
|
|
|
|
builtin->InstructionSize());
|
|
|
|
CHECK(!logger.ContainsLine(
|
2019-04-29 11:06:49 +00:00
|
|
|
{"code-creation,LazyCompile,3,", std::string(buffer.begin())}));
|
2018-08-22 13:57:49 +00:00
|
|
|
}
|
|
|
|
isolate->Dispose();
|
|
|
|
}
|