Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14bb905

Browse filesBrowse files
hashseedtargos
authored andcommitted
deps: V8: cherry-pick a440efb27f from upstream
Original commit message: [api] do not require source string for producing code cache. The embedder should not need to keep track of the source string. R=jgruber@chromium.org Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: Ie27df755a22fbcae7b6e87a435419d2d8f545558 Reviewed-on: https://chromium-review.googlesource.com/1013482 Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#52614} PR-URL: #21022 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
1 parent 3d8ec8f commit 14bb905
Copy full SHA for 14bb905

File tree

Expand file treeCollapse file tree

8 files changed

+36
-24
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

8 files changed

+36
-24
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.7',
30+
'v8_embedder_string': '-node.8',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,
Collapse file

‎deps/v8/include/v8.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8.h
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,9 @@ class V8_EXPORT ScriptCompiler {
15781578
* This will return nullptr if the script cannot be serialized. The
15791579
* CachedData returned by this function should be owned by the caller.
15801580
*/
1581+
static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script);
1582+
1583+
// Deprecated.
15811584
static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script,
15821585
Local<String> source);
15831586

@@ -1587,6 +1590,9 @@ class V8_EXPORT ScriptCompiler {
15871590
* This will return nullptr if the script cannot be serialized. The
15881591
* CachedData returned by this function should be owned by the caller.
15891592
*/
1593+
static CachedData* CreateCodeCacheForFunction(Local<Function> function);
1594+
1595+
// Deprecated.
15901596
static CachedData* CreateCodeCacheForFunction(Local<Function> function,
15911597
Local<String> source);
15921598

Collapse file

‎deps/v8/src/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api.cc
+12-4Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,21 +2626,29 @@ uint32_t ScriptCompiler::CachedDataVersionTag() {
26262626

26272627
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
26282628
Local<UnboundScript> unbound_script, Local<String> source) {
2629+
return CreateCodeCache(unbound_script);
2630+
}
2631+
2632+
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache(
2633+
Local<UnboundScript> unbound_script) {
26292634
i::Handle<i::SharedFunctionInfo> shared =
26302635
i::Handle<i::SharedFunctionInfo>::cast(
26312636
Utils::OpenHandle(*unbound_script));
2632-
i::Handle<i::String> source_str = Utils::OpenHandle(*source);
26332637
DCHECK(shared->is_toplevel());
2634-
return i::CodeSerializer::Serialize(shared, source_str);
2638+
return i::CodeSerializer::Serialize(shared);
26352639
}
26362640

26372641
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction(
26382642
Local<Function> function, Local<String> source) {
2643+
return CreateCodeCacheForFunction(function);
2644+
}
2645+
2646+
ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction(
2647+
Local<Function> function) {
26392648
i::Handle<i::SharedFunctionInfo> shared(
26402649
i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*function))->shared());
2641-
i::Handle<i::String> source_str = Utils::OpenHandle(*source);
26422650
CHECK(shared->is_wrapped());
2643-
return i::CodeSerializer::Serialize(shared, source_str);
2651+
return i::CodeSerializer::Serialize(shared);
26442652
}
26452653

26462654
MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source,
Collapse file

‎deps/v8/src/d8.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/d8.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
636636
ShellOptions::CodeCacheOptions::kProduceCache) {
637637
// Serialize and store it in memory for the next execution.
638638
ScriptCompiler::CachedData* cached_data =
639-
ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source);
639+
ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
640640
StoreInCodeCache(isolate, source, cached_data);
641641
delete cached_data;
642642
}
@@ -645,7 +645,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
645645
ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) {
646646
// Serialize and store it in memory for the next execution.
647647
ScriptCompiler::CachedData* cached_data =
648-
ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source);
648+
ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
649649
StoreInCodeCache(isolate, source, cached_data);
650650
delete cached_data;
651651
}
Collapse file

‎deps/v8/src/snapshot/code-serializer.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/snapshot/code-serializer.cc
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ScriptData::ScriptData(const byte* data, int length)
3232

3333
// static
3434
ScriptCompiler::CachedData* CodeSerializer::Serialize(
35-
Handle<SharedFunctionInfo> info, Handle<String> source) {
35+
Handle<SharedFunctionInfo> info) {
3636
Isolate* isolate = info->GetIsolate();
3737
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute");
3838
HistogramTimerScope histogram_timer(isolate->counters()->compile_serialize());
@@ -45,8 +45,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
4545
Handle<Script> script(Script::cast(info->script()), isolate);
4646
if (FLAG_trace_serializer) {
4747
PrintF("[Serializing from");
48-
Object* script = info->script();
49-
Script::cast(script)->name()->ShortPrint();
48+
script->name()->ShortPrint();
5049
PrintF("]\n");
5150
}
5251
// TODO(7110): Enable serialization of Asm modules once the AsmWasmData is
@@ -55,10 +54,11 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
5554
if (isolate->debug()->is_loaded()) return nullptr;
5655

5756
// Serialize code object.
57+
Handle<String> source(String::cast(script->source()), isolate);
5858
CodeSerializer cs(isolate, SerializedCodeData::SourceHash(source));
5959
DisallowHeapAllocation no_gc;
6060
cs.reference_map()->AddAttachedReference(*source);
61-
ScriptData* script_data = cs.Serialize(info);
61+
ScriptData* script_data = cs.SerializeSharedFunctionInfo(info);
6262

6363
if (FLAG_profile_deserialization) {
6464
double ms = timer.Elapsed().InMillisecondsF();
@@ -75,11 +75,12 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize(
7575
return result;
7676
}
7777

78-
ScriptData* CodeSerializer::Serialize(Handle<HeapObject> obj) {
78+
ScriptData* CodeSerializer::SerializeSharedFunctionInfo(
79+
Handle<SharedFunctionInfo> info) {
7980
DisallowHeapAllocation no_gc;
8081

8182
VisitRootPointer(Root::kHandleScope, nullptr,
82-
Handle<Object>::cast(obj).location());
83+
Handle<Object>::cast(info).location());
8384
SerializeDeferredObjects();
8485
Pad();
8586

Collapse file

‎deps/v8/src/snapshot/code-serializer.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/snapshot/code-serializer.h
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ class ScriptData {
4545

4646
class CodeSerializer : public Serializer<> {
4747
public:
48-
static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info,
49-
Handle<String> source);
48+
static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info);
5049

51-
ScriptData* Serialize(Handle<HeapObject> obj);
50+
ScriptData* SerializeSharedFunctionInfo(Handle<SharedFunctionInfo> info);
5251

5352
V8_WARN_UNUSED_RESULT static MaybeHandle<SharedFunctionInfo> Deserialize(
5453
Isolate* isolate, ScriptData* cached_data, Handle<String> source);
Collapse file

‎deps/v8/test/cctest/test-api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-api.cc
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25678,8 +25678,7 @@ TEST(CodeCache) {
2567825678
v8::ScriptCompiler::kNoCompileOptions;
2567925679
v8::Local<v8::Script> script =
2568025680
v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked();
25681-
cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript(),
25682-
source_string);
25681+
cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript());
2568325682
}
2568425683
isolate1->Dispose();
2568525684

Collapse file

‎deps/v8/test/cctest/test-serialize.cc‎

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-serialize.cc
+5-6Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,7 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache(
12401240
NOT_NATIVES_CODE)
12411241
.ToHandleChecked();
12421242
std::unique_ptr<ScriptCompiler::CachedData> cached_data(
1243-
ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi),
1244-
Utils::ToLocal(source)));
1243+
ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi)));
12451244
uint8_t* buffer = NewArray<uint8_t>(cached_data->length);
12461245
MemCopy(buffer, cached_data->data, cached_data->length);
12471246
*script_data = new i::ScriptData(buffer, cached_data->length);
@@ -1895,7 +1894,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
18951894
.ToLocalChecked();
18961895

18971896
if (cacheType != CodeCacheType::kAfterExecute) {
1898-
cache = ScriptCompiler::CreateCodeCache(script, source_str);
1897+
cache = ScriptCompiler::CreateCodeCache(script);
18991898
}
19001899

19011900
v8::Local<v8::Value> result = script->BindToCurrentContext()
@@ -1907,7 +1906,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache(
19071906
.FromJust());
19081907

19091908
if (cacheType == CodeCacheType::kAfterExecute) {
1910-
cache = ScriptCompiler::CreateCodeCache(script, source_str);
1909+
cache = ScriptCompiler::CreateCodeCache(script);
19111910
}
19121911
CHECK(cache);
19131912
}
@@ -2153,7 +2152,7 @@ TEST(CodeSerializerWithHarmonyScoping) {
21532152
v8::ScriptCompiler::CompileUnboundScript(
21542153
isolate1, &source, v8::ScriptCompiler::kNoCompileOptions)
21552154
.ToLocalChecked();
2156-
cache = v8::ScriptCompiler::CreateCodeCache(script, source_str);
2155+
cache = v8::ScriptCompiler::CreateCodeCache(script);
21572156
CHECK(cache);
21582157

21592158
v8::Local<v8::Value> result = script->BindToCurrentContext()
@@ -2218,7 +2217,7 @@ TEST(Regress503552) {
22182217
heap::SimulateIncrementalMarking(isolate->heap());
22192218

22202219
v8::ScriptCompiler::CachedData* cache_data =
2221-
CodeSerializer::Serialize(shared, source);
2220+
CodeSerializer::Serialize(shared);
22222221
delete cache_data;
22232222
}
22242223

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.