| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 __ Push(a0); | 217 __ Push(a0); |
| 218 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); | 218 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 | 222 |
| 223 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 223 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
| 224 // ----------- S t a t e ------------- | 224 // ----------- S t a t e ------------- |
| 225 // -- a0 : number of arguments | 225 // -- a0 : number of arguments |
| 226 // -- a1 : constructor function | 226 // -- a1 : constructor function |
| 227 // -- a3 : original constructor |
| 227 // -- ra : return address | 228 // -- ra : return address |
| 228 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 229 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
| 229 // -- sp[argc * 8] : receiver | 230 // -- sp[argc * 8] : receiver |
| 230 // ----------------------------------- | 231 // ----------------------------------- |
| 231 | 232 |
| 232 // 1. Load the first argument into a0 and get rid of the rest (including the | 233 // 1. Load the first argument into a0 and get rid of the rest (including the |
| 233 // receiver). | 234 // receiver). |
| 234 { | 235 { |
| 235 Label no_arguments, done; | 236 Label no_arguments, done; |
| 236 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); | 237 __ Branch(USE_DELAY_SLOT, &no_arguments, eq, a0, Operand(zero_reg)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 250 { | 251 { |
| 251 Label convert, done_convert; | 252 Label convert, done_convert; |
| 252 __ JumpIfSmi(a0, &convert); | 253 __ JumpIfSmi(a0, &convert); |
| 253 __ GetObjectType(a0, a2, a2); | 254 __ GetObjectType(a0, a2, a2); |
| 254 __ And(t0, a2, Operand(kIsNotStringMask)); | 255 __ And(t0, a2, Operand(kIsNotStringMask)); |
| 255 __ Branch(&done_convert, eq, t0, Operand(zero_reg)); | 256 __ Branch(&done_convert, eq, t0, Operand(zero_reg)); |
| 256 __ bind(&convert); | 257 __ bind(&convert); |
| 257 { | 258 { |
| 258 FrameScope scope(masm, StackFrame::INTERNAL); | 259 FrameScope scope(masm, StackFrame::INTERNAL); |
| 259 ToStringStub stub(masm->isolate()); | 260 ToStringStub stub(masm->isolate()); |
| 260 __ Push(a1); | 261 __ Push(a1, a3); |
| 261 __ CallStub(&stub); | 262 __ CallStub(&stub); |
| 262 __ Move(a0, v0); | 263 __ Move(a0, v0); |
| 263 __ Pop(a1); | 264 __ Pop(a1, a3); |
| 264 } | 265 } |
| 265 __ bind(&done_convert); | 266 __ bind(&done_convert); |
| 266 } | 267 } |
| 267 | 268 |
| 268 // 3. Allocate a JSValue wrapper for the string. | 269 // 3. Allocate a JSValue wrapper for the string. |
| 269 { | 270 { |
| 270 // ----------- S t a t e ------------- | 271 // ----------- S t a t e ------------- |
| 271 // -- a0 : the first argument | 272 // -- a0 : the first argument |
| 272 // -- a1 : constructor function | 273 // -- a1 : constructor function |
| 274 // -- a3 : original constructor |
| 273 // -- ra : return address | 275 // -- ra : return address |
| 274 // ----------------------------------- | 276 // ----------------------------------- |
| 275 | 277 |
| 276 Label allocate, done_allocate; | 278 Label allocate, done_allocate, rt_call; |
| 279 |
| 280 // Fall back to runtime if the original constructor and function differ. |
| 281 __ Branch(&rt_call, ne, a1, Operand(a3)); |
| 282 |
| 277 __ Allocate(JSValue::kSize, v0, a2, a3, &allocate, TAG_OBJECT); | 283 __ Allocate(JSValue::kSize, v0, a2, a3, &allocate, TAG_OBJECT); |
| 278 __ bind(&done_allocate); | 284 __ bind(&done_allocate); |
| 279 | 285 |
| 280 // Initialize the JSValue in eax. | 286 // Initialize the JSValue in eax. |
| 281 __ LoadGlobalFunctionInitialMap(a1, a2, a3); | 287 __ LoadGlobalFunctionInitialMap(a1, a2, a3); |
| 282 __ sd(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); | 288 __ sd(a2, FieldMemOperand(v0, HeapObject::kMapOffset)); |
| 283 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); | 289 __ LoadRoot(a3, Heap::kEmptyFixedArrayRootIndex); |
| 284 __ sd(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); | 290 __ sd(a3, FieldMemOperand(v0, JSObject::kPropertiesOffset)); |
| 285 __ sd(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); | 291 __ sd(a3, FieldMemOperand(v0, JSObject::kElementsOffset)); |
| 286 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); | 292 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); |
| 287 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 293 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
| 288 __ Ret(); | 294 __ Ret(); |
| 289 | 295 |
| 290 // Fallback to the runtime to allocate in new space. | 296 // Fallback to the runtime to allocate in new space. |
| 291 __ bind(&allocate); | 297 __ bind(&allocate); |
| 292 { | 298 { |
| 293 FrameScope scope(masm, StackFrame::INTERNAL); | 299 FrameScope scope(masm, StackFrame::INTERNAL); |
| 294 __ Move(a2, Smi::FromInt(JSValue::kSize)); | 300 __ Move(a2, Smi::FromInt(JSValue::kSize)); |
| 295 __ Push(a0, a1, a2); | 301 __ Push(a0, a1, a2); |
| 296 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 302 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
| 297 __ Pop(a0, a1); | 303 __ Pop(a0, a1); |
| 298 } | 304 } |
| 299 __ jmp(&done_allocate); | 305 __ jmp(&done_allocate); |
| 306 |
| 307 // Fallback to the runtime to create new object. |
| 308 __ bind(&rt_call); |
| 309 { |
| 310 FrameScope scope(masm, StackFrame::INTERNAL); |
| 311 __ Push(a0, a1, a1, a3); // constructor function, original constructor |
| 312 __ CallRuntime(Runtime::kNewObject, 2); |
| 313 __ Pop(a0, a1); |
| 314 } |
| 315 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); |
| 316 __ Ret(); |
| 300 } | 317 } |
| 301 } | 318 } |
| 302 | 319 |
| 303 | 320 |
| 304 static void CallRuntimePassFunction( | 321 static void CallRuntimePassFunction( |
| 305 MacroAssembler* masm, Runtime::FunctionId function_id) { | 322 MacroAssembler* masm, Runtime::FunctionId function_id) { |
| 306 FrameScope scope(masm, StackFrame::INTERNAL); | 323 FrameScope scope(masm, StackFrame::INTERNAL); |
| 307 // Push a copy of the function onto the stack. | 324 // Push a copy of the function onto the stack. |
| 308 // Push call kind information and function as parameter to the runtime call. | 325 // Push call kind information and function as parameter to the runtime call. |
| 309 __ Push(a1, a1); | 326 __ Push(a1, a1); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 // Reload the original constructor and fall-through. | 518 // Reload the original constructor and fall-through. |
| 502 __ bind(&rt_call_reload_new_target); | 519 __ bind(&rt_call_reload_new_target); |
| 503 __ ld(a3, MemOperand(sp, 0 * kPointerSize)); | 520 __ ld(a3, MemOperand(sp, 0 * kPointerSize)); |
| 504 } | 521 } |
| 505 | 522 |
| 506 // Allocate the new receiver object using the runtime call. | 523 // Allocate the new receiver object using the runtime call. |
| 507 // a1: constructor function | 524 // a1: constructor function |
| 508 // a3: original constructor | 525 // a3: original constructor |
| 509 __ bind(&rt_call); | 526 __ bind(&rt_call); |
| 510 | 527 |
| 511 __ Push(a1, a3); // arguments 2-3 / 1-2 | 528 __ Push(a1, a3); // constructor function, original constructor |
| 512 __ CallRuntime(Runtime::kNewObject, 2); | 529 __ CallRuntime(Runtime::kNewObject, 2); |
| 513 __ mov(t0, v0); | 530 __ mov(t0, v0); |
| 514 | 531 |
| 515 // Receiver for constructor call allocated. | 532 // Receiver for constructor call allocated. |
| 516 // t0: JSObject | 533 // t0: JSObject |
| 517 __ bind(&allocated); | 534 __ bind(&allocated); |
| 518 | 535 |
| 519 // Restore the parameters. | 536 // Restore the parameters. |
| 520 __ Pop(a3); // new.target | 537 __ Pop(a3); // new.target |
| 521 __ Pop(a1); | 538 __ Pop(a1); |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 } | 1941 } |
| 1925 } | 1942 } |
| 1926 | 1943 |
| 1927 | 1944 |
| 1928 #undef __ | 1945 #undef __ |
| 1929 | 1946 |
| 1930 } // namespace internal | 1947 } // namespace internal |
| 1931 } // namespace v8 | 1948 } // namespace v8 |
| 1932 | 1949 |
| 1933 #endif // V8_TARGET_ARCH_MIPS64 | 1950 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |