OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 // Run the native code for the Array function called as a normal function. | 134 // Run the native code for the Array function called as a normal function. |
135 // Tail call a stub. | 135 // Tail call a stub. |
136 __ mov(a3, a1); | 136 __ mov(a3, a1); |
137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 137 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
138 ArrayConstructorStub stub(masm->isolate()); | 138 ArrayConstructorStub stub(masm->isolate()); |
139 __ TailCallStub(&stub); | 139 __ TailCallStub(&stub); |
140 } | 140 } |
141 | 141 |
142 | 142 |
143 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 143 // static |
| 144 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { |
144 // ----------- S t a t e ------------- | 145 // ----------- S t a t e ------------- |
145 // -- a0 : number of arguments | 146 // -- a0 : number of arguments |
146 // -- a1 : constructor function | 147 // -- a1 : constructor function |
| 148 // -- ra : return address |
| 149 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
| 150 // -- sp[argc * 8] : receiver |
| 151 // ----------------------------------- |
| 152 |
| 153 // 1. Load the first argument into a0 and get rid of the rest (including the |
| 154 // receiver). |
| 155 Label no_arguments; |
| 156 { |
| 157 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
| 158 __ Dsubu(a0, a0, Operand(1)); |
| 159 __ dsll(a0, a0, kPointerSizeLog2); |
| 160 __ Daddu(sp, a0, sp); |
| 161 __ ld(a0, MemOperand(sp)); |
| 162 __ Drop(2); |
| 163 } |
| 164 |
| 165 // 2a. At least one argument, return a0 if it's a string, otherwise |
| 166 // dispatch to appropriate conversion. |
| 167 Label to_string, symbol_descriptive_string; |
| 168 { |
| 169 __ JumpIfSmi(a0, &to_string); |
| 170 __ GetObjectType(a0, a1, a1); |
| 171 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE); |
| 172 __ Subu(a1, a1, Operand(FIRST_NONSTRING_TYPE)); |
| 173 __ Branch(&symbol_descriptive_string, eq, a1, Operand(zero_reg)); |
| 174 __ Branch(&to_string, gt, a1, Operand(zero_reg)); |
| 175 __ Ret(USE_DELAY_SLOT); |
| 176 __ mov(v0, a0); |
| 177 } |
| 178 |
| 179 // 2b. No arguments, return the empty string (and pop the receiver). |
| 180 __ bind(&no_arguments); |
| 181 { |
| 182 __ LoadRoot(v0, Heap::kempty_stringRootIndex); |
| 183 __ DropAndRet(1); |
| 184 } |
| 185 |
| 186 // 3a. Convert a0 to a string. |
| 187 __ bind(&to_string); |
| 188 { |
| 189 ToStringStub stub(masm->isolate()); |
| 190 __ TailCallStub(&stub); |
| 191 } |
| 192 |
| 193 // 3b. Convert symbol in a0 to a string. |
| 194 __ bind(&symbol_descriptive_string); |
| 195 { |
| 196 __ Push(a0); |
| 197 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
| 198 } |
| 199 } |
| 200 |
| 201 |
| 202 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
| 203 // ----------- S t a t e ------------- |
| 204 // -- a0 : number of arguments |
| 205 // -- a1 : constructor function |
147 // -- ra : return address | 206 // -- ra : return address |
148 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 207 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
149 // -- sp[argc * 8] : receiver | 208 // -- sp[argc * 8] : receiver |
150 // ----------------------------------- | 209 // ----------------------------------- |
151 | 210 |
152 // 1. Load the first argument into a0 and get rid of the rest (including the | 211 // 1. Load the first argument into a0 and get rid of the rest (including the |
153 // receiver). | 212 // receiver). |
154 { | 213 { |
155 Label no_arguments, done; | 214 Label no_arguments, done; |
156 __ Branch(&no_arguments, eq, a0, Operand(zero_reg)); | 215 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
157 __ Dsubu(a0, a0, Operand(1)); | 216 __ Dsubu(a0, a0, Operand(1)); |
158 __ dsll(a0, a0, kPointerSizeLog2); | 217 __ dsll(a0, a0, kPointerSizeLog2); |
159 __ Daddu(sp, a0, sp); | 218 __ Daddu(sp, a0, sp); |
160 __ ld(a0, MemOperand(sp)); | 219 __ ld(a0, MemOperand(sp)); |
161 __ Drop(2); | 220 __ Drop(2); |
162 __ jmp(&done); | 221 __ jmp(&done); |
163 __ bind(&no_arguments); | 222 __ bind(&no_arguments); |
164 __ LoadRoot(a0, Heap::kempty_stringRootIndex); | 223 __ LoadRoot(a0, Heap::kempty_stringRootIndex); |
165 __ Drop(1); | 224 __ Drop(1); |
166 __ bind(&done); | 225 __ bind(&done); |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 } | 1856 } |
1798 } | 1857 } |
1799 | 1858 |
1800 | 1859 |
1801 #undef __ | 1860 #undef __ |
1802 | 1861 |
1803 } // namespace internal | 1862 } // namespace internal |
1804 } // namespace v8 | 1863 } // namespace v8 |
1805 | 1864 |
1806 #endif // V8_TARGET_ARCH_MIPS64 | 1865 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |