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

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

Issue 11663005: Adapt Danno's Track Allocation Info idea to fast literals. When allocating a literal array, (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported to other platforms Created 7 years, 11 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Need to collect. Call into runtime system. 337 // Need to collect. Call into runtime system.
338 __ bind(&gc); 338 __ bind(&gc);
339 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1); 339 __ TailCallRuntime(Runtime::kPushBlockContext, 2, 1);
340 } 340 }
341 341
342 342
343 static void GenerateFastCloneShallowArrayCommon( 343 static void GenerateFastCloneShallowArrayCommon(
344 MacroAssembler* masm, 344 MacroAssembler* masm,
345 int length, 345 int length,
346 FastCloneShallowArrayStub::Mode mode, 346 FastCloneShallowArrayStub::Mode mode,
347 FastCloneShallowArrayStub::AllocationInfoMode allocation_info_mode,
347 Label* fail) { 348 Label* fail) {
348 // Registers on entry: 349 // Registers on entry:
349 // 350 //
350 // r3: boilerplate literal array. 351 // r3: boilerplate literal array.
351 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS); 352 ASSERT(mode != FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS);
352 353
353 // All sizes here are multiples of kPointerSize. 354 // All sizes here are multiples of kPointerSize.
354 int elements_size = 0; 355 int elements_size = 0;
355 if (length > 0) { 356 if (length > 0) {
356 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS 357 elements_size = mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS
357 ? FixedDoubleArray::SizeFor(length) 358 ? FixedDoubleArray::SizeFor(length)
358 : FixedArray::SizeFor(length); 359 : FixedArray::SizeFor(length);
359 } 360 }
360 int size = JSArray::kSize + elements_size; 361 int size = JSArray::kSize;
362 int allocation_info_start = size;
363 if (allocation_info_mode ==
364 FastCloneShallowArrayStub::TRACK_ALLOCATION_INFO) {
365 size += AllocationSiteInfo::kSize;
366 }
367 size += elements_size;
361 368
362 // Allocate both the JS array and the elements array in one big 369 // Allocate both the JS array and the elements array in one big
363 // allocation. This avoids multiple limit checks. 370 // allocation. This avoids multiple limit checks.
364 AllocationFlags flags = TAG_OBJECT; 371 AllocationFlags flags = TAG_OBJECT;
365 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) { 372 if (mode == FastCloneShallowArrayStub::CLONE_DOUBLE_ELEMENTS) {
366 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags); 373 flags = static_cast<AllocationFlags>(DOUBLE_ALIGNMENT | flags);
367 } 374 }
368 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags); 375 __ AllocateInNewSpace(size, r0, r1, r2, fail, flags);
369 376
377 if (allocation_info_mode ==
378 FastCloneShallowArrayStub::TRACK_ALLOCATION_INFO) {
379 __ mov(r2, Operand(Handle<Map>(masm->isolate()->heap()->
380 allocation_site_info_map())));
381 __ str(r2,
382 FieldMemOperand(r0, allocation_info_start));
danno 2013/01/04 08:50:55 nit: one line
mvstanton 2013/01/04 12:07:52 Done.
383 __ str(r3, FieldMemOperand(r0, allocation_info_start + kPointerSize));
384 }
385
370 // Copy the JS array part. 386 // Copy the JS array part.
371 for (int i = 0; i < JSArray::kSize; i += kPointerSize) { 387 for (int i = 0; i < JSArray::kSize; i += kPointerSize) {
372 if ((i != JSArray::kElementsOffset) || (length == 0)) { 388 if ((i != JSArray::kElementsOffset) || (length == 0)) {
373 __ ldr(r1, FieldMemOperand(r3, i)); 389 __ ldr(r1, FieldMemOperand(r3, i));
374 __ str(r1, FieldMemOperand(r0, i)); 390 __ str(r1, FieldMemOperand(r0, i));
375 } 391 }
376 } 392 }
377 393
378 if (length > 0) { 394 if (length > 0) {
379 // Get hold of the elements array of the boilerplate and setup the 395 // Get hold of the elements array of the boilerplate and setup the
380 // elements pointer in the resulting object. 396 // elements pointer in the resulting object.
381 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); 397 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset));
382 __ add(r2, r0, Operand(JSArray::kSize)); 398 if (allocation_info_mode ==
399 FastCloneShallowArrayStub::TRACK_ALLOCATION_INFO) {
400 __ add(r2, r0, Operand(JSArray::kSize + AllocationSiteInfo::kSize));
401 } else {
402 __ add(r2, r0, Operand(JSArray::kSize));
403 }
383 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset)); 404 __ str(r2, FieldMemOperand(r0, JSArray::kElementsOffset));
384 405
385 // Copy the elements array. 406 // Copy the elements array.
386 ASSERT((elements_size % kPointerSize) == 0); 407 ASSERT((elements_size % kPointerSize) == 0);
387 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize); 408 __ CopyFields(r2, r3, r1.bit(), elements_size / kPointerSize);
388 } 409 }
389 } 410 }
390 411
391 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) { 412 void FastCloneShallowArrayStub::Generate(MacroAssembler* masm) {
392 // Stack layout on entry: 413 // Stack layout on entry:
393 // 414 //
394 // [sp]: constant elements. 415 // [sp]: constant elements.
395 // [sp + kPointerSize]: literal index. 416 // [sp + kPointerSize]: literal index.
396 // [sp + (2 * kPointerSize)]: literals array. 417 // [sp + (2 * kPointerSize)]: literals array.
397 418
398 // Load boilerplate object into r3 and check if we need to create a 419 // Load boilerplate object into r3 and check if we need to create a
399 // boilerplate. 420 // boilerplate.
400 Label slow_case; 421 Label slow_case;
401 __ ldr(r3, MemOperand(sp, 2 * kPointerSize)); 422 __ ldr(r3, MemOperand(sp, 2 * kPointerSize));
402 __ ldr(r0, MemOperand(sp, 1 * kPointerSize)); 423 __ ldr(r0, MemOperand(sp, 1 * kPointerSize));
403 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); 424 __ add(r3, r3, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
404 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize)); 425 __ ldr(r3, MemOperand(r3, r0, LSL, kPointerSizeLog2 - kSmiTagSize));
405 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex); 426 __ CompareRoot(r3, Heap::kUndefinedValueRootIndex);
406 __ b(eq, &slow_case); 427 __ b(eq, &slow_case);
407 428
408 FastCloneShallowArrayStub::Mode mode = mode_; 429 FastCloneShallowArrayStub::Mode mode = mode_;
430 FastCloneShallowArrayStub::AllocationInfoMode allocation_info_mode =
431 DONT_TRACK_ALLOCATION_INFO;
432 if (mode == CLONE_ANY_ELEMENTS_WITH_ALLOCATION_INFO) {
433 mode = CLONE_ANY_ELEMENTS;
434 allocation_info_mode = TRACK_ALLOCATION_INFO;
435 }
436
409 if (mode == CLONE_ANY_ELEMENTS) { 437 if (mode == CLONE_ANY_ELEMENTS) {
410 Label double_elements, check_fast_elements; 438 Label double_elements, check_fast_elements;
411 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset)); 439 __ ldr(r0, FieldMemOperand(r3, JSArray::kElementsOffset));
412 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset)); 440 __ ldr(r0, FieldMemOperand(r0, HeapObject::kMapOffset));
413 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex); 441 __ CompareRoot(r0, Heap::kFixedCOWArrayMapRootIndex);
414 __ b(ne, &check_fast_elements); 442 __ b(ne, &check_fast_elements);
415 GenerateFastCloneShallowArrayCommon(masm, 0, 443 GenerateFastCloneShallowArrayCommon(masm, 0,
416 COPY_ON_WRITE_ELEMENTS, &slow_case); 444 COPY_ON_WRITE_ELEMENTS,
445 allocation_info_mode,
446 &slow_case);
417 // Return and remove the on-stack parameters. 447 // Return and remove the on-stack parameters.
418 __ add(sp, sp, Operand(3 * kPointerSize)); 448 __ add(sp, sp, Operand(3 * kPointerSize));
419 __ Ret(); 449 __ Ret();
420 450
421 __ bind(&check_fast_elements); 451 __ bind(&check_fast_elements);
422 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); 452 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex);
423 __ b(ne, &double_elements); 453 __ b(ne, &double_elements);
424 GenerateFastCloneShallowArrayCommon(masm, length_, 454 GenerateFastCloneShallowArrayCommon(masm, length_,
425 CLONE_ELEMENTS, &slow_case); 455 CLONE_ELEMENTS,
456 allocation_info_mode,
457 &slow_case);
426 // Return and remove the on-stack parameters. 458 // Return and remove the on-stack parameters.
427 __ add(sp, sp, Operand(3 * kPointerSize)); 459 __ add(sp, sp, Operand(3 * kPointerSize));
428 __ Ret(); 460 __ Ret();
429 461
430 __ bind(&double_elements); 462 __ bind(&double_elements);
431 mode = CLONE_DOUBLE_ELEMENTS; 463 mode = CLONE_DOUBLE_ELEMENTS;
432 // Fall through to generate the code to handle double elements. 464 // Fall through to generate the code to handle double elements.
433 } 465 }
434 466
435 if (FLAG_debug_code) { 467 if (FLAG_debug_code) {
(...skipping 11 matching lines...) Expand all
447 expected_map_index = Heap::kFixedCOWArrayMapRootIndex; 479 expected_map_index = Heap::kFixedCOWArrayMapRootIndex;
448 } 480 }
449 __ push(r3); 481 __ push(r3);
450 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset)); 482 __ ldr(r3, FieldMemOperand(r3, JSArray::kElementsOffset));
451 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset)); 483 __ ldr(r3, FieldMemOperand(r3, HeapObject::kMapOffset));
452 __ CompareRoot(r3, expected_map_index); 484 __ CompareRoot(r3, expected_map_index);
453 __ Assert(eq, message); 485 __ Assert(eq, message);
454 __ pop(r3); 486 __ pop(r3);
455 } 487 }
456 488
457 GenerateFastCloneShallowArrayCommon(masm, length_, mode, &slow_case); 489 GenerateFastCloneShallowArrayCommon(masm, length_, mode,
490 allocation_info_mode, &slow_case);
458 491
459 // Return and remove the on-stack parameters. 492 // Return and remove the on-stack parameters.
460 __ add(sp, sp, Operand(3 * kPointerSize)); 493 __ add(sp, sp, Operand(3 * kPointerSize));
461 __ Ret(); 494 __ Ret();
462 495
463 __ bind(&slow_case); 496 __ bind(&slow_case);
464 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1); 497 __ TailCallRuntime(Runtime::kCreateArrayLiteralShallow, 3, 1);
465 } 498 }
466 499
467 500
(...skipping 7242 matching lines...) Expand 10 before | Expand all | Expand 10 after
7710 7743
7711 __ Pop(lr, r5, r1); 7744 __ Pop(lr, r5, r1);
7712 __ Ret(); 7745 __ Ret();
7713 } 7746 }
7714 7747
7715 #undef __ 7748 #undef __
7716 7749
7717 } } // namespace v8::internal 7750 } } // namespace v8::internal
7718 7751
7719 #endif // V8_TARGET_ARCH_ARM 7752 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/arm/codegen-arm.cc » ('j') | src/arm/macro-assembler-arm.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698