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

Unified Diff: src/codegen.cc

Issue 566008: Incorporate the arguments to the code generator constructors and their (Closed)
Patch Set: Incorporate the arguments to the code generator constructors and their... Created 10 years, 11 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/arm/full-codegen-arm.cc ('k') | src/codegen-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codegen.cc
===================================================================
--- src/codegen.cc (revision 3788)
+++ src/codegen.cc (working copy)
@@ -126,7 +126,7 @@
}
-void CodeGenerator::MakeCodePrologue(FunctionLiteral* fun) {
+void CodeGenerator::MakeCodePrologue(CompilationInfo* info) {
#ifdef DEBUG
bool print_source = false;
bool print_ast = false;
@@ -147,34 +147,35 @@
if (FLAG_trace_codegen || print_source || print_ast) {
PrintF("*** Generate code for %s function: ", ftype);
- fun->name()->ShortPrint();
+ info->function()->name()->ShortPrint();
PrintF(" ***\n");
}
if (print_source) {
- PrintF("--- Source from AST ---\n%s\n", PrettyPrinter().PrintProgram(fun));
+ PrintF("--- Source from AST ---\n%s\n",
+ PrettyPrinter().PrintProgram(info->function()));
}
if (print_ast) {
- PrintF("--- AST ---\n%s\n", AstPrinter().PrintProgram(fun));
+ PrintF("--- AST ---\n%s\n",
+ AstPrinter().PrintProgram(info->function()));
}
if (print_json_ast) {
JsonAstBuilder builder;
- PrintF("%s", builder.BuildProgram(fun));
+ PrintF("%s", builder.BuildProgram(info->function()));
}
#endif // DEBUG
}
-Handle<Code> CodeGenerator::MakeCodeEpilogue(FunctionLiteral* fun,
- MacroAssembler* masm,
+Handle<Code> CodeGenerator::MakeCodeEpilogue(MacroAssembler* masm,
Code::Flags flags,
- Handle<Script> script) {
+ CompilationInfo* info) {
// Allocate and install the code.
CodeDesc desc;
masm->GetCode(&desc);
- ZoneScopeInfo sinfo(fun->scope());
+ ZoneScopeInfo sinfo(info->scope());
Handle<Code> code =
Factory::NewCode(desc, &sinfo, flags, masm->CodeObject());
@@ -187,20 +188,23 @@
: FLAG_print_code;
if (print_code) {
// Print the source code if available.
+ Handle<Script> script = info->script();
+ FunctionLiteral* function = info->function();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
PrintF("--- Raw source ---\n");
StringInputBuffer stream(String::cast(script->source()));
- stream.Seek(fun->start_position());
+ stream.Seek(function->start_position());
// fun->end_position() points to the last character in the stream. We
// need to compensate by adding one to calculate the length.
- int source_len = fun->end_position() - fun->start_position() + 1;
+ int source_len =
+ function->end_position() - function->start_position() + 1;
for (int i = 0; i < source_len; i++) {
if (stream.has_more()) PrintF("%c", stream.GetNext());
}
PrintF("\n\n");
}
PrintF("--- Code ---\n");
- code->Disassemble(*fun->name()->ToCString());
+ code->Disassemble(*function->name()->ToCString());
}
#endif // ENABLE_DISASSEMBLER
@@ -214,21 +218,19 @@
// 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(FunctionLiteral* fun,
- Handle<Script> script,
- bool is_eval,
- CompilationInfo* info) {
+Handle<Code> CodeGenerator::MakeCode(CompilationInfo* info) {
+ Handle<Script> script = info->script();
if (!script->IsUndefined() && !script->source()->IsUndefined()) {
int len = String::cast(script->source())->length();
Counters::total_old_codegen_source_size.Increment(len);
}
- MakeCodePrologue(fun);
+ MakeCodePrologue(info);
// Generate code.
const int kInitialBufferSize = 4 * KB;
MacroAssembler masm(NULL, kInitialBufferSize);
- CodeGenerator cgen(&masm, script, is_eval);
+ CodeGenerator cgen(&masm);
CodeGeneratorScope scope(&cgen);
- cgen.Generate(fun, PRIMARY, info);
+ cgen.Generate(info, PRIMARY);
if (cgen.HasStackOverflow()) {
ASSERT(!Top::has_pending_exception());
return Handle<Code>::null();
@@ -236,7 +238,7 @@
InLoopFlag in_loop = (cgen.loop_nesting() != 0) ? IN_LOOP : NOT_IN_LOOP;
Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, in_loop);
- return MakeCodeEpilogue(fun, cgen.masm(), flags, script);
+ return MakeCodeEpilogue(cgen.masm(), flags, info);
}
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/codegen-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698