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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 134 |
135 // Run the native code for the Array function called as a normal function. | 135 // Run the native code for the Array function called as a normal function. |
136 // Tail call a stub. | 136 // Tail call a stub. |
137 __ mov(a3, a1); | 137 __ mov(a3, a1); |
138 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 138 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
139 ArrayConstructorStub stub(masm->isolate()); | 139 ArrayConstructorStub stub(masm->isolate()); |
140 __ TailCallStub(&stub); | 140 __ TailCallStub(&stub); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 void Builtins::Generate_StringConstructCode(MacroAssembler* masm) { | 144 // static |
| 145 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { |
145 // ----------- S t a t e ------------- | 146 // ----------- S t a t e ------------- |
146 // -- a0 : number of arguments | 147 // -- a0 : number of arguments |
147 // -- a1 : constructor function | 148 // -- a1 : constructor function |
| 149 // -- ra : return address |
| 150 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
| 151 // -- sp[argc * 4] : receiver |
| 152 // ----------------------------------- |
| 153 |
| 154 // 1. Load the first argument into a0 and get rid of the rest (including the |
| 155 // receiver). |
| 156 Label no_arguments; |
| 157 { |
| 158 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
| 159 __ Subu(a0, a0, Operand(1)); |
| 160 __ sll(a0, a0, kPointerSizeLog2); |
| 161 __ Addu(sp, a0, sp); |
| 162 __ lw(a0, MemOperand(sp)); |
| 163 __ Drop(2); |
| 164 } |
| 165 |
| 166 // 2a. At least one argument, return a0 if it's a string, otherwise |
| 167 // dispatch to appropriate conversion. |
| 168 Label to_string, symbol_descriptive_string; |
| 169 { |
| 170 __ JumpIfSmi(a0, &to_string); |
| 171 __ GetObjectType(a0, a1, a1); |
| 172 STATIC_ASSERT(FIRST_NONSTRING_TYPE == SYMBOL_TYPE); |
| 173 __ Subu(a1, a1, Operand(FIRST_NONSTRING_TYPE)); |
| 174 __ Branch(&symbol_descriptive_string, eq, a1, Operand(zero_reg)); |
| 175 __ Branch(&to_string, gt, a1, Operand(zero_reg)); |
| 176 __ Ret(USE_DELAY_SLOT); |
| 177 __ mov(v0, a0); |
| 178 } |
| 179 |
| 180 // 2b. No arguments, return the empty string (and pop the receiver). |
| 181 __ bind(&no_arguments); |
| 182 { |
| 183 __ LoadRoot(v0, Heap::kempty_stringRootIndex); |
| 184 __ DropAndRet(1); |
| 185 } |
| 186 |
| 187 // 3a. Convert a0 to a string. |
| 188 __ bind(&to_string); |
| 189 { |
| 190 ToStringStub stub(masm->isolate()); |
| 191 __ TailCallStub(&stub); |
| 192 } |
| 193 |
| 194 // 3b. Convert symbol in a0 to a string. |
| 195 __ bind(&symbol_descriptive_string); |
| 196 { |
| 197 __ Push(a0); |
| 198 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
| 199 } |
| 200 } |
| 201 |
| 202 |
| 203 // static |
| 204 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
| 205 // ----------- S t a t e ------------- |
| 206 // -- a0 : number of arguments |
| 207 // -- a1 : constructor function |
148 // -- ra : return address | 208 // -- ra : return address |
149 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) | 209 // -- sp[(argc - n - 1) * 4] : arg[n] (zero based) |
150 // -- sp[argc * 4] : receiver | 210 // -- sp[argc * 4] : receiver |
151 // ----------------------------------- | 211 // ----------------------------------- |
152 | 212 |
153 // 1. Load the first argument into a0 and get rid of the rest (including the | 213 // 1. Load the first argument into a0 and get rid of the rest (including the |
154 // receiver). | 214 // receiver). |
155 { | 215 { |
156 Label no_arguments, done; | 216 Label no_arguments, done; |
157 __ Branch(&no_arguments, eq, a0, Operand(zero_reg)); | 217 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
158 __ Subu(a0, a0, Operand(1)); | 218 __ Subu(a0, a0, Operand(1)); |
159 __ sll(a0, a0, kPointerSizeLog2); | 219 __ sll(a0, a0, kPointerSizeLog2); |
160 __ Addu(sp, a0, sp); | 220 __ Addu(sp, a0, sp); |
161 __ lw(a0, MemOperand(sp)); | 221 __ lw(a0, MemOperand(sp)); |
162 __ Drop(2); | 222 __ Drop(2); |
163 __ jmp(&done); | 223 __ jmp(&done); |
164 __ bind(&no_arguments); | 224 __ bind(&no_arguments); |
165 __ LoadRoot(a0, Heap::kempty_stringRootIndex); | 225 __ LoadRoot(a0, Heap::kempty_stringRootIndex); |
166 __ Drop(1); | 226 __ Drop(1); |
167 __ bind(&done); | 227 __ bind(&done); |
(...skipping 29 matching lines...) Expand all Loading... |
197 Label allocate, done_allocate; | 257 Label allocate, done_allocate; |
198 __ Allocate(JSValue::kSize, v0, a2, a3, &allocate, TAG_OBJECT); | 258 __ Allocate(JSValue::kSize, v0, a2, a3, &allocate, TAG_OBJECT); |
199 __ bind(&done_allocate); | 259 __ bind(&done_allocate); |
200 | 260 |
201 // Initialize the JSValue in eax. | 261 // Initialize the JSValue in eax. |
202 __ LoadGlobalFunctionInitialMap(a1, a2, a3); | 262 __ LoadGlobalFunctionInitialMap(a1, a2, a3); |
203 __ sw(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); | 263 __ sw(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); |
204 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); | 264 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); |
205 __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); | 265 __ sw(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); |
206 __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); | 266 __ sw(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); |
| 267 __ Ret(USE_DELAY_SLOT); |
207 __ sw(a0, FieldMemOperand(v0, JSValue::kValueOffset)); | 268 __ sw(a0, FieldMemOperand(v0, JSValue::kValueOffset)); |
208 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 269 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
209 __ Ret(); | |
210 | 270 |
211 // Fallback to the runtime to allocate in new space. | 271 // Fallback to the runtime to allocate in new space. |
212 __ bind(&allocate); | 272 __ bind(&allocate); |
213 { | 273 { |
214 FrameScope scope(masm, StackFrame::INTERNAL); | 274 FrameScope scope(masm, StackFrame::INTERNAL); |
215 __ Move(a2, Smi::FromInt(JSValue::kSize)); | 275 __ Move(a2, Smi::FromInt(JSValue::kSize)); |
216 __ Push(a0, a1, a2); | 276 __ Push(a0, a1, a2); |
217 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 277 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
218 __ Pop(a0, a1); | 278 __ Pop(a0, a1); |
219 } | 279 } |
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 } | 1860 } |
1801 } | 1861 } |
1802 | 1862 |
1803 | 1863 |
1804 #undef __ | 1864 #undef __ |
1805 | 1865 |
1806 } // namespace internal | 1866 } // namespace internal |
1807 } // namespace v8 | 1867 } // namespace v8 |
1808 | 1868 |
1809 #endif // V8_TARGET_ARCH_MIPS | 1869 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |