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