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

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

Issue 6685088: Merge isolates to bleeding_edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
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/ia32/regexp-macro-assembler-ia32.cc ('k') | src/ia32/simulator-ia32.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 24 matching lines...) Expand all
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 // ------------------------------------------------------------------------- 39 // -------------------------------------------------------------------------
40 // Result implementation. 40 // Result implementation.
41 41
42 void Result::ToRegister() { 42 void Result::ToRegister() {
43 ASSERT(is_valid()); 43 ASSERT(is_valid());
44 if (is_constant()) { 44 if (is_constant()) {
45 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(); 45 CodeGenerator* code_generator =
46 CodeGeneratorScope::Current(Isolate::Current());
47 Result fresh = code_generator->allocator()->Allocate();
46 ASSERT(fresh.is_valid()); 48 ASSERT(fresh.is_valid());
47 if (is_untagged_int32()) { 49 if (is_untagged_int32()) {
48 fresh.set_untagged_int32(true); 50 fresh.set_untagged_int32(true);
49 if (handle()->IsSmi()) { 51 if (handle()->IsSmi()) {
50 CodeGeneratorScope::Current()->masm()->Set( 52 code_generator->masm()->Set(
51 fresh.reg(), 53 fresh.reg(),
52 Immediate(Smi::cast(*handle())->value())); 54 Immediate(Smi::cast(*handle())->value()));
53 } else if (handle()->IsHeapNumber()) { 55 } else if (handle()->IsHeapNumber()) {
54 double double_value = HeapNumber::cast(*handle())->value(); 56 double double_value = HeapNumber::cast(*handle())->value();
55 int32_t value = DoubleToInt32(double_value); 57 int32_t value = DoubleToInt32(double_value);
56 if (double_value == 0 && signbit(double_value)) { 58 if (double_value == 0 && signbit(double_value)) {
57 // Negative zero must not be converted to an int32 unless 59 // Negative zero must not be converted to an int32 unless
58 // the context allows it. 60 // the context allows it.
59 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal); 61 code_generator->unsafe_bailout_->Branch(equal);
60 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal); 62 code_generator->unsafe_bailout_->Branch(not_equal);
61 } else if (double_value == value) { 63 } else if (double_value == value) {
62 CodeGeneratorScope::Current()->masm()->Set( 64 code_generator->masm()->Set(fresh.reg(), Immediate(value));
63 fresh.reg(), Immediate(value));
64 } else { 65 } else {
65 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal); 66 code_generator->unsafe_bailout_->Branch(equal);
66 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal); 67 code_generator->unsafe_bailout_->Branch(not_equal);
67 } 68 }
68 } else { 69 } else {
69 // Constant is not a number. This was not predicted by AST analysis. 70 // Constant is not a number. This was not predicted by AST analysis.
70 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal); 71 code_generator->unsafe_bailout_->Branch(equal);
71 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal); 72 code_generator->unsafe_bailout_->Branch(not_equal);
72 } 73 }
73 } else if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { 74 } else if (code_generator->IsUnsafeSmi(handle())) {
74 CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle()); 75 code_generator->MoveUnsafeSmi(fresh.reg(), handle());
75 } else { 76 } else {
76 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), 77 code_generator->masm()->Set(fresh.reg(), Immediate(handle()));
77 Immediate(handle()));
78 } 78 }
79 // This result becomes a copy of the fresh one. 79 // This result becomes a copy of the fresh one.
80 fresh.set_type_info(type_info()); 80 fresh.set_type_info(type_info());
81 *this = fresh; 81 *this = fresh;
82 } 82 }
83 ASSERT(is_register()); 83 ASSERT(is_register());
84 } 84 }
85 85
86 86
87 void Result::ToRegister(Register target) { 87 void Result::ToRegister(Register target) {
88 CodeGenerator* code_generator =
89 CodeGeneratorScope::Current(Isolate::Current());
88 ASSERT(is_valid()); 90 ASSERT(is_valid());
89 if (!is_register() || !reg().is(target)) { 91 if (!is_register() || !reg().is(target)) {
90 Result fresh = CodeGeneratorScope::Current()->allocator()->Allocate(target); 92 Result fresh = code_generator->allocator()->Allocate(target);
91 ASSERT(fresh.is_valid()); 93 ASSERT(fresh.is_valid());
92 if (is_register()) { 94 if (is_register()) {
93 CodeGeneratorScope::Current()->masm()->mov(fresh.reg(), reg()); 95 code_generator->masm()->mov(fresh.reg(), reg());
94 } else { 96 } else {
95 ASSERT(is_constant()); 97 ASSERT(is_constant());
96 if (is_untagged_int32()) { 98 if (is_untagged_int32()) {
97 if (handle()->IsSmi()) { 99 if (handle()->IsSmi()) {
98 CodeGeneratorScope::Current()->masm()->Set( 100 code_generator->masm()->Set(
99 fresh.reg(), 101 fresh.reg(),
100 Immediate(Smi::cast(*handle())->value())); 102 Immediate(Smi::cast(*handle())->value()));
101 } else { 103 } else {
102 ASSERT(handle()->IsHeapNumber()); 104 ASSERT(handle()->IsHeapNumber());
103 double double_value = HeapNumber::cast(*handle())->value(); 105 double double_value = HeapNumber::cast(*handle())->value();
104 int32_t value = DoubleToInt32(double_value); 106 int32_t value = DoubleToInt32(double_value);
105 if (double_value == 0 && signbit(double_value)) { 107 if (double_value == 0 && signbit(double_value)) {
106 // Negative zero must not be converted to an int32 unless 108 // Negative zero must not be converted to an int32 unless
107 // the context allows it. 109 // the context allows it.
108 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal); 110 code_generator->unsafe_bailout_->Branch(equal);
109 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal); 111 code_generator->unsafe_bailout_->Branch(not_equal);
110 } else if (double_value == value) { 112 } else if (double_value == value) {
111 CodeGeneratorScope::Current()->masm()->Set( 113 code_generator->masm()->Set(fresh.reg(), Immediate(value));
112 fresh.reg(), Immediate(value));
113 } else { 114 } else {
114 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(equal); 115 code_generator->unsafe_bailout_->Branch(equal);
115 CodeGeneratorScope::Current()->unsafe_bailout_->Branch(not_equal); 116 code_generator->unsafe_bailout_->Branch(not_equal);
116 } 117 }
117 } 118 }
118 } else { 119 } else {
119 if (CodeGeneratorScope::Current()->IsUnsafeSmi(handle())) { 120 if (code_generator->IsUnsafeSmi(handle())) {
120 CodeGeneratorScope::Current()->MoveUnsafeSmi(fresh.reg(), handle()); 121 code_generator->MoveUnsafeSmi(fresh.reg(), handle());
121 } else { 122 } else {
122 CodeGeneratorScope::Current()->masm()->Set(fresh.reg(), 123 code_generator->masm()->Set(fresh.reg(), Immediate(handle()));
123 Immediate(handle()));
124 } 124 }
125 } 125 }
126 } 126 }
127 fresh.set_type_info(type_info()); 127 fresh.set_type_info(type_info());
128 fresh.set_untagged_int32(is_untagged_int32()); 128 fresh.set_untagged_int32(is_untagged_int32());
129 *this = fresh; 129 *this = fresh;
130 } else if (is_register() && reg().is(target)) { 130 } else if (is_register() && reg().is(target)) {
131 ASSERT(CodeGeneratorScope::Current()->has_valid_frame()); 131 ASSERT(code_generator->has_valid_frame());
132 CodeGeneratorScope::Current()->frame()->Spill(target); 132 code_generator->frame()->Spill(target);
133 ASSERT(CodeGeneratorScope::Current()->allocator()->count(target) == 1); 133 ASSERT(code_generator->allocator()->count(target) == 1);
134 } 134 }
135 ASSERT(is_register()); 135 ASSERT(is_register());
136 ASSERT(reg().is(target)); 136 ASSERT(reg().is(target));
137 } 137 }
138 138
139 139
140 // ------------------------------------------------------------------------- 140 // -------------------------------------------------------------------------
141 // RegisterAllocator implementation. 141 // RegisterAllocator implementation.
142 142
143 Result RegisterAllocator::AllocateByteRegisterWithoutSpilling() { 143 Result RegisterAllocator::AllocateByteRegisterWithoutSpilling() {
144 Result result = AllocateWithoutSpilling(); 144 Result result = AllocateWithoutSpilling();
145 // Check that the register is a byte register. If not, unuse the 145 // Check that the register is a byte register. If not, unuse the
146 // register if valid and return an invalid result. 146 // register if valid and return an invalid result.
147 if (result.is_valid() && !result.reg().is_byte_register()) { 147 if (result.is_valid() && !result.reg().is_byte_register()) {
148 result.Unuse(); 148 result.Unuse();
149 return Result(); 149 return Result();
150 } 150 }
151 return result; 151 return result;
152 } 152 }
153 153
154 154
155 } } // namespace v8::internal 155 } } // namespace v8::internal
156 156
157 #endif // V8_TARGET_ARCH_IA32 157 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/regexp-macro-assembler-ia32.cc ('k') | src/ia32/simulator-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698