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

Side by Side Diff: src/a64/builtins-a64.cc

Issue 190763012: A64: Implement and use FillFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased patch Created 6 years, 9 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 | « no previous file | src/a64/lithium-a64.h » ('j') | src/a64/macro-assembler-a64.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 Register new_obj = x4; 408 Register new_obj = x4;
409 __ Ldrb(obj_size, FieldMemOperand(init_map, Map::kInstanceSizeOffset)); 409 __ Ldrb(obj_size, FieldMemOperand(init_map, Map::kInstanceSizeOffset));
410 __ Allocate(obj_size, new_obj, x10, x11, &rt_call, SIZE_IN_WORDS); 410 __ Allocate(obj_size, new_obj, x10, x11, &rt_call, SIZE_IN_WORDS);
411 411
412 // Allocated the JSObject, now initialize the fields. Map is set to 412 // Allocated the JSObject, now initialize the fields. Map is set to
413 // initial map and properties and elements are set to empty fixed array. 413 // initial map and properties and elements are set to empty fixed array.
414 // NB. the object pointer is not tagged, so MemOperand is used. 414 // NB. the object pointer is not tagged, so MemOperand is used.
415 Register empty = x5; 415 Register empty = x5;
416 __ LoadRoot(empty, Heap::kEmptyFixedArrayRootIndex); 416 __ LoadRoot(empty, Heap::kEmptyFixedArrayRootIndex);
417 __ Str(init_map, MemOperand(new_obj, JSObject::kMapOffset)); 417 __ Str(init_map, MemOperand(new_obj, JSObject::kMapOffset));
418 __ Str(empty, MemOperand(new_obj, JSObject::kPropertiesOffset)); 418 STATIC_ASSERT(JSObject::kElementsOffset ==
419 __ Str(empty, MemOperand(new_obj, JSObject::kElementsOffset)); 419 (JSObject::kPropertiesOffset + kPointerSize));
420 __ Stp(empty, empty, MemOperand(new_obj, JSObject::kPropertiesOffset));
420 421
421 Register first_prop = x5; 422 Register first_prop = x5;
422 __ Add(first_prop, new_obj, JSObject::kHeaderSize); 423 __ Add(first_prop, new_obj, JSObject::kHeaderSize);
423 424
424 // Fill all of the in-object properties with the appropriate filler. 425 // Fill all of the in-object properties with the appropriate filler.
425 Register obj_end = x6;
426 __ Add(obj_end, new_obj, Operand(obj_size, LSL, kPointerSizeLog2));
427 Register undef = x7; 426 Register undef = x7;
428 __ LoadRoot(undef, Heap::kUndefinedValueRootIndex); 427 __ LoadRoot(undef, Heap::kUndefinedValueRootIndex);
429 428
430 // Obtain number of pre-allocated property fields and in-object 429 // Obtain number of pre-allocated property fields and in-object
431 // properties. 430 // properties.
432 Register prealloc_fields = x10; 431 Register prealloc_fields = x10;
433 Register inobject_props = x11; 432 Register inobject_props = x11;
434 Register inst_sizes = x11; 433 Register inst_sizes = x11;
435 __ Ldr(inst_sizes, FieldMemOperand(init_map, Map::kInstanceSizesOffset)); 434 __ Ldr(inst_sizes, FieldMemOperand(init_map, Map::kInstanceSizesOffset));
436 __ Ubfx(prealloc_fields, inst_sizes, 435 __ Ubfx(prealloc_fields, inst_sizes,
437 Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte, 436 Map::kPreAllocatedPropertyFieldsByte * kBitsPerByte,
438 kBitsPerByte); 437 kBitsPerByte);
439 __ Ubfx(inobject_props, inst_sizes, 438 __ Ubfx(inobject_props, inst_sizes,
440 Map::kInObjectPropertiesByte * kBitsPerByte, kBitsPerByte); 439 Map::kInObjectPropertiesByte * kBitsPerByte, kBitsPerByte);
441 440
441 // Calculate number of property fields in the object.
442 Register prop_fields = x6;
443 __ Sub(prop_fields, obj_size, JSObject::kHeaderSize / kPointerSize);
444
442 if (count_constructions) { 445 if (count_constructions) {
446 // Fill the pre-allocated fields with undef.
447 __ FillFields(first_prop, prealloc_fields, undef);
448
443 // Register first_non_prealloc is the offset of the first field after 449 // Register first_non_prealloc is the offset of the first field after
444 // pre-allocated fields. 450 // pre-allocated fields.
445 Register first_non_prealloc = x12; 451 Register first_non_prealloc = x12;
446 __ Add(first_non_prealloc, first_prop, 452 __ Add(first_non_prealloc, first_prop,
447 Operand(prealloc_fields, LSL, kPointerSizeLog2)); 453 Operand(prealloc_fields, LSL, kPointerSizeLog2));
448 454
449 if (FLAG_debug_code) { 455 if (FLAG_debug_code) {
456 Register obj_end = x5;
ulan 2014/03/12 12:17:26 Maybe set first_prop = NoReg to show that it is no
457 __ Add(obj_end, new_obj, Operand(obj_size, LSL, kPointerSizeLog2));
450 __ Cmp(first_non_prealloc, obj_end); 458 __ Cmp(first_non_prealloc, obj_end);
451 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); 459 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields);
452 } 460 }
453 __ InitializeFieldsWithFiller(first_prop, first_non_prealloc, undef); 461
454 // To allow for truncation. 462 // Fill the remaining fields with one pointer filler map.
455 __ LoadRoot(x12, Heap::kOnePointerFillerMapRootIndex); 463 Register one_pointer_filler = x5;
456 __ InitializeFieldsWithFiller(first_prop, obj_end, x12); 464 Register non_prealloc_fields = x6;
465 __ LoadRoot(one_pointer_filler, Heap::kOnePointerFillerMapRootIndex);
466 __ Sub(non_prealloc_fields, prop_fields, prealloc_fields);
467 __ FillFields(first_non_prealloc, non_prealloc_fields,
468 one_pointer_filler);
457 } else { 469 } else {
458 __ InitializeFieldsWithFiller(first_prop, obj_end, undef); 470 // Fill all of the property fields with undef.
471 __ FillFields(first_prop, prop_fields, undef);
459 } 472 }
460 473
461 // Add the object tag to make the JSObject real, so that we can continue 474 // Add the object tag to make the JSObject real, so that we can continue
462 // and jump into the continuation code at any time from now on. Any 475 // and jump into the continuation code at any time from now on. Any
463 // failures need to undo the allocation, so that the heap is in a 476 // failures need to undo the allocation, so that the heap is in a
464 // consistent state and verifiable. 477 // consistent state and verifiable.
465 __ Add(new_obj, new_obj, kHeapObjectTag); 478 __ Add(new_obj, new_obj, kHeapObjectTag);
466 479
467 // Check if a non-empty properties array is needed. Continue with 480 // Check if a non-empty properties array is needed. Continue with
468 // allocated object if not, or fall through to runtime call if it is. 481 // allocated object if not, or fall through to runtime call if it is.
469 Register element_count = x3; 482 Register element_count = x3;
470 __ Ldrb(x3, FieldMemOperand(init_map, Map::kUnusedPropertyFieldsOffset)); 483 __ Ldrb(x3, FieldMemOperand(init_map, Map::kUnusedPropertyFieldsOffset));
ulan 2014/03/12 12:17:26 x3 => element_count, here and below.
471 // The field instance sizes contains both pre-allocated property fields 484 // The field instance sizes contains both pre-allocated property fields
472 // and in-object properties. 485 // and in-object properties.
473 __ Add(x3, x3, prealloc_fields); 486 __ Add(x3, x3, prealloc_fields);
474 __ Subs(element_count, x3, inobject_props); 487 __ Subs(element_count, x3, inobject_props);
475 488
476 // Done if no extra properties are to be allocated. 489 // Done if no extra properties are to be allocated.
477 __ B(eq, &allocated); 490 __ B(eq, &allocated);
478 __ Assert(pl, kPropertyAllocationCountFailed); 491 __ Assert(pl, kPropertyAllocationCountFailed);
479 492
480 // Scale the number of elements by pointer size and add the header for 493 // Scale the number of elements by pointer size and add the header for
481 // FixedArrays to the start of the next object calculation from above. 494 // FixedArrays to the start of the next object calculation from above.
482 Register new_array = x5; 495 Register new_array = x5;
483 Register array_size = x6; 496 Register array_size = x6;
484 __ Add(array_size, element_count, FixedArray::kHeaderSize / kPointerSize); 497 __ Add(array_size, element_count, FixedArray::kHeaderSize / kPointerSize);
485 __ Allocate(array_size, new_array, x11, x12, &undo_allocation, 498 __ Allocate(array_size, new_array, x11, x12, &undo_allocation,
486 static_cast<AllocationFlags>(RESULT_CONTAINS_TOP | 499 static_cast<AllocationFlags>(RESULT_CONTAINS_TOP |
487 SIZE_IN_WORDS)); 500 SIZE_IN_WORDS));
488 501
489 Register array_map = x10; 502 Register array_map = x10;
490 __ LoadRoot(array_map, Heap::kFixedArrayMapRootIndex); 503 __ LoadRoot(array_map, Heap::kFixedArrayMapRootIndex);
491 __ Str(array_map, MemOperand(new_array, FixedArray::kMapOffset)); 504 __ Str(array_map, MemOperand(new_array, FixedArray::kMapOffset));
492 __ SmiTag(x0, element_count); 505 __ SmiTag(x0, element_count);
493 __ Str(x0, MemOperand(new_array, FixedArray::kLengthOffset)); 506 __ Str(x0, MemOperand(new_array, FixedArray::kLengthOffset));
494 507
495 // Initialize the fields to undefined. 508 // Initialize the fields to undefined.
496 Register elements = x10; 509 Register elements = x10;
497 Register elements_end = x11;
498 __ Add(elements, new_array, FixedArray::kHeaderSize); 510 __ Add(elements, new_array, FixedArray::kHeaderSize);
499 __ Add(elements_end, elements, 511 __ FillFields(elements, element_count, undef);
500 Operand(element_count, LSL, kPointerSizeLog2));
501 __ InitializeFieldsWithFiller(elements, elements_end, undef);
502 512
503 // Store the initialized FixedArray into the properties field of the 513 // Store the initialized FixedArray into the properties field of the
504 // JSObject. 514 // JSObject.
505 __ Add(new_array, new_array, kHeapObjectTag); 515 __ Add(new_array, new_array, kHeapObjectTag);
506 __ Str(new_array, FieldMemOperand(new_obj, JSObject::kPropertiesOffset)); 516 __ Str(new_array, FieldMemOperand(new_obj, JSObject::kPropertiesOffset));
507 517
508 // Continue with JSObject being successfully allocated. 518 // Continue with JSObject being successfully allocated.
509 __ B(&allocated); 519 __ B(&allocated);
510 520
511 // Undo the setting of the new top so that the heap is verifiable. For 521 // Undo the setting of the new top so that the heap is verifiable. For
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 __ Bind(&dont_adapt_arguments); 1494 __ Bind(&dont_adapt_arguments);
1485 __ Jump(code_entry); 1495 __ Jump(code_entry);
1486 } 1496 }
1487 1497
1488 1498
1489 #undef __ 1499 #undef __
1490 1500
1491 } } // namespace v8::internal 1501 } } // namespace v8::internal
1492 1502
1493 #endif // V8_TARGET_ARCH_ARM 1503 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/a64/lithium-a64.h » ('j') | src/a64/macro-assembler-a64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698