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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 byte* new_start) { | 497 byte* new_start) { |
498 for (int i = 0; i < infos->length(); i++) { | 498 for (int i = 0; i < infos->length(); i++) { |
499 RelocInfo* info = &(*infos)[i]; | 499 RelocInfo* info = &(*infos)[i]; |
500 info->set_pc(new_start + (info->pc() - old_start)); | 500 info->set_pc(new_start + (info->pc() - old_start)); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 | 504 |
505 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { | 505 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { |
506 for (int i = 0; i < infos->length(); i++) { | 506 for (int i = 0; i < infos->length(); i++) { |
507 Address target_address = (*infos)[i].target_address(); | 507 RelocInfo reloc_entry = (*infos)[i]; |
| 508 Address target_address = reloc_entry.target_address(); |
508 unsigned ast_id = static_cast<unsigned>((*infos)[i].data()); | 509 unsigned ast_id = static_cast<unsigned>((*infos)[i].data()); |
509 ProcessTargetAt(target_address, ast_id); | 510 Code* target = Code::GetCodeFromTargetAddress(target_address); |
| 511 switch (target->kind()) { |
| 512 case Code::LOAD_IC: |
| 513 case Code::STORE_IC: |
| 514 case Code::CALL_IC: |
| 515 case Code::KEYED_CALL_IC: |
| 516 if (target->ic_state() == MONOMORPHIC) { |
| 517 if (target->kind() == Code::CALL_IC && |
| 518 target->check_type() != RECEIVER_MAP_CHECK) { |
| 519 SetInfo(ast_id, Smi::FromInt(target->check_type())); |
| 520 } else { |
| 521 Object* map = target->FindFirstMap(); |
| 522 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); |
| 523 } |
| 524 } else if (target->ic_state() == MEGAMORPHIC) { |
| 525 SetInfo(ast_id, target); |
| 526 } |
| 527 break; |
| 528 |
| 529 case Code::KEYED_LOAD_IC: |
| 530 case Code::KEYED_STORE_IC: |
| 531 if (target->ic_state() == MONOMORPHIC || |
| 532 target->ic_state() == MEGAMORPHIC) { |
| 533 SetInfo(ast_id, target); |
| 534 } |
| 535 break; |
| 536 |
| 537 case Code::UNARY_OP_IC: |
| 538 case Code::BINARY_OP_IC: |
| 539 case Code::COMPARE_IC: |
| 540 case Code::TO_BOOLEAN_IC: |
| 541 SetInfo(ast_id, target); |
| 542 break; |
| 543 |
| 544 case Code::STUB: |
| 545 if (target->major_key() == CodeStub::CallFunction && |
| 546 target->has_function_cache()) { |
| 547 Object* value = CallFunctionStub::GetCachedValue(reloc_entry.pc()); |
| 548 if (value->IsJSFunction()) { |
| 549 SetInfo(ast_id, value); |
| 550 } |
| 551 } |
| 552 break; |
| 553 |
| 554 default: |
| 555 break; |
| 556 } |
510 } | 557 } |
511 } | 558 } |
512 | 559 |
513 | |
514 void TypeFeedbackOracle::ProcessTargetAt(Address target_address, | |
515 unsigned ast_id) { | |
516 Code* target = Code::GetCodeFromTargetAddress(target_address); | |
517 switch (target->kind()) { | |
518 case Code::LOAD_IC: | |
519 case Code::STORE_IC: | |
520 case Code::CALL_IC: | |
521 case Code::KEYED_CALL_IC: | |
522 if (target->ic_state() == MONOMORPHIC) { | |
523 if (target->kind() == Code::CALL_IC && | |
524 target->check_type() != RECEIVER_MAP_CHECK) { | |
525 SetInfo(ast_id, Smi::FromInt(target->check_type())); | |
526 } else { | |
527 Object* map = target->FindFirstMap(); | |
528 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map); | |
529 } | |
530 } else if (target->ic_state() == MEGAMORPHIC) { | |
531 SetInfo(ast_id, target); | |
532 } | |
533 break; | |
534 | |
535 case Code::KEYED_LOAD_IC: | |
536 case Code::KEYED_STORE_IC: | |
537 if (target->ic_state() == MONOMORPHIC || | |
538 target->ic_state() == MEGAMORPHIC) { | |
539 SetInfo(ast_id, target); | |
540 } | |
541 break; | |
542 | |
543 case Code::UNARY_OP_IC: | |
544 case Code::BINARY_OP_IC: | |
545 case Code::COMPARE_IC: | |
546 case Code::TO_BOOLEAN_IC: | |
547 SetInfo(ast_id, target); | |
548 break; | |
549 | |
550 case Code::STUB: | |
551 if (target->major_key() == CodeStub::CallFunction && | |
552 target->has_function_cache()) { | |
553 Object* value = CallFunctionStub::GetCachedValue(target_address); | |
554 if (value->IsJSFunction()) { | |
555 SetInfo(ast_id, value); | |
556 } | |
557 } | |
558 break; | |
559 | |
560 default: | |
561 break; | |
562 } | |
563 } | |
564 | |
565 | 560 |
566 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { | 561 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { |
567 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); | 562 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); |
568 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); | 563 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); |
569 USE(maybe_result); | 564 USE(maybe_result); |
570 #ifdef DEBUG | 565 #ifdef DEBUG |
571 Object* result = NULL; | 566 Object* result = NULL; |
572 // Dictionary has been allocated with sufficient size for all elements. | 567 // Dictionary has been allocated with sufficient size for all elements. |
573 ASSERT(maybe_result->ToObject(&result)); | 568 ASSERT(maybe_result->ToObject(&result)); |
574 ASSERT(*dictionary_ == result); | 569 ASSERT(*dictionary_ == result); |
575 #endif | 570 #endif |
576 } | 571 } |
577 | 572 |
578 } } // namespace v8::internal | 573 } } // namespace v8::internal |
OLD | NEW |