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

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

Issue 1488023002: Fix inobject slack tracking for both subclassing and non-subclassing cases. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moved and updated comments about slack tracking Created 5 years 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
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/objects.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 __ Branch(&rt_call, ne, a1, Operand(a5)); 383 __ Branch(&rt_call, ne, a1, Operand(a5));
384 384
385 // Check that the constructor is not constructing a JSFunction (see 385 // Check that the constructor is not constructing a JSFunction (see
386 // comments in Runtime_NewObject in runtime.cc). In which case the 386 // comments in Runtime_NewObject in runtime.cc). In which case the
387 // initial map's instance type would be JS_FUNCTION_TYPE. 387 // initial map's instance type would be JS_FUNCTION_TYPE.
388 // a1: constructor function 388 // a1: constructor function
389 // a2: initial map 389 // a2: initial map
390 __ lbu(t1, FieldMemOperand(a2, Map::kInstanceTypeOffset)); 390 __ lbu(t1, FieldMemOperand(a2, Map::kInstanceTypeOffset));
391 __ Branch(&rt_call, eq, t1, Operand(JS_FUNCTION_TYPE)); 391 __ Branch(&rt_call, eq, t1, Operand(JS_FUNCTION_TYPE));
392 392
393 if (!is_api_function) {
394 Label allocate;
395 MemOperand bit_field3 = FieldMemOperand(a2, Map::kBitField3Offset);
396 // Check if slack tracking is enabled.
397 __ lwu(a4, bit_field3);
398 __ DecodeField<Map::Counter>(a6, a4);
399 __ Branch(
400 &allocate, lt, a6,
401 Operand(static_cast<int64_t>(Map::kSlackTrackingCounterEnd)));
402 // Decrease generous allocation count.
403 __ Dsubu(a4, a4, Operand(1 << Map::Counter::kShift));
404 __ Branch(USE_DELAY_SLOT, &allocate, ne, a6,
405 Operand(Map::kSlackTrackingCounterEnd));
406 __ sw(a4, bit_field3); // In delay slot.
407
408 // Push the constructor, new_target and map to the stack, and
409 // the map again as an argument to the runtime call.
410 __ Push(a1, a3, a2, a2);
411 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
412
413 __ Pop(a1, a3, a2);
414 __ li(a6, Operand(Map::kSlackTrackingCounterEnd - 1));
415
416 __ bind(&allocate);
417 }
418
419 // Now allocate the JSObject on the heap. 393 // Now allocate the JSObject on the heap.
420 // a1: constructor function 394 // a1: constructor function
421 // a2: initial map 395 // a2: initial map
422 // a6: slack tracking counter (non-API function case)
423 __ lbu(a4, FieldMemOperand(a2, Map::kInstanceSizeOffset)); 396 __ lbu(a4, FieldMemOperand(a2, Map::kInstanceSizeOffset));
424 __ Allocate(a4, t0, a4, t2, &rt_call, SIZE_IN_WORDS); 397 __ Allocate(a4, t0, a4, t2, &rt_call, SIZE_IN_WORDS);
425 398
426 // Allocated the JSObject, now initialize the fields. Map is set to 399 // Allocated the JSObject, now initialize the fields. Map is set to
427 // initial map and properties and elements are set to empty fixed array. 400 // initial map and properties and elements are set to empty fixed array.
428 // a1: constructor function 401 // a1: constructor function
429 // a2: initial map 402 // a2: initial map
430 // a3: object size 403 // a3: object size
431 // t0: JSObject (not tagged) 404 // t0: JSObject (not HeapObject tagged - the actual address).
432 // a4: start of next object 405 // a4: start of next object
433 // a6: slack tracking counter (non-API function case)
434 __ LoadRoot(t2, Heap::kEmptyFixedArrayRootIndex); 406 __ LoadRoot(t2, Heap::kEmptyFixedArrayRootIndex);
435 __ mov(t1, t0); 407 __ mov(t1, t0);
436 STATIC_ASSERT(0 * kPointerSize == JSObject::kMapOffset); 408 STATIC_ASSERT(0 * kPointerSize == JSObject::kMapOffset);
437 __ sd(a2, MemOperand(t1, JSObject::kMapOffset)); 409 __ sd(a2, MemOperand(t1, JSObject::kMapOffset));
438 STATIC_ASSERT(1 * kPointerSize == JSObject::kPropertiesOffset); 410 STATIC_ASSERT(1 * kPointerSize == JSObject::kPropertiesOffset);
439 __ sd(t2, MemOperand(t1, JSObject::kPropertiesOffset)); 411 __ sd(t2, MemOperand(t1, JSObject::kPropertiesOffset));
440 STATIC_ASSERT(2 * kPointerSize == JSObject::kElementsOffset); 412 STATIC_ASSERT(2 * kPointerSize == JSObject::kElementsOffset);
441 __ sd(t2, MemOperand(t1, JSObject::kElementsOffset)); 413 __ sd(t2, MemOperand(t1, JSObject::kElementsOffset));
442 STATIC_ASSERT(3 * kPointerSize == JSObject::kHeaderSize); 414 STATIC_ASSERT(3 * kPointerSize == JSObject::kHeaderSize);
443 __ Daddu(t1, t1, Operand(3 * kPointerSize)); 415 __ Daddu(t1, t1, Operand(3 * kPointerSize));
444 416
417 // Add the object tag to make the JSObject real, so that we can continue
418 // and jump into the continuation code at any time from now on.
419 __ Daddu(t0, t0, Operand(kHeapObjectTag));
420
445 // Fill all the in-object properties with appropriate filler. 421 // Fill all the in-object properties with appropriate filler.
422 // t0: JSObject (tagged)
446 // t1: First in-object property of JSObject (not tagged) 423 // t1: First in-object property of JSObject (not tagged)
447
448 // Use t3 to hold undefined, which is used in several places below.
449 __ LoadRoot(t3, Heap::kUndefinedValueRootIndex); 424 __ LoadRoot(t3, Heap::kUndefinedValueRootIndex);
450 425
451 if (!is_api_function) { 426 if (!is_api_function) {
452 Label no_inobject_slack_tracking; 427 Label no_inobject_slack_tracking;
453 428
429 MemOperand bit_field3 = FieldMemOperand(a2, Map::kBitField3Offset);
454 // Check if slack tracking is enabled. 430 // Check if slack tracking is enabled.
455 __ Branch( 431 __ lwu(t2, bit_field3);
456 &no_inobject_slack_tracking, lt, a6, 432 __ DecodeField<Map::Counter>(a6, t2);
457 Operand(static_cast<int64_t>(Map::kSlackTrackingCounterEnd))); 433 // a6: slack tracking counter
434 __ Branch(&no_inobject_slack_tracking, lt, a6,
435 Operand(Map::kSlackTrackingCounterEnd));
436 // Decrease generous allocation count.
437 __ Dsubu(t2, t2, Operand(1 << Map::Counter::kShift));
438 __ sw(t2, bit_field3);
458 439
459 // Allocate object with a slack. 440 // Allocate object with a slack.
460 __ lbu(a0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset)); 441 __ lbu(a0, FieldMemOperand(a2, Map::kUnusedPropertyFieldsOffset));
461 __ dsll(a0, a0, kPointerSizeLog2); 442 __ dsll(a0, a0, kPointerSizeLog2);
462 __ dsubu(a0, a4, a0); 443 __ dsubu(a0, a4, a0);
463 // a0: offset of first field after pre-allocated fields 444 // a0: offset of first field after pre-allocated fields
464 if (FLAG_debug_code) { 445 if (FLAG_debug_code) {
465 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields, t1, 446 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields, t1,
466 Operand(a0)); 447 Operand(a0));
467 } 448 }
468 __ InitializeFieldsWithFiller(t1, a0, t3); 449 __ InitializeFieldsWithFiller(t1, a0, t3);
469 450
470 // To allow truncation fill the remaining fields with one pointer 451 // To allow truncation fill the remaining fields with one pointer
471 // filler map. 452 // filler map.
472 __ LoadRoot(t3, Heap::kOnePointerFillerMapRootIndex); 453 __ LoadRoot(t3, Heap::kOnePointerFillerMapRootIndex);
454 __ InitializeFieldsWithFiller(t1, a4, t3);
455
456 // a6: slack tracking counter value before decreasing.
457 __ Branch(&allocated, ne, a6, Operand(Map::kSlackTrackingCounterEnd));
458
459 // Push the constructor, new_target and the object to the stack,
460 // and then the initial map as an argument to the runtime call.
461 __ Push(a1, a3, t0, a2);
462 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1);
463 __ Pop(a1, a3, t0);
464
465 // Continue with JSObject being successfully allocated.
466 // a1: constructor function
467 // a3: new target
468 // t0: JSObject
469 __ jmp(&allocated);
473 470
474 __ bind(&no_inobject_slack_tracking); 471 __ bind(&no_inobject_slack_tracking);
475 } 472 }
476 473
477 __ InitializeFieldsWithFiller(t1, a4, t3); 474 __ InitializeFieldsWithFiller(t1, a4, t3);
478 475
479 // Add the object tag to make the JSObject real, so that we can continue
480 // and jump into the continuation code at any time from now on.
481 __ Daddu(t0, t0, Operand(kHeapObjectTag));
482
483 // Continue with JSObject being successfully allocated. 476 // Continue with JSObject being successfully allocated.
484 // a1: constructor function 477 // a1: constructor function
485 // a3: new target 478 // a3: new target
486 // a4: JSObject 479 // t0: JSObject
487 __ jmp(&allocated); 480 __ jmp(&allocated);
488 } 481 }
489 482
490 // Allocate the new receiver object using the runtime call. 483 // Allocate the new receiver object using the runtime call.
491 // a1: constructor function 484 // a1: constructor function
492 // a3: new target 485 // a3: new target
493 __ bind(&rt_call); 486 __ bind(&rt_call);
494 487
495 // Push the constructor and new_target twice, second pair as arguments 488 // Push the constructor and new_target twice, second pair as arguments
496 // to the runtime call. 489 // to the runtime call.
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 } 1971 }
1979 } 1972 }
1980 1973
1981 1974
1982 #undef __ 1975 #undef __
1983 1976
1984 } // namespace internal 1977 } // namespace internal
1985 } // namespace v8 1978 } // namespace v8
1986 1979
1987 #endif // V8_TARGET_ARCH_MIPS64 1980 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698