OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 first_instruction_index_(-1), | 68 first_instruction_index_(-1), |
69 last_instruction_index_(-1), | 69 last_instruction_index_(-1), |
70 deleted_phis_(4, graph->zone()), | 70 deleted_phis_(4, graph->zone()), |
71 parent_loop_header_(NULL), | 71 parent_loop_header_(NULL), |
72 is_inline_return_target_(false), | 72 is_inline_return_target_(false), |
73 is_deoptimizing_(false), | 73 is_deoptimizing_(false), |
74 dominates_loop_successors_(false), | 74 dominates_loop_successors_(false), |
75 is_osr_entry_(false) { } | 75 is_osr_entry_(false) { } |
76 | 76 |
77 | 77 |
| 78 Isolate* HBasicBlock::isolate() const { |
| 79 return graph_->isolate(); |
| 80 } |
| 81 |
| 82 |
78 void HBasicBlock::AttachLoopInformation() { | 83 void HBasicBlock::AttachLoopInformation() { |
79 ASSERT(!IsLoopHeader()); | 84 ASSERT(!IsLoopHeader()); |
80 loop_information_ = new(zone()) HLoopInformation(this, zone()); | 85 loop_information_ = new(zone()) HLoopInformation(this, zone()); |
81 } | 86 } |
82 | 87 |
83 | 88 |
84 void HBasicBlock::DetachLoopInformation() { | 89 void HBasicBlock::DetachLoopInformation() { |
85 ASSERT(IsLoopHeader()); | 90 ASSERT(IsLoopHeader()); |
86 loop_information_ = NULL; | 91 loop_information_ = NULL; |
87 } | 92 } |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 | 827 |
823 builder_->set_current_block(exit_block_); | 828 builder_->set_current_block(exit_block_); |
824 // Pop the phi from the expression stack | 829 // Pop the phi from the expression stack |
825 builder_->environment()->Pop(); | 830 builder_->environment()->Pop(); |
826 finished_ = true; | 831 finished_ = true; |
827 } | 832 } |
828 | 833 |
829 | 834 |
830 HGraph* HGraphBuilder::CreateGraph() { | 835 HGraph* HGraphBuilder::CreateGraph() { |
831 graph_ = new(zone()) HGraph(info_); | 836 graph_ = new(zone()) HGraph(info_); |
832 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info_); | 837 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); |
833 HPhase phase("H_Block building", graph()->isolate()); | 838 HPhase phase("H_Block building", isolate()); |
834 set_current_block(graph()->entry_block()); | 839 set_current_block(graph()->entry_block()); |
835 if (!BuildGraph()) return NULL; | 840 if (!BuildGraph()) return NULL; |
836 return graph_; | 841 return graph_; |
837 } | 842 } |
838 | 843 |
839 | 844 |
840 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { | 845 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { |
841 ASSERT(current_block() != NULL); | 846 ASSERT(current_block() != NULL); |
842 current_block()->AddInstruction(instr); | 847 current_block()->AddInstruction(instr); |
843 return instr; | 848 return instr; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 if (mapcheck != NULL) { | 999 if (mapcheck != NULL) { |
995 mapcheck->ClearGVNFlag(kDependsOnElementsKind); | 1000 mapcheck->ClearGVNFlag(kDependsOnElementsKind); |
996 } | 1001 } |
997 } | 1002 } |
998 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); | 1003 bool fast_smi_only_elements = IsFastSmiElementsKind(elements_kind); |
999 bool fast_elements = IsFastObjectElementsKind(elements_kind); | 1004 bool fast_elements = IsFastObjectElementsKind(elements_kind); |
1000 HInstruction* elements = | 1005 HInstruction* elements = |
1001 AddInstruction(new(zone) HLoadElements(object, mapcheck)); | 1006 AddInstruction(new(zone) HLoadElements(object, mapcheck)); |
1002 if (is_store && (fast_elements || fast_smi_only_elements)) { | 1007 if (is_store && (fast_elements || fast_smi_only_elements)) { |
1003 HCheckMaps* check_cow_map = new(zone) HCheckMaps( | 1008 HCheckMaps* check_cow_map = new(zone) HCheckMaps( |
1004 elements, graph()->isolate()->factory()->fixed_array_map(), zone); | 1009 elements, isolate()->factory()->fixed_array_map(), zone); |
1005 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); | 1010 check_cow_map->ClearGVNFlag(kDependsOnElementsKind); |
1006 AddInstruction(check_cow_map); | 1011 AddInstruction(check_cow_map); |
1007 } | 1012 } |
1008 HInstruction* length = NULL; | 1013 HInstruction* length = NULL; |
1009 HInstruction* checked_key = NULL; | 1014 HInstruction* checked_key = NULL; |
1010 if (IsExternalArrayElementsKind(elements_kind)) { | 1015 if (IsExternalArrayElementsKind(elements_kind)) { |
1011 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); | 1016 length = AddInstruction(new(zone) HFixedArrayBaseLength(elements)); |
1012 checked_key = AddBoundsCheck( | 1017 checked_key = AddBoundsCheck( |
1013 key, length, ALLOW_SMI_KEY, checked_index_representation); | 1018 key, length, ALLOW_SMI_KEY, checked_index_representation); |
1014 HLoadExternalArrayPointer* external_elements = | 1019 HLoadExternalArrayPointer* external_elements = |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1064 |
1060 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; | 1065 HAllocate::Flags flags = HAllocate::CAN_ALLOCATE_IN_NEW_SPACE; |
1061 if (IsFastDoubleElementsKind(kind)) { | 1066 if (IsFastDoubleElementsKind(kind)) { |
1062 flags = static_cast<HAllocate::Flags>( | 1067 flags = static_cast<HAllocate::Flags>( |
1063 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); | 1068 flags | HAllocate::ALLOCATE_DOUBLE_ALIGNED); |
1064 } | 1069 } |
1065 | 1070 |
1066 HValue* elements = | 1071 HValue* elements = |
1067 AddInstruction(new(zone) HAllocate(context, total_size, | 1072 AddInstruction(new(zone) HAllocate(context, total_size, |
1068 HType::JSArray(), flags)); | 1073 HType::JSArray(), flags)); |
1069 Isolate* isolate = graph()->isolate(); | |
1070 | 1074 |
1071 Factory* factory = isolate->factory(); | 1075 Factory* factory = isolate()->factory(); |
1072 Handle<Map> map = IsFastDoubleElementsKind(kind) | 1076 Handle<Map> map = IsFastDoubleElementsKind(kind) |
1073 ? factory->fixed_double_array_map() | 1077 ? factory->fixed_double_array_map() |
1074 : factory->fixed_array_map(); | 1078 : factory->fixed_array_map(); |
1075 BuildStoreMap(elements, map, BailoutId::StubEntry()); | 1079 BuildStoreMap(elements, map, BailoutId::StubEntry()); |
1076 | 1080 |
1077 Handle<String> fixed_array_length_field_name = | 1081 Handle<String> fixed_array_length_field_name = factory->length_field_string(); |
1078 isolate->factory()->length_field_string(); | |
1079 HInstruction* store_length = | 1082 HInstruction* store_length = |
1080 new(zone) HStoreNamedField(elements, fixed_array_length_field_name, | 1083 new(zone) HStoreNamedField(elements, fixed_array_length_field_name, |
1081 capacity, true, FixedArray::kLengthOffset); | 1084 capacity, true, FixedArray::kLengthOffset); |
1082 AddInstruction(store_length); | 1085 AddInstruction(store_length); |
1083 AddSimulate(BailoutId::StubEntry(), FIXED_SIMULATE); | 1086 AddSimulate(BailoutId::StubEntry(), FIXED_SIMULATE); |
1084 | 1087 |
1085 return elements; | 1088 return elements; |
1086 } | 1089 } |
1087 | 1090 |
1088 | 1091 |
1089 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, | 1092 HInstruction* HGraphBuilder::BuildStoreMap(HValue* object, |
1090 HValue* map, | 1093 HValue* map, |
1091 BailoutId id) { | 1094 BailoutId id) { |
1092 Zone* zone = this->zone(); | 1095 Zone* zone = this->zone(); |
1093 Isolate* isolate = graph()->isolate(); | 1096 Factory* factory = isolate()->factory(); |
1094 Factory* factory = isolate->factory(); | |
1095 Handle<String> map_field_name = factory->map_field_string(); | 1097 Handle<String> map_field_name = factory->map_field_string(); |
1096 HInstruction* store_map = | 1098 HInstruction* store_map = |
1097 new(zone) HStoreNamedField(object, map_field_name, map, | 1099 new(zone) HStoreNamedField(object, map_field_name, map, |
1098 true, JSObject::kMapOffset); | 1100 true, JSObject::kMapOffset); |
1099 store_map->SetGVNFlag(kChangesMaps); | 1101 store_map->SetGVNFlag(kChangesMaps); |
1100 AddInstruction(store_map); | 1102 AddInstruction(store_map); |
1101 AddSimulate(id, FIXED_SIMULATE); | 1103 AddSimulate(id, FIXED_SIMULATE); |
1102 return store_map; | 1104 return store_map; |
1103 } | 1105 } |
1104 | 1106 |
(...skipping 8268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9373 HValue* right = Pop(); | 9375 HValue* right = Pop(); |
9374 HValue* left = Pop(); | 9376 HValue* left = Pop(); |
9375 Token::Value op = expr->op(); | 9377 Token::Value op = expr->op(); |
9376 | 9378 |
9377 HTypeof* typeof_expr = NULL; | 9379 HTypeof* typeof_expr = NULL; |
9378 Handle<String> check; | 9380 Handle<String> check; |
9379 if (IsLiteralCompareTypeof(left, op, right, &typeof_expr, &check)) { | 9381 if (IsLiteralCompareTypeof(left, op, right, &typeof_expr, &check)) { |
9380 return HandleLiteralCompareTypeof(expr, typeof_expr, check); | 9382 return HandleLiteralCompareTypeof(expr, typeof_expr, check); |
9381 } | 9383 } |
9382 HValue* sub_expr = NULL; | 9384 HValue* sub_expr = NULL; |
9383 Factory* f = graph()->isolate()->factory(); | 9385 Factory* f = isolate()->factory(); |
9384 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { | 9386 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { |
9385 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); | 9387 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); |
9386 } | 9388 } |
9387 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { | 9389 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { |
9388 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); | 9390 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); |
9389 } | 9391 } |
9390 if (IsLiteralCompareBool(left, op, right)) { | 9392 if (IsLiteralCompareBool(left, op, right)) { |
9391 HCompareObjectEqAndBranch* result = | 9393 HCompareObjectEqAndBranch* result = |
9392 new(zone()) HCompareObjectEqAndBranch(left, right); | 9394 new(zone()) HCompareObjectEqAndBranch(left, right); |
9393 result->set_position(expr->position()); | 9395 result->set_position(expr->position()); |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10504 } else { | 10506 } else { |
10505 CodeStub::Major major_key = info->code_stub()->MajorKey(); | 10507 CodeStub::Major major_key = info->code_stub()->MajorKey(); |
10506 PrintStringProperty("name", CodeStub::MajorName(major_key, false)); | 10508 PrintStringProperty("name", CodeStub::MajorName(major_key, false)); |
10507 PrintStringProperty("method", "stub"); | 10509 PrintStringProperty("method", "stub"); |
10508 } | 10510 } |
10509 PrintLongProperty("date", static_cast<int64_t>(OS::TimeCurrentMillis())); | 10511 PrintLongProperty("date", static_cast<int64_t>(OS::TimeCurrentMillis())); |
10510 } | 10512 } |
10511 | 10513 |
10512 | 10514 |
10513 void HTracer::TraceLithium(const char* name, LChunk* chunk) { | 10515 void HTracer::TraceLithium(const char* name, LChunk* chunk) { |
10514 AllowHandleDereference allow_handle_deref(chunk->graph()->isolate()); | 10516 AllowHandleDereference allow_handle_deref(chunk->isolate()); |
10515 Trace(name, chunk->graph(), chunk); | 10517 Trace(name, chunk->graph(), chunk); |
10516 } | 10518 } |
10517 | 10519 |
10518 | 10520 |
10519 void HTracer::TraceHydrogen(const char* name, HGraph* graph) { | 10521 void HTracer::TraceHydrogen(const char* name, HGraph* graph) { |
10520 AllowHandleDereference allow_handle_deref(graph->isolate()); | 10522 AllowHandleDereference allow_handle_deref(graph->isolate()); |
10521 Trace(name, graph, NULL); | 10523 Trace(name, graph, NULL); |
10522 } | 10524 } |
10523 | 10525 |
10524 | 10526 |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10803 Init(isolate, name, NULL, NULL, NULL); | 10805 Init(isolate, name, NULL, NULL, NULL); |
10804 } | 10806 } |
10805 | 10807 |
10806 | 10808 |
10807 HPhase::HPhase(const char* name, HGraph* graph) { | 10809 HPhase::HPhase(const char* name, HGraph* graph) { |
10808 Init(graph->isolate(), name, graph, NULL, NULL); | 10810 Init(graph->isolate(), name, graph, NULL, NULL); |
10809 } | 10811 } |
10810 | 10812 |
10811 | 10813 |
10812 HPhase::HPhase(const char* name, LChunk* chunk) { | 10814 HPhase::HPhase(const char* name, LChunk* chunk) { |
10813 Init(chunk->graph()->isolate(), name, NULL, chunk, NULL); | 10815 Init(chunk->isolate(), name, NULL, chunk, NULL); |
10814 } | 10816 } |
10815 | 10817 |
10816 | 10818 |
10817 HPhase::HPhase(const char* name, LAllocator* allocator) { | 10819 HPhase::HPhase(const char* name, LAllocator* allocator) { |
10818 Init(allocator->graph()->isolate(), name, NULL, NULL, allocator); | 10820 Init(allocator->isolate(), name, NULL, NULL, allocator); |
10819 } | 10821 } |
10820 | 10822 |
10821 | 10823 |
10822 void HPhase::Init(Isolate* isolate, | 10824 void HPhase::Init(Isolate* isolate, |
10823 const char* name, | 10825 const char* name, |
10824 HGraph* graph, | 10826 HGraph* graph, |
10825 LChunk* chunk, | 10827 LChunk* chunk, |
10826 LAllocator* allocator) { | 10828 LAllocator* allocator) { |
10827 isolate_ = isolate; | 10829 isolate_ = isolate; |
10828 name_ = name; | 10830 name_ = name; |
10829 graph_ = graph; | 10831 graph_ = graph; |
10830 chunk_ = chunk; | 10832 chunk_ = chunk; |
10831 allocator_ = allocator; | 10833 allocator_ = allocator; |
10832 if (allocator != NULL && chunk_ == NULL) { | 10834 if (allocator != NULL && chunk_ == NULL) { |
10833 chunk_ = allocator->chunk(); | 10835 chunk_ = allocator->chunk(); |
10834 } | 10836 } |
10835 if (FLAG_hydrogen_stats) { | 10837 if (FLAG_hydrogen_stats) { |
10836 start_ticks_ = OS::Ticks(); | 10838 start_ticks_ = OS::Ticks(); |
10837 start_allocation_size_ = Zone::allocation_size_; | 10839 start_allocation_size_ = Zone::allocation_size_; |
10838 } | 10840 } |
10839 } | 10841 } |
10840 | 10842 |
10841 | 10843 |
10842 HPhase::~HPhase() { | 10844 HPhase::~HPhase() { |
10843 if (FLAG_hydrogen_stats) { | 10845 if (FLAG_hydrogen_stats) { |
10844 int64_t ticks = OS::Ticks() - start_ticks_; | 10846 int64_t ticks = OS::Ticks() - start_ticks_; |
10845 unsigned size = Zone::allocation_size_ - start_allocation_size_; | 10847 unsigned size = Zone::allocation_size_ - start_allocation_size_; |
10846 HStatistics::Instance()->SaveTiming(name_, ticks, size); | 10848 isolate_->GetHStatistics()->SaveTiming(name_, ticks, size); |
10847 } | 10849 } |
10848 | 10850 |
10849 // Produce trace output if flag is set so that the first letter of the | 10851 // Produce trace output if flag is set so that the first letter of the |
10850 // phase name matches the command line parameter FLAG_trace_phase. | 10852 // phase name matches the command line parameter FLAG_trace_phase. |
10851 if (FLAG_trace_hydrogen && | 10853 if (FLAG_trace_hydrogen && |
10852 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) { | 10854 OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL) { |
10853 if (graph_ != NULL) { | 10855 if (graph_ != NULL) { |
10854 isolate_->GetHTracer()->TraceHydrogen(name_, graph_); | 10856 isolate_->GetHTracer()->TraceHydrogen(name_, graph_); |
10855 } | 10857 } |
10856 if (chunk_ != NULL) { | 10858 if (chunk_ != NULL) { |
10857 isolate_->GetHTracer()->TraceLithium(name_, chunk_); | 10859 isolate_->GetHTracer()->TraceLithium(name_, chunk_); |
10858 } | 10860 } |
10859 if (allocator_ != NULL) { | 10861 if (allocator_ != NULL) { |
10860 isolate_->GetHTracer()->TraceLiveRanges(name_, allocator_); | 10862 isolate_->GetHTracer()->TraceLiveRanges(name_, allocator_); |
10861 } | 10863 } |
10862 } | 10864 } |
10863 | 10865 |
10864 #ifdef DEBUG | 10866 #ifdef DEBUG |
10865 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 10867 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
10866 if (allocator_ != NULL) allocator_->Verify(); | 10868 if (allocator_ != NULL) allocator_->Verify(); |
10867 #endif | 10869 #endif |
10868 } | 10870 } |
10869 | 10871 |
10870 } } // namespace v8::internal | 10872 } } // namespace v8::internal |
OLD | NEW |