Commit 41719a42 authored by vogelheim's avatar vogelheim Committed by Commit bot

Restrict GeneratePreagedPrologue to proper functions.

This solves a bug discovered with fast accessors, where a pre-age prologue
was written into a stub. Since StaticMarkingVisitor<.>::IsFlushable will
only flush Code::FUNCTION [1], we'll restrict GeneratePreagedPrologue to
functions, too, instead of adding a Code::STUB restriction.

Also, generalize api accessor test cases to --optimize-for-size.
Also, fix CompilationCacheCachingBehavior for --optimize-for-size.

[1] https://code.google.com/p/chromium/codesearch#chromium/src/v8/src/heap/objects-visiting-inl.h&l=629-632

R=epertoso
BUG=

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

Cr-Commit-Position: refs/heads/master@{#33291}
parent 2d36bdff
......@@ -270,10 +270,10 @@ class CompilationInfo {
bool GeneratePreagedPrologue() const {
// Generate a pre-aged prologue if we are optimizing for size, which
// will make code flushing more aggressive. The code for WASM functions
// cannot be flushed, so it does not make sense to age them.
// will make code flushing more aggressive. Only apply to Code::FUNCTION,
// since StaticMarkingVisitor::IsFlushable only flushes proper functions.
return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
!is_debug() && output_code_kind_ != Code::WASM_FUNCTION;
!is_debug() && output_code_kind_ == Code::FUNCTION;
}
void EnsureFeedbackVector();
......
......@@ -1567,18 +1567,26 @@ TEST(CompilationCacheCachingBehavior) {
language_mode);
CHECK(!info.is_null());
// Check that the code cache entry survives at least on GC.
// (Unless --optimize-for-size, in which case it might get collected
// immediately.)
if (!FLAG_optimize_for_size) {
heap->CollectAllGarbage();
// On second compilation, the hash is replaced by a real cache entry mapping
// the source to the shared function info containing the code.
info = compilation_cache->LookupScript(
source, Handle<Object>(), 0, 0,
v8::ScriptOriginOptions(false, true, false), native_context,
language_mode);
CHECK(!info.is_null());
}
// Progress code age until it's old and ready for GC.
while (!info.ToHandleChecked()->code()->IsOld()) {
info.ToHandleChecked()->code()->MakeOlder(NO_MARKING_PARITY);
// To guarantee progress, we have to MakeOlder with different parities.
// We can't just use NO_MARKING_PARITY, since e.g. kExecutedOnceCodeAge is
// always NO_MARKING_PARITY and the code age only progresses if the parity
// is different.
info.ToHandleChecked()->code()->MakeOlder(ODD_MARKING_PARITY);
info.ToHandleChecked()->code()->MakeOlder(EVEN_MARKING_PARITY);
}
heap->CollectAllGarbage();
......
......@@ -28,7 +28,7 @@ v8::experimental::FastAccessorBuilder* FastAccessor(v8::Isolate* isolate) {
TEST(FastAccessors) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope scope(isolate);
......
......@@ -38,7 +38,7 @@ static void NativePropertyAccessor(
// Build a simple "fast accessor" and verify that it is being called.
TEST(FastAccessor) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......@@ -88,7 +88,7 @@ void AddInternalFieldAccessor(v8::Isolate* isolate,
// "Fast" accessor that accesses an internal field.
TEST(FastAccessorWithInternalField) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......@@ -120,7 +120,7 @@ TEST(FastAccessorWithInternalField) {
// "Fast" accessor with control flow via ...OrReturnNull methods.
TEST(FastAccessorOrReturnNull) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......@@ -173,7 +173,7 @@ TEST(FastAccessorOrReturnNull) {
// "Fast" accessor with simple control flow via explicit labels.
TEST(FastAccessorControlFlowWithLabels) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......@@ -210,7 +210,7 @@ TEST(FastAccessorControlFlowWithLabels) {
// "Fast" accessor, loading things.
TEST(FastAccessorLoad) {
if (i::FLAG_always_opt || i::FLAG_optimize_for_size) return;
if (i::FLAG_always_opt) return;
LocalContext env;
v8::Isolate* isolate = env->GetIsolate();
......
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