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