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

Side by Side Diff: src/hydrogen.cc

Issue 6683022: [Isolates] Merge 7111:7152 from bleeding_edge to isolates. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: Created 9 years, 9 months 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/hydrogen.h ('k') | src/ia32/deoptimizer-ia32.cc » ('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 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 864 }
865 865
866 RollBackTo(last_changed_range); 866 RollBackTo(last_changed_range);
867 } 867 }
868 868
869 869
870 void HRangeAnalysis::InferControlFlowRange(HTest* test, HBasicBlock* dest) { 870 void HRangeAnalysis::InferControlFlowRange(HTest* test, HBasicBlock* dest) {
871 ASSERT((test->FirstSuccessor() == dest) == (test->SecondSuccessor() != dest)); 871 ASSERT((test->FirstSuccessor() == dest) == (test->SecondSuccessor() != dest));
872 if (test->value()->IsCompare()) { 872 if (test->value()->IsCompare()) {
873 HCompare* compare = HCompare::cast(test->value()); 873 HCompare* compare = HCompare::cast(test->value());
874 Token::Value op = compare->token(); 874 if (compare->GetInputRepresentation().IsInteger32()) {
875 if (test->SecondSuccessor() == dest) { 875 Token::Value op = compare->token();
876 op = Token::NegateCompareOp(op); 876 if (test->SecondSuccessor() == dest) {
877 op = Token::NegateCompareOp(op);
878 }
879 Token::Value inverted_op = Token::InvertCompareOp(op);
880 InferControlFlowRange(op, compare->left(), compare->right());
881 InferControlFlowRange(inverted_op, compare->right(), compare->left());
877 } 882 }
878 Token::Value inverted_op = Token::InvertCompareOp(op);
879 InferControlFlowRange(op, compare->left(), compare->right());
880 InferControlFlowRange(inverted_op, compare->right(), compare->left());
881 } 883 }
882 } 884 }
883 885
884 886
885 // We know that value [op] other. Use this information to update the range on 887 // We know that value [op] other. Use this information to update the range on
886 // value. 888 // value.
887 void HRangeAnalysis::InferControlFlowRange(Token::Value op, 889 void HRangeAnalysis::InferControlFlowRange(Token::Value op,
888 HValue* value, 890 HValue* value,
889 HValue* other) { 891 HValue* other) {
890 Range temp_range; 892 Range temp_range;
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 2100
2099 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) { 2101 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
2100 for (int i = 0; i < exprs->length(); ++i) { 2102 for (int i = 0; i < exprs->length(); ++i) {
2101 VISIT_FOR_VALUE(exprs->at(i)); 2103 VISIT_FOR_VALUE(exprs->at(i));
2102 } 2104 }
2103 } 2105 }
2104 2106
2105 2107
2106 HGraph* HGraphBuilder::CreateGraph() { 2108 HGraph* HGraphBuilder::CreateGraph() {
2107 graph_ = new HGraph(info()); 2109 graph_ = new HGraph(info());
2110 if (FLAG_hydrogen_stats) HStatistics::Instance()->Initialize(info());
2111
2108 { 2112 {
2109 HPhase phase("Block building"); 2113 HPhase phase("Block building");
2110 current_block_ = graph()->entry_block(); 2114 current_block_ = graph()->entry_block();
2111 2115
2112 Scope* scope = info()->scope(); 2116 Scope* scope = info()->scope();
2113 if (scope->HasIllegalRedeclaration()) { 2117 if (scope->HasIllegalRedeclaration()) {
2114 Bailout("function with illegal redeclaration"); 2118 Bailout("function with illegal redeclaration");
2115 return NULL; 2119 return NULL;
2116 } 2120 }
2117 SetupScope(scope); 2121 SetupScope(scope);
(...skipping 2108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4226 Handle<Map> receiver_map = 4230 Handle<Map> receiver_map =
4227 (types == NULL) ? Handle<Map>::null() : types->first(); 4231 (types == NULL) ? Handle<Map>::null() : types->first();
4228 if (TryInlineBuiltinFunction(expr, 4232 if (TryInlineBuiltinFunction(expr,
4229 receiver, 4233 receiver,
4230 receiver_map, 4234 receiver_map,
4231 expr->check_type())) { 4235 expr->check_type())) {
4232 return; 4236 return;
4233 } 4237 }
4234 4238
4235 if (HasCustomCallGenerator(expr->target()) || 4239 if (HasCustomCallGenerator(expr->target()) ||
4240 CallOptimization(*expr->target()).is_simple_api_call() ||
4236 expr->check_type() != RECEIVER_MAP_CHECK) { 4241 expr->check_type() != RECEIVER_MAP_CHECK) {
4237 // When the target has a custom call IC generator, use the IC, 4242 // When the target has a custom call IC generator, use the IC,
4238 // because it is likely to generate better code. Also use the 4243 // because it is likely to generate better code. Similarly, we
4239 // IC when a primitive receiver check is required. 4244 // generate better call stubs for some API functions.
4245 // Also use the IC when a primitive receiver check is required.
4240 HContext* context = new HContext; 4246 HContext* context = new HContext;
4241 AddInstruction(context); 4247 AddInstruction(context);
4242 call = PreProcessCall(new HCallNamed(context, name, argument_count)); 4248 call = PreProcessCall(new HCallNamed(context, name, argument_count));
4243 } else { 4249 } else {
4244 AddCheckConstantFunction(expr, receiver, receiver_map, true); 4250 AddCheckConstantFunction(expr, receiver, receiver_map, true);
4245 4251
4246 if (TryInline(expr)) { 4252 if (TryInline(expr)) {
4247 return; 4253 return;
4248 } else { 4254 } else {
4249 // Check for bailout, as the TryInline call in the if condition above 4255 // Check for bailout, as the TryInline call in the if condition above
(...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after
5697 } 5703 }
5698 } 5704 }
5699 } 5705 }
5700 } 5706 }
5701 5707
5702 5708
5703 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) { 5709 void HTracer::TraceLiveRanges(const char* name, LAllocator* allocator) {
5704 Tag tag(this, "intervals"); 5710 Tag tag(this, "intervals");
5705 PrintStringProperty("name", name); 5711 PrintStringProperty("name", name);
5706 5712
5707 const ZoneList<LiveRange*>* fixed_d = allocator->fixed_double_live_ranges(); 5713 const Vector<LiveRange*>* fixed_d = allocator->fixed_double_live_ranges();
5708 for (int i = 0; i < fixed_d->length(); ++i) { 5714 for (int i = 0; i < fixed_d->length(); ++i) {
5709 TraceLiveRange(fixed_d->at(i), "fixed"); 5715 TraceLiveRange(fixed_d->at(i), "fixed");
5710 } 5716 }
5711 5717
5712 const ZoneList<LiveRange*>* fixed = allocator->fixed_live_ranges(); 5718 const Vector<LiveRange*>* fixed = allocator->fixed_live_ranges();
5713 for (int i = 0; i < fixed->length(); ++i) { 5719 for (int i = 0; i < fixed->length(); ++i) {
5714 TraceLiveRange(fixed->at(i), "fixed"); 5720 TraceLiveRange(fixed->at(i), "fixed");
5715 } 5721 }
5716 5722
5717 const ZoneList<LiveRange*>* live_ranges = allocator->live_ranges(); 5723 const ZoneList<LiveRange*>* live_ranges = allocator->live_ranges();
5718 for (int i = 0; i < live_ranges->length(); ++i) { 5724 for (int i = 0; i < live_ranges->length(); ++i) {
5719 TraceLiveRange(live_ranges->at(i), "object"); 5725 TraceLiveRange(live_ranges->at(i), "object");
5720 } 5726 }
5721 } 5727 }
5722 5728
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
5773 } 5779 }
5774 } 5780 }
5775 5781
5776 5782
5777 void HTracer::FlushToFile() { 5783 void HTracer::FlushToFile() {
5778 AppendChars(filename_, *trace_.ToCString(), trace_.length(), false); 5784 AppendChars(filename_, *trace_.ToCString(), trace_.length(), false);
5779 trace_.Reset(); 5785 trace_.Reset();
5780 } 5786 }
5781 5787
5782 5788
5789 void HStatistics::Initialize(CompilationInfo* info) {
5790 source_size_ += info->shared_info()->SourceSize();
5791 }
5792
5793
5783 void HStatistics::Print() { 5794 void HStatistics::Print() {
5784 PrintF("Timing results:\n"); 5795 PrintF("Timing results:\n");
5785 int64_t sum = 0; 5796 int64_t sum = 0;
5786 for (int i = 0; i < timing_.length(); ++i) { 5797 for (int i = 0; i < timing_.length(); ++i) {
5787 sum += timing_[i]; 5798 sum += timing_[i];
5788 } 5799 }
5789 5800
5790 for (int i = 0; i < names_.length(); ++i) { 5801 for (int i = 0; i < names_.length(); ++i) {
5791 PrintF("%30s", names_[i]); 5802 PrintF("%30s", names_[i]);
5792 double ms = static_cast<double>(timing_[i]) / 1000; 5803 double ms = static_cast<double>(timing_[i]) / 1000;
5793 double percent = static_cast<double>(timing_[i]) * 100 / sum; 5804 double percent = static_cast<double>(timing_[i]) * 100 / sum;
5794 PrintF(" - %7.3f ms / %4.1f %% ", ms, percent); 5805 PrintF(" - %7.3f ms / %4.1f %% ", ms, percent);
5795 5806
5796 unsigned size = sizes_[i]; 5807 unsigned size = sizes_[i];
5797 double size_percent = static_cast<double>(size) * 100 / total_size_; 5808 double size_percent = static_cast<double>(size) * 100 / total_size_;
5798 PrintF(" %8u bytes / %4.1f %%\n", size, size_percent); 5809 PrintF(" %8u bytes / %4.1f %%\n", size, size_percent);
5799 } 5810 }
5800 PrintF("%30s - %7.3f ms %8u bytes\n", "Sum", 5811 double source_size_in_kb = static_cast<double>(source_size_) / 1024;
5801 static_cast<double>(sum) / 1000, 5812 PrintF("%30s - %7.3f ms %7.3f bytes\n", "Sum",
5802 total_size_); 5813 (static_cast<double>(sum) / 1000) / source_size_in_kb,
5814 total_size_ / source_size_in_kb);
5803 PrintF("---------------------------------------------------------------\n"); 5815 PrintF("---------------------------------------------------------------\n");
5804 PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n", 5816 PrintF("%30s - %7.3f ms (%.1f times slower than full code gen)\n",
5805 "Total", 5817 "Total",
5806 static_cast<double>(total_) / 1000, 5818 static_cast<double>(total_) / 1000,
5807 static_cast<double>(total_) / full_code_gen_); 5819 static_cast<double>(total_) / full_code_gen_);
5808 } 5820 }
5809 5821
5810 5822
5811 void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) { 5823 void HStatistics::SaveTiming(const char* name, int64_t ticks, unsigned size) {
5812 if (name == HPhase::kFullCodeGen) { 5824 if (name == HPhase::kFullCodeGen) {
(...skipping 24 matching lines...) Expand all
5837 HGraph* graph, 5849 HGraph* graph,
5838 LChunk* chunk, 5850 LChunk* chunk,
5839 LAllocator* allocator) { 5851 LAllocator* allocator) {
5840 name_ = name; 5852 name_ = name;
5841 graph_ = graph; 5853 graph_ = graph;
5842 chunk_ = chunk; 5854 chunk_ = chunk;
5843 allocator_ = allocator; 5855 allocator_ = allocator;
5844 if (allocator != NULL && chunk_ == NULL) { 5856 if (allocator != NULL && chunk_ == NULL) {
5845 chunk_ = allocator->chunk(); 5857 chunk_ = allocator->chunk();
5846 } 5858 }
5847 if (FLAG_time_hydrogen) start_ = OS::Ticks(); 5859 if (FLAG_hydrogen_stats) start_ = OS::Ticks();
5848 start_allocation_size_ = Zone::allocation_size_; 5860 start_allocation_size_ = Zone::allocation_size_;
5849 } 5861 }
5850 5862
5851 5863
5852 void HPhase::End() const { 5864 void HPhase::End() const {
5853 if (FLAG_time_hydrogen) { 5865 if (FLAG_hydrogen_stats) {
5854 int64_t end = OS::Ticks(); 5866 int64_t end = OS::Ticks();
5855 unsigned size = Zone::allocation_size_ - start_allocation_size_; 5867 unsigned size = Zone::allocation_size_ - start_allocation_size_;
5856 HStatistics::Instance()->SaveTiming(name_, end - start_, size); 5868 HStatistics::Instance()->SaveTiming(name_, end - start_, size);
5857 } 5869 }
5858 5870
5859 if (FLAG_trace_hydrogen) { 5871 if (FLAG_trace_hydrogen) {
5860 if (graph_ != NULL) HTracer::Instance()->TraceHydrogen(name_, graph_); 5872 if (graph_ != NULL) HTracer::Instance()->TraceHydrogen(name_, graph_);
5861 if (chunk_ != NULL) HTracer::Instance()->TraceLithium(name_, chunk_); 5873 if (chunk_ != NULL) HTracer::Instance()->TraceLithium(name_, chunk_);
5862 if (allocator_ != NULL) { 5874 if (allocator_ != NULL) {
5863 HTracer::Instance()->TraceLiveRanges(name_, allocator_); 5875 HTracer::Instance()->TraceLiveRanges(name_, allocator_);
5864 } 5876 }
5865 } 5877 }
5866 5878
5867 #ifdef DEBUG 5879 #ifdef DEBUG
5868 if (graph_ != NULL) graph_->Verify(); 5880 if (graph_ != NULL) graph_->Verify();
5869 if (allocator_ != NULL) allocator_->Verify(); 5881 if (allocator_ != NULL) allocator_->Verify();
5870 #endif 5882 #endif
5871 } 5883 }
5872 5884
5873 } } // namespace v8::internal 5885 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/ia32/deoptimizer-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698