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

Side by Side Diff: src/codegen.cc

Issue 131101: Initial implementation of printing the AST as a JSON string. This... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 bool is_eval) { 133 bool is_eval) {
134 #ifdef ENABLE_DISASSEMBLER 134 #ifdef ENABLE_DISASSEMBLER
135 bool print_code = Bootstrapper::IsActive() 135 bool print_code = Bootstrapper::IsActive()
136 ? FLAG_print_builtin_code 136 ? FLAG_print_builtin_code
137 : FLAG_print_code; 137 : FLAG_print_code;
138 #endif 138 #endif
139 139
140 #ifdef DEBUG 140 #ifdef DEBUG
141 bool print_source = false; 141 bool print_source = false;
142 bool print_ast = false; 142 bool print_ast = false;
143 bool print_json_ast = false;
143 const char* ftype; 144 const char* ftype;
144 145
145 if (Bootstrapper::IsActive()) { 146 if (Bootstrapper::IsActive()) {
146 print_source = FLAG_print_builtin_source; 147 print_source = FLAG_print_builtin_source;
147 print_ast = FLAG_print_builtin_ast; 148 print_ast = FLAG_print_builtin_ast;
149 print_json_ast = FLAG_print_builtin_json_ast;
148 ftype = "builtin"; 150 ftype = "builtin";
149 } else { 151 } else {
150 print_source = FLAG_print_source; 152 print_source = FLAG_print_source;
151 print_ast = FLAG_print_ast; 153 print_ast = FLAG_print_ast;
154 print_json_ast = FLAG_print_json_ast;
152 ftype = "user-defined"; 155 ftype = "user-defined";
153 } 156 }
154 157
155 if (FLAG_trace_codegen || print_source || print_ast) { 158 if (FLAG_trace_codegen || print_source || print_ast) {
156 PrintF("*** Generate code for %s function: ", ftype); 159 PrintF("*** Generate code for %s function: ", ftype);
157 flit->name()->ShortPrint(); 160 flit->name()->ShortPrint();
158 PrintF(" ***\n"); 161 PrintF(" ***\n");
159 } 162 }
160 163
161 if (print_source) { 164 if (print_source) {
162 PrintF("--- Source from AST ---\n%s\n", PrettyPrinter().PrintProgram(flit)); 165 PrintF("--- Source from AST ---\n%s\n", PrettyPrinter().PrintProgram(flit));
163 } 166 }
164 167
165 if (print_ast) { 168 if (print_ast) {
166 PrintF("--- AST ---\n%s\n", AstPrinter().PrintProgram(flit)); 169 PrintF("--- AST ---\n%s\n", AstPrinter().PrintProgram(flit));
167 } 170 }
171
172 if (print_json_ast) {
173 JsonAstBuilder builder;
174 PrintF("%s", builder.BuildProgram(flit));
175 }
168 #endif // DEBUG 176 #endif // DEBUG
169 177
170 // Generate code. 178 // Generate code.
171 const int initial_buffer_size = 4 * KB; 179 const int initial_buffer_size = 4 * KB;
172 CodeGenerator cgen(initial_buffer_size, script, is_eval); 180 CodeGenerator cgen(initial_buffer_size, script, is_eval);
173 CodeGeneratorScope scope(&cgen); 181 CodeGeneratorScope scope(&cgen);
174 cgen.GenCode(flit); 182 cgen.GenCode(flit);
175 if (cgen.HasStackOverflow()) { 183 if (cgen.HasStackOverflow()) {
176 ASSERT(!Top::has_pending_exception()); 184 ASSERT(!Top::has_pending_exception());
177 return Handle<Code>::null(); 185 return Handle<Code>::null();
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 void ArgumentsAccessStub::Generate(MacroAssembler* masm) { 542 void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
535 switch (type_) { 543 switch (type_) {
536 case READ_LENGTH: GenerateReadLength(masm); break; 544 case READ_LENGTH: GenerateReadLength(masm); break;
537 case READ_ELEMENT: GenerateReadElement(masm); break; 545 case READ_ELEMENT: GenerateReadElement(masm); break;
538 case NEW_OBJECT: GenerateNewObject(masm); break; 546 case NEW_OBJECT: GenerateNewObject(masm); break;
539 } 547 }
540 } 548 }
541 549
542 550
543 } } // namespace v8::internal 551 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.cc ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698