Reviewers: vogelheim,
Description:
Fix issues with code serializer.
- code pre-aging does not work with serializing.
- compilation info needs to remember that we compile for serializing.
- test case leaks memory.
[email protected]
Please review this at https://codereview.chromium.org/379563002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+22, -8 lines):
M src/compiler.h
M src/compiler.cc
M src/full-codegen.cc
M test/cctest/cctest.status
M test/cctest/test-compiler.cc
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
2b451501f02b3d01ef2462daf213ad518df75ed6..59c6a3693f796b484aa885837469a8a496ce256f
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -981,6 +981,9 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
info.SetCachedData(cached_data, cached_data_mode);
info.SetExtension(extension);
info.SetContext(context);
+ if (FLAG_serialize_toplevel && cached_data_mode ==
PRODUCE_CACHED_DATA) {
+ info.PrepareForSerializing();
+ }
if (FLAG_use_strict) info.SetStrictMode(STRICT);
result = CompileToplevel(&info);
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index
3aa845858f29e439ebf1485f3621d9c9fee01c2c..b0c4e11856c3c4721c5a6a44ef31d398101fbf14
100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -76,10 +76,12 @@ class CompilationInfo {
ASSERT(!is_lazy());
flags_ |= IsEval::encode(true);
}
+
void MarkAsGlobal() {
ASSERT(!is_lazy());
flags_ |= IsGlobal::encode(true);
}
+
void set_parameter_count(int parameter_count) {
ASSERT(IsStub());
parameter_count_ = parameter_count;
@@ -88,13 +90,16 @@ class CompilationInfo {
void set_this_has_uses(bool has_no_uses) {
this_has_uses_ = has_no_uses;
}
+
bool this_has_uses() {
return this_has_uses_;
}
+
void SetStrictMode(StrictMode strict_mode) {
ASSERT(this->strict_mode() == SLOPPY || this->strict_mode() ==
strict_mode);
flags_ = StrictModeField::update(flags_, strict_mode);
}
+
void MarkAsNative() {
flags_ |= IsNative::encode(true);
}
@@ -155,8 +160,16 @@ class CompilationInfo {
return IsDebug::decode(flags_);
}
+ void PrepareForSerializing() {
+ ASSERT(!is_lazy());
+ flags_ |= PrepareForSerializing::encode(true);
+ }
+
+ bool will_serialize() const { return
PrepareForSerializing::decode(flags_); }
+
bool IsCodePreAgingActive() const {
- return FLAG_optimize_for_size && FLAG_age_code && !is_debug();
+ return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
+ !is_debug();
}
void SetParseRestriction(ParseRestriction restriction) {
@@ -393,6 +406,8 @@ class CompilationInfo {
class RequiresFrame: public BitField<bool, 13, 1> {};
// If the function cannot build a frame (for unspecified reasons)
class MustNotHaveEagerFrame: public BitField<bool, 14, 1> {};
+ // If we plan to serialize the compiled code.
+ class PrepareForSerializing : public BitField<bool, 15, 1> {};
unsigned flags_;
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index
cb5e94a0c38a684b234aa2e0ba330af4ff9145dc..de7faa3caaa63befef89f036a6b8d53bfc29d6a5
100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -301,10 +301,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo*
info) {
CodeGenerator::MakeCodePrologue(info, "full");
const int kInitialBufferSize = 4 * KB;
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize);
- if (FLAG_serialize_toplevel &&
- info->cached_data_mode() == PRODUCE_CACHED_DATA &&
info->is_global()) {
- masm.enable_serializer();
- }
+ if (info->will_serialize()) masm.enable_serializer();
#ifdef ENABLE_GDB_JIT_INTERFACE
masm.positions_recorder()->StartGDBJITLineInfoRecording();
Index: test/cctest/cctest.status
diff --git a/test/cctest/cctest.status b/test/cctest/cctest.status
index
b0a9caf0dfc5cc788b9211ce22e58c7999d41b4d..78f94a07d3babbf7383e5e4efc364dd83da23e13
100644
--- a/test/cctest/cctest.status
+++ b/test/cctest/cctest.status
@@ -75,9 +75,6 @@
# BUG(3287). (test-cpu-profiler/SampleWhenFrameIsNotSetup)
'test-cpu-profiler/*': [PASS, FLAKY],
- # TODO(yangguo): Temporarily disable code serializer test
- 'test-compiler/SerializeToplevel': [SKIP],
-
############################################################################
# Slow tests.
'test-api/Threading1': [PASS, ['mode == debug', SLOW]],
Index: test/cctest/test-compiler.cc
diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
index
c77b4b2dd3924936b4a758a1e776802d77f7fae5..8e629b44a7136ea38ee44468fc40c2beb5b73c56
100644
--- a/test/cctest/test-compiler.cc
+++ b/test/cctest/test-compiler.cc
@@ -436,6 +436,8 @@ TEST(SerializeToplevel) {
Handle<Object> result =
Execution::Call(isolate, fun, global, 0, NULL).ToHandleChecked();
CHECK_EQ(2, Handle<Smi>::cast(result)->value());
+
+ delete cache;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.