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

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

Issue 8743010: MIPS: Port array literal changes on ARM. (Closed)
Patch Set: Created 9 years 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
« no previous file with comments | « no previous file | src/mips/full-codegen-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 __ mov(cp, v0); 248 __ mov(cp, v0);
249 __ Addu(sp, sp, Operand(2 * kPointerSize)); 249 __ Addu(sp, sp, Operand(2 * kPointerSize));
250 __ Ret(); 250 __ Ret();
251 251
252 // Need to collect. Call into runtime system. 252 // Need to collect. Call into runtime system.
253 __ bind(&gc); 253 __ bind(&gc);
254 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); 254 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1);
255 } 255 }
256 256
257 257
258 static void GenerateFastCloneShallowArrayCommon(
259 MacroAssembler* masm,
260 int length,
261 FastCloneShallowArrayStub::Mode mode,
262 Label* fail) {
263 // Registers on entry:
264 // a3: boilerplate literal array.
265 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS);
266
267 // All sizes here are multiples of kPointerSize.
268 int elements_size = 0;
269 if (length > 0) {
270 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
271 ? FixedDoubleArray::SizeFor(length)
272 : FixedArray::SizeFor(length);
273 }
274 int size = JSArray::kSize + elements_size;
275
276 // Allocate both the JS array and the elements array in one big
277 // allocation. This avoids multiple limit checks.
278 __ AllocateInNewSpace(size,
279 v0,
280 a1,
281 a2,
282 fail,
283 TAG_OBJECT);
284
285 // Copy the JS array part.
286 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
287 if ((i != JSArray::kElementsOffset) || (length == 0)) {
288 __ lw(a1, FieldMemOperand(a3, i));
289 __ sw(a1, FieldMemOperand(v0, i));
290 }
291 }
292
293 if (length > 0) {
294 // Get hold of the elements array of the boilerplate and setup the
295 // elements pointer in the resulting object.
296 __ lw(a3, FieldMemOperand(a3, JSArray::kElementsOffset));
297 __ Addu(a2, v0, Operand(JSArray::kSize));
298 __ sw(a2, FieldMemOperand(v0, JSArray::kElementsOffset));
299
300 // Copy the elements array.
301 ASSERT((elements_size % kPointerSize) == 0);
302 __ CopyFields(a2, a3, a1.bit(), elements_size / kPointerSize);
303 }
304 }
305
258 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { 306 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
259 // Stack layout on entry: 307 // Stack layout on entry:
308 //
260 // [sp]: constant elements. 309 // [sp]: constant elements.
261 // [sp + kPointerSize]: literal index. 310 // [sp + kPointerSize]: literal index.
262 // [sp + (2 * kPointerSize)]: literals array. 311 // [sp + (2 * kPointerSize)]: literals array.
263 312
264 // All sizes here are multiples of kPointerSize.
265 int elements_size = 0;
266 if (length_ > 0) {
267 elements_size = mode_ == CLONE_DOUBLE_ELEMENTS
268 ? FixedDoubleArray::SizeFor(length_)
269 : FixedArray::SizeFor(length_);
270 }
271 int size = JSArray::kSize + elements_size;
272
273 // Load boilerplate object into r3 and check if we need to create a 313 // Load boilerplate object into r3 and check if we need to create a
274 // boilerplate. 314 // boilerplate.
275 Label slow_case; 315 Label slow_case;
276 __ lw(a3, MemOperand(sp, 2 * kPointerSize)); 316 __ lw(a3, MemOperand(sp, 2 * kPointerSize));
277 __ lw(a0, MemOperand(sp, 1 * kPointerSize)); 317 __ lw(a0, MemOperand(sp, 1 * kPointerSize));
278 __ Addu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 318 __ Addu(a3, a3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
279 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize); 319 __ sll(t0, a0, kPointerSizeLog2 - kSmiTagSize);
280 __ Addu(t0, a3, t0); 320 __ Addu(t0, a3, t0);
281 __ lw(a3, MemOperand(t0)); 321 __ lw(a3, MemOperand(t0));
282 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex); 322 __ LoadRoot(t1, Heap::kUndefinedValueRootIndex);
283 __ Branch(&slow_case, eq, a3, Operand(t1)); 323 __ Branch(&slow_case, eq, a3, Operand(t1));
284 324
325 FastCloneShallowArrayStub::Mode mode = mode_;
326 if (mode == CLONE_ANY_ELEMENTS) {
327 Label double_elements, check_fast_elements;
328 __ lw(v0, FieldMemOperand(a3, JSArray::kElementsOffset));
329 __ lw(v0, FieldMemOperand(v0, HeapObject::kMapOffset));
330 __ LoadRoot(t1, Heap::kFixedCOWArrayMapRootIndex);
331 __ Branch(&check_fast_elements, ne, v0, Operand(t1));
332 GenerateFastCloneShallowArrayCommon(masm, 0,
333 COPY_ON_WRITE_ELEMENTS, &slow_case);
334 // Return and remove the on-stack parameters.
335 __ DropAndRet(3);
336
337 __ bind(&check_fast_elements);
338 __ LoadRoot(t1, Heap::kFixedArrayMapRootIndex);
339 __ Branch(&double_elements, ne, v0, Operand(t1));
340 GenerateFastCloneShallowArrayCommon(masm, length_,
341 CLONE_ELEMENTS, &slow_case);
342 // Return and remove the on-stack parameters.
343 __ DropAndRet(3);
344
345 __ bind(&double_elements);
346 mode = CLONE_DOUBLE_ELEMENTS;
347 // Fall through to generate the code to handle double elements.
348 }
349
285 if (FLAG_debug_code) { 350 if (FLAG_debug_code) {
286 const char* message; 351 const char* message;
287 Heap::RootListIndex expected_map_index; 352 Heap::RootListIndex expected_map_index;
288 if (mode_ == CLONE_ELEMENTS) { 353 if (mode == CLONE_ELEMENTS) {
289 message = "Expected (writable) fixed array"; 354 message = "Expected (writable) fixed array";
290 expected_map_index = Heap::kFixedArrayMapRootIndex; 355 expected_map_index = Heap::kFixedArrayMapRootIndex;
291 } else if (mode_ == CLONE_DOUBLE_ELEMENTS) { 356 } else if (mode == CLONE_DOUBLE_ELEMENTS) {
292 message = "Expected (writable) fixed double array"; 357 message = "Expected (writable) fixed double array";
293 expected_map_index = Heap::kFixedDoubleArrayMapRootIndex; 358 expected_map_index = Heap::kFixedDoubleArrayMapRootIndex;
294 } else { 359 } else {
295 ASSERT(mode_ == COPY_ON_WRITE_ELEMENTS); 360 ASSERT(mode == COPY_ON_WRITE_ELEMENTS);
296 message = "Expected copy-on-write fixed array"; 361 message = "Expected copy-on-write fixed array";
297 expected_map_index = Heap::kFixedCOWArrayMapRootIndex; 362 expected_map_index = Heap::kFixedCOWArrayMapRootIndex;
298 } 363 }
299 __ push(a3); 364 __ push(a3);
300 __ lw(a3, FieldMemOperand(a3, JSArray::kElementsOffset)); 365 __ lw(a3, FieldMemOperand(a3, JSArray::kElementsOffset));
301 __ lw(a3, FieldMemOperand(a3, HeapObject::kMapOffset)); 366 __ lw(a3, FieldMemOperand(a3, HeapObject::kMapOffset));
302 __ LoadRoot(at, expected_map_index); 367 __ LoadRoot(at, expected_map_index);
303 __ Assert(eq, message, a3, Operand(at)); 368 __ Assert(eq, message, a3, Operand(at));
304 __ pop(a3); 369 __ pop(a3);
305 } 370 }
306 371
307 // Allocate both the JS array and the elements array in one big 372 GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case);
308 // allocation. This avoids multiple limit checks.
309 // Return new object in v0.
310 __ AllocateInNewSpace(size,
311 v0,
312 a1,
313 a2,
314 &slow_case,
315 TAG_OBJECT);
316
317 // Copy the JS array part.
318 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
319 if ((i != JSArray::kElementsOffset) || (length_ == 0)) {
320 __ lw(a1, FieldMemOperand(a3, i));
321 __ sw(a1, FieldMemOperand(v0, i));
322 }
323 }
324
325 if (length_ > 0) {
326 // Get hold of the elements array of the boilerplate and setup the
327 // elements pointer in the resulting object.
328 __ lw(a3, FieldMemOperand(a3, JSArray::kElementsOffset));
329 __ Addu(a2, v0, Operand(JSArray::kSize));
330 __ sw(a2, FieldMemOperand(v0, JSArray::kElementsOffset));
331
332 // Copy the elements array.
333 ASSERT((elements_size % kPointerSize) == 0);
334 __ CopyFields(a2, a3, a1.bit(), elements_size / kPointerSize);
335 }
336 373
337 // Return and remove the on-stack parameters. 374 // Return and remove the on-stack parameters.
338 __ Addu(sp, sp, Operand(3 * kPointerSize)); 375 __ Addu(sp, sp, Operand(3 * kPointerSize));
339 __ Ret(); 376 __ Ret();
340 377
341 __ bind(&slow_case); 378 __ bind(&slow_case);
342 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); 379 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
343 } 380 }
344 381
345 382
(...skipping 7090 matching lines...) Expand 10 before | Expand all | Expand 10 after
7436 // Array literal has ElementsKind of FAST_ELEMENTS and value is an object. 7473 // Array literal has ElementsKind of FAST_ELEMENTS and value is an object.
7437 __ bind(&fast_elements); 7474 __ bind(&fast_elements);
7438 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset)); 7475 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset));
7439 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize); 7476 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize);
7440 __ Addu(t2, t1, t2); 7477 __ Addu(t2, t1, t2);
7441 __ Addu(t2, t2, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 7478 __ Addu(t2, t2, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
7442 __ sw(a0, MemOperand(t2, 0)); 7479 __ sw(a0, MemOperand(t2, 0));
7443 // Update the write barrier for the array store. 7480 // Update the write barrier for the array store.
7444 __ RecordWrite(t1, t2, a0, kRAHasNotBeenSaved, kDontSaveFPRegs, 7481 __ RecordWrite(t1, t2, a0, kRAHasNotBeenSaved, kDontSaveFPRegs,
7445 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 7482 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
7446 __ Ret(); 7483 __ Ret(USE_DELAY_SLOT);
7484 __ mov(v0, a0);
7447 7485
7448 // Array literal has ElementsKind of FAST_SMI_ONLY_ELEMENTS or 7486 // Array literal has ElementsKind of FAST_SMI_ONLY_ELEMENTS or
7449 // FAST_ELEMENTS, and value is Smi. 7487 // FAST_ELEMENTS, and value is Smi.
7450 __ bind(&smi_element); 7488 __ bind(&smi_element);
7451 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset)); 7489 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset));
7452 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize); 7490 __ sll(t2, a3, kPointerSizeLog2 - kSmiTagSize);
7453 __ Addu(t2, t1, t2); 7491 __ Addu(t2, t1, t2);
7454 __ sw(a0, FieldMemOperand(t2, FixedArray::kHeaderSize)); 7492 __ sw(a0, FieldMemOperand(t2, FixedArray::kHeaderSize));
7455 __ Ret(); 7493 __ Ret(USE_DELAY_SLOT);
7494 __ mov(v0, a0);
7456 7495
7457 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS. 7496 // Array literal has ElementsKind of FAST_DOUBLE_ELEMENTS.
7458 __ bind(&double_elements); 7497 __ bind(&double_elements);
7459 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset)); 7498 __ lw(t1, FieldMemOperand(a1, JSObject::kElementsOffset));
7460 __ StoreNumberToDoubleElements(a0, a3, a1, t1, t2, t3, t5, t6, 7499 __ StoreNumberToDoubleElements(a0, a3, a1, t1, t2, t3, t5, t6,
7461 &slow_elements); 7500 &slow_elements);
7462 __ Ret(); 7501 __ Ret(USE_DELAY_SLOT);
7502 __ mov(v0, a0);
7463 } 7503 }
7464 7504
7465 7505
7466 #undef __ 7506 #undef __
7467 7507
7468 } } // namespace v8::internal 7508 } } // namespace v8::internal
7469 7509
7470 #endif // V8_TARGET_ARCH_MIPS 7510 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « no previous file | src/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698