Index: src/code-stubs.cc |
=================================================================== |
--- src/code-stubs.cc (revision 9957) |
+++ src/code-stubs.cc (working copy) |
@@ -96,12 +96,18 @@ |
} |
-Handle<Code> CodeStub::GetCode() { |
+Handle<Code> CodeStub::GetCode(bool use_special_cache) { |
Isolate* isolate = Isolate::Current(); |
Factory* factory = isolate->factory(); |
Heap* heap = isolate->heap(); |
Code* code; |
- if (!FindCodeInCache(&code)) { |
+ |
+ if (use_special_cache || !FindCodeInCache(&code)) { |
Kevin Millikin (Chromium)
2011/11/10 19:08:42
I think this is a little clearer if it is somethin
Kevin Millikin (Chromium)
2011/11/10 19:11:18
And then include the compilation code starting wit
Rico
2011/11/11 08:49:11
Done and moved the pregenerated check up here
|
+ // Using a specialized cache is delegated to code in the specific stub. |
+ if (use_special_cache && FindCodeInSpecialCache(&code)) { |
+ return Handle<Code>(code, isolate); |
+ } |
+ |
HandleScope scope(isolate); |
// Generate the new code. |
@@ -122,12 +128,18 @@ |
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 (use_special_cache) { |
+ CHECK(AddToSpecialCache(new_object)); |
+ } 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 { |
@@ -159,6 +171,35 @@ |
} |
+bool ICCompareStub::AddToSpecialCache(Handle<Code> new_object) { |
+ ASSERT(known_map_ != NULL); |
+ Isolate* isolate = Isolate::Current(); |
Kevin Millikin (Chromium)
2011/11/10 19:08:42
If you want to avoid TLS to fetch the isolate, you
Rico
2011/11/11 08:49:11
Done.
|
+ 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(); |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+ |
int ICCompareStub::MinorKey() { |
return OpField::encode(op_ - Token::EQ) | StateField::encode(state_); |
} |
@@ -184,6 +225,10 @@ |
case CompareIC::OBJECTS: |
GenerateObjects(masm); |
break; |
+ case CompareIC::KNOWN_OBJECTS: |
+ ASSERT(known_map_ != NULL); |
+ GenerateKnownObjects(masm, known_map_); |
+ break; |
default: |
UNREACHABLE(); |
} |