| 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 19 matching lines...) Expand all Loading... |
| 30 #include "bootstrapper.h" | 30 #include "bootstrapper.h" |
| 31 #include "code-stubs.h" | 31 #include "code-stubs.h" |
| 32 #include "factory.h" | 32 #include "factory.h" |
| 33 #include "macro-assembler.h" | 33 #include "macro-assembler.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 Handle<Code> CodeStub::GetCode() { | 38 Handle<Code> CodeStub::GetCode() { |
| 39 uint32_t key = GetKey(); | 39 uint32_t key = GetKey(); |
| 40 int index = Heap::code_stubs()->FindNumberEntry(key); | 40 int index = Heap::code_stubs()->FindEntry(key); |
| 41 if (index == -1) { | 41 if (index == NumberDictionary::kNotFound) { |
| 42 HandleScope scope; | 42 HandleScope scope; |
| 43 | 43 |
| 44 // Update the static counter each time a new code stub is generated. | 44 // Update the static counter each time a new code stub is generated. |
| 45 Counters::code_stubs.Increment(); | 45 Counters::code_stubs.Increment(); |
| 46 | 46 |
| 47 // Generate the new code. | 47 // Generate the new code. |
| 48 MacroAssembler masm(NULL, 256); | 48 MacroAssembler masm(NULL, 256); |
| 49 | 49 |
| 50 // Nested stubs are not allowed for leafs. | 50 // Nested stubs are not allowed for leafs. |
| 51 masm.set_allow_stub_calls(AllowsStubCalls()); | 51 masm.set_allow_stub_calls(AllowsStubCalls()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 if (FLAG_print_code_stubs) { | 73 if (FLAG_print_code_stubs) { |
| 74 #ifdef DEBUG | 74 #ifdef DEBUG |
| 75 Print(); | 75 Print(); |
| 76 #endif | 76 #endif |
| 77 code->Disassemble(GetName()); | 77 code->Disassemble(GetName()); |
| 78 PrintF("\n"); | 78 PrintF("\n"); |
| 79 } | 79 } |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 // Update the dictionary and the root in Heap. | 82 // Update the dictionary and the root in Heap. |
| 83 Handle<Dictionary> dict = | 83 Handle<NumberDictionary> dict = |
| 84 Factory::DictionaryAtNumberPut(Handle<Dictionary>(Heap::code_stubs()), | 84 Factory::DictionaryAtNumberPut( |
| 85 key, | 85 Handle<NumberDictionary>(Heap::code_stubs()), |
| 86 code); | 86 key, |
| 87 code); |
| 87 Heap::set_code_stubs(*dict); | 88 Heap::set_code_stubs(*dict); |
| 88 index = Heap::code_stubs()->FindNumberEntry(key); | 89 index = Heap::code_stubs()->FindEntry(key); |
| 89 } | 90 } |
| 90 ASSERT(index != -1); | 91 ASSERT(index != NumberDictionary::kNotFound); |
| 91 | 92 |
| 92 return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index))); | 93 return Handle<Code>(Code::cast(Heap::code_stubs()->ValueAt(index))); |
| 93 } | 94 } |
| 94 | 95 |
| 95 | 96 |
| 96 const char* CodeStub::MajorName(CodeStub::Major major_key) { | 97 const char* CodeStub::MajorName(CodeStub::Major major_key) { |
| 97 switch (major_key) { | 98 switch (major_key) { |
| 98 case CallFunction: | 99 case CallFunction: |
| 99 return "CallFunction"; | 100 return "CallFunction"; |
| 100 case GenericBinaryOp: | 101 case GenericBinaryOp: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 case WriteInt32ToHeapNumber: | 139 case WriteInt32ToHeapNumber: |
| 139 return "WriteInt32ToHeapNumber"; | 140 return "WriteInt32ToHeapNumber"; |
| 140 default: | 141 default: |
| 141 UNREACHABLE(); | 142 UNREACHABLE(); |
| 142 return NULL; | 143 return NULL; |
| 143 } | 144 } |
| 144 } | 145 } |
| 145 | 146 |
| 146 | 147 |
| 147 } } // namespace v8::internal | 148 } } // namespace v8::internal |
| OLD | NEW |