Reviewers: fschneider,
Description:
Delay processing of declarations for inlining candidates.
Processing the declarations in an inlining candidate must be performed
after constructing the Hydrogen environment of the candidate function.
[email protected]
BUG=
TEST=
Please review this at http://codereview.chromium.org/7027028/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/hydrogen.cc
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
85fb18765b1e275281f7229a532fc21a9e775099..e2948d8afed50db44c8c0131f3f9ff3e2b0a7d5a
100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -4195,14 +4195,6 @@ bool HGraphBuilder::TryInline(Call* expr) {
return false;
}
- // Check if we can handle all declarations in the inlined functions.
- VisitDeclarations(target_info.scope()->declarations());
- if (HasStackOverflow()) {
- TraceInline(target, caller, "target has non-trivial declaration");
- ClearStackOverflow();
- return false;
- }
-
// Don't inline functions that uses the arguments object or that
// have a mismatching number of parameters.
int arity = expr->arguments()->length();
@@ -4236,7 +4228,6 @@ bool HGraphBuilder::TryInline(Call* expr) {
target_shared);
}
- // ----------------------------------------------------------------
// Save the pending call context and type feedback oracle. Set up new
ones
// for the inlined function.
ASSERT(target_shared->has_deoptimization_support());
@@ -4254,9 +4245,19 @@ bool HGraphBuilder::TryInline(Call* expr) {
call_kind);
HBasicBlock* body_entry = CreateBasicBlock(inner_env);
current_block()->Goto(body_entry);
-
body_entry->SetJoinId(expr->ReturnId());
set_current_block(body_entry);
+ // Check if we can handle all declarations in the inlined functions.
+ VisitDeclarations(target_info.scope()->declarations());
+ if (HasStackOverflow()) {
+ TraceInline(target, caller, "target has non-trivial declaration");
+ ClearStackOverflow();
+ return false;
+ }
+
+ // ----------------------------------------------------------------
+ // After this point, we've made a decision to inline this function (so
+ // TryInline should always return true).
AddInstruction(new(zone()) HEnterInlined(target,
function,
call_kind));
@@ -5372,9 +5373,12 @@ void HGraphBuilder::VisitThisFunction(ThisFunction*
expr) {
void HGraphBuilder::VisitDeclaration(Declaration* decl) {
- // We allow only declarations that do not require code generation.
- // The following all require code generation: global variables,
- // functions, and variables with slot type LOOKUP
+ // The use of this function in TryInline assumes that it does not emit
+ // instructions into the graph. Mutating the current environment is OK.
+
+ // We allow only declarations that do not require code generation. The
+ // following all require code generation: global variables, functions,
and
+ // variables with slot type LOOKUP
Variable* var = decl->proxy()->var();
Slot* slot = var->AsSlot();
if (var->is_global() ||
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev