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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 isolate_->builtins()->builtin(Builtins::kStoreIC_GlobalProxy)) { | 431 isolate_->builtins()->builtin(Builtins::kStoreIC_GlobalProxy)) { |
| 432 // TODO(fschneider): We could collect the maps and signal that | 432 // TODO(fschneider): We could collect the maps and signal that |
| 433 // we need a generic store (or load) here. | 433 // we need a generic store (or load) here. |
| 434 ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC); | 434 ASSERT(Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC); |
| 435 } else if (object->IsMap()) { | 435 } else if (object->IsMap()) { |
| 436 types->Add(Handle<Map>::cast(object)); | 436 types->Add(Handle<Map>::cast(object)); |
| 437 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && | 437 } else if (FLAG_collect_megamorphic_maps_from_stub_cache && |
| 438 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { | 438 Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { |
| 439 types->Reserve(4); | 439 types->Reserve(4); |
| 440 ASSERT(object->IsCode()); | 440 ASSERT(object->IsCode()); |
| 441 isolate_->stub_cache()->CollectMatchingMaps(types, *name, flags); | 441 isolate_->stub_cache()->CollectMatchingMaps(types, |
| 442 *name, | |
| 443 flags, | |
| 444 global_context_); | |
| 442 } | 445 } |
| 443 } | 446 } |
| 444 | 447 |
| 445 | 448 |
| 449 bool TypeFeedbackOracle::InSameContext(Handle<Map> map, | |
| 450 Handle<Context> global_context) { | |
| 451 Handle<Object> constructor(map->constructor()); | |
| 452 if (constructor.is_null()) return true; | |
| 453 if (!constructor->IsJSFunction()) return true; | |
| 454 Handle<JSFunction> function = Handle<JSFunction>::cast(constructor); | |
| 455 return function->context()->global() == global_context->global() | |
| 456 || function->context()->global() == global_context->builtins(); | |
| 457 } | |
| 458 | |
|
Vyacheslav Egorov (Chromium)
2011/12/12 13:34:44
add empty line
| |
| 446 static void AddMapIfMissing(Handle<Map> map, SmallMapList* list) { | 459 static void AddMapIfMissing(Handle<Map> map, SmallMapList* list) { |
| 447 for (int i = 0; i < list->length(); ++i) { | 460 for (int i = 0; i < list->length(); ++i) { |
| 448 if (list->at(i).is_identical_to(map)) return; | 461 if (list->at(i).is_identical_to(map)) return; |
| 449 } | 462 } |
| 450 list->Add(map); | 463 list->Add(map); |
| 451 } | 464 } |
| 452 | 465 |
| 453 | 466 |
| 454 void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id, | 467 void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id, |
| 455 SmallMapList* types) { | 468 SmallMapList* types) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 case Code::LOAD_IC: | 545 case Code::LOAD_IC: |
| 533 case Code::STORE_IC: | 546 case Code::STORE_IC: |
| 534 case Code::CALL_IC: | 547 case Code::CALL_IC: |
| 535 case Code::KEYED_CALL_IC: | 548 case Code::KEYED_CALL_IC: |
| 536 if (target->ic_state() == MONOMORPHIC) { | 549 if (target->ic_state() == MONOMORPHIC) { |
| 537 if (target->kind() == Code::CALL_IC && | 550 if (target->kind() == Code::CALL_IC && |
| 538 target->check_type() != RECEIVER_MAP_CHECK) { | 551 target->check_type() != RECEIVER_MAP_CHECK) { |
| 539 SetInfo(ast_id, Smi::FromInt(target->check_type())); | 552 SetInfo(ast_id, Smi::FromInt(target->check_type())); |
| 540 } else { | 553 } else { |
| 541 Object* map = target->FindFirstMap(); | 554 Object* map = target->FindFirstMap(); |
| 542 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); | 555 if (map == NULL) { |
| 556 SetInfo(ast_id, static_cast<Object*>(target)); | |
| 557 } else if (InSameContext(Handle<Map>(Map::cast(map)), | |
| 558 global_context_)) { | |
| 559 SetInfo(ast_id, map); | |
| 560 } | |
| 543 } | 561 } |
| 544 } else if (target->ic_state() == MEGAMORPHIC) { | 562 } else if (target->ic_state() == MEGAMORPHIC) { |
| 545 SetInfo(ast_id, target); | 563 SetInfo(ast_id, target); |
| 546 } | 564 } |
| 547 break; | 565 break; |
| 548 | 566 |
| 549 case Code::KEYED_LOAD_IC: | 567 case Code::KEYED_LOAD_IC: |
| 550 case Code::KEYED_STORE_IC: | 568 case Code::KEYED_STORE_IC: |
| 551 if (target->ic_state() == MONOMORPHIC || | 569 if (target->ic_state() == MONOMORPHIC || |
| 552 target->ic_state() == MEGAMORPHIC) { | 570 target->ic_state() == MEGAMORPHIC) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 584 USE(maybe_result); | 602 USE(maybe_result); |
| 585 #ifdef DEBUG | 603 #ifdef DEBUG |
| 586 Object* result = NULL; | 604 Object* result = NULL; |
| 587 // Dictionary has been allocated with sufficient size for all elements. | 605 // Dictionary has been allocated with sufficient size for all elements. |
| 588 ASSERT(maybe_result->ToObject(&result)); | 606 ASSERT(maybe_result->ToObject(&result)); |
| 589 ASSERT(*dictionary_ == result); | 607 ASSERT(*dictionary_ == result); |
| 590 #endif | 608 #endif |
| 591 } | 609 } |
| 592 | 610 |
| 593 } } // namespace v8::internal | 611 } } // namespace v8::internal |
| OLD | NEW |