OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/code-stubs.h" | 5 #include "src/code-stubs.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/compiler/code-stub-assembler.h" | 10 #include "src/compiler/code-stub-assembler.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 DCHECK(*known_map_ != NULL); | 444 DCHECK(*known_map_ != NULL); |
445 GenerateKnownReceivers(masm); | 445 GenerateKnownReceivers(masm); |
446 break; | 446 break; |
447 case CompareICState::GENERIC: | 447 case CompareICState::GENERIC: |
448 GenerateGeneric(masm); | 448 GenerateGeneric(masm); |
449 break; | 449 break; |
450 } | 450 } |
451 } | 451 } |
452 | 452 |
453 | 453 |
454 void CompareNilICStub::UpdateStatus(Handle<Object> object) { | |
455 State state = this->state(); | |
456 DCHECK(!state.Contains(GENERIC)); | |
457 State old_state = state; | |
458 if (object->IsNull()) { | |
459 state.Add(NULL_TYPE); | |
460 } else if (object->IsUndefined()) { | |
461 state.Add(UNDEFINED); | |
462 } else if (object->IsUndetectableObject() || object->IsSmi()) { | |
463 state.RemoveAll(); | |
464 state.Add(GENERIC); | |
465 } else if (IsMonomorphic()) { | |
466 state.RemoveAll(); | |
467 state.Add(GENERIC); | |
468 } else { | |
469 state.Add(MONOMORPHIC_MAP); | |
470 } | |
471 TraceTransition(old_state, state); | |
472 set_sub_minor_key(TypesBits::update(sub_minor_key(), state.ToIntegral())); | |
473 } | |
474 | |
475 | |
476 Handle<Code> TurboFanCodeStub::GenerateCode() { | 454 Handle<Code> TurboFanCodeStub::GenerateCode() { |
477 const char* name = CodeStub::MajorName(MajorKey()); | 455 const char* name = CodeStub::MajorName(MajorKey()); |
478 Zone zone; | 456 Zone zone; |
479 CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor()); | 457 CallInterfaceDescriptor descriptor(GetCallInterfaceDescriptor()); |
480 compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor, | 458 compiler::CodeStubAssembler assembler(isolate(), &zone, descriptor, |
481 GetCodeFlags(), name); | 459 GetCodeFlags(), name); |
482 GenerateAssembly(&assembler); | 460 GenerateAssembly(&assembler); |
483 return assembler.GenerateCode(); | 461 return assembler.GenerateCode(); |
484 } | 462 } |
485 | 463 |
(...skipping 15 matching lines...) Expand all Loading... |
501 // bug somewhere in our state transition machinery. | 479 // bug somewhere in our state transition machinery. |
502 DCHECK(from != to); | 480 DCHECK(from != to); |
503 if (!FLAG_trace_ic) return; | 481 if (!FLAG_trace_ic) return; |
504 OFStream os(stdout); | 482 OFStream os(stdout); |
505 os << "["; | 483 os << "["; |
506 PrintBaseName(os); | 484 PrintBaseName(os); |
507 os << ": " << from << "=>" << to << "]" << std::endl; | 485 os << ": " << from << "=>" << to << "]" << std::endl; |
508 } | 486 } |
509 | 487 |
510 | 488 |
511 void CompareNilICStub::PrintBaseName(std::ostream& os) const { // NOLINT | |
512 CodeStub::PrintBaseName(os); | |
513 os << ((nil_value() == kNullValue) ? "(NullValue)" : "(UndefinedValue)"); | |
514 } | |
515 | |
516 | |
517 void CompareNilICStub::PrintState(std::ostream& os) const { // NOLINT | |
518 os << state(); | |
519 } | |
520 | |
521 | |
522 // TODO(svenpanne) Make this a real infix_ostream_iterator. | 489 // TODO(svenpanne) Make this a real infix_ostream_iterator. |
523 class SimpleListPrinter { | 490 class SimpleListPrinter { |
524 public: | 491 public: |
525 explicit SimpleListPrinter(std::ostream& os) : os_(os), first_(true) {} | 492 explicit SimpleListPrinter(std::ostream& os) : os_(os), first_(true) {} |
526 | 493 |
527 void Add(const char* s) { | 494 void Add(const char* s) { |
528 if (first_) { | 495 if (first_) { |
529 first_ = false; | 496 first_ = false; |
530 } else { | 497 } else { |
531 os_ << ","; | 498 os_ << ","; |
532 } | 499 } |
533 os_ << s; | 500 os_ << s; |
534 } | 501 } |
535 | 502 |
536 private: | 503 private: |
537 std::ostream& os_; | 504 std::ostream& os_; |
538 bool first_; | 505 bool first_; |
539 }; | 506 }; |
540 | 507 |
541 | 508 |
542 std::ostream& operator<<(std::ostream& os, const CompareNilICStub::State& s) { | |
543 os << "("; | |
544 SimpleListPrinter p(os); | |
545 if (s.IsEmpty()) p.Add("None"); | |
546 if (s.Contains(CompareNilICStub::UNDEFINED)) p.Add("Undefined"); | |
547 if (s.Contains(CompareNilICStub::NULL_TYPE)) p.Add("Null"); | |
548 if (s.Contains(CompareNilICStub::MONOMORPHIC_MAP)) p.Add("MonomorphicMap"); | |
549 if (s.Contains(CompareNilICStub::GENERIC)) p.Add("Generic"); | |
550 return os << ")"; | |
551 } | |
552 | |
553 | |
554 Type* CompareNilICStub::GetType(Zone* zone, Handle<Map> map) { | |
555 State state = this->state(); | |
556 if (state.Contains(CompareNilICStub::GENERIC)) return Type::Any(); | |
557 | |
558 Type* result = Type::None(); | |
559 if (state.Contains(CompareNilICStub::UNDEFINED)) { | |
560 result = Type::Union(result, Type::Undefined(), zone); | |
561 } | |
562 if (state.Contains(CompareNilICStub::NULL_TYPE)) { | |
563 result = Type::Union(result, Type::Null(), zone); | |
564 } | |
565 if (state.Contains(CompareNilICStub::MONOMORPHIC_MAP)) { | |
566 Type* type = map.is_null() ? Type::Detectable() : Type::Class(map, zone); | |
567 result = Type::Union(result, type, zone); | |
568 } | |
569 | |
570 return result; | |
571 } | |
572 | |
573 | |
574 Type* CompareNilICStub::GetInputType(Zone* zone, Handle<Map> map) { | |
575 Type* output_type = GetType(zone, map); | |
576 Type* nil_type = nil_value() == kNullValue ? Type::Null() : Type::Undefined(); | |
577 return Type::Union(output_type, nil_type, zone); | |
578 } | |
579 | |
580 | |
581 void CallICStub::PrintState(std::ostream& os) const { // NOLINT | 509 void CallICStub::PrintState(std::ostream& os) const { // NOLINT |
582 os << state(); | 510 os << state(); |
583 } | 511 } |
584 | 512 |
585 | 513 |
586 void JSEntryStub::FinishCode(Handle<Code> code) { | 514 void JSEntryStub::FinishCode(Handle<Code> code) { |
587 Handle<FixedArray> handler_table = | 515 Handle<FixedArray> handler_table = |
588 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); | 516 code->GetIsolate()->factory()->NewFixedArray(1, TENURED); |
589 handler_table->set(0, Smi::FromInt(handler_offset_)); | 517 handler_table->set(0, Smi::FromInt(handler_offset_)); |
590 code->set_handler_table(*handler_table); | 518 code->set_handler_table(*handler_table); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
732 descriptor->Initialize(); | 660 descriptor->Initialize(); |
733 } | 661 } |
734 | 662 |
735 | 663 |
736 void AllocateInNewSpaceStub::InitializeDescriptor( | 664 void AllocateInNewSpaceStub::InitializeDescriptor( |
737 CodeStubDescriptor* descriptor) { | 665 CodeStubDescriptor* descriptor) { |
738 descriptor->Initialize(); | 666 descriptor->Initialize(); |
739 } | 667 } |
740 | 668 |
741 | 669 |
742 void CompareNilICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | |
743 descriptor->Initialize(FUNCTION_ADDR(Runtime_CompareNilIC_Miss)); | |
744 descriptor->SetMissHandler(ExternalReference( | |
745 Runtime::FunctionForId(Runtime::kCompareNilIC_Miss), isolate())); | |
746 } | |
747 | |
748 | |
749 void ToBooleanStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 670 void ToBooleanStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
750 descriptor->Initialize(FUNCTION_ADDR(Runtime_ToBooleanIC_Miss)); | 671 descriptor->Initialize(FUNCTION_ADDR(Runtime_ToBooleanIC_Miss)); |
751 descriptor->SetMissHandler(ExternalReference( | 672 descriptor->SetMissHandler(ExternalReference( |
752 Runtime::FunctionForId(Runtime::kToBooleanIC_Miss), isolate())); | 673 Runtime::FunctionForId(Runtime::kToBooleanIC_Miss), isolate())); |
753 } | 674 } |
754 | 675 |
755 | 676 |
756 void BinaryOpICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { | 677 void BinaryOpICStub::InitializeDescriptor(CodeStubDescriptor* descriptor) { |
757 descriptor->Initialize(FUNCTION_ADDR(Runtime_BinaryOpIC_Miss)); | 678 descriptor->Initialize(FUNCTION_ADDR(Runtime_BinaryOpIC_Miss)); |
758 descriptor->SetMissHandler(ExternalReference( | 679 descriptor->SetMissHandler(ExternalReference( |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 if (type->Is(Type::UntaggedPointer())) { | 907 if (type->Is(Type::UntaggedPointer())) { |
987 return Representation::External(); | 908 return Representation::External(); |
988 } | 909 } |
989 | 910 |
990 DCHECK(!type->Is(Type::Untagged())); | 911 DCHECK(!type->Is(Type::Untagged())); |
991 return Representation::Tagged(); | 912 return Representation::Tagged(); |
992 } | 913 } |
993 | 914 |
994 } // namespace internal | 915 } // namespace internal |
995 } // namespace v8 | 916 } // namespace v8 |
OLD | NEW |