OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 typedef void (*Generator)(MacroAssembler*, int); | 635 typedef void (*Generator)(MacroAssembler*, int); |
636 Generator g = FUNCTION_CAST<Generator>(functions[i].generator); | 636 Generator g = FUNCTION_CAST<Generator>(functions[i].generator); |
637 // We pass all arguments to the generator, but it may not use all of | 637 // We pass all arguments to the generator, but it may not use all of |
638 // them. This works because the first arguments are on top of the | 638 // them. This works because the first arguments are on top of the |
639 // stack. | 639 // stack. |
640 g(&masm, functions[i].name); | 640 g(&masm, functions[i].name); |
641 // Move the code into the object heap. | 641 // Move the code into the object heap. |
642 CodeDesc desc; | 642 CodeDesc desc; |
643 masm.GetCode(&desc); | 643 masm.GetCode(&desc); |
644 Code::Flags flags = functions[i].flags; | 644 Code::Flags flags = functions[i].flags; |
645 Object* code = Heap::CreateCode(desc, NULL, flags); | 645 Object* code; |
646 if (code->IsFailure()) { | 646 { |
647 if (code->IsRetryAfterGC()) { | 647 // During startup it's OK to always allocate and defer GC to later. |
648 CHECK(Heap::CollectGarbage(Failure::cast(code)->requested(), | 648 // This simplifies things because we don't need to retry. |
649 Failure::cast(code)->allocation_space())); | 649 AlwaysAllocateScope __scope__; |
650 code = Heap::CreateCode(desc, NULL, flags); | 650 code = Heap::CreateCode(desc, NULL, flags); |
651 } | |
652 if (code->IsFailure()) { | 651 if (code->IsFailure()) { |
653 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); | 652 v8::internal::V8::FatalProcessOutOfMemory("CreateCode"); |
654 } | 653 } |
655 } | 654 } |
656 // Add any unresolved jumps or calls to the fixup list in the | 655 // Add any unresolved jumps or calls to the fixup list in the |
657 // bootstrapper. | 656 // bootstrapper. |
658 Bootstrapper::AddFixup(Code::cast(code), &masm); | 657 Bootstrapper::AddFixup(Code::cast(code), &masm); |
659 // Log the event and add the code to the builtins array. | 658 // Log the event and add the code to the builtins array. |
660 LOG(CodeCreateEvent("Builtin", Code::cast(code), functions[i].s_name)); | 659 LOG(CodeCreateEvent("Builtin", Code::cast(code), functions[i].s_name)); |
661 builtins_[i] = code; | 660 builtins_[i] = code; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 if (entry->contains(pc)) { | 694 if (entry->contains(pc)) { |
696 return names_[i]; | 695 return names_[i]; |
697 } | 696 } |
698 } | 697 } |
699 } | 698 } |
700 return NULL; | 699 return NULL; |
701 } | 700 } |
702 | 701 |
703 | 702 |
704 } } // namespace v8::internal | 703 } } // namespace v8::internal |
OLD | NEW |