Reviewers: Yang,
Description:
Merged r11592 into 3.9 branch.
Disable optimization for functions that have scopes that cannot be
reconstructed
from the context chain.
BUG=v8:2071
[email protected]
TEST=
Please review this at https://chromiumcodereview.appspot.com/10448006/
SVN Base: https://v8.googlecode.com/svn/branches/3.9
Affected files:
M src/compiler.cc
M src/full-codegen.cc
M src/scopes.h
M src/scopes.cc
M src/version.cc
A tools/merge-to-branch.sh
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
c9c2480fa2c6dbf326b1bc3314bb5d46de302cd8..ecac5cba69065c1226df0d281d14fd66db6cb5af
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -118,7 +118,7 @@ bool CompilationInfo::ShouldSelfOptimize() {
FLAG_crankshaft &&
!function()->flags()->Contains(kDontSelfOptimize) &&
!function()->flags()->Contains(kDontOptimize) &&
- function()->scope()->allows_lazy_recompilation() &&
+ function()->scope()->AllowsLazyRecompilation() &&
(shared_info().is_null() || !shared_info()->optimization_disabled());
}
Index: src/full-codegen.cc
diff --git a/src/full-codegen.cc b/src/full-codegen.cc
index
531eed249182a79cf4896cb6162144a05ebb2dc6..44fe011a4e0c422bf8c4ca06e92bdbe4022e4996
100644
--- a/src/full-codegen.cc
+++ b/src/full-codegen.cc
@@ -314,7 +314,8 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info)
{
Code::Flags flags = Code::ComputeFlags(Code::FUNCTION);
Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info);
code->set_optimizable(info->IsOptimizable() &&
- !info->function()->flags()->Contains(kDontOptimize));
+ !info->function()->flags()->Contains(kDontOptimize)
&&
+
info->function()->scope()->AllowsLazyRecompilation());
code->set_self_optimization_header(cgen.has_self_optimization_header_);
cgen.PopulateDeoptimizationData(code);
cgen.PopulateTypeFeedbackInfo(code);
Index: src/scopes.cc
diff --git a/src/scopes.cc b/src/scopes.cc
index
859cbd1ae61c8323c4f9edfb215ac1b8bfd53cc8..c142c3d61a02846f35094e1e8e678de17f65c260
100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -649,6 +649,26 @@ bool Scope::HasTrivialOuterContext() const {
}
+bool Scope::AllowsLazyRecompilation() const {
+ return !force_eager_compilation_ &&
+ !TrivialDeclarationScopesBeforeWithScope();
+}
+
+
+bool Scope::TrivialDeclarationScopesBeforeWithScope() const {
+ Scope* outer = outer_scope_;
+ if (outer == NULL) return false;
+ outer = outer->DeclarationScope();
+ while (outer != NULL) {
+ if (outer->is_with_scope()) return true;
+ if (outer->is_declaration_scope() && outer->num_heap_slots() > 0)
+ return false;
+ outer = outer->outer_scope_;
+ }
+ return false;
+}
+
+
int Scope::ContextChainLength(Scope* scope) {
int n = 0;
for (Scope* s = this; s != scope; s = s->outer_scope_) {
Index: src/scopes.h
diff --git a/src/scopes.h b/src/scopes.h
index
d315b7e5dcf806f883c9fcfe66124f23aa03c492..174dbdbf049d1b08e267ca366e4631d5c2ab90e4
100644
--- a/src/scopes.h
+++ b/src/scopes.h
@@ -369,13 +369,16 @@ class Scope: public ZoneObject {
bool AllowsLazyCompilation() const;
// True if we can lazily recompile functions with this scope.
- bool allows_lazy_recompilation() const {
- return !force_eager_compilation_;
- }
+ bool AllowsLazyRecompilation() const;
// True if the outer context of this scope is always the global context.
bool HasTrivialOuterContext() const;
+ // True if this scope is inside a with scope and all declaration scopes
+ // between them have empty contexts. Such declaration scopes become
+ // invisible during scope info deserialization.
+ bool TrivialDeclarationScopesBeforeWithScope() const;
+
// The number of contexts between this and scope; zero if this == scope.
int ContextChainLength(Scope* scope);
Index: src/version.cc
diff --git a/src/version.cc b/src/version.cc
index
558c4ac9321e85e221539ac1c5a4c725043c8ba9..25769f244dc4284fc75a564f241692e7d1178d2d
100644
--- a/src/version.cc
+++ b/src/version.cc
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 9
#define BUILD_NUMBER 24
-#define PATCH_LEVEL 28
+#define PATCH_LEVEL 29
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
Index: tools/merge-to-branch.sh
diff --git a/tools/merge-to-branch.sh b/tools/merge-to-branch.sh
old mode 100644
new mode 100755
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev