Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: src/codegen.cc

Issue 3561012: More refactoring of class Compiler's interface. (Closed)
Patch Set: Reindent some code, change some copyright dates. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast.h ('k') | src/compiler.h » ('j') | src/compiler.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/ast.h ('k') | src/compiler.h » ('j') | src/compiler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698