| OLD | NEW |
| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 void FullCodeGenSyntaxChecker::VisitThisFunction(ThisFunction* expr) { | 432 void FullCodeGenSyntaxChecker::VisitThisFunction(ThisFunction* expr) { |
| 433 // Supported. | 433 // Supported. |
| 434 } | 434 } |
| 435 | 435 |
| 436 #undef BAILOUT | 436 #undef BAILOUT |
| 437 #undef CHECK_BAILOUT | 437 #undef CHECK_BAILOUT |
| 438 | 438 |
| 439 | 439 |
| 440 #define __ ACCESS_MASM(masm()) | 440 #define __ ACCESS_MASM(masm()) |
| 441 | 441 |
| 442 Handle<Code> FullCodeGenerator::MakeCode(FunctionLiteral* fun, | 442 Handle<Code> FullCodeGenerator::MakeCode(CompilationInfo* info) { |
| 443 Handle<Script> script, | 443 Handle<Script> script = info->script(); |
| 444 bool is_eval) { | |
| 445 if (!script->IsUndefined() && !script->source()->IsUndefined()) { | 444 if (!script->IsUndefined() && !script->source()->IsUndefined()) { |
| 446 int len = String::cast(script->source())->length(); | 445 int len = String::cast(script->source())->length(); |
| 447 Counters::total_full_codegen_source_size.Increment(len); | 446 Counters::total_full_codegen_source_size.Increment(len); |
| 448 } | 447 } |
| 449 CodeGenerator::MakeCodePrologue(fun); | 448 CodeGenerator::MakeCodePrologue(info); |
| 450 const int kInitialBufferSize = 4 * KB; | 449 const int kInitialBufferSize = 4 * KB; |
| 451 MacroAssembler masm(NULL, kInitialBufferSize); | 450 MacroAssembler masm(NULL, kInitialBufferSize); |
| 452 FullCodeGenerator cgen(&masm, script, is_eval); | 451 FullCodeGenerator cgen(&masm); |
| 453 cgen.Generate(fun, PRIMARY); | 452 cgen.Generate(info, PRIMARY); |
| 454 if (cgen.HasStackOverflow()) { | 453 if (cgen.HasStackOverflow()) { |
| 455 ASSERT(!Top::has_pending_exception()); | 454 ASSERT(!Top::has_pending_exception()); |
| 456 return Handle<Code>::null(); | 455 return Handle<Code>::null(); |
| 457 } | 456 } |
| 458 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); | 457 Code::Flags flags = Code::ComputeFlags(Code::FUNCTION, NOT_IN_LOOP); |
| 459 return CodeGenerator::MakeCodeEpilogue(fun, &masm, flags, script); | 458 return CodeGenerator::MakeCodeEpilogue(&masm, flags, info); |
| 460 } | 459 } |
| 461 | 460 |
| 462 | 461 |
| 463 int FullCodeGenerator::SlotOffset(Slot* slot) { | 462 int FullCodeGenerator::SlotOffset(Slot* slot) { |
| 464 ASSERT(slot != NULL); | 463 ASSERT(slot != NULL); |
| 465 // Offset is negative because higher indexes are at lower addresses. | 464 // Offset is negative because higher indexes are at lower addresses. |
| 466 int offset = -slot->index() * kPointerSize; | 465 int offset = -slot->index() * kPointerSize; |
| 467 // Adjust by a (parameter or local) base offset. | 466 // Adjust by a (parameter or local) base offset. |
| 468 switch (slot->type()) { | 467 switch (slot->type()) { |
| 469 case Slot::PARAMETER: | 468 case Slot::PARAMETER: |
| 470 offset += (function_->scope()->num_parameters() + 1) * kPointerSize; | 469 offset += (scope()->num_parameters() + 1) * kPointerSize; |
| 471 break; | 470 break; |
| 472 case Slot::LOCAL: | 471 case Slot::LOCAL: |
| 473 offset += JavaScriptFrameConstants::kLocal0Offset; | 472 offset += JavaScriptFrameConstants::kLocal0Offset; |
| 474 break; | 473 break; |
| 475 case Slot::CONTEXT: | 474 case Slot::CONTEXT: |
| 476 case Slot::LOOKUP: | 475 case Slot::LOOKUP: |
| 477 UNREACHABLE(); | 476 UNREACHABLE(); |
| 478 } | 477 } |
| 479 return offset; | 478 return offset; |
| 480 } | 479 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 array->set(j++, *(var->name())); | 512 array->set(j++, *(var->name())); |
| 514 if (decl->fun() == NULL) { | 513 if (decl->fun() == NULL) { |
| 515 if (var->mode() == Variable::CONST) { | 514 if (var->mode() == Variable::CONST) { |
| 516 // In case this is const property use the hole. | 515 // In case this is const property use the hole. |
| 517 array->set_the_hole(j++); | 516 array->set_the_hole(j++); |
| 518 } else { | 517 } else { |
| 519 array->set_undefined(j++); | 518 array->set_undefined(j++); |
| 520 } | 519 } |
| 521 } else { | 520 } else { |
| 522 Handle<JSFunction> function = | 521 Handle<JSFunction> function = |
| 523 Compiler::BuildBoilerplate(decl->fun(), script_, this); | 522 Compiler::BuildBoilerplate(decl->fun(), script(), this); |
| 524 // Check for stack-overflow exception. | 523 // Check for stack-overflow exception. |
| 525 if (HasStackOverflow()) return; | 524 if (HasStackOverflow()) return; |
| 526 array->set(j++, *function); | 525 array->set(j++, *function); |
| 527 } | 526 } |
| 528 } | 527 } |
| 529 } | 528 } |
| 530 // Invoke the platform-dependent code generator to do the actual | 529 // Invoke the platform-dependent code generator to do the actual |
| 531 // declaration the global variables and functions. | 530 // declaration the global variables and functions. |
| 532 DeclareGlobals(array); | 531 DeclareGlobals(array); |
| 533 } | 532 } |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 // The macros used here must preserve the result register. | 1145 // The macros used here must preserve the result register. |
| 1147 __ Drop(stack_depth); | 1146 __ Drop(stack_depth); |
| 1148 __ PopTryHandler(); | 1147 __ PopTryHandler(); |
| 1149 return 0; | 1148 return 0; |
| 1150 } | 1149 } |
| 1151 | 1150 |
| 1152 #undef __ | 1151 #undef __ |
| 1153 | 1152 |
| 1154 | 1153 |
| 1155 } } // namespace v8::internal | 1154 } } // namespace v8::internal |
| OLD | NEW |