Chromium Code Reviews| Index: src/code-stubs.cc |
| =================================================================== |
| --- src/code-stubs.cc (revision 9957) |
| +++ src/code-stubs.cc (working copy) |
| @@ -101,7 +101,14 @@ |
| Factory* factory = isolate->factory(); |
| Heap* heap = isolate->heap(); |
| Code* code; |
| - if (!FindCodeInCache(&code)) { |
| + if (UseSpecialCache() |
| + ? FindCodeInSpecialCache(&code) |
| + : FindCodeInCache(&code)) { |
| + CHECK(IsPregenerated() == code->is_pregenerated()); |
|
Kevin Millikin (Chromium)
2011/11/11 10:12:34
Maybe I'm missing a good reason for this, but plea
Rico
2011/11/15 10:12:26
Done (checked with Erik that we can actally make t
|
| + return Handle<Code>(code); |
| + } |
| + |
| + { |
| HandleScope scope(isolate); |
| // Generate the new code. |
| @@ -122,18 +129,21 @@ |
| FinishCode(*new_object); |
| // Update the dictionary and the root in Heap. |
| - Handle<NumberDictionary> dict = |
| - factory->DictionaryAtNumberPut( |
| - Handle<NumberDictionary>(heap->code_stubs()), |
| - GetKey(), |
| - new_object); |
| - heap->public_set_code_stubs(*dict); |
| + |
| + if (UseSpecialCache()) { |
| + CHECK(AddToSpecialCache(new_object)); |
|
Kevin Millikin (Chromium)
2011/11/11 10:12:34
This function can only return true, so get rid of
Rico
2011/11/15 10:12:26
Done.
|
| + } else { |
| + Handle<NumberDictionary> dict = |
| + factory->DictionaryAtNumberPut( |
| + Handle<NumberDictionary>(heap->code_stubs()), |
| + GetKey(), |
| + new_object); |
| + heap->public_set_code_stubs(*dict); |
| + } |
| code = *new_object; |
| - Activate(code); |
| - } else { |
| - CHECK(IsPregenerated() == code->is_pregenerated()); |
| } |
| + Activate(code); |
| ASSERT(!NeedsImmovableCode() || heap->lo_space()->Contains(code)); |
| return Handle<Code>(code, isolate); |
| } |
| @@ -159,6 +169,35 @@ |
| } |
| +bool ICCompareStub::AddToSpecialCache(Handle<Code> new_object) { |
| + ASSERT(known_map_ != NULL); |
| + Isolate* isolate = new_object->GetIsolate(); |
|
Kevin Millikin (Chromium)
2011/11/11 10:12:34
I still don't fully understand why we need a separ
Rico
2011/11/15 10:12:26
I discussed with Erik and found a solution for usi
|
| + Factory* factory = isolate->factory(); |
| + Heap* heap = isolate->heap(); |
| + Handle<NumberDictionary> dict = |
| + factory->DictionaryAtNumberPut( |
| + Handle<NumberDictionary>(heap->compare_stubs_known_objects()), |
| + static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*known_map_)), |
| + new_object); |
| + heap->public_set_compare_stubs_known_objects(*dict); |
| + return true; |
| +} |
| + |
| + |
| +bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) { |
| + ASSERT(known_map_ != NULL); |
| + Heap* heap = Isolate::Current()->heap(); |
| + int index = heap->compare_stubs_known_objects()->FindEntry( |
| + static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*known_map_))); |
| + if (index != NumberDictionary::kNotFound) { |
| + *code_out = Code::cast(heap->compare_stubs_known_objects()->ValueAt(index)); |
| + UNREACHABLE(); |
|
Kevin Millikin (Chromium)
2011/11/11 10:12:34
Huh?
Rico
2011/11/15 10:12:26
Done.
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| + |
| int ICCompareStub::MinorKey() { |
| return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); |
| } |
| @@ -184,6 +223,10 @@ |
| case CompareIC::OBJECTS: |
| GenerateObjects(masm); |
| break; |
| + case CompareIC::KNOWN_OBJECTS: |
| + ASSERT(known_map_ != NULL); |
| + GenerateKnownObjects(masm, known_map_); |
|
Kevin Millikin (Chromium)
2011/11/11 10:12:34
No real need to pass known_map_ here.
Rico
2011/11/15 10:12:26
Done.
|
| + break; |
| default: |
| UNREACHABLE(); |
| } |