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

Side by Side Diff: src/full-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 unified diff | Download patch
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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 Visit(expr->right()); 270 Visit(expr->right());
271 } 271 }
272 272
273 273
274 void BreakableStatementChecker::VisitThisFunction(ThisFunction* expr) { 274 void BreakableStatementChecker::VisitThisFunction(ThisFunction* expr) {
275 } 275 }
276 276
277 277
278 #define __ ACCESS_MASM(masm()) 278 #define __ ACCESS_MASM(masm())
279 279
280 Handle<Code> FullCodeGenerator::MakeCode(CompilationInfo* info) { 280 bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
281 Handle<Script> script = info->script(); 281 Handle<Script> script = info->script();
282 if (!script->IsUndefined() && !script->source()->IsUndefined()) { 282 if (!script->IsUndefined() && !script->source()->IsUndefined()) {
283 int len = String::cast(script->source())->length(); 283 int len = String::cast(script->source())->length();
284 Counters::total_full_codegen_source_size.Increment(len); 284 Counters::total_full_codegen_source_size.Increment(len);
285 } 285 }
286 CodeGenerator::MakeCodePrologue(info); 286 CodeGenerator::MakeCodePrologue(info);
287 const int kInitialBufferSize = 4 * KB; 287 const int kInitialBufferSize = 4 * KB;
288 MacroAssembler masm(NULL, kInitialBufferSize); 288 MacroAssembler masm(NULL, kInitialBufferSize);
289 289
290 FullCodeGenerator cgen(&masm); 290 FullCodeGenerator cgen(&masm);
291 cgen.Generate(info); 291 cgen.Generate(info);
292 if (cgen.HasStackOverflow()) { 292 if (cgen.HasStackOverflow()) {
293 ASSERT(!Top::has_pending_exception()); 293 ASSERT(!Top::has_pending_exception());
294 return Handle<Code>::null(); 294 return false;
295 } 295 }
296
296 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); 297 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP);
297 return CodeGenerator::MakeCodeEpilogue(&masm, flags, info); 298 Handle<Code> code = CodeGenerator::MakeCodeEpilogue(&masm, flags, info);
299 info->SetCode(code); // may be an empty handle.
300 return !code.is_null();
298 } 301 }
299 302
300 303
301 MemOperand FullCodeGenerator::ContextOperand(Register context, int index) { 304 MemOperand FullCodeGenerator::ContextOperand(Register context, int index) {
302 return CodeGenerator::ContextOperand(context, index); 305 return CodeGenerator::ContextOperand(context, index);
303 } 306 }
304 307
305 308
306 int FullCodeGenerator::SlotOffset(Slot* slot) { 309 int FullCodeGenerator::SlotOffset(Slot* slot) {
307 ASSERT(slot != NULL); 310 ASSERT(slot != NULL);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 array->set(j++, *(var->name())); 458 array->set(j++, *(var->name()));
456 if (decl->fun() == NULL) { 459 if (decl->fun() == NULL) {
457 if (var->mode() == Variable::CONST) { 460 if (var->mode() == Variable::CONST) {
458 // In case this is const property use the hole. 461 // In case this is const property use the hole.
459 array->set_the_hole(j++); 462 array->set_the_hole(j++);
460 } else { 463 } else {
461 array->set_undefined(j++); 464 array->set_undefined(j++);
462 } 465 }
463 } else { 466 } else {
464 Handle<SharedFunctionInfo> function = 467 Handle<SharedFunctionInfo> function =
465 Compiler::BuildFunctionInfo(decl->fun(), script(), this); 468 Compiler::BuildFunctionInfo(decl->fun(), script());
466 // Check for stack-overflow exception. 469 // Check for stack-overflow exception.
467 if (HasStackOverflow()) return; 470 if (function.is_null()) {
471 SetStackOverflow();
472 return;
473 }
468 array->set(j++, *function); 474 array->set(j++, *function);
469 } 475 }
470 } 476 }
471 } 477 }
472 // Invoke the platform-dependent code generator to do the actual 478 // Invoke the platform-dependent code generator to do the actual
473 // declaration the global variables and functions. 479 // declaration the global variables and functions.
474 DeclareGlobals(array); 480 DeclareGlobals(array);
475 } 481 }
476 } 482 }
477 483
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 Comment cmnt(masm_, "[ Literal"); 1155 Comment cmnt(masm_, "[ Literal");
1150 context()->Plug(expr->handle()); 1156 context()->Plug(expr->handle());
1151 } 1157 }
1152 1158
1153 1159
1154 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) { 1160 void FullCodeGenerator::VisitFunctionLiteral(FunctionLiteral* expr) {
1155 Comment cmnt(masm_, "[ FunctionLiteral"); 1161 Comment cmnt(masm_, "[ FunctionLiteral");
1156 1162
1157 // Build the function boilerplate and instantiate it. 1163 // Build the function boilerplate and instantiate it.
1158 Handle<SharedFunctionInfo> function_info = 1164 Handle<SharedFunctionInfo> function_info =
1159 Compiler::BuildFunctionInfo(expr, script(), this); 1165 Compiler::BuildFunctionInfo(expr, script());
1160 if (HasStackOverflow()) return; 1166 if (function_info.is_null()) {
1167 SetStackOverflow();
1168 return;
1169 }
1161 EmitNewClosure(function_info); 1170 EmitNewClosure(function_info);
1162 } 1171 }
1163 1172
1164 1173
1165 void FullCodeGenerator::VisitSharedFunctionInfoLiteral( 1174 void FullCodeGenerator::VisitSharedFunctionInfoLiteral(
1166 SharedFunctionInfoLiteral* expr) { 1175 SharedFunctionInfoLiteral* expr) {
1167 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral"); 1176 Comment cmnt(masm_, "[ SharedFunctionInfoLiteral");
1168 EmitNewClosure(expr->shared_function_info()); 1177 EmitNewClosure(expr->shared_function_info());
1169 } 1178 }
1170 1179
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 ASSERT(args->length() == 1); 1224 ASSERT(args->length() == 1);
1216 VisitForStackValue(args->at(0)); 1225 VisitForStackValue(args->at(0));
1217 __ CallRuntime(Runtime::kRegExpCloneResult, 1); 1226 __ CallRuntime(Runtime::kRegExpCloneResult, 1);
1218 context()->Plug(result_register()); 1227 context()->Plug(result_register());
1219 } 1228 }
1220 1229
1221 #undef __ 1230 #undef __
1222 1231
1223 1232
1224 } } // namespace v8::internal 1233 } } // namespace v8::internal
OLDNEW
« src/compiler.h ('K') | « src/full-codegen.h ('k') | src/ia32/codegen-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698