OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 | 428 |
429 __ bind(&allocate); | 429 __ bind(&allocate); |
430 } | 430 } |
431 | 431 |
432 // Now allocate the JSObject on the heap. | 432 // Now allocate the JSObject on the heap. |
433 // a1: constructor function | 433 // a1: constructor function |
434 // a2: initial map | 434 // a2: initial map |
435 Label rt_call_reload_new_target; | 435 Label rt_call_reload_new_target; |
436 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); | 436 __ lbu(a3, FieldMemOperand(a2, Map::kInstanceSizeOffset)); |
437 | 437 |
438 __ Allocate(a3, t4, t5, t6, &rt_call_reload_new_target, SIZE_IN_WORDS); | 438 __ Allocate(a3, t4, t3, t6, &rt_call_reload_new_target, SIZE_IN_WORDS); |
439 | 439 |
440 // Allocated the JSObject, now initialize the fields. Map is set to | 440 // Allocated the JSObject, now initialize the fields. Map is set to |
441 // initial map and properties and elements are set to empty fixed array. | 441 // initial map and properties and elements are set to empty fixed array. |
442 // a1: constructor function | 442 // a1: constructor function |
443 // a2: initial map | 443 // a2: initial map |
444 // a3: object size | 444 // a3: object size |
445 // t4: JSObject (not tagged) | 445 // t4: JSObject (not tagged) |
| 446 // t3: start of next object |
446 __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); | 447 __ LoadRoot(t6, Heap::kEmptyFixedArrayRootIndex); |
447 __ mov(t5, t4); | 448 __ mov(t5, t4); |
| 449 STATIC_ASSERT(0 * kPointerSize == JSObject::kMapOffset); |
448 __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); | 450 __ sw(a2, MemOperand(t5, JSObject::kMapOffset)); |
| 451 STATIC_ASSERT(1 * kPointerSize == JSObject::kPropertiesOffset); |
449 __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); | 452 __ sw(t6, MemOperand(t5, JSObject::kPropertiesOffset)); |
| 453 STATIC_ASSERT(2 * kPointerSize == JSObject::kElementsOffset); |
450 __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); | 454 __ sw(t6, MemOperand(t5, JSObject::kElementsOffset)); |
451 __ Addu(t5, t5, Operand(3 * kPointerSize)); | 455 __ Addu(t5, t5, Operand(3 * kPointerSize)); |
452 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); | |
453 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | |
454 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); | |
455 | 456 |
456 // Fill all the in-object properties with appropriate filler. | 457 // Fill all the in-object properties with appropriate filler. |
457 // a1: constructor function | 458 // a1: constructor function |
458 // a2: initial map | 459 // a2: initial map |
459 // a3: object size (in words) | 460 // a3: object size (in words) |
460 // t4: JSObject (not tagged) | 461 // t4: JSObject (not tagged) |
461 // t5: First in-object property of JSObject (not tagged) | 462 // t5: First in-object property of JSObject (not tagged) |
462 // t2: slack tracking counter (non-API function case) | 463 // t2: slack tracking counter (non-API function case) |
463 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); | 464 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
464 | 465 |
465 // Use t7 to hold undefined, which is used in several places below. | 466 // Use t7 to hold undefined, which is used in several places below. |
466 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); | 467 __ LoadRoot(t7, Heap::kUndefinedValueRootIndex); |
467 | 468 |
468 if (!is_api_function) { | 469 if (!is_api_function) { |
469 Label no_inobject_slack_tracking; | 470 Label no_inobject_slack_tracking; |
470 | 471 |
471 // Check if slack tracking is enabled. | 472 // Check if slack tracking is enabled. |
472 __ Branch(&no_inobject_slack_tracking, lt, t2, | 473 __ Branch(&no_inobject_slack_tracking, lt, t2, |
473 Operand(Map::kSlackTrackingCounterEnd)); | 474 Operand(Map::kSlackTrackingCounterEnd)); |
474 | 475 |
475 // Allocate object with a slack. | 476 // Allocate object with a slack. |
476 __ lbu(a0, | 477 __ lbu(a0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); |
477 FieldMemOperand( | 478 __ sll(a0, a0, kPointerSizeLog2); |
478 a2, | 479 __ subu(a0, t3, a0); |
479 Map::kInObjectPropertiesOrConstructorFunctionIndexOffset)); | |
480 __ lbu(a2, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); | |
481 __ subu(a0, a0, a2); | |
482 __ sll(at, a0, kPointerSizeLog2); | |
483 __ addu(a0, t5, at); | |
484 // a0: offset of first field after pre-allocated fields | 480 // a0: offset of first field after pre-allocated fields |
485 if (FLAG_debug_code) { | 481 if (FLAG_debug_code) { |
486 __ sll(at, a3, kPointerSizeLog2); | 482 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields, t5, |
487 __ Addu(t6, t4, Operand(at)); // End of object. | 483 Operand(a0)); |
488 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields, a0, | |
489 Operand(t6)); | |
490 } | 484 } |
491 __ InitializeFieldsWithFiller(t5, a0, t7); | 485 __ InitializeFieldsWithFiller(t5, a0, t7); |
492 // To allow for truncation. | 486 // To allow for truncation. |
493 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); | 487 __ LoadRoot(t7, Heap::kOnePointerFillerMapRootIndex); |
494 // Fill the remaining fields with one pointer filler map. | 488 // Fill the remaining fields with one pointer filler map. |
495 | 489 |
496 __ bind(&no_inobject_slack_tracking); | 490 __ bind(&no_inobject_slack_tracking); |
497 } | 491 } |
498 | 492 |
499 __ sll(at, a3, kPointerSizeLog2); | 493 __ InitializeFieldsWithFiller(t5, t3, t7); |
500 __ Addu(a0, t4, Operand(at)); // End of object. | |
501 __ InitializeFieldsWithFiller(t5, a0, t7); | |
502 | 494 |
503 // 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 |
504 // 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. |
505 __ Addu(t4, t4, Operand(kHeapObjectTag)); | 497 __ Addu(t4, t4, Operand(kHeapObjectTag)); |
506 | 498 |
507 // Continue with JSObject being successfully allocated. | 499 // Continue with JSObject being successfully allocated. |
508 // t4: JSObject | 500 // t4: JSObject |
509 __ jmp(&allocated); | 501 __ jmp(&allocated); |
510 | 502 |
511 // Reload the new target and fall-through. | 503 // Reload the new target and fall-through. |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1875 } | 1867 } |
1876 } | 1868 } |
1877 | 1869 |
1878 | 1870 |
1879 #undef __ | 1871 #undef __ |
1880 | 1872 |
1881 } // namespace internal | 1873 } // namespace internal |
1882 } // namespace v8 | 1874 } // namespace v8 |
1883 | 1875 |
1884 #endif // V8_TARGET_ARCH_MIPS | 1876 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |