| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 #ifdef DEBUG | 76 #ifdef DEBUG |
| 77 Print(); | 77 Print(); |
| 78 #endif | 78 #endif |
| 79 code->Disassemble(GetName()); | 79 code->Disassemble(GetName()); |
| 80 PrintF("\n"); | 80 PrintF("\n"); |
| 81 } | 81 } |
| 82 #endif | 82 #endif |
| 83 } | 83 } |
| 84 | 84 |
| 85 | 85 |
| 86 int CodeStub::GetCodeKind() { |
| 87 return Code::STUB; |
| 88 } |
| 89 |
| 90 |
| 86 Handle<Code> CodeStub::GetCode() { | 91 Handle<Code> CodeStub::GetCode() { |
| 87 Code* code; | 92 Code* code; |
| 88 if (!FindCodeInCache(&code)) { | 93 if (!FindCodeInCache(&code)) { |
| 89 v8::HandleScope scope; | 94 v8::HandleScope scope; |
| 90 | 95 |
| 91 // Generate the new code. | 96 // Generate the new code. |
| 92 MacroAssembler masm(NULL, 256); | 97 MacroAssembler masm(NULL, 256); |
| 93 GenerateCode(&masm); | 98 GenerateCode(&masm); |
| 94 | 99 |
| 95 // Create the code object. | 100 // Create the code object. |
| 96 CodeDesc desc; | 101 CodeDesc desc; |
| 97 masm.GetCode(&desc); | 102 masm.GetCode(&desc); |
| 98 | 103 |
| 99 // Copy the generated code into a heap object. | 104 // Copy the generated code into a heap object. |
| 100 Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop()); | 105 Code::Flags flags = Code::ComputeFlags( |
| 106 static_cast<Code::Kind>(GetCodeKind()), |
| 107 InLoop(), |
| 108 GetICState()); |
| 101 Handle<Code> new_object = | 109 Handle<Code> new_object = |
| 102 Factory::NewCode(desc, NULL, flags, masm.CodeObject()); | 110 Factory::NewCode(desc, NULL, flags, masm.CodeObject()); |
| 103 RecordCodeGeneration(*new_object, &masm); | 111 RecordCodeGeneration(*new_object, &masm); |
| 104 | 112 |
| 105 if (has_custom_cache()) { | 113 if (has_custom_cache()) { |
| 106 SetCustomCache(*new_object); | 114 SetCustomCache(*new_object); |
| 107 } else { | 115 } else { |
| 108 // Update the dictionary and the root in Heap. | 116 // Update the dictionary and the root in Heap. |
| 109 Handle<NumberDictionary> dict = | 117 Handle<NumberDictionary> dict = |
| 110 Factory::DictionaryAtNumberPut( | 118 Factory::DictionaryAtNumberPut( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 125 if (!FindCodeInCache(&code)) { | 133 if (!FindCodeInCache(&code)) { |
| 126 // Generate the new code. | 134 // Generate the new code. |
| 127 MacroAssembler masm(NULL, 256); | 135 MacroAssembler masm(NULL, 256); |
| 128 GenerateCode(&masm); | 136 GenerateCode(&masm); |
| 129 | 137 |
| 130 // Create the code object. | 138 // Create the code object. |
| 131 CodeDesc desc; | 139 CodeDesc desc; |
| 132 masm.GetCode(&desc); | 140 masm.GetCode(&desc); |
| 133 | 141 |
| 134 // Try to copy the generated code into a heap object. | 142 // Try to copy the generated code into a heap object. |
| 135 Code::Flags flags = Code::ComputeFlags(Code::STUB, InLoop()); | 143 Code::Flags flags = Code::ComputeFlags( |
| 144 static_cast<Code::Kind>(GetCodeKind()), |
| 145 InLoop(), |
| 146 GetICState()); |
| 136 Object* new_object = | 147 Object* new_object = |
| 137 Heap::CreateCode(desc, NULL, flags, masm.CodeObject()); | 148 Heap::CreateCode(desc, NULL, flags, masm.CodeObject()); |
| 138 if (new_object->IsFailure()) return new_object; | 149 if (new_object->IsFailure()) return new_object; |
| 139 code = Code::cast(new_object); | 150 code = Code::cast(new_object); |
| 140 RecordCodeGeneration(code, &masm); | 151 RecordCodeGeneration(code, &masm); |
| 141 | 152 |
| 142 if (has_custom_cache()) { | 153 if (has_custom_cache()) { |
| 143 SetCustomCache(code); | 154 SetCustomCache(code); |
| 144 } else { | 155 } else { |
| 145 // Try to update the code cache but do not fail if unable. | 156 // Try to update the code cache but do not fail if unable. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 163 default: | 174 default: |
| 164 if (!allow_unknown_keys) { | 175 if (!allow_unknown_keys) { |
| 165 UNREACHABLE(); | 176 UNREACHABLE(); |
| 166 } | 177 } |
| 167 return NULL; | 178 return NULL; |
| 168 } | 179 } |
| 169 } | 180 } |
| 170 | 181 |
| 171 | 182 |
| 172 } } // namespace v8::internal | 183 } } // namespace v8::internal |
| OLD | NEW |