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