Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: src/type-info.cc

Issue 8404030: Version 3.7.1 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/type-info.h ('k') | src/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } else if (object->IsMap()) { 416 } else if (object->IsMap()) {
417 types->Add(Handle<Map>::cast(object)); 417 types->Add(Handle<Map>::cast(object));
418 } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) { 418 } else if (Handle<Code>::cast(object)->ic_state() == MEGAMORPHIC) {
419 types->Reserve(4); 419 types->Reserve(4);
420 ASSERT(object->IsCode()); 420 ASSERT(object->IsCode());
421 isolate_->stub_cache()->CollectMatchingMaps(types, *name, flags); 421 isolate_->stub_cache()->CollectMatchingMaps(types, *name, flags);
422 } 422 }
423 } 423 }
424 424
425 425
426 static void AddMapIfMissing(Handle<Map> map, SmallMapList* list) {
427 for (int i = 0; i < list->length(); ++i) {
428 if (list->at(i).is_identical_to(map)) return;
429 }
430 list->Add(map);
431 }
432
433
426 void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id, 434 void TypeFeedbackOracle::CollectKeyedReceiverTypes(unsigned ast_id,
427 SmallMapList* types) { 435 SmallMapList* types) {
428 Handle<Object> object = GetInfo(ast_id); 436 Handle<Object> object = GetInfo(ast_id);
429 if (!object->IsCode()) return; 437 if (!object->IsCode()) return;
430 Handle<Code> code = Handle<Code>::cast(object); 438 Handle<Code> code = Handle<Code>::cast(object);
431 if (code->kind() == Code::KEYED_LOAD_IC || 439 if (code->kind() == Code::KEYED_LOAD_IC ||
432 code->kind() == Code::KEYED_STORE_IC) { 440 code->kind() == Code::KEYED_STORE_IC) {
433 AssertNoAllocation no_allocation; 441 AssertNoAllocation no_allocation;
434 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 442 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
435 for (RelocIterator it(*code, mask); !it.done(); it.next()) { 443 for (RelocIterator it(*code, mask); !it.done(); it.next()) {
436 RelocInfo* info = it.rinfo(); 444 RelocInfo* info = it.rinfo();
437 Object* object = info->target_object(); 445 Object* object = info->target_object();
438 if (object->IsMap()) { 446 if (object->IsMap()) {
439 types->Add(Handle<Map>(Map::cast(object))); 447 AddMapIfMissing(Handle<Map>(Map::cast(object)), types);
440 } 448 }
441 } 449 }
442 } 450 }
443 } 451 }
444 452
445 453
446 byte TypeFeedbackOracle::ToBooleanTypes(unsigned ast_id) { 454 byte TypeFeedbackOracle::ToBooleanTypes(unsigned ast_id) {
447 Handle<Object> object = GetInfo(ast_id); 455 Handle<Object> object = GetInfo(ast_id);
448 return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0; 456 return object->IsCode() ? Handle<Code>::cast(object)->to_boolean_state() : 0;
449 } 457 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 byte* new_start) { 497 byte* new_start) {
490 for (int i = 0; i < infos->length(); i++) { 498 for (int i = 0; i < infos->length(); i++) {
491 RelocInfo* info = &(*infos)[i]; 499 RelocInfo* info = &(*infos)[i];
492 info->set_pc(new_start + (info->pc() - old_start)); 500 info->set_pc(new_start + (info->pc() - old_start));
493 } 501 }
494 } 502 }
495 503
496 504
497 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) { 505 void TypeFeedbackOracle::ProcessRelocInfos(ZoneList<RelocInfo>* infos) {
498 for (int i = 0; i < infos->length(); i++) { 506 for (int i = 0; i < infos->length(); i++) {
499 Address target_address = (*infos)[i].target_address(); 507 RelocInfo reloc_entry = (*infos)[i];
508 Address target_address = reloc_entry.target_address();
500 unsigned ast_id = static_cast<unsigned>((*infos)[i].data()); 509 unsigned ast_id = static_cast<unsigned>((*infos)[i].data());
501 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 }
502 } 557 }
503 } 558 }
504 559
505
506 void TypeFeedbackOracle::ProcessTargetAt(Address target_address,
507 unsigned ast_id) {
508 Code* target = Code::GetCodeFromTargetAddress(target_address);
509 switch (target->kind()) {
510 case Code::LOAD_IC:
511 case Code::STORE_IC:
512 case Code::CALL_IC:
513 case Code::KEYED_CALL_IC:
514 if (target->ic_state() == MONOMORPHIC) {
515 if (target->kind() == Code::CALL_IC &&
516 target->check_type() != RECEIVER_MAP_CHECK) {
517 SetInfo(ast_id, Smi::FromInt(target->check_type()));
518 } else {
519 Object* map = target->FindFirstMap();
520 SetInfo(ast_id, map == NULL ? static_cast<Object*>(target) : map);
521 }
522 } else if (target->ic_state() == MEGAMORPHIC) {
523 SetInfo(ast_id, target);
524 }
525 break;
526
527 case Code::KEYED_LOAD_IC:
528 case Code::KEYED_STORE_IC:
529 if (target->ic_state() == MONOMORPHIC ||
530 target->ic_state() == MEGAMORPHIC) {
531 SetInfo(ast_id, target);
532 }
533 break;
534
535 case Code::UNARY_OP_IC:
536 case Code::BINARY_OP_IC:
537 case Code::COMPARE_IC:
538 case Code::TO_BOOLEAN_IC:
539 SetInfo(ast_id, target);
540 break;
541
542 case Code::STUB:
543 if (target->major_key() == CodeStub::CallFunction &&
544 target->has_function_cache()) {
545 Object* value = CallFunctionStub::GetCachedValue(target_address);
546 if (value->IsJSFunction()) {
547 SetInfo(ast_id, value);
548 }
549 }
550 break;
551
552 default:
553 break;
554 }
555 }
556
557 560
558 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) { 561 void TypeFeedbackOracle::SetInfo(unsigned ast_id, Object* target) {
559 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound); 562 ASSERT(dictionary_->FindEntry(ast_id) == NumberDictionary::kNotFound);
560 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target); 563 MaybeObject* maybe_result = dictionary_->AtNumberPut(ast_id, target);
561 USE(maybe_result); 564 USE(maybe_result);
562 #ifdef DEBUG 565 #ifdef DEBUG
563 Object* result = NULL; 566 Object* result = NULL;
564 // Dictionary has been allocated with sufficient size for all elements. 567 // Dictionary has been allocated with sufficient size for all elements.
565 ASSERT(maybe_result->ToObject(&result)); 568 ASSERT(maybe_result->ToObject(&result));
566 ASSERT(*dictionary_ == result); 569 ASSERT(*dictionary_ == result);
567 #endif 570 #endif
568 } 571 }
569 572
570 } } // namespace v8::internal 573 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/type-info.h ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698