| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/debug.h" | 10 #include "src/debug.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // -- sp[4 * (argc - 1)] : first argument (argc == r0) | 33 // -- sp[4 * (argc - 1)] : first argument (argc == r0) |
| 34 // -- sp[4 * argc] : receiver | 34 // -- sp[4 * argc] : receiver |
| 35 // ----------------------------------- | 35 // ----------------------------------- |
| 36 | 36 |
| 37 // Insert extra arguments. | 37 // Insert extra arguments. |
| 38 int num_extra_args = 0; | 38 int num_extra_args = 0; |
| 39 if (extra_args == NEEDS_CALLED_FUNCTION) { | 39 if (extra_args == NEEDS_CALLED_FUNCTION) { |
| 40 num_extra_args = 1; | 40 num_extra_args = 1; |
| 41 __ push(r1); | 41 __ push(r1); |
| 42 } else { | 42 } else { |
| 43 ASSERT(extra_args == NO_EXTRA_ARGUMENTS); | 43 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // JumpToExternalReference expects r0 to contain the number of arguments | 46 // JumpToExternalReference expects r0 to contain the number of arguments |
| 47 // including the receiver and the extra arguments. | 47 // including the receiver and the extra arguments. |
| 48 __ add(r0, r0, Operand(num_extra_args + 1)); | 48 __ add(r0, r0, Operand(num_extra_args + 1)); |
| 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 49 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 // Load the built-in InternalArray function from the current context. | 53 // Load the built-in InternalArray function from the current context. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 bool create_memento) { | 316 bool create_memento) { |
| 317 // ----------- S t a t e ------------- | 317 // ----------- S t a t e ------------- |
| 318 // -- r0 : number of arguments | 318 // -- r0 : number of arguments |
| 319 // -- r1 : constructor function | 319 // -- r1 : constructor function |
| 320 // -- r2 : allocation site or undefined | 320 // -- r2 : allocation site or undefined |
| 321 // -- lr : return address | 321 // -- lr : return address |
| 322 // -- sp[...]: constructor arguments | 322 // -- sp[...]: constructor arguments |
| 323 // ----------------------------------- | 323 // ----------------------------------- |
| 324 | 324 |
| 325 // Should never create mementos for api functions. | 325 // Should never create mementos for api functions. |
| 326 ASSERT(!is_api_function || !create_memento); | 326 DCHECK(!is_api_function || !create_memento); |
| 327 | 327 |
| 328 Isolate* isolate = masm->isolate(); | 328 Isolate* isolate = masm->isolate(); |
| 329 | 329 |
| 330 // Enter a construct frame. | 330 // Enter a construct frame. |
| 331 { | 331 { |
| 332 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 332 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
| 333 | 333 |
| 334 if (create_memento) { | 334 if (create_memento) { |
| 335 __ AssertUndefinedOrAllocationSite(r2, r3); | 335 __ AssertUndefinedOrAllocationSite(r2, r3); |
| 336 __ push(r2); | 336 __ push(r2); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 __ Allocate(r3, r4, r5, r6, &rt_call, SIZE_IN_WORDS); | 404 __ Allocate(r3, r4, r5, r6, &rt_call, SIZE_IN_WORDS); |
| 405 | 405 |
| 406 // Allocated the JSObject, now initialize the fields. Map is set to | 406 // Allocated the JSObject, now initialize the fields. Map is set to |
| 407 // initial map and properties and elements are set to empty fixed array. | 407 // initial map and properties and elements are set to empty fixed array. |
| 408 // r1: constructor function | 408 // r1: constructor function |
| 409 // r2: initial map | 409 // r2: initial map |
| 410 // r3: object size (not including memento if create_memento) | 410 // r3: object size (not including memento if create_memento) |
| 411 // r4: JSObject (not tagged) | 411 // r4: JSObject (not tagged) |
| 412 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); | 412 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
| 413 __ mov(r5, r4); | 413 __ mov(r5, r4); |
| 414 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); | 414 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 415 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); | 415 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); |
| 416 ASSERT_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | 416 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); |
| 417 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 417 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 418 ASSERT_EQ(2 * kPointerSize, JSObject::kElementsOffset); | 418 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); |
| 419 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 419 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 420 | 420 |
| 421 // Fill all the in-object properties with the appropriate filler. | 421 // Fill all the in-object properties with the appropriate filler. |
| 422 // r1: constructor function | 422 // r1: constructor function |
| 423 // r2: initial map | 423 // r2: initial map |
| 424 // r3: object size (in words, including memento if create_memento) | 424 // r3: object size (in words, including memento if create_memento) |
| 425 // r4: JSObject (not tagged) | 425 // r4: JSObject (not tagged) |
| 426 // r5: First in-object property of JSObject (not tagged) | 426 // r5: First in-object property of JSObject (not tagged) |
| 427 ASSERT_EQ(3 * kPointerSize, JSObject::kHeaderSize); | 427 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
| 428 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); | 428 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
| 429 | 429 |
| 430 if (!is_api_function) { | 430 if (!is_api_function) { |
| 431 Label no_inobject_slack_tracking; | 431 Label no_inobject_slack_tracking; |
| 432 | 432 |
| 433 // Check if slack tracking is enabled. | 433 // Check if slack tracking is enabled. |
| 434 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); | 434 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); |
| 435 __ DecodeField<Map::ConstructionCount>(ip); | 435 __ DecodeField<Map::ConstructionCount>(ip); |
| 436 __ cmp(ip, Operand(JSFunction::kNoSlackTracking)); | 436 __ cmp(ip, Operand(JSFunction::kNoSlackTracking)); |
| 437 __ b(eq, &no_inobject_slack_tracking); | 437 __ b(eq, &no_inobject_slack_tracking); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 456 } | 456 } |
| 457 | 457 |
| 458 if (create_memento) { | 458 if (create_memento) { |
| 459 __ sub(ip, r3, Operand(AllocationMemento::kSize / kPointerSize)); | 459 __ sub(ip, r3, Operand(AllocationMemento::kSize / kPointerSize)); |
| 460 __ add(r0, r4, Operand(ip, LSL, kPointerSizeLog2)); // End of object. | 460 __ add(r0, r4, Operand(ip, LSL, kPointerSizeLog2)); // End of object. |
| 461 __ InitializeFieldsWithFiller(r5, r0, r6); | 461 __ InitializeFieldsWithFiller(r5, r0, r6); |
| 462 | 462 |
| 463 // Fill in memento fields. | 463 // Fill in memento fields. |
| 464 // r5: points to the allocated but uninitialized memento. | 464 // r5: points to the allocated but uninitialized memento. |
| 465 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); | 465 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); |
| 466 ASSERT_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); | 466 DCHECK_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); |
| 467 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 467 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 468 // Load the AllocationSite | 468 // Load the AllocationSite |
| 469 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); | 469 __ ldr(r6, MemOperand(sp, 2 * kPointerSize)); |
| 470 ASSERT_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); | 470 DCHECK_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); |
| 471 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 471 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
| 472 } else { | 472 } else { |
| 473 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | 473 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 474 __ InitializeFieldsWithFiller(r5, r0, r6); | 474 __ InitializeFieldsWithFiller(r5, r0, r6); |
| 475 } | 475 } |
| 476 | 476 |
| 477 // Add the object tag to make the JSObject real, so that we can continue | 477 // Add the object tag to make the JSObject real, so that we can continue |
| 478 // and jump into the continuation code at any time from now on. Any | 478 // and jump into the continuation code at any time from now on. Any |
| 479 // failures need to undo the allocation, so that the heap is in a | 479 // failures need to undo the allocation, so that the heap is in a |
| 480 // consistent state and verifiable. | 480 // consistent state and verifiable. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 &undo_allocation, | 515 &undo_allocation, |
| 516 static_cast<AllocationFlags>(RESULT_CONTAINS_TOP | SIZE_IN_WORDS)); | 516 static_cast<AllocationFlags>(RESULT_CONTAINS_TOP | SIZE_IN_WORDS)); |
| 517 | 517 |
| 518 // Initialize the FixedArray. | 518 // Initialize the FixedArray. |
| 519 // r1: constructor | 519 // r1: constructor |
| 520 // r3: number of elements in properties array | 520 // r3: number of elements in properties array |
| 521 // r4: JSObject | 521 // r4: JSObject |
| 522 // r5: FixedArray (not tagged) | 522 // r5: FixedArray (not tagged) |
| 523 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); | 523 __ LoadRoot(r6, Heap::kFixedArrayMapRootIndex); |
| 524 __ mov(r2, r5); | 524 __ mov(r2, r5); |
| 525 ASSERT_EQ(0 * kPointerSize, JSObject::kMapOffset); | 525 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); |
| 526 __ str(r6, MemOperand(r2, kPointerSize, PostIndex)); | 526 __ str(r6, MemOperand(r2, kPointerSize, PostIndex)); |
| 527 ASSERT_EQ(1 * kPointerSize, FixedArray::kLengthOffset); | 527 DCHECK_EQ(1 * kPointerSize, FixedArray::kLengthOffset); |
| 528 __ SmiTag(r0, r3); | 528 __ SmiTag(r0, r3); |
| 529 __ str(r0, MemOperand(r2, kPointerSize, PostIndex)); | 529 __ str(r0, MemOperand(r2, kPointerSize, PostIndex)); |
| 530 | 530 |
| 531 // Initialize the fields to undefined. | 531 // Initialize the fields to undefined. |
| 532 // r1: constructor function | 532 // r1: constructor function |
| 533 // r2: First element of FixedArray (not tagged) | 533 // r2: First element of FixedArray (not tagged) |
| 534 // r3: number of elements in properties array | 534 // r3: number of elements in properties array |
| 535 // r4: JSObject | 535 // r4: JSObject |
| 536 // r5: FixedArray (not tagged) | 536 // r5: FixedArray (not tagged) |
| 537 __ add(r6, r2, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | 537 __ add(r6, r2, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
| 538 ASSERT_EQ(2 * kPointerSize, FixedArray::kHeaderSize); | 538 DCHECK_EQ(2 * kPointerSize, FixedArray::kHeaderSize); |
| 539 { Label loop, entry; | 539 { Label loop, entry; |
| 540 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 540 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 541 __ b(&entry); | 541 __ b(&entry); |
| 542 __ bind(&loop); | 542 __ bind(&loop); |
| 543 __ str(r0, MemOperand(r2, kPointerSize, PostIndex)); | 543 __ str(r0, MemOperand(r2, kPointerSize, PostIndex)); |
| 544 __ bind(&entry); | 544 __ bind(&entry); |
| 545 __ cmp(r2, r6); | 545 __ cmp(r2, r6); |
| 546 __ b(lt, &loop); | 546 __ b(lt, &loop); |
| 547 } | 547 } |
| 548 | 548 |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 __ bkpt(0); | 1551 __ bkpt(0); |
| 1552 } | 1552 } |
| 1553 } | 1553 } |
| 1554 | 1554 |
| 1555 | 1555 |
| 1556 #undef __ | 1556 #undef __ |
| 1557 | 1557 |
| 1558 } } // namespace v8::internal | 1558 } } // namespace v8::internal |
| 1559 | 1559 |
| 1560 #endif // V8_TARGET_ARCH_ARM | 1560 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |