| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 __ b(hs, &ok); | 303 __ b(hs, &ok); |
| 304 | 304 |
| 305 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 305 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
| 306 GenerateTailCallToReturnedCode(masm); | 306 GenerateTailCallToReturnedCode(masm); |
| 307 | 307 |
| 308 __ bind(&ok); | 308 __ bind(&ok); |
| 309 GenerateTailCallToSharedCode(masm); | 309 GenerateTailCallToSharedCode(masm); |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 static void Generate_Runtime_NewObject(MacroAssembler* masm, |
| 314 bool create_memento, |
| 315 Register original_constructor, |
| 316 Label* count_incremented, |
| 317 Label* allocated) { |
| 318 if (create_memento) { |
| 319 // Get the cell or allocation site. |
| 320 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); |
| 321 __ push(r2); |
| 322 } |
| 323 |
| 324 __ push(r1); // argument for Runtime_NewObject |
| 325 __ push(original_constructor); // original constructor |
| 326 if (create_memento) { |
| 327 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| 328 } else { |
| 329 __ CallRuntime(Runtime::kNewObject, 2); |
| 330 } |
| 331 __ mov(r4, r0); |
| 332 |
| 333 // Runtime_NewObjectWithAllocationSite increments allocation count. |
| 334 // Skip the increment. |
| 335 if (create_memento) { |
| 336 __ jmp(count_incremented); |
| 337 } else { |
| 338 __ jmp(allocated); |
| 339 } |
| 340 } |
| 341 |
| 342 |
| 313 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 343 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 314 bool is_api_function, | 344 bool is_api_function, |
| 315 bool create_memento) { | 345 bool create_memento) { |
| 316 // ----------- S t a t e ------------- | 346 // ----------- S t a t e ------------- |
| 317 // -- r0 : number of arguments | 347 // -- r0 : number of arguments |
| 318 // -- r1 : constructor function | 348 // -- r1 : constructor function |
| 319 // -- r2 : allocation site or undefined | 349 // -- r2 : allocation site or undefined |
| 350 // -- r3 : original constructor |
| 320 // -- lr : return address | 351 // -- lr : return address |
| 321 // -- sp[...]: constructor arguments | 352 // -- sp[...]: constructor arguments |
| 322 // ----------------------------------- | 353 // ----------------------------------- |
| 323 | 354 |
| 324 // Should never create mementos for api functions. | 355 // Should never create mementos for api functions. |
| 325 DCHECK(!is_api_function || !create_memento); | 356 DCHECK(!is_api_function || !create_memento); |
| 326 | 357 |
| 327 Isolate* isolate = masm->isolate(); | 358 Isolate* isolate = masm->isolate(); |
| 328 | 359 |
| 329 // Enter a construct frame. | 360 // Enter a construct frame. |
| 330 { | 361 { |
| 331 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 362 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
| 332 | 363 |
| 333 if (create_memento) { | 364 if (create_memento) { |
| 334 __ AssertUndefinedOrAllocationSite(r2, r3); | 365 __ AssertUndefinedOrAllocationSite(r2, r4); |
| 335 __ push(r2); | 366 __ push(r2); |
| 336 } | 367 } |
| 337 | 368 |
| 338 // Preserve the two incoming parameters on the stack. | 369 // Preserve the two incoming parameters on the stack. |
| 339 __ SmiTag(r0); | 370 __ SmiTag(r0); |
| 340 __ push(r0); // Smi-tagged arguments count. | 371 __ push(r0); // Smi-tagged arguments count. |
| 341 __ push(r1); // Constructor function. | 372 __ push(r1); // Constructor function. |
| 342 | 373 |
| 374 Label rt_call, allocated, normal_new, count_incremented; |
| 375 __ cmp(r1, r3); |
| 376 __ b(eq, &normal_new); |
| 377 |
| 378 // Original constructor and function are different. |
| 379 Generate_Runtime_NewObject(masm, create_memento, r3, &count_incremented, |
| 380 &allocated); |
| 381 __ bind(&normal_new); |
| 382 |
| 343 // Try to allocate the object without transitioning into C code. If any of | 383 // Try to allocate the object without transitioning into C code. If any of |
| 344 // the preconditions is not met, the code bails out to the runtime call. | 384 // the preconditions is not met, the code bails out to the runtime call. |
| 345 Label rt_call, allocated; | |
| 346 if (FLAG_inline_new) { | 385 if (FLAG_inline_new) { |
| 347 Label undo_allocation; | 386 Label undo_allocation; |
| 348 ExternalReference debug_step_in_fp = | 387 ExternalReference debug_step_in_fp = |
| 349 ExternalReference::debug_step_in_fp_address(isolate); | 388 ExternalReference::debug_step_in_fp_address(isolate); |
| 350 __ mov(r2, Operand(debug_step_in_fp)); | 389 __ mov(r2, Operand(debug_step_in_fp)); |
| 351 __ ldr(r2, MemOperand(r2)); | 390 __ ldr(r2, MemOperand(r2)); |
| 352 __ tst(r2, r2); | 391 __ tst(r2, r2); |
| 353 __ b(ne, &rt_call); | 392 __ b(ne, &rt_call); |
| 354 | 393 |
| 355 // Load the initial map and verify that it is in fact a map. | 394 // Load the initial map and verify that it is in fact a map. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 // example, the map's unused properties potentially do not match the | 601 // example, the map's unused properties potentially do not match the |
| 563 // allocated objects unused properties. | 602 // allocated objects unused properties. |
| 564 // r4: JSObject (previous new top) | 603 // r4: JSObject (previous new top) |
| 565 __ bind(&undo_allocation); | 604 __ bind(&undo_allocation); |
| 566 __ UndoAllocationInNewSpace(r4, r5); | 605 __ UndoAllocationInNewSpace(r4, r5); |
| 567 } | 606 } |
| 568 | 607 |
| 569 // Allocate the new receiver object using the runtime call. | 608 // Allocate the new receiver object using the runtime call. |
| 570 // r1: constructor function | 609 // r1: constructor function |
| 571 __ bind(&rt_call); | 610 __ bind(&rt_call); |
| 572 if (create_memento) { | 611 Generate_Runtime_NewObject(masm, create_memento, r1, &count_incremented, |
| 573 // Get the cell or allocation site. | 612 &allocated); |
| 574 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); | |
| 575 __ push(r2); | |
| 576 } | |
| 577 | |
| 578 __ push(r1); // argument for Runtime_NewObject | |
| 579 if (create_memento) { | |
| 580 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); | |
| 581 } else { | |
| 582 __ CallRuntime(Runtime::kNewObject, 1); | |
| 583 } | |
| 584 __ mov(r4, r0); | |
| 585 | |
| 586 // If we ended up using the runtime, and we want a memento, then the | |
| 587 // runtime call made it for us, and we shouldn't do create count | |
| 588 // increment. | |
| 589 Label count_incremented; | |
| 590 if (create_memento) { | |
| 591 __ jmp(&count_incremented); | |
| 592 } | |
| 593 | 613 |
| 594 // Receiver for constructor call allocated. | 614 // Receiver for constructor call allocated. |
| 595 // r4: JSObject | 615 // r4: JSObject |
| 596 __ bind(&allocated); | 616 __ bind(&allocated); |
| 597 | 617 |
| 598 if (create_memento) { | 618 if (create_memento) { |
| 599 __ ldr(r2, MemOperand(sp, kPointerSize * 2)); | 619 __ ldr(r2, MemOperand(sp, kPointerSize * 2)); |
| 600 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | 620 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); |
| 601 __ cmp(r2, r5); | 621 __ cmp(r2, r5); |
| 602 __ b(eq, &count_incremented); | 622 __ b(eq, &count_incremented); |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 __ bkpt(0); | 1564 __ bkpt(0); |
| 1545 } | 1565 } |
| 1546 } | 1566 } |
| 1547 | 1567 |
| 1548 | 1568 |
| 1549 #undef __ | 1569 #undef __ |
| 1550 | 1570 |
| 1551 } } // namespace v8::internal | 1571 } } // namespace v8::internal |
| 1552 | 1572 |
| 1553 #endif // V8_TARGET_ARCH_ARM | 1573 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |