| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 Loading... |
| 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 "codegen-inl.h" | 30 #include "codegen-inl.h" |
| 31 #include "fast-codegen.h" | 31 #include "fast-codegen.h" |
| 32 #include "scopes.h" |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 #define __ ACCESS_MASM(masm()) | 37 #define __ ACCESS_MASM(masm()) |
| 37 | 38 |
| 38 Register FastCodeGenerator::accumulator0() { return r0; } | 39 Register FastCodeGenerator::accumulator0() { return r0; } |
| 39 Register FastCodeGenerator::accumulator1() { return r1; } | 40 Register FastCodeGenerator::accumulator1() { return r1; } |
| 40 Register FastCodeGenerator::scratch0() { return r3; } | 41 Register FastCodeGenerator::scratch0() { return r3; } |
| 41 Register FastCodeGenerator::scratch1() { return r4; } | 42 Register FastCodeGenerator::scratch1() { return r4; } |
| 43 Register FastCodeGenerator::scratch2() { return r5; } |
| 42 Register FastCodeGenerator::receiver_reg() { return r2; } | 44 Register FastCodeGenerator::receiver_reg() { return r2; } |
| 43 Register FastCodeGenerator::context_reg() { return cp; } | 45 Register FastCodeGenerator::context_reg() { return cp; } |
| 44 | 46 |
| 45 | 47 |
| 46 void FastCodeGenerator::EmitLoadReceiver() { | 48 void FastCodeGenerator::EmitLoadReceiver() { |
| 47 // Offset 2 is due to return address and saved frame pointer. | 49 // Offset 2 is due to return address and saved frame pointer. |
| 48 int index = 2 + scope()->num_parameters(); | 50 int index = 2 + scope()->num_parameters(); |
| 49 __ ldr(receiver_reg(), MemOperand(sp, index * kPointerSize)); | 51 __ ldr(receiver_reg(), MemOperand(sp, index * kPointerSize)); |
| 50 } | 52 } |
| 51 | 53 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 94 } |
| 93 } else { | 95 } else { |
| 94 offset += FixedArray::kHeaderSize; | 96 offset += FixedArray::kHeaderSize; |
| 95 __ ldr(scratch0(), | 97 __ ldr(scratch0(), |
| 96 FieldMemOperand(receiver_reg(), JSObject::kPropertiesOffset)); | 98 FieldMemOperand(receiver_reg(), JSObject::kPropertiesOffset)); |
| 97 __ str(accumulator0(), FieldMemOperand(scratch0(), offset)); | 99 __ str(accumulator0(), FieldMemOperand(scratch0(), offset)); |
| 98 } | 100 } |
| 99 | 101 |
| 100 if (needs_write_barrier) { | 102 if (needs_write_barrier) { |
| 101 __ mov(scratch1(), Operand(offset)); | 103 __ mov(scratch1(), Operand(offset)); |
| 102 __ RecordWrite(scratch0(), scratch1(), ip); | 104 __ RecordWrite(scratch0(), scratch1(), scratch2()); |
| 103 } | 105 } |
| 104 | 106 |
| 105 if (destination().is(accumulator1())) { | 107 if (destination().is(accumulator1())) { |
| 106 __ mov(accumulator1(), accumulator0()); | 108 __ mov(accumulator1(), accumulator0()); |
| 107 if (is_smi(accumulator0())) { | 109 if (is_smi(accumulator0())) { |
| 108 set_as_smi(accumulator1()); | 110 set_as_smi(accumulator1()); |
| 109 } else { | 111 } else { |
| 110 clear_as_smi(accumulator1()); | 112 clear_as_smi(accumulator1()); |
| 111 } | 113 } |
| 112 } | 114 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 // If we didn't bailout, the result (in fact, both inputs too) is known to | 174 // If we didn't bailout, the result (in fact, both inputs too) is known to |
| 173 // be a smi. | 175 // be a smi. |
| 174 set_as_smi(accumulator0()); | 176 set_as_smi(accumulator0()); |
| 175 set_as_smi(accumulator1()); | 177 set_as_smi(accumulator1()); |
| 176 } | 178 } |
| 177 | 179 |
| 178 | 180 |
| 179 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) { | 181 void FastCodeGenerator::Generate(CompilationInfo* compilation_info) { |
| 180 ASSERT(info_ == NULL); | 182 ASSERT(info_ == NULL); |
| 181 info_ = compilation_info; | 183 info_ = compilation_info; |
| 184 Comment cmnt(masm_, "[ function compiled by fast code generator"); |
| 182 | 185 |
| 183 // Save the caller's frame pointer and set up our own. | 186 // Save the caller's frame pointer and set up our own. |
| 184 Comment prologue_cmnt(masm(), ";; Prologue"); | 187 Comment prologue_cmnt(masm(), ";; Prologue"); |
| 185 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); | 188 __ stm(db_w, sp, r1.bit() | cp.bit() | fp.bit() | lr.bit()); |
| 186 __ add(fp, sp, Operand(2 * kPointerSize)); | 189 __ add(fp, sp, Operand(2 * kPointerSize)); |
| 187 // Note that we keep a live register reference to cp (context) at | 190 // Note that we keep a live register reference to cp (context) at |
| 188 // this point. | 191 // this point. |
| 189 | 192 |
| 190 Label* bailout_to_beginning = info()->AddBailout(); | 193 Label* bailout_to_beginning = info()->AddBailout(); |
| 191 // Receiver (this) is allocated to a fixed register. | 194 // Receiver (this) is allocated to a fixed register. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; | 229 int32_t sp_delta = (scope()->num_parameters() + 1) * kPointerSize; |
| 227 __ add(sp, sp, Operand(sp_delta)); | 230 __ add(sp, sp, Operand(sp_delta)); |
| 228 __ Jump(lr); | 231 __ Jump(lr); |
| 229 } | 232 } |
| 230 | 233 |
| 231 | 234 |
| 232 #undef __ | 235 #undef __ |
| 233 | 236 |
| 234 | 237 |
| 235 } } // namespace v8::internal | 238 } } // namespace v8::internal |
| OLD | NEW |