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

Side by Side Diff: runtime/vm/stub_code_mips.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_ia32.cc ('k') | runtime/vm/stub_code_x64.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_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
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/compiler.h" 10 #include "vm/compiler.h"
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 451
452 // Jump to the dart function. 452 // Jump to the dart function.
453 __ lw(T0, FieldAddress(T0, Code::instructions_offset())); 453 __ lw(T0, FieldAddress(T0, Code::instructions_offset()));
454 __ AddImmediate(T0, T0, Instructions::HeaderSize() - kHeapObjectTag); 454 __ AddImmediate(T0, T0, Instructions::HeaderSize() - kHeapObjectTag);
455 455
456 // Remove the stub frame. 456 // Remove the stub frame.
457 __ LeaveStubFrameAndReturn(T0); 457 __ LeaveStubFrameAndReturn(T0);
458 } 458 }
459 459
460 460
461 // Called from array allocate instruction when the allocation stub has been
462 // disabled.
463 // A0: element type (preserved).
464 // A1: length (preserved).
465 void StubCode::GenerateFixAllocateArrayStubTargetStub(Assembler* assembler) {
466 __ TraceSimMsg("FixAllocationStubTarget");
467 __ EnterStubFrame();
468 // Setup space on stack for return value.
469 __ addiu(SP, SP, Immediate(-3 * kWordSize));
470 __ sw(A0, Address(SP, 2 * kWordSize));
471 __ sw(A1, Address(SP, 1 * kWordSize));
472 __ LoadImmediate(TMP, reinterpret_cast<intptr_t>(Object::null()));
473 __ sw(TMP, Address(SP, 0 * kWordSize));
474 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0);
475 // Get Code object result.
476 __ lw(T0, Address(SP, 0 * kWordSize));
477 __ lw(A1, Address(SP, 1 * kWordSize));
478 __ lw(A0, Address(SP, 2 * kWordSize));
479 __ addiu(SP, SP, Immediate(3 * kWordSize));
480
481 // Jump to the dart function.
482 __ lw(T0, FieldAddress(T0, Code::instructions_offset()));
483 __ AddImmediate(T0, T0, Instructions::HeaderSize() - kHeapObjectTag);
484
485 // Remove the stub frame.
486 __ LeaveStubFrameAndReturn(T0);
487 }
488
489
461 // Input parameters: 490 // Input parameters:
462 // A1: Smi-tagged argument count, may be zero. 491 // A1: Smi-tagged argument count, may be zero.
463 // FP[kParamEndSlotFromFp + 1]: Last argument. 492 // FP[kParamEndSlotFromFp + 1]: Last argument.
464 static void PushArgumentsArray(Assembler* assembler) { 493 static void PushArgumentsArray(Assembler* assembler) {
465 StubCode* stub_code = Isolate::Current()->stub_code(); 494 StubCode* stub_code = Isolate::Current()->stub_code();
466 __ TraceSimMsg("PushArgumentsArray"); 495 __ TraceSimMsg("PushArgumentsArray");
467 // Allocate array to store arguments of caller. 496 // Allocate array to store arguments of caller.
468 __ LoadImmediate(A0, reinterpret_cast<intptr_t>(Object::null())); 497 __ LoadImmediate(A0, reinterpret_cast<intptr_t>(Object::null()));
469 // A0: Null element type for raw Array. 498 // A0: Null element type for raw Array.
470 // A1: Smi-tagged argument count, may be zero. 499 // A1: Smi-tagged argument count, may be zero.
471 __ BranchLink(&stub_code->AllocateArrayLabel()); 500 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub());
501 const ExternalLabel array_label(array_stub.EntryPoint());
502 __ BranchLink(&array_label);
472 __ TraceSimMsg("PushArgumentsArray return"); 503 __ TraceSimMsg("PushArgumentsArray return");
473 // V0: newly allocated array. 504 // V0: newly allocated array.
474 // A1: Smi-tagged argument count, may be zero (was preserved by the stub). 505 // A1: Smi-tagged argument count, may be zero (was preserved by the stub).
475 __ Push(V0); // Array is in V0 and on top of stack. 506 __ Push(V0); // Array is in V0 and on top of stack.
476 __ sll(T1, A1, 1); 507 __ sll(T1, A1, 1);
477 __ addu(T1, FP, T1); 508 __ addu(T1, FP, T1);
478 __ AddImmediate(T1, kParamEndSlotFromFp * kWordSize); 509 __ AddImmediate(T1, kParamEndSlotFromFp * kWordSize);
479 // T1: address of first argument on stack. 510 // T1: address of first argument on stack.
480 // T2: address of first argument in array. 511 // T2: address of first argument in array.
481 512
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 711 }
681 712
682 713
683 // Called for inline allocation of arrays. 714 // Called for inline allocation of arrays.
684 // Input parameters: 715 // Input parameters:
685 // RA: return address. 716 // RA: return address.
686 // A1: Array length as Smi (must be preserved). 717 // A1: Array length as Smi (must be preserved).
687 // A0: array element type (either NULL or an instantiated type). 718 // A0: array element type (either NULL or an instantiated type).
688 // NOTE: A1 cannot be clobbered here as the caller relies on it being saved. 719 // NOTE: A1 cannot be clobbered here as the caller relies on it being saved.
689 // The newly allocated object is returned in V0. 720 // The newly allocated object is returned in V0.
690 void StubCode::GenerateAllocateArrayStub(Assembler* assembler) { 721 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler,
722 uword* entry_patch_offset, uword* patch_code_pc_offset) {
691 __ TraceSimMsg("AllocateArrayStub"); 723 __ TraceSimMsg("AllocateArrayStub");
724 *entry_patch_offset = assembler->CodeSize();
692 Label slow_case; 725 Label slow_case;
693 726
694 // Compute the size to be allocated, it is based on the array length 727 // Compute the size to be allocated, it is based on the array length
695 // and is computed as: 728 // and is computed as:
696 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). 729 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)).
697 __ mov(T3, A1); // Array length. 730 __ mov(T3, A1); // Array length.
698 731
699 // Check that length is a positive Smi. 732 // Check that length is a positive Smi.
700 __ andi(CMPRES1, T3, Immediate(kSmiTagMask)); 733 __ andi(CMPRES1, T3, Immediate(kSmiTagMask));
701 __ bne(CMPRES1, ZR, &slow_case); 734 __ bne(CMPRES1, ZR, &slow_case);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 __ sw(A0, Address(SP, 0 * kWordSize)); 843 __ sw(A0, Address(SP, 0 * kWordSize));
811 __ CallRuntime(kAllocateArrayRuntimeEntry, 2); 844 __ CallRuntime(kAllocateArrayRuntimeEntry, 2);
812 __ TraceSimMsg("AllocateArrayStub return"); 845 __ TraceSimMsg("AllocateArrayStub return");
813 // Pop arguments; result is popped in IP. 846 // Pop arguments; result is popped in IP.
814 __ lw(V0, Address(SP, 2 * kWordSize)); 847 __ lw(V0, Address(SP, 2 * kWordSize));
815 __ lw(A1, Address(SP, 1 * kWordSize)); 848 __ lw(A1, Address(SP, 1 * kWordSize));
816 __ lw(A0, Address(SP, 0 * kWordSize)); 849 __ lw(A0, Address(SP, 0 * kWordSize));
817 __ addiu(SP, SP, Immediate(3 * kWordSize)); 850 __ addiu(SP, SP, Immediate(3 * kWordSize));
818 851
819 __ LeaveStubFrameAndReturn(); 852 __ LeaveStubFrameAndReturn();
853 *patch_code_pc_offset = assembler->CodeSize();
854 StubCode* stub_code = Isolate::Current()->stub_code();
855 __ BranchPatchable(&stub_code->FixAllocateArrayStubTargetLabel());
820 } 856 }
821 857
822 858
823 // Called when invoking Dart code from C++ (VM code). 859 // Called when invoking Dart code from C++ (VM code).
824 // Input parameters: 860 // Input parameters:
825 // RA : points to return address. 861 // RA : points to return address.
826 // A0 : entrypoint of the Dart function to call. 862 // A0 : entrypoint of the Dart function to call.
827 // A1 : arguments descriptor array. 863 // A1 : arguments descriptor array.
828 // A2 : arguments array. 864 // A2 : arguments array.
829 // A3 : new context containing the current isolate pointer. 865 // A3 : new context containing the current isolate pointer.
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
2229 const Register right = T0; 2265 const Register right = T0;
2230 __ lw(left, Address(SP, 1 * kWordSize)); 2266 __ lw(left, Address(SP, 1 * kWordSize));
2231 __ lw(right, Address(SP, 0 * kWordSize)); 2267 __ lw(right, Address(SP, 0 * kWordSize));
2232 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2); 2268 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp1, temp2);
2233 __ Ret(); 2269 __ Ret();
2234 } 2270 }
2235 2271
2236 } // namespace dart 2272 } // namespace dart
2237 2273
2238 #endif // defined TARGET_ARCH_MIPS 2274 #endif // defined TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_ia32.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698