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

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 233293005: Remove hand-written assembly ArrayPush stubs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ni Created 6 years, 8 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3981 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 // Compare flat ASCII strings natively. Remove arguments from stack first. 3992 // Compare flat ASCII strings natively. Remove arguments from stack first.
3993 __ IncrementCounter(counters->string_compare_native(), 1, a2, a3); 3993 __ IncrementCounter(counters->string_compare_native(), 1, a2, a3);
3994 __ Addu(sp, sp, Operand(2 * kPointerSize)); 3994 __ Addu(sp, sp, Operand(2 * kPointerSize));
3995 GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, t0, t1); 3995 GenerateCompareFlatAsciiStrings(masm, a1, a0, a2, a3, t0, t1);
3996 3996
3997 __ bind(&runtime); 3997 __ bind(&runtime);
3998 __ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1); 3998 __ TailCallRuntime(Runtime::kHiddenStringCompare, 2, 1);
3999 } 3999 }
4000 4000
4001 4001
4002 void ArrayPushStub::Generate(MacroAssembler* masm) {
4003 Register receiver = a0;
4004 Register scratch = a1;
4005
4006 int argc = arguments_count();
4007
4008 if (argc == 0) {
4009 // Nothing to do, just return the length.
4010 __ lw(v0, FieldMemOperand(receiver, JSArray::kLengthOffset));
4011 __ DropAndRet(argc + 1);
4012 return;
4013 }
4014
4015 Isolate* isolate = masm->isolate();
4016
4017 if (argc != 1) {
4018 __ TailCallExternalReference(
4019 ExternalReference(Builtins::c_ArrayPush, isolate), argc + 1, 1);
4020 return;
4021 }
4022
4023 Label call_builtin, attempt_to_grow_elements, with_write_barrier;
4024
4025 Register elements = t2;
4026 Register end_elements = t1;
4027 // Get the elements array of the object.
4028 __ lw(elements, FieldMemOperand(receiver, JSArray::kElementsOffset));
4029
4030 if (IsFastSmiOrObjectElementsKind(elements_kind())) {
4031 // Check that the elements are in fast mode and writable.
4032 __ CheckMap(elements,
4033 scratch,
4034 Heap::kFixedArrayMapRootIndex,
4035 &call_builtin,
4036 DONT_DO_SMI_CHECK);
4037 }
4038
4039 // Get the array's length into scratch and calculate new length.
4040 __ lw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
4041 __ Addu(scratch, scratch, Operand(Smi::FromInt(argc)));
4042
4043 // Get the elements' length.
4044 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
4045
4046 const int kEndElementsOffset =
4047 FixedArray::kHeaderSize - kHeapObjectTag - argc * kPointerSize;
4048
4049 if (IsFastSmiOrObjectElementsKind(elements_kind())) {
4050 // Check if we could survive without allocation.
4051 __ Branch(&attempt_to_grow_elements, gt, scratch, Operand(t0));
4052
4053 // Check if value is a smi.
4054 __ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize));
4055 __ JumpIfNotSmi(t0, &with_write_barrier);
4056
4057 // Store the value.
4058 // We may need a register containing the address end_elements below,
4059 // so write back the value in end_elements.
4060 __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
4061 __ Addu(end_elements, elements, end_elements);
4062 __ Addu(end_elements, end_elements, kEndElementsOffset);
4063 __ sw(t0, MemOperand(end_elements));
4064 } else {
4065 // Check if we could survive without allocation.
4066 __ Branch(&call_builtin, gt, scratch, Operand(t0));
4067
4068 __ lw(t0, MemOperand(sp, (argc - 1) * kPointerSize));
4069 __ StoreNumberToDoubleElements(t0, scratch, elements, a3, t1, a2,
4070 &call_builtin, argc * kDoubleSize);
4071 }
4072
4073 // Save new length.
4074 __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
4075 __ mov(v0, scratch);
4076 __ DropAndRet(argc + 1);
4077
4078 if (IsFastDoubleElementsKind(elements_kind())) {
4079 __ bind(&call_builtin);
4080 __ TailCallExternalReference(
4081 ExternalReference(Builtins::c_ArrayPush, isolate), argc + 1, 1);
4082 return;
4083 }
4084
4085 __ bind(&with_write_barrier);
4086
4087 if (IsFastSmiElementsKind(elements_kind())) {
4088 if (FLAG_trace_elements_transitions) __ jmp(&call_builtin);
4089
4090 __ lw(t3, FieldMemOperand(t0, HeapObject::kMapOffset));
4091 __ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
4092 __ Branch(&call_builtin, eq, t3, Operand(at));
4093
4094 ElementsKind target_kind = IsHoleyElementsKind(elements_kind())
4095 ? FAST_HOLEY_ELEMENTS : FAST_ELEMENTS;
4096 __ lw(a3, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX));
4097 __ lw(a3, FieldMemOperand(a3, GlobalObject::kNativeContextOffset));
4098 __ lw(a3, ContextOperand(a3, Context::JS_ARRAY_MAPS_INDEX));
4099 const int header_size = FixedArrayBase::kHeaderSize;
4100 // Verify that the object can be transitioned in place.
4101 const int origin_offset = header_size + elements_kind() * kPointerSize;
4102 __ lw(a2, FieldMemOperand(receiver, origin_offset));
4103 __ lw(at, FieldMemOperand(a3, HeapObject::kMapOffset));
4104 __ Branch(&call_builtin, ne, a2, Operand(at));
4105
4106
4107 const int target_offset = header_size + target_kind * kPointerSize;
4108 __ lw(a3, FieldMemOperand(a3, target_offset));
4109 __ mov(a2, receiver);
4110 ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
4111 masm, DONT_TRACK_ALLOCATION_SITE, NULL);
4112 }
4113
4114 // Save new length.
4115 __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
4116
4117 // Store the value.
4118 // We may need a register containing the address end_elements below, so write
4119 // back the value in end_elements.
4120 __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
4121 __ Addu(end_elements, elements, end_elements);
4122 __ Addu(end_elements, end_elements, kEndElementsOffset);
4123 __ sw(t0, MemOperand(end_elements));
4124
4125 __ RecordWrite(elements,
4126 end_elements,
4127 t0,
4128 kRAHasNotBeenSaved,
4129 kDontSaveFPRegs,
4130 EMIT_REMEMBERED_SET,
4131 OMIT_SMI_CHECK);
4132 __ mov(v0, scratch);
4133 __ DropAndRet(argc + 1);
4134
4135 __ bind(&attempt_to_grow_elements);
4136 // scratch: array's length + 1.
4137
4138 if (!FLAG_inline_new) {
4139 __ bind(&call_builtin);
4140 __ TailCallExternalReference(
4141 ExternalReference(Builtins::c_ArrayPush, isolate), argc + 1, 1);
4142 return;
4143 }
4144
4145 __ lw(a2, MemOperand(sp, (argc - 1) * kPointerSize));
4146 // Growing elements that are SMI-only requires special handling in case the
4147 // new element is non-Smi. For now, delegate to the builtin.
4148 if (IsFastSmiElementsKind(elements_kind())) {
4149 __ JumpIfNotSmi(a2, &call_builtin);
4150 }
4151
4152 // We could be lucky and the elements array could be at the top of new-space.
4153 // In this case we can just grow it in place by moving the allocation pointer
4154 // up.
4155 ExternalReference new_space_allocation_top =
4156 ExternalReference::new_space_allocation_top_address(isolate);
4157 ExternalReference new_space_allocation_limit =
4158 ExternalReference::new_space_allocation_limit_address(isolate);
4159
4160 const int kAllocationDelta = 4;
4161 ASSERT(kAllocationDelta >= argc);
4162 // Load top and check if it is the end of elements.
4163 __ sll(end_elements, scratch, kPointerSizeLog2 - kSmiTagSize);
4164 __ Addu(end_elements, elements, end_elements);
4165 __ Addu(end_elements, end_elements, Operand(kEndElementsOffset));
4166 __ li(t0, Operand(new_space_allocation_top));
4167 __ lw(a3, MemOperand(t0));
4168 __ Branch(&call_builtin, ne, a3, Operand(end_elements));
4169
4170 __ li(t3, Operand(new_space_allocation_limit));
4171 __ lw(t3, MemOperand(t3));
4172 __ Addu(a3, a3, Operand(kAllocationDelta * kPointerSize));
4173 __ Branch(&call_builtin, hi, a3, Operand(t3));
4174
4175 // We fit and could grow elements.
4176 // Update new_space_allocation_top.
4177 __ sw(a3, MemOperand(t0));
4178 // Push the argument.
4179 __ sw(a2, MemOperand(end_elements));
4180 // Fill the rest with holes.
4181 __ LoadRoot(a3, Heap::kTheHoleValueRootIndex);
4182 for (int i = 1; i < kAllocationDelta; i++) {
4183 __ sw(a3, MemOperand(end_elements, i * kPointerSize));
4184 }
4185
4186 // Update elements' and array's sizes.
4187 __ sw(scratch, FieldMemOperand(receiver, JSArray::kLengthOffset));
4188 __ lw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
4189 __ Addu(t0, t0, Operand(Smi::FromInt(kAllocationDelta)));
4190 __ sw(t0, FieldMemOperand(elements, FixedArray::kLengthOffset));
4191
4192 // Elements are in new space, so write barrier is not required.
4193 __ mov(v0, scratch);
4194 __ DropAndRet(argc + 1);
4195
4196 __ bind(&call_builtin);
4197 __ TailCallExternalReference(
4198 ExternalReference(Builtins::c_ArrayPush, isolate), argc + 1, 1);
4199 }
4200
4201
4202 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 4002 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
4203 // ----------- S t a t e ------------- 4003 // ----------- S t a t e -------------
4204 // -- a1 : left 4004 // -- a1 : left
4205 // -- a0 : right 4005 // -- a0 : right
4206 // -- ra : return address 4006 // -- ra : return address
4207 // ----------------------------------- 4007 // -----------------------------------
4208 Isolate* isolate = masm->isolate(); 4008 Isolate* isolate = masm->isolate();
4209 4009
4210 // Load a2 with the allocation site. We stick an undefined dummy value here 4010 // Load a2 with the allocation site. We stick an undefined dummy value here
4211 // and replace it with the real allocation site later when we instantiate this 4011 // and replace it with the real allocation site later when we instantiate this
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
5644 MemOperand(fp, 6 * kPointerSize), 5444 MemOperand(fp, 6 * kPointerSize),
5645 NULL); 5445 NULL);
5646 } 5446 }
5647 5447
5648 5448
5649 #undef __ 5449 #undef __
5650 5450
5651 } } // namespace v8::internal 5451 } } // namespace v8::internal
5652 5452
5653 #endif // V8_TARGET_ARCH_MIPS 5453 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« src/hydrogen.cc ('K') | « src/ia32/code-stubs-ia32.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698