| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 CodeDesc desc; | 96 CodeDesc desc; |
| 97 masm.GetCode(&desc); | 97 masm.GetCode(&desc); |
| 98 | 98 |
| 99 // Copy the generated code into a heap object. | 99 // Copy the generated code into a heap object. |
| 100 Code::Flags flags = Code::ComputeFlags( | 100 Code::Flags flags = Code::ComputeFlags( |
| 101 static_cast<Code::Kind>(GetCodeKind()), | 101 static_cast<Code::Kind>(GetCodeKind()), |
| 102 InLoop(), | 102 InLoop(), |
| 103 GetICState()); | 103 GetICState()); |
| 104 Handle<Code> new_object = FACTORY->NewCode(desc, flags, masm.CodeObject()); | 104 Handle<Code> new_object = FACTORY->NewCode(desc, flags, masm.CodeObject()); |
| 105 RecordCodeGeneration(*new_object, &masm); | 105 RecordCodeGeneration(*new_object, &masm); |
| 106 FinishCode(*new_object); |
| 106 | 107 |
| 107 // Update the dictionary and the root in Heap. | 108 // Update the dictionary and the root in Heap. |
| 108 Handle<NumberDictionary> dict = | 109 Handle<NumberDictionary> dict = |
| 109 FACTORY->DictionaryAtNumberPut( | 110 FACTORY->DictionaryAtNumberPut( |
| 110 Handle<NumberDictionary>(HEAP->code_stubs()), | 111 Handle<NumberDictionary>(HEAP->code_stubs()), |
| 111 GetKey(), | 112 GetKey(), |
| 112 new_object); | 113 new_object); |
| 113 HEAP->public_set_code_stubs(*dict); | 114 HEAP->public_set_code_stubs(*dict); |
| 114 | 115 |
| 115 code = *new_object; | 116 code = *new_object; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 135 static_cast<Code::Kind>(GetCodeKind()), | 136 static_cast<Code::Kind>(GetCodeKind()), |
| 136 InLoop(), | 137 InLoop(), |
| 137 GetICState()); | 138 GetICState()); |
| 138 Object* new_object; | 139 Object* new_object; |
| 139 { MaybeObject* maybe_new_object = | 140 { MaybeObject* maybe_new_object = |
| 140 HEAP->CreateCode(desc, flags, masm.CodeObject()); | 141 HEAP->CreateCode(desc, flags, masm.CodeObject()); |
| 141 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; | 142 if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| 142 } | 143 } |
| 143 code = Code::cast(new_object); | 144 code = Code::cast(new_object); |
| 144 RecordCodeGeneration(code, &masm); | 145 RecordCodeGeneration(code, &masm); |
| 146 FinishCode(code); |
| 145 | 147 |
| 146 // Try to update the code cache but do not fail if unable. | 148 // Try to update the code cache but do not fail if unable. |
| 147 MaybeObject* maybe_new_object = | 149 MaybeObject* maybe_new_object = |
| 148 HEAP->code_stubs()->AtNumberPut(GetKey(), code); | 150 HEAP->code_stubs()->AtNumberPut(GetKey(), code); |
| 149 if (maybe_new_object->ToObject(&new_object)) { | 151 if (maybe_new_object->ToObject(&new_object)) { |
| 150 HEAP->public_set_code_stubs(NumberDictionary::cast(new_object)); | 152 HEAP->public_set_code_stubs(NumberDictionary::cast(new_object)); |
| 151 } | 153 } |
| 152 } | 154 } |
| 153 | 155 |
| 154 return code; | 156 return code; |
| 155 } | 157 } |
| 156 | 158 |
| 157 | 159 |
| 158 const char* CodeStub::MajorName(CodeStub::Major major_key, | 160 const char* CodeStub::MajorName(CodeStub::Major major_key, |
| 159 bool allow_unknown_keys) { | 161 bool allow_unknown_keys) { |
| 160 switch (major_key) { | 162 switch (major_key) { |
| 161 #define DEF_CASE(name) case name: return #name; | 163 #define DEF_CASE(name) case name: return #name; |
| 162 CODE_STUB_LIST(DEF_CASE) | 164 CODE_STUB_LIST(DEF_CASE) |
| 163 #undef DEF_CASE | 165 #undef DEF_CASE |
| 164 default: | 166 default: |
| 165 if (!allow_unknown_keys) { | 167 if (!allow_unknown_keys) { |
| 166 UNREACHABLE(); | 168 UNREACHABLE(); |
| 167 } | 169 } |
| 168 return NULL; | 170 return NULL; |
| 169 } | 171 } |
| 170 } | 172 } |
| 171 | 173 |
| 172 | 174 |
| 175 int ICCompareStub::MinorKey() { |
| 176 return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); |
| 177 } |
| 178 |
| 179 |
| 180 void ICCompareStub::Generate(MacroAssembler* masm) { |
| 181 switch (state_) { |
| 182 case CompareIC::UNINITIALIZED: |
| 183 GenerateMiss(masm); |
| 184 break; |
| 185 case CompareIC::SMIS: |
| 186 GenerateSmis(masm); |
| 187 break; |
| 188 case CompareIC::HEAP_NUMBERS: |
| 189 GenerateHeapNumbers(masm); |
| 190 break; |
| 191 case CompareIC::OBJECTS: |
| 192 GenerateObjects(masm); |
| 193 break; |
| 194 default: |
| 195 UNREACHABLE(); |
| 196 } |
| 197 } |
| 198 |
| 199 |
| 173 } } // namespace v8::internal | 200 } } // namespace v8::internal |
| OLD | NEW |