OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "bindings/core/v8/ScriptStreamer.h" | 29 #include "bindings/core/v8/ScriptStreamer.h" |
30 #include "bindings/core/v8/V8Binding.h" | 30 #include "bindings/core/v8/V8Binding.h" |
31 #include "bindings/core/v8/V8GCController.h" | 31 #include "bindings/core/v8/V8GCController.h" |
32 #include "bindings/core/v8/V8RecursionScope.h" | 32 #include "bindings/core/v8/V8RecursionScope.h" |
33 #include "bindings/core/v8/V8ThrowException.h" | 33 #include "bindings/core/v8/V8ThrowException.h" |
34 #include "core/dom/ExecutionContext.h" | 34 #include "core/dom/ExecutionContext.h" |
35 #include "core/fetch/CachedMetadata.h" | 35 #include "core/fetch/CachedMetadata.h" |
36 #include "core/fetch/ScriptResource.h" | 36 #include "core/fetch/ScriptResource.h" |
37 #include "core/inspector/InspectorInstrumentation.h" | 37 #include "core/inspector/InspectorInstrumentation.h" |
38 #include "core/inspector/InspectorTraceEvents.h" | 38 #include "core/inspector/InspectorTraceEvents.h" |
| 39 #include "platform/Histogram.h" |
39 #include "platform/ScriptForbiddenScope.h" | 40 #include "platform/ScriptForbiddenScope.h" |
40 #include "platform/TraceEvent.h" | 41 #include "platform/TraceEvent.h" |
41 #include "public/platform/Platform.h" | 42 #include "public/platform/Platform.h" |
42 #include "wtf/CurrentTime.h" | 43 #include "wtf/CurrentTime.h" |
43 | 44 |
44 #if OS(WIN) | 45 #if OS(WIN) |
45 #include <malloc.h> | 46 #include <malloc.h> |
46 #else | 47 #else |
47 #include <alloca.h> | 48 #include <alloca.h> |
48 #endif | 49 #endif |
(...skipping 23 matching lines...) Expand all Loading... |
72 | 73 |
73 V8CompileHistogram::V8CompileHistogram(V8CompileHistogram::Cacheability cacheabi
lity) | 74 V8CompileHistogram::V8CompileHistogram(V8CompileHistogram::Cacheability cacheabi
lity) |
74 : m_cacheability(cacheability) | 75 : m_cacheability(cacheability) |
75 , m_timeStamp(WTF::currentTime()) | 76 , m_timeStamp(WTF::currentTime()) |
76 { | 77 { |
77 } | 78 } |
78 | 79 |
79 V8CompileHistogram::~V8CompileHistogram() | 80 V8CompileHistogram::~V8CompileHistogram() |
80 { | 81 { |
81 int64_t elapsedMicroSeconds = static_cast<int64_t>((WTF::currentTime() - m_t
imeStamp) * 1000000); | 82 int64_t elapsedMicroSeconds = static_cast<int64_t>((WTF::currentTime() - m_t
imeStamp) * 1000000); |
82 const char* name = ""; | |
83 switch (m_cacheability) { | 83 switch (m_cacheability) { |
84 case Cacheable: | 84 case Cacheable: { |
85 name = "V8.CompileCacheableMicroSeconds"; | 85 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, compileCacheableHi
stogram, new CustomCountHistogram("V8.CompileCacheableMicroSeconds", 0, 1000000,
50)); |
86 break; | 86 compileCacheableHistogram.count(elapsedMicroSeconds); |
87 case Noncacheable: | |
88 name = "V8.CompileNoncacheableMicroSeconds"; | |
89 break; | |
90 case InlineScript: | |
91 name = "V8.CompileInlineScriptMicroSeconds"; | |
92 break; | 87 break; |
93 } | 88 } |
94 Platform::current()->histogramCustomCounts(name, elapsedMicroSeconds, 0, 100
0000, 50); | 89 case Noncacheable: { |
| 90 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, compileNonCacheabl
eHistogram, new CustomCountHistogram("V8.CompileNoncacheableMicroSeconds", 0, 10
00000, 50)); |
| 91 compileNonCacheableHistogram.count(elapsedMicroSeconds); |
| 92 break; |
| 93 } |
| 94 case InlineScript: { |
| 95 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, compileInlineHisto
gram, new CustomCountHistogram("V8.CompileInlineScriptMicroSeconds", 0, 1000000,
50)); |
| 96 compileInlineHistogram.count(elapsedMicroSeconds); |
| 97 break; |
| 98 } |
| 99 } |
95 } | 100 } |
96 | 101 |
97 // In order to make sure all pending messages to be processed in | 102 // In order to make sure all pending messages to be processed in |
98 // v8::Function::Call, we don't call throwStackOverflowException | 103 // v8::Function::Call, we don't call throwStackOverflowException |
99 // directly. Instead, we create a v8::Function of | 104 // directly. Instead, we create a v8::Function of |
100 // throwStackOverflowException and call it. | 105 // throwStackOverflowException and call it. |
101 void throwStackOverflowException(const v8::FunctionCallbackInfo<v8::Value>& info
) | 106 void throwStackOverflowException(const v8::FunctionCallbackInfo<v8::Value>& info
) |
102 { | 107 { |
103 V8ThrowException::throwRangeError(info.GetIsolate(), "Maximum call stack siz
e exceeded."); | 108 V8ThrowException::throwRangeError(info.GetIsolate(), "Maximum call stack siz
e exceeded."); |
104 } | 109 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); | 156 V8CompileHistogram histogramScope(V8CompileHistogram::Cacheable); |
152 v8::ScriptCompiler::Source source(code, origin); | 157 v8::ScriptCompiler::Source source(code, origin); |
153 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), &source, compileOptions); | 158 v8::MaybeLocal<v8::Script> script = v8::ScriptCompiler::Compile(isolate->Get
CurrentContext(), &source, compileOptions); |
154 const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData(); | 159 const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData(); |
155 if (cachedData) { | 160 if (cachedData) { |
156 const char* data = reinterpret_cast<const char*>(cachedData->data); | 161 const char* data = reinterpret_cast<const char*>(cachedData->data); |
157 int length = cachedData->length; | 162 int length = cachedData->length; |
158 if (length > 1024) { | 163 if (length > 1024) { |
159 // Omit histogram samples for small cache data to avoid outliers. | 164 // Omit histogram samples for small cache data to avoid outliers. |
160 int cacheSizeRatio = static_cast<int>(100.0 * length / code->Length(
)); | 165 int cacheSizeRatio = static_cast<int>(100.0 * length / code->Length(
)); |
161 Platform::current()->histogramCustomCounts("V8.CodeCacheSizeRatio",
cacheSizeRatio, 0, 10000, 50); | 166 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, codeCacheSizeH
istogram, new CustomCountHistogram("V8.CodeCacheSizeRatio", 0, 10000, 50)); |
| 167 codeCacheSizeHistogram.count(cacheSizeRatio); |
162 } | 168 } |
163 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); | 169 cacheHandler->clearCachedMetadata(CachedMetadataHandler::CacheLocally); |
164 cacheHandler->setCachedMetadata(tag, data, length, cacheType); | 170 cacheHandler->setCachedMetadata(tag, data, length, cacheType); |
165 } | 171 } |
166 return script; | 172 return script; |
167 } | 173 } |
168 | 174 |
169 // Compile a script, and consume or produce a V8 Cache, depending on whether the | 175 // Compile a script, and consume or produce a V8 Cache, depending on whether the |
170 // given resource already has cached data available. | 176 // given resource already has cached data available. |
171 v8::MaybeLocal<v8::Script> compileAndConsumeOrProduce(CachedMetadataHandler* cac
heHandler, unsigned tag, v8::ScriptCompiler::CompileOptions consumeOptions, v8::
ScriptCompiler::CompileOptions produceOptions, CachedMetadataHandler::CacheType
cacheType, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrigin or
igin) | 177 v8::MaybeLocal<v8::Script> compileAndConsumeOrProduce(CachedMetadataHandler* cac
heHandler, unsigned tag, v8::ScriptCompiler::CompileOptions consumeOptions, v8::
ScriptCompiler::CompileOptions produceOptions, CachedMetadataHandler::CacheType
cacheType, v8::Isolate* isolate, v8::Local<v8::String> code, v8::ScriptOrigin or
igin) |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 { | 518 { |
513 return cacheTag(CacheTagParser, cacheHandler); | 519 return cacheTag(CacheTagParser, cacheHandler); |
514 } | 520 } |
515 | 521 |
516 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) | 522 unsigned V8ScriptRunner::tagForCodeCache(CachedMetadataHandler* cacheHandler) |
517 { | 523 { |
518 return cacheTag(CacheTagCode, cacheHandler); | 524 return cacheTag(CacheTagCode, cacheHandler); |
519 } | 525 } |
520 | 526 |
521 } // namespace blink | 527 } // namespace blink |
OLD | NEW |