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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 index = Heap::code_stubs()->FindEntry(key); | 52 index = Heap::code_stubs()->FindEntry(key); |
53 if (index != NumberDictionary::kNotFound) | 53 if (index != NumberDictionary::kNotFound) |
54 return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index))); | 54 return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index))); |
55 } | 55 } |
56 | 56 |
57 Code* result; | 57 Code* result; |
58 { | 58 { |
59 v8::HandleScope scope; | 59 v8::HandleScope scope; |
60 | 60 |
61 // Update the static counter each time a new code stub is generated. | 61 // Update the static counter each time a new code stub is generated. |
62 Counters::code_stubs.Increment(); | 62 INC_COUNTER(code_stubs); |
63 | 63 |
64 // Generate the new code. | 64 // Generate the new code. |
65 MacroAssembler masm(NULL, 256); | 65 MacroAssembler masm(NULL, 256); |
66 | 66 |
67 // Nested stubs are not allowed for leafs. | 67 // Nested stubs are not allowed for leafs. |
68 masm.set_allow_stub_calls(AllowsStubCalls()); | 68 masm.set_allow_stub_calls(AllowsStubCalls()); |
69 | 69 |
70 // Generate the code for the stub. | 70 // Generate the code for the stub. |
71 masm.set_generating_stub(true); | 71 masm.set_generating_stub(true); |
72 Generate(&masm); | 72 Generate(&masm); |
73 | 73 |
74 // Create the code object. | 74 // Create the code object. |
75 CodeDesc desc; | 75 CodeDesc desc; |
76 masm.GetCode(&desc); | 76 masm.GetCode(&desc); |
77 | 77 |
78 // Copy the generated code into a heap object, and store the major key. | 78 // Copy the generated code into a heap object, and store the major key. |
79 Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop()); | 79 Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop()); |
80 Handle<Code> code = Factory::NewCode(desc, NULL, flags, masm.CodeObject()); | 80 Handle<Code> code = Factory::NewCode(desc, NULL, flags, masm.CodeObject()); |
81 code->set_major_key(MajorKey()); | 81 code->set_major_key(MajorKey()); |
82 | 82 |
83 // Add unresolved entries in the code to the fixup list. | 83 // Add unresolved entries in the code to the fixup list. |
84 Bootstrapper::AddFixup(*code, &masm); | 84 Bootstrapper::AddFixup(*code, &masm); |
85 | 85 |
86 LOG(CodeCreateEvent(Logger::STUB_TAG, *code, GetName())); | 86 LOG(CodeCreateEvent(Logger::STUB_TAG, *code, GetName())); |
87 Counters::total_stubs_code_size.Increment(code->instruction_size()); | 87 INCREMENT_COUNTER(total_stubs_code_size, code->instruction_size()); |
88 | 88 |
89 #ifdef ENABLE_DISASSEMBLER | 89 #ifdef ENABLE_DISASSEMBLER |
90 if (FLAG_print_code_stubs) { | 90 if (FLAG_print_code_stubs) { |
91 #ifdef DEBUG | 91 #ifdef DEBUG |
92 Print(); | 92 Print(); |
93 #endif | 93 #endif |
94 code->Disassemble(GetName()); | 94 code->Disassemble(GetName()); |
95 PrintF("\n"); | 95 PrintF("\n"); |
96 } | 96 } |
97 #endif | 97 #endif |
(...skipping 22 matching lines...) Expand all Loading... |
120 CODE_STUB_LIST(DEF_CASE) | 120 CODE_STUB_LIST(DEF_CASE) |
121 #undef DEF_CASE | 121 #undef DEF_CASE |
122 default: | 122 default: |
123 UNREACHABLE(); | 123 UNREACHABLE(); |
124 return NULL; | 124 return NULL; |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 | 128 |
129 } } // namespace v8::internal | 129 } } // namespace v8::internal |
OLD | NEW |