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

Side by Side Diff: src/register-allocator.cc

Issue 42296: Speed up the inner loop of free register allocation. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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/register-allocator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } 76 }
77 } 77 }
78 78
79 79
80 // ------------------------------------------------------------------------- 80 // -------------------------------------------------------------------------
81 // RegisterAllocator implementation. 81 // RegisterAllocator implementation.
82 82
83 83
84 Result RegisterAllocator::AllocateWithoutSpilling() { 84 Result RegisterAllocator::AllocateWithoutSpilling() {
85 // Return the first free register, if any. 85 // Return the first free register, if any.
86 for (int i = 0; i < kNumRegisters; i++) { 86 int free_reg = registers_.ScanForFreeRegister();
87 if (!is_used(i)) { 87 if (free_reg < kNumRegisters) {
88 Register free_reg = { i }; 88 Register free_result = { free_reg };
89 return Result(free_reg, cgen_); 89 return Result(free_result, cgen_);
90 }
91 } 90 }
92 return Result(cgen_); 91 return Result(cgen_);
93 } 92 }
94 93
95 94
96 Result RegisterAllocator::Allocate() { 95 Result RegisterAllocator::Allocate() {
97 Result result = AllocateWithoutSpilling(); 96 Result result = AllocateWithoutSpilling();
98 if (!result.is_valid()) { 97 if (!result.is_valid()) {
99 // Ask the current frame to spill a register. 98 // Ask the current frame to spill a register.
100 ASSERT(cgen_->has_valid_frame()); 99 ASSERT(cgen_->has_valid_frame());
(...skipping 19 matching lines...) Expand all
120 cgen_->frame()->Spill(target); 119 cgen_->frame()->Spill(target);
121 ASSERT(!is_used(target)); 120 ASSERT(!is_used(target));
122 return Result(target, cgen_); 121 return Result(target, cgen_);
123 } 122 }
124 // Otherwise (if it's referenced outside the frame) we cannot allocate it. 123 // Otherwise (if it's referenced outside the frame) we cannot allocate it.
125 return Result(cgen_); 124 return Result(cgen_);
126 } 125 }
127 126
128 127
129 } } // namespace v8::internal 128 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/register-allocator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698