Chromium Code Reviews| Index: src/type-info.cc |
| =================================================================== |
| --- src/type-info.cc (revision 10237) |
| +++ src/type-info.cc (working copy) |
| @@ -438,11 +438,24 @@ |
| Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
| types->Reserve(4); |
| ASSERT(object->IsCode()); |
| - isolate_->stub_cache()->CollectMatchingMaps(types, *name, flags); |
| + isolate_->stub_cache()->CollectMatchingMaps(types, |
| + *name, |
| + flags, |
| + global_context_); |
| } |
| } |
| +bool TypeFeedbackOracle::InSameContext(Handle<Map> map, |
| + Handle<Context> global_context) { |
| + Handle<Object> constructor(map->constructor()); |
| + if (constructor.is_null()) return true; |
| + if (!constructor->IsJSFunction()) return true; |
| + Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); |
| + return function->context()->global() == global_context->global() |
| + || function->context()->global() == global_context->builtins(); |
| +} |
| + |
|
Vyacheslav Egorov (Chromium)
2011/12/12 13:34:44
add empty line
|
| static void AddMapIfMissing(Handle<Map> map, SmallMapList* list) { |
| for (int i = 0; i < list->length(); ++i) { |
| if (list->at(i).is_identical_to(map)) return; |
| @@ -539,7 +552,12 @@ |
| SetInfo(ast_id, Smi::FromInt(target->check_type())); |
| } else { |
| Object* map = target->FindFirstMap(); |
| - SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); |
| + if (map == NULL) { |
| + SetInfo(ast_id, static_cast<Object*>(target)); |
| + } else if (InSameContext(Handle<Map>(Map::cast(map)), |
| + global_context_)) { |
| + SetInfo(ast_id, map); |
| + } |
| } |
| } else if (target->ic_state() == MEGAMORPHIC) { |
| SetInfo(ast_id, target); |