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/hydrogen.cc

Issue 14315005: Replace qsort with std::sort. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years, 8 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/d8.cc ('k') | src/list-inl.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 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "v8.h"
29 #include "hydrogen.h" 28 #include "hydrogen.h"
30 29
30 #include <algorithm>
31
32 #include "v8.h"
31 #include "codegen.h" 33 #include "codegen.h"
32 #include "full-codegen.h" 34 #include "full-codegen.h"
33 #include "hashmap.h" 35 #include "hashmap.h"
34 #include "lithium-allocator.h" 36 #include "lithium-allocator.h"
35 #include "parser.h" 37 #include "parser.h"
36 #include "scopeinfo.h" 38 #include "scopeinfo.h"
37 #include "scopes.h" 39 #include "scopes.h"
38 #include "stub-cache.h" 40 #include "stub-cache.h"
39 41
40 #if V8_TARGET_ARCH_IA32 42 #if V8_TARGET_ARCH_IA32
(...skipping 8017 matching lines...) Expand 10 before | Expand all | Expand 10 after
8058 int src_length() const { return src_length_; } 8060 int src_length() const { return src_length_; }
8059 8061
8060 private: 8062 private:
8061 int index_; 8063 int index_;
8062 int ticks_; 8064 int ticks_;
8063 int ast_length_; 8065 int ast_length_;
8064 int src_length_; 8066 int src_length_;
8065 }; 8067 };
8066 8068
8067 8069
8068 static int CompareHotness(void const* a, void const* b) { 8070 inline bool operator<(const FunctionSorter& lhs, const FunctionSorter& rhs) {
8069 FunctionSorter const* function1 = reinterpret_cast<FunctionSorter const*>(a); 8071 int diff = lhs.ticks() - rhs.ticks();
8070 FunctionSorter const* function2 = reinterpret_cast<FunctionSorter const*>(b); 8072 if (diff != 0) return diff > 0;
8071 int diff = function1->ticks() - function2->ticks(); 8073 diff = lhs.ast_length() - rhs.ast_length();
8072 if (diff != 0) return -diff; 8074 if (diff != 0) return diff < 0;
8073 diff = function1->ast_length() - function2->ast_length(); 8075 return lhs.src_length() < rhs.src_length();
8074 if (diff != 0) return diff;
8075 return function1->src_length() - function2->src_length();
8076 } 8076 }
8077 8077
8078 8078
8079 void HOptimizedGraphBuilder::HandlePolymorphicCallNamed( 8079 void HOptimizedGraphBuilder::HandlePolymorphicCallNamed(
8080 Call* expr, 8080 Call* expr,
8081 HValue* receiver, 8081 HValue* receiver,
8082 SmallMapList* types, 8082 SmallMapList* types,
8083 Handle<String> name) { 8083 Handle<String> name) {
8084 // TODO(ager): We should recognize when the prototype chains for different 8084 // TODO(ager): We should recognize when the prototype chains for different
8085 // maps are identical. In that case we can avoid repeatedly generating the 8085 // maps are identical. In that case we can avoid repeatedly generating the
(...skipping 22 matching lines...) Expand all
8108 if (expr->ComputeTarget(map, name)) { 8108 if (expr->ComputeTarget(map, name)) {
8109 if (map.is_identical_to(number_marker_map)) handle_smi = true; 8109 if (map.is_identical_to(number_marker_map)) handle_smi = true;
8110 order[ordered_functions++] = 8110 order[ordered_functions++] =
8111 FunctionSorter(i, 8111 FunctionSorter(i,
8112 expr->target()->shared()->profiler_ticks(), 8112 expr->target()->shared()->profiler_ticks(),
8113 InliningAstSize(expr->target()), 8113 InliningAstSize(expr->target()),
8114 expr->target()->shared()->SourceSize()); 8114 expr->target()->shared()->SourceSize());
8115 } 8115 }
8116 } 8116 }
8117 8117
8118 qsort(reinterpret_cast<void*>(&order[0]), 8118 std::sort(order, order + ordered_functions);
8119 ordered_functions,
8120 sizeof(order[0]),
8121 &CompareHotness);
8122 8119
8123 HBasicBlock* number_block = NULL; 8120 HBasicBlock* number_block = NULL;
8124 8121
8125 for (int fn = 0; fn < ordered_functions; ++fn) { 8122 for (int fn = 0; fn < ordered_functions; ++fn) {
8126 int i = order[fn].index(); 8123 int i = order[fn].index();
8127 Handle<Map> map = types->at(i); 8124 Handle<Map> map = types->at(i);
8128 if (fn == 0) { 8125 if (fn == 0) {
8129 // Only needed once. 8126 // Only needed once.
8130 join = graph()->CreateBasicBlock(); 8127 join = graph()->CreateBasicBlock();
8131 if (handle_smi) { 8128 if (handle_smi) {
(...skipping 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after
11872 } 11869 }
11873 } 11870 }
11874 11871
11875 #ifdef DEBUG 11872 #ifdef DEBUG
11876 if (graph_ != NULL) graph_->Verify(false); // No full verify. 11873 if (graph_ != NULL) graph_->Verify(false); // No full verify.
11877 if (allocator_ != NULL) allocator_->Verify(); 11874 if (allocator_ != NULL) allocator_->Verify();
11878 #endif 11875 #endif
11879 } 11876 }
11880 11877
11881 } } // namespace v8::internal 11878 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/d8.cc ('k') | src/list-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698