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

Side by Side Diff: src/arm/cfg-arm.cc

Issue 160584: Add support to the CFG builder for non-short-circuited binary... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 4 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 | « no previous file | src/arm/codegen-arm.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 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 11 matching lines...) Expand all
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" 28 #include "v8.h"
29 29
30 #include "cfg.h" 30 #include "cfg.h"
31 #include "codegen-inl.h" 31 #include "codegen-inl.h"
32 #include "codegen-arm.h" // Include after codegen-inl.h.
32 #include "macro-assembler-arm.h" 33 #include "macro-assembler-arm.h"
33 34
34 namespace v8 { 35 namespace v8 {
35 namespace internal { 36 namespace internal {
36 37
37 #define __ ACCESS_MASM(masm) 38 #define __ ACCESS_MASM(masm)
38 39
39 void InstructionBlock::Compile(MacroAssembler* masm) { 40 void InstructionBlock::Compile(MacroAssembler* masm) {
40 ASSERT(!is_marked()); 41 ASSERT(!is_marked());
41 is_marked_ = true; 42 is_marked_ = true;
42 { 43 {
43 Comment cmt(masm, "[ InstructionBlock"); 44 Comment cmt(masm, "[ InstructionBlock");
44 for (int i = 0, len = instructions_.length(); i < len; i++) { 45 for (int i = 0, len = instructions_.length(); i < len; i++) {
46 // If the location of the current instruction is a temp, then the
47 // instruction cannot be in tail position in the block. Allocate the
48 // temp based on peeking ahead to the next instruction.
49 Instruction* instr = instructions_[i];
50 Location* loc = instr->location();
51 if (loc->is_temporary()) {
52 instructions_[i+1]->FastAllocate(TempLocation::cast(loc));
53 }
45 instructions_[i]->Compile(masm); 54 instructions_[i]->Compile(masm);
46 } 55 }
47 } 56 }
48 successor_->Compile(masm); 57 successor_->Compile(masm);
49 } 58 }
50 59
51 60
52 void EntryNode::Compile(MacroAssembler* masm) { 61 void EntryNode::Compile(MacroAssembler* masm) {
53 ASSERT(!is_marked()); 62 ASSERT(!is_marked());
54 is_marked_ = true; 63 is_marked_ = true;
(...skipping 29 matching lines...) Expand all
84 __ CallRuntime(Runtime::kTraceExit, 1); 93 __ CallRuntime(Runtime::kTraceExit, 1);
85 } 94 }
86 __ mov(sp, fp); 95 __ mov(sp, fp);
87 __ ldm(ia_w, sp, fp.bit() | lr.bit()); 96 __ ldm(ia_w, sp, fp.bit() | lr.bit());
88 int count = CfgGlobals::current()->fun()->scope()->num_parameters(); 97 int count = CfgGlobals::current()->fun()->scope()->num_parameters();
89 __ add(sp, sp, Operand((count + 1) * kPointerSize)); 98 __ add(sp, sp, Operand((count + 1) * kPointerSize));
90 __ Jump(lr); 99 __ Jump(lr);
91 } 100 }
92 101
93 102
103 void BinaryOpInstr::Compile(MacroAssembler* masm) {
104 // The right value should not be on the stack---if it is a
105 // compiler-generated temporary it is in the accumulator.
106 ASSERT(!val1_->is_on_stack());
107
108 // We can overwrite one of the operands if it is a temporary.
109 OverwriteMode mode = NO_OVERWRITE;
110 if (val0_->is_temporary()) {
111 mode = OVERWRITE_LEFT;
112 } else if (val1_->is_temporary()) {
113 mode = OVERWRITE_RIGHT;
114 }
115
116 // Move left to r1 and right to r0.
117 val0_->Get(masm, r1);
118 val1_->Get(masm, r0);
119 GenericBinaryOpStub stub(op_, mode);
120 __ CallStub(&stub);
121 loc_->Set(masm, r0);
122 }
123
124
94 void ReturnInstr::Compile(MacroAssembler* masm) { 125 void ReturnInstr::Compile(MacroAssembler* masm) {
126 // The location should be 'Effect'. As a side effect, move the value to
127 // the accumulator.
95 Comment cmnt(masm, "[ ReturnInstr"); 128 Comment cmnt(masm, "[ ReturnInstr");
96 value_->ToRegister(masm, r0); 129 value_->Get(masm, r0);
97 } 130 }
98 131
99 132
100 void Constant::ToRegister(MacroAssembler* masm, Register reg) { 133 void Constant::Get(MacroAssembler* masm, Register reg) {
101 __ mov(reg, Operand(handle_)); 134 __ mov(reg, Operand(handle_));
102 } 135 }
103 136
104 137
105 void SlotLocation::ToRegister(MacroAssembler* masm, Register reg) { 138 void Constant::Push(MacroAssembler* masm) {
106 switch (type_) { 139 __ mov(ip, Operand(handle_));
140 __ push(ip);
141 }
142
143
144 static MemOperand ToMemOperand(SlotLocation* loc) {
145 switch (loc->type()) {
107 case Slot::PARAMETER: { 146 case Slot::PARAMETER: {
108 int count = CfgGlobals::current()->fun()->scope()->num_parameters(); 147 int count = CfgGlobals::current()->fun()->scope()->num_parameters();
109 __ ldr(reg, MemOperand(fp, (1 + count - index_) * kPointerSize)); 148 return MemOperand(fp, (1 + count - loc->index()) * kPointerSize);
110 break;
111 } 149 }
112 case Slot::LOCAL: { 150 case Slot::LOCAL: {
113 const int kOffset = JavaScriptFrameConstants::kLocal0Offset; 151 const int kOffset = JavaScriptFrameConstants::kLocal0Offset;
114 __ ldr(reg, MemOperand(fp, kOffset - index_ * kPointerSize)); 152 return MemOperand(fp, kOffset - loc->index() * kPointerSize);
115 break;
116 } 153 }
117 default: 154 default:
118 UNREACHABLE(); 155 UNREACHABLE();
156 return MemOperand(r0);
119 } 157 }
120 } 158 }
121 159
160
161 void SlotLocation::Get(MacroAssembler* masm, Register reg) {
162 __ ldr(reg, ToMemOperand(this));
163 }
164
165
166 void SlotLocation::Set(MacroAssembler* masm, Register reg) {
167 __ str(reg, ToMemOperand(this));
168 }
169
170
171 void SlotLocation::Push(MacroAssembler* masm) {
172 __ ldr(ip, ToMemOperand(this));
173 __ push(ip); // Push will not destroy ip.
174 }
175
176
177 void TempLocation::Get(MacroAssembler* masm, Register reg) {
178 switch (where_) {
179 case ACCUMULATOR:
180 if (!reg.is(r0)) __ mov(reg, r0);
181 break;
182 case STACK:
183 __ pop(reg);
184 break;
185 case NOWHERE:
186 UNREACHABLE();
187 break;
188 }
189 }
190
191
192 void TempLocation::Set(MacroAssembler* masm, Register reg) {
193 switch (where_) {
194 case ACCUMULATOR:
195 if (!reg.is(r0)) __ mov(r0, reg);
196 break;
197 case STACK:
198 __ push(reg);
199 break;
200 case NOWHERE:
201 UNREACHABLE();
202 break;
203 }
204 }
205
206
207 void TempLocation::Push(MacroAssembler* masm) {
208 switch (where_) {
209 case ACCUMULATOR:
210 __ push(r0);
211 break;
212 case STACK:
213 case NOWHERE:
214 UNREACHABLE();
215 break;
216 }
217 }
218
219
122 #undef __ 220 #undef __
123 221
124 } } // namespace v8::internal 222 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/arm/codegen-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698