src: add patches for Node upgrade v10.6.0 (#626)

Update patches in preparation for the upgrade to Chromium 67

Included commits:
62ca2cf21c deps: cherry-pick 70c4340 from upstream V8
ab27e0e785 deps: cherry-pick acc336c from upstream V8
37a5c8c2ff deps: cherry-pick b20faff from upstream V8
4663d1c22e deps: backport aa6ce3e from upstream V8
5d7218965d deps: cherry-pick 5dd3395 from upstream V8
14bb905d18 deps: V8: cherry-pick a440efb27f from upstream
35d6661973 deps: cherry-pick 6989b3f6d7 from V8 upstream
4e788dc2f5 deps: backport 91ddb65d from upstream V8
This commit is contained in:
Shelley Vohr 2018-08-04 12:06:25 -07:00 коммит произвёл Aleksei Kuzmin
Родитель 1c700d20eb
Коммит 3a2e1cf307
10 изменённых файлов: 4512 добавлений и 4 удалений

Просмотреть файл

@ -53,3 +53,35 @@ patches:
author: Aleksei Kuzmin <alkuzmin@microsoft.com>
file: backport_23652c5f.patch
description: Node 10.2.0 needs it.
-
owners: codebytere
file: backport_91ddb65d.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_6989b3f6d7.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_a440efb27f.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_5dd3395.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: backport_aa6ce3e.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_b20faff.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_acc336c.patch
description: Node 10.6.0 needs it.
-
owners: codebytere
file: cherry-pick_70c4340.patch
description: Node 10.6.0 needs it.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,12 @@
diff --git a/src/log.cc b/src/log.cc
index 903cc8e2e6..ce917b0be1 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -327,6 +327,7 @@ void PerfBasicLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
const char* name, int length) {
if (FLAG_perf_basic_prof_only_functions &&
(code->kind() != AbstractCode::INTERPRETED_FUNCTION &&
+ code->kind() != AbstractCode::BUILTIN &&
code->kind() != AbstractCode::OPTIMIZED_FUNCTION)) {
return;
}

Просмотреть файл

@ -0,0 +1,300 @@
diff --git a/src/js/intl.js b/src/js/intl.js
index 53fbe1f947..3c7112716c 100644
--- a/src/js/intl.js
+++ b/src/js/intl.js
@@ -152,18 +152,11 @@ var AVAILABLE_LOCALES = {
*/
var DEFAULT_ICU_LOCALE = UNDEFINED;
-function GetDefaultICULocaleJS(service) {
+function GetDefaultICULocaleJS() {
if (IS_UNDEFINED(DEFAULT_ICU_LOCALE)) {
DEFAULT_ICU_LOCALE = %GetDefaultICULocale();
}
- // Check that this is a valid default for this service,
- // otherwise fall back to "und"
- // TODO(littledan,jshin): AvailableLocalesOf sometimes excludes locales
- // which don't require tailoring, but work fine with root data. Look into
- // exposing this fact in ICU or the way Chrome bundles data.
- return (IS_UNDEFINED(service) ||
- HAS_OWN_PROPERTY(getAvailableLocalesOf(service), DEFAULT_ICU_LOCALE))
- ? DEFAULT_ICU_LOCALE : "und";
+ return DEFAULT_ICU_LOCALE;
}
/**
@@ -434,6 +427,48 @@ function resolveLocale(service, requestedLocales, options) {
}
+/**
+ * Look up the longest non-empty prefix of |locale| that is an element of
+ * |availableLocales|. Returns undefined when the |locale| is completely
+ * unsupported by |availableLocales|.
+ */
+function bestAvailableLocale(availableLocales, locale) {
+ do {
+ if (!IS_UNDEFINED(availableLocales[locale])) {
+ return locale;
+ }
+ // Truncate locale if possible.
+ var pos = %StringLastIndexOf(locale, '-');
+ if (pos === -1) {
+ break;
+ }
+ locale = %_Call(StringSubstring, locale, 0, pos);
+ } while (true);
+
+ return UNDEFINED;
+}
+
+
+/**
+ * Try to match any mutation of |requestedLocale| against |availableLocales|.
+ */
+function attemptSingleLookup(availableLocales, requestedLocale) {
+ // Remove all extensions.
+ var noExtensionsLocale = %RegExpInternalReplace(
+ GetAnyExtensionRE(), requestedLocale, '');
+ var availableLocale = bestAvailableLocale(
+ availableLocales, requestedLocale);
+ if (!IS_UNDEFINED(availableLocale)) {
+ // Return the resolved locale and extension.
+ var extensionMatch = %regexp_internal_match(
+ GetUnicodeExtensionRE(), requestedLocale);
+ var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
+ return {locale: availableLocale, extension: extension};
+ }
+ return UNDEFINED;
+}
+
+
/**
* Returns best matched supported locale and extension info using basic
* lookup algorithm.
@@ -446,31 +481,25 @@ function lookupMatcher(service, requestedLocales) {
var availableLocales = getAvailableLocalesOf(service);
for (var i = 0; i < requestedLocales.length; ++i) {
- // Remove all extensions.
- var locale = %RegExpInternalReplace(
- GetAnyExtensionRE(), requestedLocales[i], '');
- do {
- if (!IS_UNDEFINED(availableLocales[locale])) {
- // Return the resolved locale and extension.
- var extensionMatch = %regexp_internal_match(
- GetUnicodeExtensionRE(), requestedLocales[i]);
- var extension = IS_NULL(extensionMatch) ? '' : extensionMatch[0];
- return {locale: locale, extension: extension, position: i};
- }
- // Truncate locale if possible.
- var pos = %StringLastIndexOf(locale, '-');
- if (pos === -1) {
- break;
- }
- locale = %_Call(StringSubstring, locale, 0, pos);
- } while (true);
+ var result = attemptSingleLookup(availableLocales, requestedLocales[i]);
+ if (!IS_UNDEFINED(result)) {
+ return result;
+ }
+ }
+
+ var defLocale = GetDefaultICULocaleJS();
+
+ // While ECMA-402 returns defLocale directly, we have to check if it is
+ // supported, as such support is not guaranteed.
+ var result = attemptSingleLookup(availableLocales, defLocale);
+ if (!IS_UNDEFINED(result)) {
+ return result;
}
// Didn't find a match, return default.
return {
- locale: GetDefaultICULocaleJS(service),
- extension: '',
- position: -1
+ locale: 'und',
+ extension: ''
};
}
diff --git a/test/intl/assert.js b/test/intl/assert.js
index d8cc85849f..c11e7c0bbf 100644
--- a/test/intl/assert.js
+++ b/test/intl/assert.js
@@ -132,6 +132,16 @@ function assertFalse(value, user_message = '') {
}
+/**
+ * Throws if value is null.
+ */
+function assertNotNull(value, user_message = '') {
+ if (value === null) {
+ fail("not null", value, user_message);
+ }
+}
+
+
/**
* Runs code() and asserts that it throws the specified exception.
*/
@@ -189,3 +199,34 @@ function assertInstanceof(obj, type) {
(actualTypeName ? ' but of < ' + actualTypeName + '>' : ''));
}
}
+
+
+/**
+ * Split a BCP 47 language tag into locale and extension.
+ */
+function splitLanguageTag(tag) {
+ var extRe = /(-[0-9A-Za-z](-[0-9A-Za-z]{2,8})+)+$/;
+ var match = %regexp_internal_match(extRe, tag);
+ if (match) {
+ return { locale: tag.slice(0, match.index), extension: match[0] };
+ }
+
+ return { locale: tag, extension: '' };
+}
+
+
+/**
+ * Throw if |parent| is not a more general language tag of |child|, nor |child|
+ * itself, per BCP 47 rules.
+ */
+function assertLanguageTag(child, parent) {
+ var childSplit = splitLanguageTag(child);
+ var parentSplit = splitLanguageTag(parent);
+
+ // Do not compare extensions at this moment, as %GetDefaultICULocale()
+ // doesn't always output something we support.
+ if (childSplit.locale !== parentSplit.locale &&
+ !childSplit.locale.startsWith(parentSplit.locale + '-')) {
+ fail(child, parent, 'language tag comparison');
+ }
+}
diff --git a/test/intl/break-iterator/default-locale.js b/test/intl/break-iterator/default-locale.js
index d8d5aeadb2..e1a42a100a 100644
--- a/test/intl/break-iterator/default-locale.js
+++ b/test/intl/break-iterator/default-locale.js
@@ -37,8 +37,8 @@ assertFalse(options.locale === 'und');
assertFalse(options.locale === '');
assertFalse(options.locale === undefined);
-// Then check for equality.
-assertEquals(options.locale, %GetDefaultICULocale());
+// Then check for legitimacy.
+assertLanguageTag(%GetDefaultICULocale(), options.locale);
var iteratorNone = new Intl.v8BreakIterator();
assertEquals(options.locale, iteratorNone.resolvedOptions().locale);
diff --git a/test/intl/break-iterator/wellformed-unsupported-locale.js b/test/intl/break-iterator/wellformed-unsupported-locale.js
index 5ac8fbcd41..ffa44aef08 100644
--- a/test/intl/break-iterator/wellformed-unsupported-locale.js
+++ b/test/intl/break-iterator/wellformed-unsupported-locale.js
@@ -29,4 +29,4 @@
var iterator = Intl.v8BreakIterator(['xx']);
-assertEquals(iterator.resolvedOptions().locale, %GetDefaultICULocale());
+assertLanguageTag(%GetDefaultICULocale(), iterator.resolvedOptions().locale);
diff --git a/test/intl/collator/default-locale.js b/test/intl/collator/default-locale.js
index db9b1e7330..5fc6ff4665 100644
--- a/test/intl/collator/default-locale.js
+++ b/test/intl/collator/default-locale.js
@@ -37,8 +37,8 @@ assertFalse(options.locale === 'und');
assertFalse(options.locale === '');
assertFalse(options.locale === undefined);
-// Then check for equality.
-assertEquals(options.locale, %GetDefaultICULocale());
+// Then check for legitimacy.
+assertLanguageTag(%GetDefaultICULocale(), options.locale);
var collatorNone = new Intl.Collator();
assertEquals(options.locale, collatorNone.resolvedOptions().locale);
@@ -48,5 +48,8 @@ var collatorBraket = new Intl.Collator({});
assertEquals(options.locale, collatorBraket.resolvedOptions().locale);
var collatorWithOptions = new Intl.Collator(undefined, {usage: 'search'});
-assertEquals(%GetDefaultICULocale() + '-u-co-search',
- collatorWithOptions.resolvedOptions().locale);
+assertLanguageTag(%GetDefaultICULocale(),
+ collatorWithOptions.resolvedOptions().locale);
+assertNotNull(
+ %regexp_internal_match(/-u(-[a-zA-Z]+-[a-zA-Z]+)*-co-search/,
+ collatorWithOptions.resolvedOptions().locale));
diff --git a/test/intl/collator/wellformed-unsupported-locale.js b/test/intl/collator/wellformed-unsupported-locale.js
index 3963d47a61..ad89e3e220 100644
--- a/test/intl/collator/wellformed-unsupported-locale.js
+++ b/test/intl/collator/wellformed-unsupported-locale.js
@@ -29,4 +29,4 @@
var collator = Intl.Collator(['xx']);
-assertEquals(collator.resolvedOptions().locale, %GetDefaultICULocale());
+assertLanguageTag(%GetDefaultICULocale(), collator.resolvedOptions().locale);
diff --git a/test/intl/date-format/default-locale.js b/test/intl/date-format/default-locale.js
index 8e9b7fcec3..2d79e895b5 100644
--- a/test/intl/date-format/default-locale.js
+++ b/test/intl/date-format/default-locale.js
@@ -37,8 +37,8 @@ assertFalse(options.locale === 'und');
assertFalse(options.locale === '');
assertFalse(options.locale === undefined);
-// Then check for equality.
-assertEquals(options.locale, %GetDefaultICULocale());
+// Then check for legitimacy.
+assertLanguageTag(%GetDefaultICULocale(), options.locale);
var dtfNone = new Intl.DateTimeFormat();
assertEquals(options.locale, dtfNone.resolvedOptions().locale);
diff --git a/test/intl/date-format/wellformed-unsupported-locale.js b/test/intl/date-format/wellformed-unsupported-locale.js
index 6f063abbd1..b812164832 100644
--- a/test/intl/date-format/wellformed-unsupported-locale.js
+++ b/test/intl/date-format/wellformed-unsupported-locale.js
@@ -29,4 +29,4 @@
var dtf = Intl.DateTimeFormat(['xx']);
-assertEquals(dtf.resolvedOptions().locale, %GetDefaultICULocale());
+assertLanguageTag(%GetDefaultICULocale(), dtf.resolvedOptions().locale);
diff --git a/test/intl/number-format/default-locale.js b/test/intl/number-format/default-locale.js
index cd67ba724f..a24aec2333 100644
--- a/test/intl/number-format/default-locale.js
+++ b/test/intl/number-format/default-locale.js
@@ -37,8 +37,8 @@ assertFalse(options.locale === 'und');
assertFalse(options.locale === '');
assertFalse(options.locale === undefined);
-// Then check for equality.
-assertEquals(options.locale, %GetDefaultICULocale());
+// Then check for legitimacy.
+assertLanguageTag(%GetDefaultICULocale(), options.locale);
var nfNone = new Intl.NumberFormat();
assertEquals(options.locale, nfNone.resolvedOptions().locale);
diff --git a/test/intl/number-format/wellformed-unsupported-locale.js b/test/intl/number-format/wellformed-unsupported-locale.js
index 195eba4c19..c51753928e 100644
--- a/test/intl/number-format/wellformed-unsupported-locale.js
+++ b/test/intl/number-format/wellformed-unsupported-locale.js
@@ -29,4 +29,4 @@
var nf = Intl.NumberFormat(['xx']);
-assertEquals(nf.resolvedOptions().locale, %GetDefaultICULocale());
+assertLanguageTag(%GetDefaultICULocale(), nf.resolvedOptions().locale);
diff --git a/test/mjsunit/regress/regress-6288.js b/test/mjsunit/regress/regress-6288.js
index 337af54c1a..5f550c31c8 100644
--- a/test/mjsunit/regress/regress-6288.js
+++ b/test/mjsunit/regress/regress-6288.js
@@ -8,6 +8,6 @@
// DateTimeFormat but not Collation
if (this.Intl) {
- assertEquals('und', Intl.Collator().resolvedOptions().locale);
+ assertEquals('pt', Intl.Collator().resolvedOptions().locale);
assertEquals('pt-BR', Intl.DateTimeFormat().resolvedOptions().locale);
}

Просмотреть файл

@ -0,0 +1,30 @@
diff --git a/src/api.cc b/src/api.cc
index b46d376837..a97b38d00a 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -10217,6 +10217,10 @@ const char* CodeEvent::GetCodeEventTypeName(CodeEventType code_event_type) {
CODE_EVENTS_LIST(V)
#undef V
}
+ // The execution should never pass here
+ UNREACHABLE();
+ // NOTE(mmarchini): Workaround to fix a compiler failure on GCC 4.9
+ return "Unknown";
}
CodeEventHandler::CodeEventHandler(Isolate* isolate) {
diff --git a/src/log.cc b/src/log.cc
index d1673715e5..f70acbd54d 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -59,6 +59,10 @@ static v8::CodeEventType GetCodeEventTypeForTag(
TAGS_LIST(V)
#undef V
}
+ // The execution should never pass here
+ UNREACHABLE();
+ // NOTE(mmarchini): Workaround to fix a compiler failure on GCC 4.9
+ return v8::CodeEventType::kUnknownType;
}
#define CALL_CODE_EVENT_HANDLER(Call) \
if (listener_) { \

Просмотреть файл

@ -0,0 +1,225 @@
diff --git a/include/v8.h b/include/v8.h
index 29566f4303..07a500f7ff 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -1578,6 +1578,9 @@ class V8_EXPORT ScriptCompiler {
* This will return nullptr if the script cannot be serialized. The
* CachedData returned by this function should be owned by the caller.
*/
+ static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script);
+
+ // Deprecated.
static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script,
Local<String> source);
@@ -1587,6 +1590,9 @@ class V8_EXPORT ScriptCompiler {
* This will return nullptr if the script cannot be serialized. The
* CachedData returned by this function should be owned by the caller.
*/
+ static CachedData* CreateCodeCacheForFunction(Local<Function> function);
+
+ // Deprecated.
static CachedData* CreateCodeCacheForFunction(Local<Function> function,
Local<String> source);
diff --git a/src/api.cc b/src/api.cc
index 27e7598bfa..61b1be1401 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2628,21 +2628,29 @@ uint32_t ScriptCompiler::CachedDataVersionTag() {
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
Local<UnboundScript> unbound_script, Local<String> source) {
+ return CreateCodeCache(unbound_script);
+}
+
+ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
+ Local<UnboundScript> unbound_script) {
i::Handle<i::SharedFunctionInfo> shared =
i::Handle<i::SharedFunctionInfo>::cast(
Utils::OpenHandle(*unbound_script));
- i::Handle<i::String> source_str = Utils::OpenHandle(*source);
DCHECK(shared->is_toplevel());
- return i::CodeSerializer::Serialize(shared, source_str);
+ return i::CodeSerializer::Serialize(shared);
}
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction(
Local<Function> function, Local<String> source) {
+ return CreateCodeCacheForFunction(function);
+}
+
+ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction(
+ Local<Function> function) {
i::Handle<i::SharedFunctionInfo> shared(
i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*function))->shared());
- i::Handle<i::String> source_str = Utils::OpenHandle(*source);
CHECK(shared->is_wrapped());
- return i::CodeSerializer::Serialize(shared, source_str);
+ return i::CodeSerializer::Serialize(shared);
}
MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source,
diff --git a/src/d8.cc b/src/d8.cc
index b338dfbb2d..e6ba022795 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -636,7 +636,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
ShellOptions::CodeCacheOptions::kProduceCache) {
// Serialize and store it in memory for the next execution.
ScriptCompiler::CachedData* cached_data =
- ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source);
+ ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
StoreInCodeCache(isolate, source, cached_data);
delete cached_data;
}
@@ -645,7 +645,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) {
// Serialize and store it in memory for the next execution.
ScriptCompiler::CachedData* cached_data =
- ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source);
+ ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
StoreInCodeCache(isolate, source, cached_data);
delete cached_data;
}
diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc
index 2697e9dce4..823d8dc9af 100644
--- a/src/snapshot/code-serializer.cc
+++ b/src/snapshot/code-serializer.cc
@@ -32,7 +32,7 @@ ScriptData::ScriptData(const byte* data, int length)
// static
ScriptCompiler::CachedData* CodeSerializer::Serialize(
- Handle<SharedFunctionInfo> info, Handle<String> source) {
+ Handle<SharedFunctionInfo> info) {
Isolate* isolate = info->GetIsolate();
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
HistogramTimerScope histogram_timer(isolate->counters()->compile_serialize());
@@ -45,8 +45,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
Handle<Script> script(Script::cast(info->script()), isolate);
if (FLAG_trace_serializer) {
PrintF("[Serializing from");
- Object* script = info->script();
- Script::cast(script)->name()->ShortPrint();
+ script->name()->ShortPrint();
PrintF("]\n");
}
// TODO(7110): Enable serialization of Asm modules once the AsmWasmData is
@@ -55,10 +54,11 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
if (isolate->debug()->is_loaded()) return nullptr;
// Serialize code object.
+ Handle<String> source(String::cast(script->source()), isolate);
CodeSerializer cs(isolate, SerializedCodeData::SourceHash(source));
DisallowHeapAllocation no_gc;
cs.reference_map()->AddAttachedReference(*source);
- ScriptData* script_data = cs.Serialize(info);
+ ScriptData* script_data = cs.SerializeSharedFunctionInfo(info);
if (FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
@@ -75,11 +75,12 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
return result;
}
-ScriptData* CodeSerializer::Serialize(Handle<HeapObject> obj) {
+ScriptData* CodeSerializer::SerializeSharedFunctionInfo(
+ Handle<SharedFunctionInfo> info) {
DisallowHeapAllocation no_gc;
VisitRootPointer(Root::kHandleScope, nullptr,
- Handle<Object>::cast(obj).location());
+ Handle<Object>::cast(info).location());
SerializeDeferredObjects();
Pad();
diff --git a/src/snapshot/code-serializer.h b/src/snapshot/code-serializer.h
index 8e97f47f2f..f6b51bf9b1 100644
--- a/src/snapshot/code-serializer.h
+++ b/src/snapshot/code-serializer.h
@@ -45,10 +45,9 @@ class ScriptData {
class CodeSerializer : public Serializer<> {
public:
- static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info,
- Handle<String> source);
+ static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info);
- ScriptData* Serialize(Handle<HeapObject> obj);
+ ScriptData* SerializeSharedFunctionInfo(Handle<SharedFunctionInfo> info);
V8_WARN_UNUSED_RESULT static MaybeHandle<SharedFunctionInfo> Deserialize(
Isolate* isolate, ScriptData* cached_data, Handle<String> source);
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index f242262cf0..fbcc12190e 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -25428,8 +25428,7 @@ TEST(CodeCache) {
v8::ScriptCompiler::kNoCompileOptions;
v8::Local<v8::Script> script =
v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked();
- cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript(),
- source_string);
+ cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
}
isolate1->Dispose();
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 370791f6c2..817561c68a 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -1240,8 +1240,7 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache(
NOT_NATIVES_CODE)
.ToHandleChecked();
std::unique_ptr<ScriptCompiler::CachedData> cached_data(
- ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi),
- Utils::ToLocal(source)));
+ ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi)));
uint8_t* buffer = NewArray<uint8_t>(cached_data->length);
MemCopy(buffer, cached_data->data, cached_data->length);
*script_data = new i::ScriptData(buffer, cached_data->length);
@@ -1895,7 +1894,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
.ToLocalChecked();
if (cacheType != CodeCacheType::kAfterExecute) {
- cache = ScriptCompiler::CreateCodeCache(script, source_str);
+ cache = ScriptCompiler::CreateCodeCache(script);
}
v8::Local<v8::Value> result = script->BindToCurrentContext()
@@ -1907,7 +1906,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
.FromJust());
if (cacheType == CodeCacheType::kAfterExecute) {
- cache = ScriptCompiler::CreateCodeCache(script, source_str);
+ cache = ScriptCompiler::CreateCodeCache(script);
}
CHECK(cache);
}
@@ -2153,7 +2152,7 @@ TEST(CodeSerializerWithHarmonyScoping) {
v8::ScriptCompiler::CompileUnboundScript(
isolate1, &source, v8::ScriptCompiler::kNoCompileOptions)
.ToLocalChecked();
- cache = v8::ScriptCompiler::CreateCodeCache(script, source_str);
+ cache = v8::ScriptCompiler::CreateCodeCache(script);
CHECK(cache);
v8::Local<v8::Value> result = script->BindToCurrentContext()
@@ -2218,7 +2217,7 @@ TEST(Regress503552) {
heap::SimulateIncrementalMarking(isolate->heap());
v8::ScriptCompiler::CachedData* cache_data =
- CodeSerializer::Serialize(shared, source);
+ CodeSerializer::Serialize(shared);
delete cache_data;
}
@@ -3447,7 +3446,7 @@ TEST(CachedCompileFunctionInContext) {
env.local(), &script_source, 1, &arg_str, 0, nullptr,
v8::ScriptCompiler::kEagerCompile)
.ToLocalChecked();
- cache = v8::ScriptCompiler::CreateCodeCacheForFunction(fun, source);
+ cache = v8::ScriptCompiler::CreateCodeCacheForFunction(fun);
}
{

Просмотреть файл

@ -0,0 +1,153 @@
diff --git a/src/log.cc b/src/log.cc
index e50b00a320..832ef7519d 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -2023,7 +2023,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
break;
case AbstractCode::BUILTIN:
if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
- Code::cast(object) ==
+ Code::cast(object) !=
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
return;
}
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index c7864034c9..767541d4a3 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -36,6 +36,9 @@
#include <unordered_set>
#include <vector>
+// The C++ style guide recommends using <re2> instead of <regex>. However, the
+// former isn't available in V8.
+#include <regex> // NOLINT(build/c++11)
#include "src/api.h"
#include "src/log-utils.h"
#include "src/log.h"
@@ -257,30 +260,41 @@ class TestCodeEventHandler : public v8::CodeEventHandler {
explicit TestCodeEventHandler(v8::Isolate* isolate)
: v8::CodeEventHandler(isolate) {}
- const char* FindLine(const char* prefix, const char* suffix = nullptr,
- const char* start = nullptr) {
- if (!log_.length()) return NULL;
- const char* c_log = log_.c_str();
- if (start == nullptr) start = c_log;
- const char* end = c_log + log_.length();
- return FindLogLine(start, end, prefix, suffix);
+ 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;
}
void Handle(v8::CodeEvent* code_event) override {
- const char* code_type =
- v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
- char function_name[1000];
- strncpy(function_name, code_type, 1000);
- function_name[strlen(code_type)] = ' ';
- code_event->GetFunctionName()->WriteUtf8(
- function_name + strlen(code_type) + 1, 1000);
- function_name[strlen(function_name) + 1] = '\0';
- function_name[strlen(function_name)] = '\n';
-
- log_ += std::string(function_name);
+ 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;
}
private:
+ 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();
+ std::string buffer(functionName->Utf8Length() + 1, 0);
+ functionName->WriteUtf8(&buffer[0], functionName->Utf8Length() + 1);
+ // Sanitize name, removing unwanted \0 resulted from WriteUtf8
+ name = std::string(buffer.c_str());
+ }
+
+ return name;
+ }
+
std::string log_;
};
@@ -854,21 +868,24 @@ TEST(ExternalCodeEventListener) {
"testCodeEventListenerBeforeStart('1', 1);";
CompileRun(source_text_before_start);
- CHECK_NULL(code_event_handler.FindLine("LazyCompile",
- "testCodeEventListenerBeforeStart"));
+ CHECK_EQ(code_event_handler.CountLines("LazyCompile",
+ "testCodeEventListenerBeforeStart"),
+ 0);
code_event_handler.Enable();
- CHECK_NOT_NULL(code_event_handler.FindLine(
- "LazyCompile", "testCodeEventListenerBeforeStart"));
+ CHECK_GE(code_event_handler.CountLines("LazyCompile",
+ "testCodeEventListenerBeforeStart"),
+ 1);
const char* source_text_after_start =
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
"testCodeEventListenerAfterStart('1', 1);";
CompileRun(source_text_after_start);
- CHECK_NOT_NULL(code_event_handler.FindLine(
- "LazyCompile", "testCodeEventListenerAfterStart"));
+ CHECK_GE(code_event_handler.CountLines("LazyCompile",
+ "testCodeEventListenerAfterStart"),
+ 1);
context->Exit();
}
@@ -897,21 +914,28 @@ TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
"testCodeEventListenerBeforeStart('1', 1);";
CompileRun(source_text_before_start);
- CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
- "testCodeEventListenerBeforeStart"));
+ CHECK_EQ(code_event_handler.CountLines("InterpretedFunction",
+ "testCodeEventListenerBeforeStart"),
+ 0);
code_event_handler.Enable();
- CHECK_NOT_NULL(code_event_handler.FindLine(
- "InterpretedFunction", "testCodeEventListenerBeforeStart"));
+ CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
+ "testCodeEventListenerBeforeStart"),
+ 1);
const char* source_text_after_start =
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
"testCodeEventListenerAfterStart('1', 1);";
CompileRun(source_text_after_start);
- CHECK_NOT_NULL(code_event_handler.FindLine(
- "InterpretedFunction", "testCodeEventListenerAfterStart"));
+ CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
+ "testCodeEventListenerAfterStart"),
+ 1);
+
+ CHECK_EQ(
+ code_event_handler.CountLines("Builtin", "InterpreterEntryTrampoline"),
+ 1);
context->Exit();
}

Просмотреть файл

@ -0,0 +1,183 @@
diff --git a/src/log.cc b/src/log.cc
index 563fe3c5f0..edd883976d 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -2011,10 +2011,10 @@ FILE* Logger::TearDown() {
}
void ExistingCodeLogger::LogCodeObject(Object* object) {
- AbstractCode* code_object = AbstractCode::cast(object);
+ AbstractCode* abstract_code = AbstractCode::cast(object);
CodeEventListener::LogEventsAndTags tag = CodeEventListener::STUB_TAG;
const char* description = "Unknown code from before profiling";
- switch (code_object->kind()) {
+ switch (abstract_code->kind()) {
case AbstractCode::INTERPRETED_FUNCTION:
case AbstractCode::OPTIMIZED_FUNCTION:
return; // We log this later using LogCompiledFunctions.
@@ -2022,7 +2022,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
return; // We log it later by walking the dispatch table.
case AbstractCode::STUB:
description =
- CodeStub::MajorName(CodeStub::GetMajorKey(code_object->GetCode()));
+ CodeStub::MajorName(CodeStub::GetMajorKey(abstract_code->GetCode()));
if (description == nullptr) description = "A stub from before profiling";
tag = CodeEventListener::STUB_TAG;
break;
@@ -2031,8 +2031,13 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
tag = CodeEventListener::REG_EXP_TAG;
break;
case AbstractCode::BUILTIN:
+ if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
+ Code::cast(object) ==
+ *BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
+ return;
+ }
description =
- isolate_->builtins()->name(code_object->GetCode()->builtin_index());
+ isolate_->builtins()->name(abstract_code->GetCode()->builtin_index());
tag = CodeEventListener::BUILTIN_TAG;
break;
case AbstractCode::WASM_FUNCTION:
@@ -2058,7 +2063,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
case AbstractCode::NUMBER_OF_KINDS:
UNIMPLEMENTED();
}
- CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, code_object, description))
+ CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, abstract_code, description))
}
void ExistingCodeLogger::LogCodeObjects() {
@@ -2084,6 +2089,12 @@ void ExistingCodeLogger::LogCompiledFunctions() {
// During iteration, there can be heap allocation due to
// GetScriptLineNumber call.
for (int i = 0; i < compiled_funcs_count; ++i) {
+ if (sfis[i]->function_data()->IsInterpreterData()) {
+ LogExistingFunction(sfis[i],
+ Handle<AbstractCode>(AbstractCode::cast(
+ sfis[i]->InterpreterTrampoline())),
+ CodeEventListener::INTERPRETED_FUNCTION_TAG);
+ }
if (code_objects[i].is_identical_to(BUILTIN_CODE(isolate_, CompileLazy)))
continue;
LogExistingFunction(sfis[i], code_objects[i]);
@@ -2128,8 +2139,9 @@ void ExistingCodeLogger::LogBytecodeHandlers() {
}
}
-void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
- Handle<AbstractCode> code) {
+void ExistingCodeLogger::LogExistingFunction(
+ Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
+ CodeEventListener::LogEventsAndTags tag) {
if (shared->script()->IsScript()) {
Handle<Script> script(Script::cast(shared->script()));
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
@@ -2139,9 +2151,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<String> script_name(String::cast(script->name()));
if (line_num > 0) {
CALL_CODE_EVENT_HANDLER(
- CodeCreateEvent(Logger::ToNativeByScript(
- CodeEventListener::LAZY_COMPILE_TAG, *script),
- *code, *shared, *script_name, line_num, column_num))
+ CodeCreateEvent(Logger::ToNativeByScript(tag, *script), *code,
+ *shared, *script_name, line_num, column_num))
} else {
// Can't distinguish eval and script here, so always use Script.
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
@@ -2149,11 +2160,9 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
*code, *shared, *script_name))
}
} else {
- CALL_CODE_EVENT_HANDLER(
- CodeCreateEvent(Logger::ToNativeByScript(
- CodeEventListener::LAZY_COMPILE_TAG, *script),
- *code, *shared, isolate_->heap()->empty_string(),
- line_num, column_num))
+ CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
+ Logger::ToNativeByScript(tag, *script), *code, *shared,
+ isolate_->heap()->empty_string(), line_num, column_num))
}
} else if (shared->IsApiFunction()) {
// API function.
@@ -2169,9 +2178,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
CALL_CODE_EVENT_HANDLER(CallbackEvent(shared->DebugName(), entry_point))
}
} else {
- CALL_CODE_EVENT_HANDLER(CodeCreateEvent(CodeEventListener::LAZY_COMPILE_TAG,
- *code, *shared,
- isolate_->heap()->empty_string()))
+ CALL_CODE_EVENT_HANDLER(
+ CodeCreateEvent(tag, *code, *shared, isolate_->heap()->empty_string()))
}
}
diff --git a/src/log.h b/src/log.h
index 738aef4d73..ad254097e6 100644
--- a/src/log.h
+++ b/src/log.h
@@ -109,7 +109,9 @@ class ExistingCodeLogger {
void LogCompiledFunctions();
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
- Handle<AbstractCode> code);
+ Handle<AbstractCode> code,
+ CodeEventListener::LogEventsAndTags tag =
+ CodeEventListener::LAZY_COMPILE_TAG);
void LogCodeObject(Object* object);
void LogBytecodeHandler(interpreter::Bytecode bytecode,
interpreter::OperandScale operand_scale, Code* code);
diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc
index 97071a63f5..c7864034c9 100644
--- a/test/cctest/test-log.cc
+++ b/test/cctest/test-log.cc
@@ -875,6 +875,49 @@ TEST(ExternalCodeEventListener) {
isolate->Dispose();
}
+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);
+
+ CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
+ "testCodeEventListenerBeforeStart"));
+
+ code_event_handler.Enable();
+
+ CHECK_NOT_NULL(code_event_handler.FindLine(
+ "InterpretedFunction", "testCodeEventListenerBeforeStart"));
+
+ const char* source_text_after_start =
+ "function testCodeEventListenerAfterStart(a,b) { return a + b };"
+ "testCodeEventListenerAfterStart('1', 1);";
+ CompileRun(source_text_after_start);
+
+ CHECK_NOT_NULL(code_event_handler.FindLine(
+ "InterpretedFunction", "testCodeEventListenerAfterStart"));
+
+ context->Exit();
+ }
+ isolate->Dispose();
+}
+
TEST(TraceMaps) {
SETUP_FLAGS();
i::FLAG_trace_maps = true;

Просмотреть файл

@ -11,7 +11,7 @@ $ ./script/get-patch --repo src --commit 8e8216e5
2. Create a patch file with a default name if a specified directory.
```
$ ./script/get-patch --repo src --commit 8e8216e5 --output_dir patches
$ ./script/get-patch --repo src --commit 8e8216e5 --output-dir patches
```
3. Create a patch file with a custom name in the current directory.
@ -21,16 +21,16 @@ $ ./script/get-patch --repo src --commit 8e8216e5 --filename my.patch
4. Create a patch file with a custom name in a specified directory.
```
$ ./script/get-patch --repo src --commit 8e8216e5 --output_dir patches --filename my.patch
$ ./script/get-patch --repo src --commit 8e8216e5 --output-dir patches --filename my.patch
```
5. Create patch files with default names in a specified directory.
```
$ ./script/get-patch --repo src --output_dir patches --commit 8e8216e5 164c37e3
$ ./script/get-patch --repo src --output-dir patches --commit 8e8216e5 164c37e3
```
6. Create patch files with custom names in a specified directory.
Note that number of filenames must match the number of commits.
```
$ ./script/get-patch --repo src --output_dir patches --commit 8e8216e5 164c37e3 --filename first.patch second.patch
$ ./script/get-patch --repo src --output-dir patches --commit 8e8216e5 164c37e3 --filename first.patch second.patch
```