Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: runtime/vm/stub_code_arm.cc

Issue 600243002: Patchable AllocateArray stub, like instance allocation stubs. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code.cc ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_ARM) 6 #if defined(TARGET_ARCH_ARM)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 __ Pop(R0); 405 __ Pop(R0);
406 // Remove the stub frame. 406 // Remove the stub frame.
407 __ LeaveStubFrame(); 407 __ LeaveStubFrame();
408 // Jump to the dart function. 408 // Jump to the dart function.
409 __ ldr(R0, FieldAddress(R0, Code::instructions_offset())); 409 __ ldr(R0, FieldAddress(R0, Code::instructions_offset()));
410 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag); 410 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag);
411 __ bx(R0); 411 __ bx(R0);
412 } 412 }
413 413
414 414
415 // Called from array allocate instruction when the allocation stub has been
416 // disabled.
417 // R1: element type (preserved).
418 // R2: length (preserved).
419 void StubCode::GenerateFixAllocateArrayStubTargetStub(Assembler* assembler) {
420 __ EnterStubFrame();
421 // Setup space on stack for return value and preserve length, element type.
422 __ LoadImmediate(R0, reinterpret_cast<intptr_t>(Object::null()));
423 __ PushList((1 << R0) | (1 << R1) | (1 << R2));
424 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0);
425 // Get Code object result and restore length, element type.
426 __ PopList((1 << R0) | (1 << R1) | (1 << R2));
427 // Remove the stub frame.
428 __ LeaveStubFrame();
429 // Jump to the dart function.
430 __ ldr(R0, FieldAddress(R0, Code::instructions_offset()));
431 __ AddImmediate(R0, R0, Instructions::HeaderSize() - kHeapObjectTag);
432 __ bx(R0);
433 }
434
435
415 // Input parameters: 436 // Input parameters:
416 // R2: smi-tagged argument count, may be zero. 437 // R2: smi-tagged argument count, may be zero.
417 // FP[kParamEndSlotFromFp + 1]: last argument. 438 // FP[kParamEndSlotFromFp + 1]: last argument.
418 static void PushArgumentsArray(Assembler* assembler) { 439 static void PushArgumentsArray(Assembler* assembler) {
419 StubCode* stub_code = Isolate::Current()->stub_code(); 440 StubCode* stub_code = Isolate::Current()->stub_code();
420 // Allocate array to store arguments of caller. 441 // Allocate array to store arguments of caller.
421 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null())); 442 __ LoadImmediate(R1, reinterpret_cast<intptr_t>(Object::null()));
422 // R1: null element type for raw Array. 443 // R1: null element type for raw Array.
423 // R2: smi-tagged argument count, may be zero. 444 // R2: smi-tagged argument count, may be zero.
424 __ BranchLink(&stub_code->AllocateArrayLabel()); 445 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
446 const ExternalLabel array_label(array_stub.EntryPoint());
447 __ BranchLink(&array_label);
425 // R0: newly allocated array. 448 // R0: newly allocated array.
426 // R2: smi-tagged argument count, may be zero (was preserved by the stub). 449 // R2: smi-tagged argument count, may be zero (was preserved by the stub).
427 __ Push(R0); // Array is in R0 and on top of stack. 450 __ Push(R0); // Array is in R0 and on top of stack.
428 __ add(R1, FP, Operand(R2, LSL, 1)); 451 __ add(R1, FP, Operand(R2, LSL, 1));
429 __ AddImmediate(R1, kParamEndSlotFromFp * kWordSize); 452 __ AddImmediate(R1, kParamEndSlotFromFp * kWordSize);
430 __ AddImmediate(R3, R0, Array::data_offset() - kHeapObjectTag); 453 __ AddImmediate(R3, R0, Array::data_offset() - kHeapObjectTag);
431 // R1: address of first argument on stack. 454 // R1: address of first argument on stack.
432 // R3: address of first argument in array. 455 // R3: address of first argument in array.
433 Label loop; 456 Label loop;
434 __ Bind(&loop); 457 __ Bind(&loop);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 __ bx(R2); 623 __ bx(R2);
601 } 624 }
602 625
603 626
604 // Called for inline allocation of arrays. 627 // Called for inline allocation of arrays.
605 // Input parameters: 628 // Input parameters:
606 // LR: return address. 629 // LR: return address.
607 // R1: array element type (either NULL or an instantiated type). 630 // R1: array element type (either NULL or an instantiated type).
608 // R2: array length as Smi (must be preserved). 631 // R2: array length as Smi (must be preserved).
609 // The newly allocated object is returned in R0. 632 // The newly allocated object is returned in R0.
610 void StubCode::GenerateAllocateArrayStub(Assembler* assembler) { 633 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler,
634 uword* entry_patch_offset, uword* patch_code_pc_offset) {
635 *entry_patch_offset = assembler->CodeSize();
611 Label slow_case; 636 Label slow_case;
612 637
613 // Compute the size to be allocated, it is based on the array length 638 // Compute the size to be allocated, it is based on the array length
614 // and is computed as: 639 // and is computed as:
615 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 640 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
616 __ MoveRegister(R3, R2); // Array length. 641 __ MoveRegister(R3, R2); // Array length.
617 642
618 // Check that length is a positive Smi. 643 // Check that length is a positive Smi.
619 __ tst(R3, Operand(kSmiTagMask)); 644 __ tst(R3, Operand(kSmiTagMask));
620 __ b(&slow_case, NE); 645 __ b(&slow_case, NE);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null())); 741 __ LoadImmediate(IP, reinterpret_cast<intptr_t>(Object::null()));
717 // Setup space on stack for return value. 742 // Setup space on stack for return value.
718 // Push array length as Smi and element type. 743 // Push array length as Smi and element type.
719 __ PushList((1 << R1) | (1 << R2) | (1 << IP)); 744 __ PushList((1 << R1) | (1 << R2) | (1 << IP));
720 __ CallRuntime(kAllocateArrayRuntimeEntry, 2); 745 __ CallRuntime(kAllocateArrayRuntimeEntry, 2);
721 // Pop arguments; result is popped in IP. 746 // Pop arguments; result is popped in IP.
722 __ PopList((1 << R1) | (1 << R2) | (1 << IP)); // R2 is restored. 747 __ PopList((1 << R1) | (1 << R2) | (1 << IP)); // R2 is restored.
723 __ mov(R0, Operand(IP)); 748 __ mov(R0, Operand(IP));
724 __ LeaveStubFrame(); 749 __ LeaveStubFrame();
725 __ Ret(); 750 __ Ret();
751 *patch_code_pc_offset = assembler->CodeSize();
752 StubCode* stub_code = Isolate::Current()->stub_code();
753 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel());
726 } 754 }
727 755
728 756
729 // Called when invoking Dart code from C++ (VM code). 757 // Called when invoking Dart code from C++ (VM code).
730 // Input parameters: 758 // Input parameters:
731 // LR : points to return address. 759 // LR : points to return address.
732 // R0 : entrypoint of the Dart function to call. 760 // R0 : entrypoint of the Dart function to call.
733 // R1 : arguments descriptor array. 761 // R1 : arguments descriptor array.
734 // R2 : arguments array. 762 // R2 : arguments array.
735 // R3 : new context containing the current isolate pointer. 763 // R3 : new context containing the current isolate pointer.
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 const Register right = R0; 2002 const Register right = R0;
1975 __ ldr(left, Address(SP, 1 * kWordSize)); 2003 __ ldr(left, Address(SP, 1 * kWordSize));
1976 __ ldr(right, Address(SP, 0 * kWordSize)); 2004 __ ldr(right, Address(SP, 0 * kWordSize));
1977 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2005 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
1978 __ Ret(); 2006 __ Ret();
1979 } 2007 }
1980 2008
1981 } // namespace dart 2009 } // namespace dart
1982 2010
1983 #endif // defined TARGET_ARCH_ARM 2011 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/stub_code.cc ('k') | runtime/vm/stub_code_arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698