OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 | 378 |
379 // Check that the constructor is not constructing a JSFunction (see | 379 // Check that the constructor is not constructing a JSFunction (see |
380 // comments in Runtime_NewObject in runtime.cc). In which case the | 380 // comments in Runtime_NewObject in runtime.cc). In which case the |
381 // initial map's instance type would be JS_FUNCTION_TYPE. | 381 // initial map's instance type would be JS_FUNCTION_TYPE. |
382 // r4: constructor function | 382 // r4: constructor function |
383 // r5: initial map | 383 // r5: initial map |
384 // r6: new target | 384 // r6: new target |
385 __ CompareInstanceType(r5, r8, JS_FUNCTION_TYPE); | 385 __ CompareInstanceType(r5, r8, JS_FUNCTION_TYPE); |
386 __ beq(&rt_call); | 386 __ beq(&rt_call); |
387 | 387 |
388 if (!is_api_function) { | |
389 Label allocate; | |
390 MemOperand bit_field3 = FieldMemOperand(r5, Map::kBitField3Offset); | |
391 // Check if slack tracking is enabled. | |
392 __ lwz(r7, bit_field3); | |
393 __ DecodeField<Map::Counter>(r3, r7); | |
394 __ cmpi(r3, Operand(Map::kSlackTrackingCounterEnd)); | |
395 __ blt(&allocate); | |
396 // Decrease generous allocation count. | |
397 __ Add(r7, r7, -(1 << Map::Counter::kShift), r0); | |
398 __ stw(r7, bit_field3); | |
399 __ cmpi(r3, Operand(Map::kSlackTrackingCounterEnd)); | |
400 __ bne(&allocate); | |
401 | |
402 // Push the constructor, new target and map to the stack, and | |
403 // the map again as an argument to the runtime call. | |
404 __ Push(r4, r6, r5, r5); | |
405 | |
406 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); | |
407 | |
408 __ Pop(r4, r6, r5); | |
409 __ li(r3, Operand(Map::kSlackTrackingCounterEnd - 1)); | |
410 | |
411 __ bind(&allocate); | |
412 } | |
413 | |
414 // Now allocate the JSObject on the heap. | 388 // Now allocate the JSObject on the heap. |
415 // r4: constructor function | 389 // r4: constructor function |
416 // r5: initial map | 390 // r5: initial map |
417 // r6: new target | 391 // r6: new target |
418 // r3: slack tracking counter (non-API function case) | |
419 __ lbz(r10, FieldMemOperand(r5, Map::kInstanceSizeOffset)); | 392 __ lbz(r10, FieldMemOperand(r5, Map::kInstanceSizeOffset)); |
420 | 393 |
421 __ Allocate(r10, r7, r10, r9, &rt_call, SIZE_IN_WORDS); | 394 __ Allocate(r10, r7, r10, r9, &rt_call, SIZE_IN_WORDS); |
422 | 395 |
423 // Allocated the JSObject, now initialize the fields. Map is set to | 396 // Allocated the JSObject, now initialize the fields. Map is set to |
424 // initial map and properties and elements are set to empty fixed array. | 397 // initial map and properties and elements are set to empty fixed array. |
425 // r4: constructor function | 398 // r4: constructor function |
426 // r5: initial map | 399 // r5: initial map |
427 // r6: new target | 400 // r6: new target |
428 // r7: JSObject (not tagged) | 401 // r7: JSObject (not HeapObject tagged - the actual address). |
429 // r10: start of next object | 402 // r10: start of next object |
430 // r3: slack tracking counter (non-API function case) | |
431 __ LoadRoot(r9, Heap::kEmptyFixedArrayRootIndex); | 403 __ LoadRoot(r9, Heap::kEmptyFixedArrayRootIndex); |
432 __ StoreP(r5, MemOperand(r7, JSObject::kMapOffset)); | 404 __ StoreP(r5, MemOperand(r7, JSObject::kMapOffset)); |
433 __ StoreP(r9, MemOperand(r7, JSObject::kPropertiesOffset)); | 405 __ StoreP(r9, MemOperand(r7, JSObject::kPropertiesOffset)); |
434 __ StoreP(r9, MemOperand(r7, JSObject::kElementsOffset)); | 406 __ StoreP(r9, MemOperand(r7, JSObject::kElementsOffset)); |
435 __ addi(r8, r7, Operand(JSObject::kElementsOffset + kPointerSize)); | 407 __ addi(r8, r7, Operand(JSObject::kElementsOffset + kPointerSize)); |
436 | 408 |
409 // Add the object tag to make the JSObject real, so that we can continue | |
410 // and jump into the continuation code at any time from now on. | |
411 __ addi(r7, r7, Operand(kHeapObjectTag)); | |
412 | |
437 // Fill all the in-object properties with the appropriate filler. | 413 // Fill all the in-object properties with the appropriate filler. |
414 // r7: JSObject (tagged) | |
438 // r8: First in-object property of JSObject (not tagged) | 415 // r8: First in-object property of JSObject (not tagged) |
439 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | 416 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
440 | 417 |
441 if (!is_api_function) { | 418 if (!is_api_function) { |
442 Label no_inobject_slack_tracking; | 419 Label no_inobject_slack_tracking; |
443 | 420 |
444 // Check if slack tracking is enabled. | 421 // Check if slack tracking is enabled. |
Igor Sheludko
2015/12/03 16:47:02
This comment should be removed.
MTBrandyberry
2015/12/03 18:39:54
Done.
| |
445 __ cmpi(r3, Operand(Map::kSlackTrackingCounterEnd)); | 422 MemOperand bit_field3 = FieldMemOperand(r5, Map::kBitField3Offset); |
423 // Check if slack tracking is enabled. | |
424 __ lwz(r3, bit_field3); | |
425 __ DecodeField<Map::Counter>(r0, r3); | |
426 // r0: slack tracking counter | |
427 __ cmpi(r0, Operand(Map::kSlackTrackingCounterEnd)); | |
446 __ blt(&no_inobject_slack_tracking); | 428 __ blt(&no_inobject_slack_tracking); |
429 __ push(r0); // Save allocation count value. | |
Igor Sheludko
2015/12/03 16:47:02
It looks like there are enough registers and r0 is
MTBrandyberry
2015/12/03 18:39:54
Done.
| |
430 // Decrease generous allocation count. | |
431 __ Add(r3, r3, -(1 << Map::Counter::kShift), r0); | |
432 __ stw(r3, bit_field3); | |
447 | 433 |
448 // Allocate object with a slack. | 434 // Allocate object with a slack. |
449 __ lbz(r3, FieldMemOperand(r5, Map::kUnusedPropertyFieldsOffset)); | 435 __ lbz(r3, FieldMemOperand(r5, Map::kUnusedPropertyFieldsOffset)); |
450 __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2)); | 436 __ ShiftLeftImm(r3, r3, Operand(kPointerSizeLog2)); |
451 __ sub(r3, r10, r3); | 437 __ sub(r3, r10, r3); |
452 // r3: offset of first field after pre-allocated fields | 438 // r3: offset of first field after pre-allocated fields |
453 if (FLAG_debug_code) { | 439 if (FLAG_debug_code) { |
454 __ cmp(r8, r3); | 440 __ cmp(r8, r3); |
455 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); | 441 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); |
456 } | 442 } |
457 __ InitializeFieldsWithFiller(r8, r3, r9); | 443 __ InitializeFieldsWithFiller(r8, r3, r9); |
458 | 444 |
459 // To allow truncation fill the remaining fields with one pointer | 445 // To allow truncation fill the remaining fields with one pointer |
460 // filler map. | 446 // filler map. |
461 __ LoadRoot(r9, Heap::kOnePointerFillerMapRootIndex); | 447 __ LoadRoot(r9, Heap::kOnePointerFillerMapRootIndex); |
448 __ InitializeFieldsWithFiller(r8, r10, r9); | |
449 | |
450 __ pop(r3); // Restore allocation count value before decreasing. | |
Igor Sheludko
2015/12/03 16:47:02
Ditto. Remove pop and...
MTBrandyberry
2015/12/03 18:39:53
Done.
| |
451 __ cmpi(r3, Operand(Map::kSlackTrackingCounterEnd)); | |
Igor Sheludko
2015/12/03 16:47:02
use r0 instead of r3 here.
MTBrandyberry
2015/12/03 18:39:54
Done.
| |
452 __ bne(&allocated); | |
453 | |
454 // Push the constructor, new target and map to the stack, and | |
Igor Sheludko
2015/12/03 16:47:02
Please update this comment.
MTBrandyberry
2015/12/03 18:39:54
Done.
| |
455 // the map again as an argument to the runtime call. | |
456 __ Push(r4, r6, r7, r5); | |
457 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); | |
458 __ Pop(r4, r6, r7); | |
459 | |
460 // Continue with JSObject being successfully allocated | |
461 // r4: constructor function | |
462 // r6: new target | |
463 // r7: JSObject | |
464 __ b(&allocated); | |
462 | 465 |
463 __ bind(&no_inobject_slack_tracking); | 466 __ bind(&no_inobject_slack_tracking); |
464 } | 467 } |
465 | 468 |
466 __ InitializeFieldsWithFiller(r8, r10, r9); | 469 __ InitializeFieldsWithFiller(r8, r10, r9); |
467 | 470 |
468 // Add the object tag to make the JSObject real, so that we can continue | |
469 // and jump into the continuation code at any time from now on. | |
470 __ addi(r7, r7, Operand(kHeapObjectTag)); | |
471 | |
472 // Continue with JSObject being successfully allocated | 471 // Continue with JSObject being successfully allocated |
473 // r4: constructor function | 472 // r4: constructor function |
474 // r6: new target | 473 // r6: new target |
475 // r7: JSObject | 474 // r7: JSObject |
476 __ b(&allocated); | 475 __ b(&allocated); |
477 } | 476 } |
478 | 477 |
479 // Allocate the new receiver object using the runtime call. | 478 // Allocate the new receiver object using the runtime call. |
480 // r4: constructor function | 479 // r4: constructor function |
481 // r6: new target | 480 // r6: new target |
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1980 __ bkpt(0); | 1979 __ bkpt(0); |
1981 } | 1980 } |
1982 } | 1981 } |
1983 | 1982 |
1984 | 1983 |
1985 #undef __ | 1984 #undef __ |
1986 } // namespace internal | 1985 } // namespace internal |
1987 } // namespace v8 | 1986 } // namespace v8 |
1988 | 1987 |
1989 #endif // V8_TARGET_ARCH_PPC | 1988 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |