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

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

Issue 6811012: Remove some dead code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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/ia32/register-allocator-ia32.h ('k') | src/ia32/register-allocator-ia32-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
(Empty)
1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27
28 #include "v8.h"
29
30 #if defined(V8_TARGET_ARCH_IA32)
31
32 #include "codegen-inl.h"
33 #include "register-allocator-inl.h"
34 #include "virtual-frame-inl.h"
35
36 namespace v8 {
37 namespace internal {
38
39 // -------------------------------------------------------------------------
40 // Result implementation.
41
42 void Result::ToRegister() {
43 ASSERT(is_valid());
44 if (is_constant()) {
45 CodeGenerator* code_generator =
46 CodeGeneratorScope::Current(Isolate::Current());
47 Result fresh = code_generator->allocator()->Allocate();
48 ASSERT(fresh.is_valid());
49 if (is_untagged_int32()) {
50 fresh.set_untagged_int32(true);
51 if (handle()->IsSmi()) {
52 code_generator->masm()->Set(
53 fresh.reg(),
54 Immediate(Smi::cast(*handle())->value()));
55 } else if (handle()->IsHeapNumber()) {
56 double double_value = HeapNumber::cast(*handle())->value();
57 int32_t value = DoubleToInt32(double_value);
58 if (double_value == 0 && signbit(double_value)) {
59 // Negative zero must not be converted to an int32 unless
60 // the context allows it.
61 code_generator->unsafe_bailout_->Branch(equal);
62 code_generator->unsafe_bailout_->Branch(not_equal);
63 } else if (double_value == value) {
64 code_generator->masm()->Set(fresh.reg(), Immediate(value));
65 } else {
66 code_generator->unsafe_bailout_->Branch(equal);
67 code_generator->unsafe_bailout_->Branch(not_equal);
68 }
69 } else {
70 // Constant is not a number. This was not predicted by AST analysis.
71 code_generator->unsafe_bailout_->Branch(equal);
72 code_generator->unsafe_bailout_->Branch(not_equal);
73 }
74 } else if (code_generator->IsUnsafeSmi(handle())) {
75 code_generator->MoveUnsafeSmi(fresh.reg(), handle());
76 } else {
77 code_generator->masm()->Set(fresh.reg(), Immediate(handle()));
78 }
79 // This result becomes a copy of the fresh one.
80 fresh.set_type_info(type_info());
81 *this = fresh;
82 }
83 ASSERT(is_register());
84 }
85
86
87 void Result::ToRegister(Register target) {
88 CodeGenerator* code_generator =
89 CodeGeneratorScope::Current(Isolate::Current());
90 ASSERT(is_valid());
91 if (!is_register() || !reg().is(target)) {
92 Result fresh = code_generator->allocator()->Allocate(target);
93 ASSERT(fresh.is_valid());
94 if (is_register()) {
95 code_generator->masm()->mov(fresh.reg(), reg());
96 } else {
97 ASSERT(is_constant());
98 if (is_untagged_int32()) {
99 if (handle()->IsSmi()) {
100 code_generator->masm()->Set(
101 fresh.reg(),
102 Immediate(Smi::cast(*handle())->value()));
103 } else {
104 ASSERT(handle()->IsHeapNumber());
105 double double_value = HeapNumber::cast(*handle())->value();
106 int32_t value = DoubleToInt32(double_value);
107 if (double_value == 0 && signbit(double_value)) {
108 // Negative zero must not be converted to an int32 unless
109 // the context allows it.
110 code_generator->unsafe_bailout_->Branch(equal);
111 code_generator->unsafe_bailout_->Branch(not_equal);
112 } else if (double_value == value) {
113 code_generator->masm()->Set(fresh.reg(), Immediate(value));
114 } else {
115 code_generator->unsafe_bailout_->Branch(equal);
116 code_generator->unsafe_bailout_->Branch(not_equal);
117 }
118 }
119 } else {
120 if (code_generator->IsUnsafeSmi(handle())) {
121 code_generator->MoveUnsafeSmi(fresh.reg(), handle());
122 } else {
123 code_generator->masm()->Set(fresh.reg(), Immediate(handle()));
124 }
125 }
126 }
127 fresh.set_type_info(type_info());
128 fresh.set_untagged_int32(is_untagged_int32());
129 *this = fresh;
130 } else if (is_register() && reg().is(target)) {
131 ASSERT(code_generator->has_valid_frame());
132 code_generator->frame()->Spill(target);
133 ASSERT(code_generator->allocator()->count(target) == 1);
134 }
135 ASSERT(is_register());
136 ASSERT(reg().is(target));
137 }
138
139
140 // -------------------------------------------------------------------------
141 // RegisterAllocator implementation.
142
143 Result RegisterAllocator::AllocateByteRegisterWithoutSpilling() {
144 Result result = AllocateWithoutSpilling();
145 // Check that the register is a byte register. If not, unuse the
146 // register if valid and return an invalid result.
147 if (result.is_valid() && !result.reg().is_byte_register()) {
148 result.Unuse();
149 return Result();
150 }
151 return result;
152 }
153
154
155 } } // namespace v8::internal
156
157 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/register-allocator-ia32.h ('k') | src/ia32/register-allocator-ia32-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698