| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3d8ec8f commit 14bb905
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,7 @@ | |||
| 27 | 27 | ||
| 28 | 28 | # Reset this number to 0 on major V8 upgrades. | |
| 29 | 29 | # Increment by one for each non-official patch applied to deps/v8. | |
| 30 | - 'v8_embedder_string': '-node.7', | ||
| 30 | + 'v8_embedder_string': '-node.8', | ||
| 31 | 31 | ||
| 32 | 32 | # Enable disassembler for `--print-code` v8 options | |
| 33 | 33 | 'v8_enable_disassembler': 1, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1578,6 +1578,9 @@ class V8_EXPORT ScriptCompiler { | |||
| 1578 | 1578 | * This will return nullptr if the script cannot be serialized. The | |
| 1579 | 1579 | * CachedData returned by this function should be owned by the caller. | |
| 1580 | 1580 | */ | |
| 1581 | + static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script); | ||
| 1582 | + | ||
| 1583 | + // Deprecated. | ||
| 1581 | 1584 | static CachedData* CreateCodeCache(Local<UnboundScript> unbound_script, | |
| 1582 | 1585 | Local<String> source); | |
| 1583 | 1586 | ||
@@ -1587,6 +1590,9 @@ class V8_EXPORT ScriptCompiler { | |||
| 1587 | 1590 | * This will return nullptr if the script cannot be serialized. The | |
| 1588 | 1591 | * CachedData returned by this function should be owned by the caller. | |
| 1589 | 1592 | */ | |
| 1593 | + static CachedData* CreateCodeCacheForFunction(Local<Function> function); | ||
| 1594 | + | ||
| 1595 | + // Deprecated. | ||
| 1590 | 1596 | static CachedData* CreateCodeCacheForFunction(Local<Function> function, | |
| 1591 | 1597 | Local<String> source); | |
| 1592 | 1598 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2626,21 +2626,29 @@ uint32_t ScriptCompiler::CachedDataVersionTag() { | |||
| 2626 | 2626 | ||
| 2627 | 2627 | ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache( | |
| 2628 | 2628 | Local<UnboundScript> unbound_script, Local<String> source) { | |
| 2629 | + return CreateCodeCache(unbound_script); | ||
| 2630 | + } | ||
| 2631 | + | ||
| 2632 | + ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCache( | ||
| 2633 | + Local<UnboundScript> unbound_script) { | ||
| 2629 | 2634 | i::Handle<i::SharedFunctionInfo> shared = | |
| 2630 | 2635 | i::Handle<i::SharedFunctionInfo>::cast( | |
| 2631 | 2636 | Utils::OpenHandle(*unbound_script)); | |
| 2632 | - i::Handle<i::String> source_str = Utils::OpenHandle(*source); | ||
| 2633 | 2637 | DCHECK(shared->is_toplevel()); | |
| 2634 | - return i::CodeSerializer::Serialize(shared, source_str); | ||
| 2638 | + return i::CodeSerializer::Serialize(shared); | ||
| 2635 | 2639 | } | |
| 2636 | 2640 | ||
| 2637 | 2641 | ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction( | |
| 2638 | 2642 | Local<Function> function, Local<String> source) { | |
| 2643 | + return CreateCodeCacheForFunction(function); | ||
| 2644 | + } | ||
| 2645 | + | ||
| 2646 | + ScriptCompiler::CachedData* ScriptCompiler::CreateCodeCacheForFunction( | ||
| 2647 | + Local<Function> function) { | ||
| 2639 | 2648 | i::Handle<i::SharedFunctionInfo> shared( | |
| 2640 | 2649 | i::Handle<i::JSFunction>::cast(Utils::OpenHandle(*function))->shared()); | |
| 2641 | - i::Handle<i::String> source_str = Utils::OpenHandle(*source); | ||
| 2642 | 2650 | CHECK(shared->is_wrapped()); | |
| 2643 | - return i::CodeSerializer::Serialize(shared, source_str); | ||
| 2651 | + return i::CodeSerializer::Serialize(shared); | ||
| 2644 | 2652 | } | |
| 2645 | 2653 | ||
| 2646 | 2654 | MaybeLocal<Script> Script::Compile(Local<Context> context, Local<String> source, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -636,7 +636,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | |||
| 636 | 636 | ShellOptions::CodeCacheOptions::kProduceCache) { | |
| 637 | 637 | // Serialize and store it in memory for the next execution. | |
| 638 | 638 | ScriptCompiler::CachedData* cached_data = | |
| 639 | - ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source); | ||
| 639 | + ScriptCompiler::CreateCodeCache(script->GetUnboundScript()); | ||
| 640 | 640 | StoreInCodeCache(isolate, source, cached_data); | |
| 641 | 641 | delete cached_data; | |
| 642 | 642 | } | |
@@ -645,7 +645,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | |||
| 645 | 645 | ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) { | |
| 646 | 646 | // Serialize and store it in memory for the next execution. | |
| 647 | 647 | ScriptCompiler::CachedData* cached_data = | |
| 648 | - ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), source); | ||
| 648 | + ScriptCompiler::CreateCodeCache(script->GetUnboundScript()); | ||
| 649 | 649 | StoreInCodeCache(isolate, source, cached_data); | |
| 650 | 650 | delete cached_data; | |
| 651 | 651 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ ScriptData::ScriptData(const byte* data, int length) | |||
| 32 | 32 | ||
| 33 | 33 | // static | |
| 34 | 34 | ScriptCompiler::CachedData* CodeSerializer::Serialize( | |
| 35 | - Handle<SharedFunctionInfo> info, Handle<String> source) { | ||
| 35 | + Handle<SharedFunctionInfo> info) { | ||
| 36 | 36 | Isolate* isolate = info->GetIsolate(); | |
| 37 | 37 | TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.Execute"); | |
| 38 | 38 | HistogramTimerScope histogram_timer(isolate->counters()->compile_serialize()); | |
@@ -45,8 +45,7 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize( | |||
| 45 | 45 | Handle<Script> script(Script::cast(info->script()), isolate); | |
| 46 | 46 | if (FLAG_trace_serializer) { | |
| 47 | 47 | PrintF("[Serializing from"); | |
| 48 | - Object* script = info->script(); | ||
| 49 | - Script::cast(script)->name()->ShortPrint(); | ||
| 48 | + script->name()->ShortPrint(); | ||
| 50 | 49 | PrintF("]\n"); | |
| 51 | 50 | } | |
| 52 | 51 | // TODO(7110): Enable serialization of Asm modules once the AsmWasmData is | |
@@ -55,10 +54,11 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize( | |||
| 55 | 54 | if (isolate->debug()->is_loaded()) return nullptr; | |
| 56 | 55 | ||
| 57 | 56 | // Serialize code object. | |
| 57 | + Handle<String> source(String::cast(script->source()), isolate); | ||
| 58 | 58 | CodeSerializer cs(isolate, SerializedCodeData::SourceHash(source)); | |
| 59 | 59 | DisallowHeapAllocation no_gc; | |
| 60 | 60 | cs.reference_map()->AddAttachedReference(*source); | |
| 61 | - ScriptData* script_data = cs.Serialize(info); | ||
| 61 | + ScriptData* script_data = cs.SerializeSharedFunctionInfo(info); | ||
| 62 | 62 | ||
| 63 | 63 | if (FLAG_profile_deserialization) { | |
| 64 | 64 | double ms = timer.Elapsed().InMillisecondsF(); | |
@@ -75,11 +75,12 @@ ScriptCompiler::CachedData* CodeSerializer::Serialize( | |||
| 75 | 75 | return result; | |
| 76 | 76 | } | |
| 77 | 77 | ||
| 78 | - ScriptData* CodeSerializer::Serialize(Handle<HeapObject> obj) { | ||
| 78 | + ScriptData* CodeSerializer::SerializeSharedFunctionInfo( | ||
| 79 | + Handle<SharedFunctionInfo> info) { | ||
| 79 | 80 | DisallowHeapAllocation no_gc; | |
| 80 | 81 | ||
| 81 | 82 | VisitRootPointer(Root::kHandleScope, nullptr, | |
| 82 | - Handle<Object>::cast(obj).location()); | ||
| 83 | + Handle<Object>::cast(info).location()); | ||
| 83 | 84 | SerializeDeferredObjects(); | |
| 84 | 85 | Pad(); | |
| 85 | 86 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,10 +45,9 @@ class ScriptData { | |||
| 45 | 45 | ||
| 46 | 46 | class CodeSerializer : public Serializer<> { | |
| 47 | 47 | public: | |
| 48 | - static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info, | ||
| 49 | - Handle<String> source); | ||
| 48 | + static ScriptCompiler::CachedData* Serialize(Handle<SharedFunctionInfo> info); | ||
| 50 | 49 | ||
| 51 | - ScriptData* Serialize(Handle<HeapObject> obj); | ||
| 50 | + ScriptData* SerializeSharedFunctionInfo(Handle<SharedFunctionInfo> info); | ||
| 52 | 51 | ||
| 53 | 52 | V8_WARN_UNUSED_RESULT static MaybeHandle<SharedFunctionInfo> Deserialize( | |
| 54 | 53 | Isolate* isolate, ScriptData* cached_data, Handle<String> source); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25678,8 +25678,7 @@ TEST(CodeCache) { | |||
| 25678 | 25678 | v8::ScriptCompiler::kNoCompileOptions; | |
| 25679 | 25679 | v8::Local<v8::Script> script = | |
| 25680 | 25680 | v8::ScriptCompiler::Compile(context, &source, option).ToLocalChecked(); | |
| 25681 | - cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript(), | ||
| 25682 | - source_string); | ||
| 25681 | + cache = v8::ScriptCompiler::CreateCodeCache(script->GetUnboundScript()); | ||
| 25683 | 25682 | } | |
| 25684 | 25683 | isolate1->Dispose(); | |
| 25685 | 25684 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1240,8 +1240,7 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache( | |||
| 1240 | 1240 | NOT_NATIVES_CODE) | |
| 1241 | 1241 | .ToHandleChecked(); | |
| 1242 | 1242 | std::unique_ptr<ScriptCompiler::CachedData> cached_data( | |
| 1243 | - ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi), | ||
| 1244 | - Utils::ToLocal(source))); | ||
| 1243 | + ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi))); | ||
| 1245 | 1244 | uint8_t* buffer = NewArray<uint8_t>(cached_data->length); | |
| 1246 | 1245 | MemCopy(buffer, cached_data->data, cached_data->length); | |
| 1247 | 1246 | *script_data = new i::ScriptData(buffer, cached_data->length); | |
@@ -1895,7 +1894,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache( | |||
| 1895 | 1894 | .ToLocalChecked(); | |
| 1896 | 1895 | ||
| 1897 | 1896 | if (cacheType != CodeCacheType::kAfterExecute) { | |
| 1898 | - cache = ScriptCompiler::CreateCodeCache(script, source_str); | ||
| 1897 | + cache = ScriptCompiler::CreateCodeCache(script); | ||
| 1899 | 1898 | } | |
| 1900 | 1899 | ||
| 1901 | 1900 | v8::Local<v8::Value> result = script->BindToCurrentContext() | |
@@ -1907,7 +1906,7 @@ v8::ScriptCompiler::CachedData* CompileRunAndProduceCache( | |||
| 1907 | 1906 | .FromJust()); | |
| 1908 | 1907 | ||
| 1909 | 1908 | if (cacheType == CodeCacheType::kAfterExecute) { | |
| 1910 | - cache = ScriptCompiler::CreateCodeCache(script, source_str); | ||
| 1909 | + cache = ScriptCompiler::CreateCodeCache(script); | ||
| 1911 | 1910 | } | |
| 1912 | 1911 | CHECK(cache); | |
| 1913 | 1912 | } | |
@@ -2153,7 +2152,7 @@ TEST(CodeSerializerWithHarmonyScoping) { | |||
| 2153 | 2152 | v8::ScriptCompiler::CompileUnboundScript( | |
| 2154 | 2153 | isolate1, &source, v8::ScriptCompiler::kNoCompileOptions) | |
| 2155 | 2154 | .ToLocalChecked(); | |
| 2156 | - cache = v8::ScriptCompiler::CreateCodeCache(script, source_str); | ||
| 2155 | + cache = v8::ScriptCompiler::CreateCodeCache(script); | ||
| 2157 | 2156 | CHECK(cache); | |
| 2158 | 2157 | ||
| 2159 | 2158 | v8::Local<v8::Value> result = script->BindToCurrentContext() | |
@@ -2218,7 +2217,7 @@ TEST(Regress503552) { | |||
| 2218 | 2217 | heap::SimulateIncrementalMarking(isolate->heap()); | |
| 2219 | 2218 | ||
| 2220 | 2219 | v8::ScriptCompiler::CachedData* cache_data = | |
| 2221 | - CodeSerializer::Serialize(shared, source); | ||
| 2220 | + CodeSerializer::Serialize(shared); | ||
| 2222 | 2221 | delete cache_data; | |
| 2223 | 2222 | } | |
| 2224 | 2223 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments