Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 int CodeStub::GetCodeKind() { | 94 int CodeStub::GetCodeKind() { |
| 95 return Code::STUB; | 95 return Code::STUB; |
| 96 } | 96 } |
| 97 | 97 |
| 98 | 98 |
| 99 Handle<Code> CodeStub::GetCode() { | 99 Handle<Code> CodeStub::GetCode() { |
| 100 Isolate* isolate = Isolate::Current(); | 100 Isolate* isolate = Isolate::Current(); |
| 101 Factory* factory = isolate->factory(); | 101 Factory* factory = isolate->factory(); |
| 102 Heap* heap = isolate->heap(); | 102 Heap* heap = isolate->heap(); |
| 103 Code* code; | 103 Code* code; |
| 104 if (!FindCodeInCache(&code)) { | 104 if (UseSpecialCache() |
| 105 ? FindCodeInSpecialCache(&code) | |
| 106 : FindCodeInCache(&code)) { | |
| 107 ASSERT(IsPregenerated() == code->is_pregenerated()); | |
| 108 return Handle<Code>(code); | |
| 109 } | |
| 110 | |
| 111 { | |
| 105 HandleScope scope(isolate); | 112 HandleScope scope(isolate); |
| 106 | 113 |
| 107 // Generate the new code. | 114 // Generate the new code. |
| 108 MacroAssembler masm(isolate, NULL, 256); | 115 MacroAssembler masm(isolate, NULL, 256); |
| 109 GenerateCode(&masm); | 116 GenerateCode(&masm); |
| 110 | 117 |
| 111 // Create the code object. | 118 // Create the code object. |
| 112 CodeDesc desc; | 119 CodeDesc desc; |
| 113 masm.GetCode(&desc); | 120 masm.GetCode(&desc); |
| 114 | 121 |
| 115 // Copy the generated code into a heap object. | 122 // Copy the generated code into a heap object. |
| 116 Code::Flags flags = Code::ComputeFlags( | 123 Code::Flags flags = Code::ComputeFlags( |
| 117 static_cast<Code::Kind>(GetCodeKind()), | 124 static_cast<Code::Kind>(GetCodeKind()), |
| 118 GetICState()); | 125 GetICState()); |
| 119 Handle<Code> new_object = factory->NewCode( | 126 Handle<Code> new_object = factory->NewCode( |
| 120 desc, flags, masm.CodeObject(), NeedsImmovableCode()); | 127 desc, flags, masm.CodeObject(), NeedsImmovableCode()); |
| 121 RecordCodeGeneration(*new_object, &masm); | 128 RecordCodeGeneration(*new_object, &masm); |
| 122 FinishCode(*new_object); | 129 FinishCode(*new_object); |
| 123 | 130 |
| 124 // Update the dictionary and the root in Heap. | 131 // Update the dictionary and the root in Heap. |
|
Kevin Millikin (Chromium)
2011/12/08 13:38:15
Move this comment into the else branch.
Rico
2011/12/08 15:54:56
Done.
| |
| 125 Handle<NumberDictionary> dict = | 132 |
| 126 factory->DictionaryAtNumberPut( | 133 if (UseSpecialCache()) { |
| 127 Handle<NumberDictionary>(heap->code_stubs()), | 134 AddToSpecialCache(new_object); |
| 128 GetKey(), | 135 } else { |
| 129 new_object); | 136 Handle<NumberDictionary> dict = |
| 130 heap->public_set_code_stubs(*dict); | 137 factory->DictionaryAtNumberPut( |
| 138 Handle<NumberDictionary>(heap->code_stubs()), | |
| 139 GetKey(), | |
| 140 new_object); | |
| 141 heap->public_set_code_stubs(*dict); | |
| 142 } | |
| 131 code = *new_object; | 143 code = *new_object; |
| 132 Activate(code); | |
| 133 } else { | |
| 134 CHECK(IsPregenerated() == code->is_pregenerated()); | |
| 135 } | 144 } |
| 136 | 145 |
| 146 Activate(code); | |
| 137 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); | 147 ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); |
| 138 return Handle<Code>(code, isolate); | 148 return Handle<Code>(code, isolate); |
| 139 } | 149 } |
| 140 | 150 |
| 141 | 151 |
| 142 const char* CodeStub::MajorName(CodeStub::Major major_key, | 152 const char* CodeStub::MajorName(CodeStub::Major major_key, |
| 143 bool allow_unknown_keys) { | 153 bool allow_unknown_keys) { |
| 144 switch (major_key) { | 154 switch (major_key) { |
| 145 #define DEF_CASE(name) case name: return #name "Stub"; | 155 #define DEF_CASE(name) case name: return #name "Stub"; |
| 146 CODE_STUB_LIST(DEF_CASE) | 156 CODE_STUB_LIST(DEF_CASE) |
| 147 #undef DEF_CASE | 157 #undef DEF_CASE |
| 148 default: | 158 default: |
| 149 if (!allow_unknown_keys) { | 159 if (!allow_unknown_keys) { |
| 150 UNREACHABLE(); | 160 UNREACHABLE(); |
| 151 } | 161 } |
| 152 return NULL; | 162 return NULL; |
| 153 } | 163 } |
| 154 } | 164 } |
| 155 | 165 |
| 156 | 166 |
| 157 void CodeStub::PrintName(StringStream* stream) { | 167 void CodeStub::PrintName(StringStream* stream) { |
| 158 stream->Add("%s", MajorName(MajorKey(), false)); | 168 stream->Add("%s", MajorName(MajorKey(), false)); |
| 159 } | 169 } |
| 160 | 170 |
| 161 | 171 |
| 172 void ICCompareStub::AddToSpecialCache(Handle<Code> new_object) { | |
| 173 ASSERT(*known_map_ != NULL); | |
| 174 Isolate* isolate = new_object->GetIsolate(); | |
| 175 Factory* factory = isolate->factory(); | |
| 176 return Map::UpdateCodeCache(known_map_, | |
| 177 factory->compare_ic_symbol(), | |
| 178 new_object); | |
| 179 } | |
| 180 | |
| 181 | |
| 182 bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) { | |
| 183 return false; | |
|
Kevin Millikin (Chromium)
2011/12/08 13:38:15
Why don't we look it up in the map?
Rico
2011/12/08 15:54:56
Done.
| |
| 184 } | |
| 185 | |
| 186 | |
| 162 int ICCompareStub::MinorKey() { | 187 int ICCompareStub::MinorKey() { |
| 163 return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); | 188 return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); |
| 164 } | 189 } |
| 165 | 190 |
| 166 | 191 |
| 167 void ICCompareStub::Generate(MacroAssembler* masm) { | 192 void ICCompareStub::Generate(MacroAssembler* masm) { |
| 168 switch (state_) { | 193 switch (state_) { |
| 169 case CompareIC::UNINITIALIZED: | 194 case CompareIC::UNINITIALIZED: |
| 170 GenerateMiss(masm); | 195 GenerateMiss(masm); |
| 171 break; | 196 break; |
| 172 case CompareIC::SMIS: | 197 case CompareIC::SMIS: |
| 173 GenerateSmis(masm); | 198 GenerateSmis(masm); |
| 174 break; | 199 break; |
| 175 case CompareIC::HEAP_NUMBERS: | 200 case CompareIC::HEAP_NUMBERS: |
| 176 GenerateHeapNumbers(masm); | 201 GenerateHeapNumbers(masm); |
| 177 break; | 202 break; |
| 178 case CompareIC::STRINGS: | 203 case CompareIC::STRINGS: |
| 179 GenerateStrings(masm); | 204 GenerateStrings(masm); |
| 180 break; | 205 break; |
| 181 case CompareIC::SYMBOLS: | 206 case CompareIC::SYMBOLS: |
| 182 GenerateSymbols(masm); | 207 GenerateSymbols(masm); |
| 183 break; | 208 break; |
| 184 case CompareIC::OBJECTS: | 209 case CompareIC::OBJECTS: |
| 185 GenerateObjects(masm); | 210 GenerateObjects(masm); |
| 186 break; | 211 break; |
| 212 case CompareIC::KNOWN_OBJECTS: | |
| 213 ASSERT(*known_map_ != NULL); | |
| 214 GenerateKnownObjects(masm); | |
| 215 break; | |
| 187 default: | 216 default: |
| 188 UNREACHABLE(); | 217 UNREACHABLE(); |
| 189 } | 218 } |
| 190 } | 219 } |
| 191 | 220 |
| 192 | 221 |
| 193 void InstanceofStub::PrintName(StringStream* stream) { | 222 void InstanceofStub::PrintName(StringStream* stream) { |
| 194 const char* args = ""; | 223 const char* args = ""; |
| 195 if (HasArgsInRegisters()) { | 224 if (HasArgsInRegisters()) { |
| 196 args = "_REGS"; | 225 args = "_REGS"; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_); | 422 KeyedStoreStubCompiler::GenerateStoreFastDoubleElement(masm, is_jsarray_); |
| 394 } else { | 423 } else { |
| 395 UNREACHABLE(); | 424 UNREACHABLE(); |
| 396 } | 425 } |
| 397 } | 426 } |
| 398 masm->bind(&fail); | 427 masm->bind(&fail); |
| 399 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_); | 428 KeyedStoreIC::GenerateRuntimeSetProperty(masm, strict_mode_); |
| 400 } | 429 } |
| 401 | 430 |
| 402 } } // namespace v8::internal | 431 } } // namespace v8::internal |
| OLD | NEW |