OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); | 424 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); |
425 __ Pop(init_map, constructor); | 425 __ Pop(init_map, constructor); |
426 __ Mov(constructon_count, Operand(Map::kSlackTrackingCounterEnd - 1)); | 426 __ Mov(constructon_count, Operand(Map::kSlackTrackingCounterEnd - 1)); |
427 __ Bind(&allocate); | 427 __ Bind(&allocate); |
428 } | 428 } |
429 | 429 |
430 // Now allocate the JSObject on the heap. | 430 // Now allocate the JSObject on the heap. |
431 Label rt_call_reload_new_target; | 431 Label rt_call_reload_new_target; |
432 Register obj_size = x3; | 432 Register obj_size = x3; |
433 Register new_obj = x4; | 433 Register new_obj = x4; |
| 434 Register next_obj = x10; |
434 __ Ldrb(obj_size, FieldMemOperand(init_map, Map::kInstanceSizeOffset)); | 435 __ Ldrb(obj_size, FieldMemOperand(init_map, Map::kInstanceSizeOffset)); |
435 __ Allocate(obj_size, new_obj, x10, x11, &rt_call_reload_new_target, | 436 __ Allocate(obj_size, new_obj, next_obj, x11, |
436 SIZE_IN_WORDS); | 437 &rt_call_reload_new_target, SIZE_IN_WORDS); |
437 | 438 |
438 // Allocated the JSObject, now initialize the fields. Map is set to | 439 // Allocated the JSObject, now initialize the fields. Map is set to |
439 // initial map and properties and elements are set to empty fixed array. | 440 // initial map and properties and elements are set to empty fixed array. |
440 // NB. the object pointer is not tagged, so MemOperand is used. | 441 // NB. the object pointer is not tagged, so MemOperand is used. |
441 Register empty = x5; | 442 Register write_address = x5; |
| 443 Register empty = x7; |
| 444 __ Mov(write_address, new_obj); |
442 __ LoadRoot(empty, Heap::kEmptyFixedArrayRootIndex); | 445 __ LoadRoot(empty, Heap::kEmptyFixedArrayRootIndex); |
443 __ Str(init_map, MemOperand(new_obj, JSObject::kMapOffset)); | 446 STATIC_ASSERT(0 * kPointerSize == JSObject::kMapOffset); |
444 STATIC_ASSERT(JSObject::kElementsOffset == | 447 __ Str(init_map, MemOperand(write_address, kPointerSize, PostIndex)); |
445 (JSObject::kPropertiesOffset + kPointerSize)); | 448 STATIC_ASSERT(1 * kPointerSize == JSObject::kPropertiesOffset); |
446 __ Stp(empty, empty, MemOperand(new_obj, JSObject::kPropertiesOffset)); | 449 STATIC_ASSERT(2 * kPointerSize == JSObject::kElementsOffset); |
447 | 450 __ Stp(empty, empty, |
448 Register first_prop = x5; | 451 MemOperand(write_address, 2 * kPointerSize, PostIndex)); |
449 __ Add(first_prop, new_obj, JSObject::kHeaderSize); | |
450 | 452 |
451 // Fill all of the in-object properties with the appropriate filler. | 453 // Fill all of the in-object properties with the appropriate filler. |
452 Register filler = x7; | 454 Register filler = x7; |
453 __ LoadRoot(filler, Heap::kUndefinedValueRootIndex); | 455 __ LoadRoot(filler, Heap::kUndefinedValueRootIndex); |
454 | 456 |
455 // Obtain number of pre-allocated property fields and in-object | |
456 // properties. | |
457 Register unused_props = x10; | |
458 Register inobject_props = x11; | |
459 Register inst_sizes_or_attrs = x11; | |
460 Register prealloc_fields = x10; | |
461 __ Ldr(inst_sizes_or_attrs, | |
462 FieldMemOperand(init_map, Map::kInstanceAttributesOffset)); | |
463 __ Ubfx(unused_props, inst_sizes_or_attrs, | |
464 Map::kUnusedPropertyFieldsByte * kBitsPerByte, kBitsPerByte); | |
465 __ Ldr(inst_sizes_or_attrs, | |
466 FieldMemOperand(init_map, Map::kInstanceSizesOffset)); | |
467 __ Ubfx(inobject_props, inst_sizes_or_attrs, | |
468 Map::kInObjectPropertiesOrConstructorFunctionIndexByte * | |
469 kBitsPerByte, | |
470 kBitsPerByte); | |
471 __ Sub(prealloc_fields, inobject_props, unused_props); | |
472 | |
473 // Calculate number of property fields in the object. | |
474 Register prop_fields = x6; | |
475 __ Sub(prop_fields, obj_size, JSObject::kHeaderSize / kPointerSize); | |
476 | |
477 if (!is_api_function) { | 457 if (!is_api_function) { |
478 Label no_inobject_slack_tracking; | 458 Label no_inobject_slack_tracking; |
479 | 459 |
480 // Check if slack tracking is enabled. | 460 // Check if slack tracking is enabled. |
481 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd)); | 461 __ Cmp(constructon_count, Operand(Map::kSlackTrackingCounterEnd)); |
482 __ B(lt, &no_inobject_slack_tracking); | 462 __ B(lt, &no_inobject_slack_tracking); |
483 constructon_count = NoReg; | 463 constructon_count = NoReg; |
484 | 464 |
485 // Fill the pre-allocated fields with undef. | 465 // Allocate object with a slack. |
486 __ FillFields(first_prop, prealloc_fields, filler); | 466 Register unused_props = x11; |
| 467 __ Ldr(unused_props, |
| 468 FieldMemOperand(init_map, Map::kInstanceAttributesOffset)); |
| 469 __ Ubfx(unused_props, unused_props, |
| 470 Map::kUnusedPropertyFieldsByte * kBitsPerByte, kBitsPerByte); |
487 | 471 |
488 // Update first_prop register to be the offset of the first field | 472 Register end_of_pre_allocated = x11; |
489 // after | 473 __ Sub(end_of_pre_allocated, next_obj, |
490 // pre-allocated fields. | 474 Operand(unused_props, LSL, kPointerSizeLog2)); |
491 __ Add(first_prop, first_prop, | 475 unused_props = NoReg; |
492 Operand(prealloc_fields, LSL, kPointerSizeLog2)); | |
493 | 476 |
494 if (FLAG_debug_code) { | 477 if (FLAG_debug_code) { |
495 Register obj_end = x14; | 478 __ Cmp(write_address, end_of_pre_allocated); |
496 __ Add(obj_end, new_obj, Operand(obj_size, LSL, kPointerSizeLog2)); | |
497 __ Cmp(first_prop, obj_end); | |
498 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); | 479 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); |
499 } | 480 } |
500 | 481 |
| 482 // Fill the pre-allocated fields with undef. |
| 483 __ InitializeFieldsWithFiller(write_address, end_of_pre_allocated, |
| 484 filler); |
| 485 |
501 // Fill the remaining fields with one pointer filler map. | 486 // Fill the remaining fields with one pointer filler map. |
502 __ LoadRoot(filler, Heap::kOnePointerFillerMapRootIndex); | 487 __ LoadRoot(filler, Heap::kOnePointerFillerMapRootIndex); |
503 __ Sub(prop_fields, prop_fields, prealloc_fields); | |
504 | 488 |
505 __ bind(&no_inobject_slack_tracking); | 489 __ bind(&no_inobject_slack_tracking); |
506 } | 490 } |
507 | 491 |
508 // Fill all of the property fields with undef. | 492 // Fill all of the property fields with undef. |
509 __ FillFields(first_prop, prop_fields, filler); | 493 __ InitializeFieldsWithFiller(write_address, next_obj, filler); |
510 first_prop = NoReg; | |
511 prop_fields = NoReg; | |
512 | 494 |
513 // Add the object tag to make the JSObject real, so that we can continue | 495 // Add the object tag to make the JSObject real, so that we can continue |
514 // and jump into the continuation code at any time from now on. | 496 // and jump into the continuation code at any time from now on. |
515 __ Add(new_obj, new_obj, kHeapObjectTag); | 497 __ Add(new_obj, new_obj, kHeapObjectTag); |
516 | 498 |
517 // Continue with JSObject being successfully allocated. | 499 // Continue with JSObject being successfully allocated. |
518 __ B(&allocated); | 500 __ B(&allocated); |
519 | 501 |
520 // Reload the new target and fall-through. | 502 // Reload the new target and fall-through. |
521 __ Bind(&rt_call_reload_new_target); | 503 __ Bind(&rt_call_reload_new_target); |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 } | 1921 } |
1940 } | 1922 } |
1941 | 1923 |
1942 | 1924 |
1943 #undef __ | 1925 #undef __ |
1944 | 1926 |
1945 } // namespace internal | 1927 } // namespace internal |
1946 } // namespace v8 | 1928 } // namespace v8 |
1947 | 1929 |
1948 #endif // V8_TARGET_ARCH_ARM | 1930 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |