Index: src/codegen.cc |
diff --git a/src/codegen.cc b/src/codegen.cc |
index 92241d1c51f88f9ed243983695c3ac4072cada76..295d7b032369633e047e1e9cbdd4f8617b2058e7 100644 |
--- a/src/codegen.cc |
+++ b/src/codegen.cc |
@@ -206,10 +206,9 @@ Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm, |
} |
-// Generate the code. Takes a function literal, generates code for it, assemble |
-// all the pieces into a Code object. This function is only to be called by |
-// the compiler.cc code. |
-Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) { |
+// Generate the code. Compile the AST and assemble all the pieces into a |
+// Code object. |
+bool CodeGenerator::MakeCode(CompilationInfo* info) { |
Handle<Script> script = info->script(); |
if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
int len = String::cast(script->source())->length(); |
@@ -224,12 +223,14 @@ Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) { |
cgen.Generate(info); |
if (cgen.HasStackOverflow()) { |
ASSERT(!Top::has_pending_exception()); |
- return Handle<Code>::null(); |
+ return false; |
} |
- InLoopFlag in_loop = (cgen.loop_nesting() != 0) ? IN_LOOP : NOT_IN_LOOP; |
+ InLoopFlag in_loop = info->is_in_loop() ? IN_LOOP : NOT_IN_LOOP; |
Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop); |
- return MakeCodeEpilogue(cgen.masm(), flags, info); |
+ Handle<Code> code = MakeCodeEpilogue(cgen.masm(), flags, info); |
+ info->SetCode(code); // May be an empty handle. |
+ return !code.is_null(); |
} |
@@ -325,9 +326,12 @@ void CodeGenerator::ProcessDeclarations(ZoneList<Declaration*>* declarations) { |
} |
} else { |
Handle<SharedFunctionInfo> function = |
- Compiler::BuildFunctionInfo(node->fun(), script(), this); |
+ Compiler::BuildFunctionInfo(node->fun(), script()); |
// Check for stack-overflow exception. |
- if (HasStackOverflow()) return; |
+ if (function.is_null()) { |
+ SetStackOverflow(); |
+ return; |
+ } |
array->set(j++, *function); |
} |
} |