Revert "Optionally compress V8 code cache data with snappy."

This reverts commit dd138e54138a00f80fa1547bb3b4922aa02ad335, aka r185305.

Speculative revert to fix Android AOSP build breakage: http://build.chromium.org/p/tryserver.chromium.linux/builders/android_aosp/builds/33131/steps/compile/logs/stdio.

TBR=yangguo,jochen@chromium.org,vogelheim
BUG=

Review URL: https://codereview.chromium.org/721373002

git-svn-id: svn://svn.chromium.org/blink/trunk@185314 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent af8a094c
...@@ -7,7 +7,6 @@ include_rules = [ ...@@ -7,7 +7,6 @@ include_rules = [
"-modules", "-modules",
"+platform", "+platform",
"+public/platform", "+public/platform",
"+third_party/snappy",
"-web", "-web",
# TODO(tasak): Get this list to zero. # TODO(tasak): Get this list to zero.
......
...@@ -545,7 +545,7 @@ bool ScriptStreamer::startStreamingInternal(PendingScript& script, Settings* set ...@@ -545,7 +545,7 @@ bool ScriptStreamer::startStreamingInternal(PendingScript& script, Settings* set
// default, we generate the parser cache for streamed scripts, to emulate // default, we generate the parser cache for streamed scripts, to emulate
// the non-streaming behavior (see V8ScriptRunner::compileScript). // the non-streaming behavior (see V8ScriptRunner::compileScript).
v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProduceParserCache; v8::ScriptCompiler::CompileOptions compileOption = v8::ScriptCompiler::kProduceParserCache;
if (settings->v8CacheOptions() == V8CacheOptionsCode || settings->v8CacheOptions() == V8CacheOptionsCodeCompressed) if (settings->v8CacheOptions() == V8CacheOptionsCode)
compileOption = v8::ScriptCompiler::kProduceCodeCache; compileOption = v8::ScriptCompiler::kProduceCodeCache;
// The Resource might go out of scope if the script is no longer // The Resource might go out of scope if the script is no longer
......
...@@ -36,8 +36,7 @@ namespace blink { ...@@ -36,8 +36,7 @@ namespace blink {
enum V8CacheOptions { enum V8CacheOptions {
V8CacheOptionsOff, V8CacheOptionsOff,
V8CacheOptionsParse, V8CacheOptionsParse,
V8CacheOptionsCode, V8CacheOptionsCode
V8CacheOptionsCodeCompressed
}; };
} // namespace blink } // namespace blink
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include "core/fetch/ScriptResource.h" #include "core/fetch/ScriptResource.h"
#include "platform/ScriptForbiddenScope.h" #include "platform/ScriptForbiddenScope.h"
#include "platform/TraceEvent.h" #include "platform/TraceEvent.h"
#include "third_party/snappy/src/snappy.h"
namespace blink { namespace blink {
...@@ -65,49 +64,29 @@ v8::Local<v8::Value> throwStackOverflowExceptionIfNeeded(v8::Isolate* isolate) ...@@ -65,49 +64,29 @@ v8::Local<v8::Value> throwStackOverflowExceptionIfNeeded(v8::Isolate* isolate)
return result; return result;
} }
void writeToCache(ScriptResource* resource, unsigned cacheTag, Resource::MetadataCacheType cacheType, const v8::ScriptCompiler::CachedData* cachedData, bool compressed) v8::Local<v8::Script> compileAndProduceCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag, Resource::MetadataCacheType cacheType)
{ {
const char* data = reinterpret_cast<const char*>(cachedData->data); v8::ScriptCompiler::Source source(code, origin);
int length = cachedData->length; v8::Local<v8::Script> script = v8::ScriptCompiler::Compile(isolate, &source, options);
std::string compressedOutput; const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData();
if (compressed) { if (resource && cachedData) {
snappy::Compress(data, length, &compressedOutput);
data = compressedOutput.data();
length = compressedOutput.length();
}
resource->clearCachedMetadata(); resource->clearCachedMetadata();
resource->setCachedMetadata( resource->setCachedMetadata(
cacheTag, cacheTag,
data, reinterpret_cast<const char*>(cachedData->data),
length, cachedData->length,
cacheType); cacheType);
} }
v8::Local<v8::Script> compileAndProduceCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag, Resource::MetadataCacheType cacheType, bool compressed)
{
v8::ScriptCompiler::Source source(code, origin);
v8::Local<v8::Script> script = v8::ScriptCompiler::Compile(isolate, &source, options);
const v8::ScriptCompiler::CachedData* cachedData = source.GetCachedData();
if (resource && cachedData)
writeToCache(resource, cacheTag, cacheType, cachedData, compressed);
return script; return script;
} }
v8::Local<v8::Script> compileAndConsumeCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag, bool compressed) v8::Local<v8::Script> compileAndConsumeCache(v8::Isolate* isolate, v8::Handle<v8::String> code, v8::ScriptOrigin origin, ScriptResource* resource, v8::ScriptCompiler::CompileOptions options, unsigned cacheTag)
{ {
// Consume existing cache data: // Consume existing cache data:
CachedMetadata* cachedMetadata = resource->cachedMetadata(cacheTag); CachedMetadata* cachedMetadata = resource->cachedMetadata(cacheTag);
const char* data = cachedMetadata->data();
int length = cachedMetadata->size();
std::string uncompressedOutput;
if (compressed) {
snappy::Uncompress(data, length, &uncompressedOutput);
data = uncompressedOutput.data();
length = uncompressedOutput.length();
}
v8::ScriptCompiler::CachedData* cachedData = new v8::ScriptCompiler::CachedData( v8::ScriptCompiler::CachedData* cachedData = new v8::ScriptCompiler::CachedData(
reinterpret_cast<const uint8_t*>(data), reinterpret_cast<const uint8_t*>(cachedMetadata->data()),
length, cachedMetadata->size(),
v8::ScriptCompiler::CachedData::BufferNotOwned); v8::ScriptCompiler::CachedData::BufferNotOwned);
v8::ScriptCompiler::Source source(code, origin, cachedData); v8::ScriptCompiler::Source source(code, origin, cachedData);
return v8::ScriptCompiler::Compile(isolate, &source, options); return v8::ScriptCompiler::Compile(isolate, &source, options);
...@@ -135,7 +114,6 @@ v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, ...@@ -135,7 +114,6 @@ v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code,
v8::Local<v8::Script> script; v8::Local<v8::Script> script;
unsigned cacheTag = 0; unsigned cacheTag = 0;
bool compressed = cacheOptions == V8CacheOptionsCodeCompressed;
if (streamer) { if (streamer) {
// We don't stream scripts which don't have a Resource. // We don't stream scripts which don't have a Resource.
ASSERT(resource); ASSERT(resource);
...@@ -148,38 +126,37 @@ v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code, ...@@ -148,38 +126,37 @@ v8::Local<v8::Script> V8ScriptRunner::compileScript(v8::Handle<v8::String> code,
// streamer is started. Here we only need to get the data out. // streamer is started. Here we only need to get the data out.
const v8::ScriptCompiler::CachedData* newCachedData = streamer->source()->GetCachedData(); const v8::ScriptCompiler::CachedData* newCachedData = streamer->source()->GetCachedData();
if (newCachedData) { if (newCachedData) {
// TODO(yangguo,vogelheim): code cache should use Resource::SendToPlatform. resource->clearCachedMetadata();
writeToCache(resource, streamer->cachedDataType(), Resource::CacheLocally, newCachedData, compressed); resource->setCachedMetadata(streamer->cachedDataType(), reinterpret_cast<const char*>(newCachedData->data), newCachedData->length, Resource::CacheLocally);
} }
} else if (!resource || !resource->url().protocolIsInHTTPFamily() || code->Length() < 1024) { } else if (!resource || !resource->url().protocolIsInHTTPFamily() || code->Length() < 1024) {
v8::ScriptCompiler::Source source(code, origin); v8::ScriptCompiler::Source source(code, origin);
script = v8::ScriptCompiler::Compile(isolate, &source, v8::ScriptCompiler::kNoCompileOptions); script = v8::ScriptCompiler::Compile(isolate, &source, v8::ScriptCompiler::kNoCompileOptions);
} else { } else {
Resource::MetadataCacheType cacheType = Resource::CacheLocally;
v8::ScriptCompiler::CompileOptions consumeOption = v8::ScriptCompiler::kConsumeParserCache;
v8::ScriptCompiler::CompileOptions produceOption = v8::ScriptCompiler::kProduceParserCache;
switch (cacheOptions) { switch (cacheOptions) {
case V8CacheOptionsOff:
// Use default.
cacheTag = tagForParserCache();
break;
case V8CacheOptionsParse: case V8CacheOptionsParse:
cacheTag = tagForParserCache(); cacheTag = tagForParserCache();
cacheType = Resource::SendToPlatform; script = resource->cachedMetadata(cacheTag)
consumeOption = v8::ScriptCompiler::kConsumeParserCache; ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
produceOption = v8::ScriptCompiler::kProduceParserCache; : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::SendToPlatform);
break; break;
case V8CacheOptionsCodeCompressed:
case V8CacheOptionsCode: case V8CacheOptionsCode:
cacheTag = tagForCodeCache(); cacheTag = tagForCodeCache();
cacheType = Resource::SendToPlatform; script = resource->cachedMetadata(cacheTag)
consumeOption = v8::ScriptCompiler::kConsumeCodeCache; ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeCodeCache, cacheTag)
produceOption = v8::ScriptCompiler::kProduceCodeCache; : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceCodeCache, cacheTag, Resource::SendToPlatform);
break; break;
} case V8CacheOptionsOff:
// Previous behaviour was to always generate an in-memory parser
// cache. We emulate this here.
// FIXME: Determine whether this should get its own setting, so we
// can also have a true 'off'.
cacheTag = tagForParserCache();
script = resource->cachedMetadata(cacheTag) script = resource->cachedMetadata(cacheTag)
? compileAndConsumeCache(isolate, code, origin, resource, consumeOption, cacheTag, compressed) ? compileAndConsumeCache(isolate, code, origin, resource, v8::ScriptCompiler::kConsumeParserCache, cacheTag)
: compileAndProduceCache(isolate, code, origin, resource, produceOption, cacheTag, cacheType, compressed); : compileAndProduceCache(isolate, code, origin, resource, v8::ScriptCompiler::kProduceParserCache, cacheTag, Resource::CacheLocally);
break;
}
} }
return script; return script;
} }
......
...@@ -136,17 +136,6 @@ TEST_F(V8ScriptRunnerTest, codeOptions) ...@@ -136,17 +136,6 @@ TEST_F(V8ScriptRunnerTest, codeOptions)
EXPECT_TRUE(compileScript(V8CacheOptionsCode)); EXPECT_TRUE(compileScript(V8CacheOptionsCode));
EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache())); EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache()));
// FIXME: Code caching is presently still disabled.
// Enable EXPECT when code caching lands.
// EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache(false)));
}
TEST_F(V8ScriptRunnerTest, codeCompressedOptions)
{
setResource();
EXPECT_TRUE(compileScript(V8CacheOptionsCodeCompressed));
EXPECT_FALSE(m_resource->cachedMetadata(tagForParserCache()));
// FIXME: Code caching is presently still disabled. // FIXME: Code caching is presently still disabled.
// Enable EXPECT when code caching lands. // Enable EXPECT when code caching lands.
// EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache())); // EXPECT_TRUE(m_resource->cachedMetadata(tagForCodeCache()));
......
...@@ -90,7 +90,6 @@ source_set("prerequisites") { ...@@ -90,7 +90,6 @@ source_set("prerequisites") {
"//third_party/npapi", "//third_party/npapi",
"//third_party/ots", "//third_party/ots",
"//third_party/qcms", "//third_party/qcms",
"//third_party/snappy",
"//third_party/sqlite", "//third_party/sqlite",
"//third_party/zlib", "//third_party/zlib",
"//url", "//url",
......
...@@ -187,7 +187,6 @@ ...@@ -187,7 +187,6 @@
'<(DEPTH)/third_party/libxslt/libxslt.gyp:libxslt', '<(DEPTH)/third_party/libxslt/libxslt.gyp:libxslt',
'<(DEPTH)/third_party/npapi/npapi.gyp:npapi', '<(DEPTH)/third_party/npapi/npapi.gyp:npapi',
'<(DEPTH)/third_party/qcms/qcms.gyp:qcms', '<(DEPTH)/third_party/qcms/qcms.gyp:qcms',
'<(DEPTH)/third_party/snappy/snappy.gyp:snappy',
'<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite', '<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite',
'<(DEPTH)/url/url.gyp:url_lib', '<(DEPTH)/url/url.gyp:url_lib',
'<(DEPTH)/v8/tools/gyp/v8.gyp:v8', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8',
......
...@@ -639,7 +639,6 @@ COMPILE_ASSERT_MATCHING_ENUM(WebSelectionBound::SelectionRight, CompositedSelect ...@@ -639,7 +639,6 @@ COMPILE_ASSERT_MATCHING_ENUM(WebSelectionBound::SelectionRight, CompositedSelect
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsOff, V8CacheOptionsOff); COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsOff, V8CacheOptionsOff);
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsParse, V8CacheOptionsParse); COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsParse, V8CacheOptionsParse);
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsCode, V8CacheOptionsCode); COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsCode, V8CacheOptionsCode);
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::V8CacheOptionsCodeCompressed, V8CacheOptionsCodeCompressed);
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::PointerTypeNone, PointerTypeNone); COMPILE_ASSERT_MATCHING_ENUM(WebSettings::PointerTypeNone, PointerTypeNone);
COMPILE_ASSERT_MATCHING_ENUM(WebSettings::PointerTypeCoarse, PointerTypeCoarse); COMPILE_ASSERT_MATCHING_ENUM(WebSettings::PointerTypeCoarse, PointerTypeCoarse);
......
...@@ -55,8 +55,7 @@ public: ...@@ -55,8 +55,7 @@ public:
enum V8CacheOptions { enum V8CacheOptions {
V8CacheOptionsOff, V8CacheOptionsOff,
V8CacheOptionsParse, V8CacheOptionsParse,
V8CacheOptionsCode, V8CacheOptionsCode
V8CacheOptionsCodeCompressed
}; };
enum V8ScriptStreamingMode { enum V8ScriptStreamingMode {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment