| 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 4368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4379 __ j(not_equal, &new_object); | 4379 __ j(not_equal, &new_object); |
| 4380 | 4380 |
| 4381 // Allocate the JSObject on the heap. | 4381 // Allocate the JSObject on the heap. |
| 4382 Label allocate, done_allocate; | 4382 Label allocate, done_allocate; |
| 4383 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); | 4383 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); |
| 4384 __ lea(ebx, Operand(ebx, times_pointer_size, 0)); | 4384 __ lea(ebx, Operand(ebx, times_pointer_size, 0)); |
| 4385 __ Allocate(ebx, eax, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); | 4385 __ Allocate(ebx, eax, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); |
| 4386 __ bind(&done_allocate); | 4386 __ bind(&done_allocate); |
| 4387 | 4387 |
| 4388 // Initialize the JSObject fields. | 4388 // Initialize the JSObject fields. |
| 4389 __ mov(Operand(eax, JSObject::kMapOffset), ecx); | 4389 __ mov(FieldOperand(eax, JSObject::kMapOffset), ecx); |
| 4390 __ mov(Operand(eax, JSObject::kPropertiesOffset), | 4390 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |
| 4391 masm->isolate()->factory()->empty_fixed_array()); | 4391 masm->isolate()->factory()->empty_fixed_array()); |
| 4392 __ mov(Operand(eax, JSObject::kElementsOffset), | 4392 __ mov(FieldOperand(eax, JSObject::kElementsOffset), |
| 4393 masm->isolate()->factory()->empty_fixed_array()); | 4393 masm->isolate()->factory()->empty_fixed_array()); |
| 4394 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); | 4394 STATIC_ASSERT(JSObject::kHeaderSize == 3 * kPointerSize); |
| 4395 __ lea(ebx, Operand(eax, JSObject::kHeaderSize)); | 4395 __ lea(ebx, FieldOperand(eax, JSObject::kHeaderSize)); |
| 4396 | 4396 |
| 4397 // ----------- S t a t e ------------- | 4397 // ----------- S t a t e ------------- |
| 4398 // -- eax : result (untagged) | 4398 // -- eax : result (tagged) |
| 4399 // -- ebx : result fields (untagged) | 4399 // -- ebx : result fields (untagged) |
| 4400 // -- edi : result end (untagged) | 4400 // -- edi : result end (untagged) |
| 4401 // -- ecx : initial map | 4401 // -- ecx : initial map |
| 4402 // -- esi : context | 4402 // -- esi : context |
| 4403 // -- esp[0] : return address | 4403 // -- esp[0] : return address |
| 4404 // ----------------------------------- | 4404 // ----------------------------------- |
| 4405 | 4405 |
| 4406 // Perform in-object slack tracking if requested. | 4406 // Perform in-object slack tracking if requested. |
| 4407 Label slack_tracking; | 4407 Label slack_tracking; |
| 4408 STATIC_ASSERT(Map::kNoSlackTracking == 0); | 4408 STATIC_ASSERT(Map::kNoSlackTracking == 0); |
| 4409 __ test(FieldOperand(ecx, Map::kBitField3Offset), | 4409 __ test(FieldOperand(ecx, Map::kBitField3Offset), |
| 4410 Immediate(Map::ConstructionCounter::kMask)); | 4410 Immediate(Map::ConstructionCounter::kMask)); |
| 4411 __ j(not_zero, &slack_tracking, Label::kNear); | 4411 __ j(not_zero, &slack_tracking, Label::kNear); |
| 4412 { | 4412 { |
| 4413 // Initialize all in-object fields with undefined. | 4413 // Initialize all in-object fields with undefined. |
| 4414 __ LoadRoot(edx, Heap::kUndefinedValueRootIndex); | 4414 __ LoadRoot(edx, Heap::kUndefinedValueRootIndex); |
| 4415 __ InitializeFieldsWithFiller(ebx, edi, edx); | 4415 __ InitializeFieldsWithFiller(ebx, edi, edx); |
| 4416 | |
| 4417 // Add the object tag to make the JSObject real. | |
| 4418 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4419 __ inc(eax); | |
| 4420 __ Ret(); | 4416 __ Ret(); |
| 4421 } | 4417 } |
| 4422 __ bind(&slack_tracking); | 4418 __ bind(&slack_tracking); |
| 4423 { | 4419 { |
| 4424 // Decrease generous allocation count. | 4420 // Decrease generous allocation count. |
| 4425 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); | 4421 STATIC_ASSERT(Map::ConstructionCounter::kNext == 32); |
| 4426 __ sub(FieldOperand(ecx, Map::kBitField3Offset), | 4422 __ sub(FieldOperand(ecx, Map::kBitField3Offset), |
| 4427 Immediate(1 << Map::ConstructionCounter::kShift)); | 4423 Immediate(1 << Map::ConstructionCounter::kShift)); |
| 4428 | 4424 |
| 4429 // Initialize the in-object fields with undefined. | 4425 // Initialize the in-object fields with undefined. |
| 4430 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); | 4426 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); |
| 4431 __ neg(edx); | 4427 __ neg(edx); |
| 4432 __ lea(edx, Operand(edi, edx, times_pointer_size, 0)); | 4428 __ lea(edx, Operand(edi, edx, times_pointer_size, 0)); |
| 4433 __ LoadRoot(edi, Heap::kUndefinedValueRootIndex); | 4429 __ LoadRoot(edi, Heap::kUndefinedValueRootIndex); |
| 4434 __ InitializeFieldsWithFiller(ebx, edx, edi); | 4430 __ InitializeFieldsWithFiller(ebx, edx, edi); |
| 4435 | 4431 |
| 4436 // Initialize the remaining (reserved) fields with one pointer filler map. | 4432 // Initialize the remaining (reserved) fields with one pointer filler map. |
| 4437 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); | 4433 __ movzx_b(edx, FieldOperand(ecx, Map::kUnusedPropertyFieldsOffset)); |
| 4438 __ lea(edx, Operand(ebx, edx, times_pointer_size, 0)); | 4434 __ lea(edx, Operand(ebx, edx, times_pointer_size, 0)); |
| 4439 __ LoadRoot(edi, Heap::kOnePointerFillerMapRootIndex); | 4435 __ LoadRoot(edi, Heap::kOnePointerFillerMapRootIndex); |
| 4440 __ InitializeFieldsWithFiller(ebx, edx, edi); | 4436 __ InitializeFieldsWithFiller(ebx, edx, edi); |
| 4441 | 4437 |
| 4442 // Add the object tag to make the JSObject real. | |
| 4443 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4444 __ inc(eax); | |
| 4445 | |
| 4446 // Check if we can finalize the instance size. | 4438 // Check if we can finalize the instance size. |
| 4447 Label finalize; | 4439 Label finalize; |
| 4448 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); | 4440 STATIC_ASSERT(Map::kSlackTrackingCounterEnd == 1); |
| 4449 __ test(FieldOperand(ecx, Map::kBitField3Offset), | 4441 __ test(FieldOperand(ecx, Map::kBitField3Offset), |
| 4450 Immediate(Map::ConstructionCounter::kMask)); | 4442 Immediate(Map::ConstructionCounter::kMask)); |
| 4451 __ j(zero, &finalize, Label::kNear); | 4443 __ j(zero, &finalize, Label::kNear); |
| 4452 __ Ret(); | 4444 __ Ret(); |
| 4453 | 4445 |
| 4454 // Finalize the instance size. | 4446 // Finalize the instance size. |
| 4455 __ bind(&finalize); | 4447 __ bind(&finalize); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 4466 // Fall back to %AllocateInNewSpace. | 4458 // Fall back to %AllocateInNewSpace. |
| 4467 __ bind(&allocate); | 4459 __ bind(&allocate); |
| 4468 { | 4460 { |
| 4469 FrameScope scope(masm, StackFrame::INTERNAL); | 4461 FrameScope scope(masm, StackFrame::INTERNAL); |
| 4470 __ SmiTag(ebx); | 4462 __ SmiTag(ebx); |
| 4471 __ Push(ecx); | 4463 __ Push(ecx); |
| 4472 __ Push(ebx); | 4464 __ Push(ebx); |
| 4473 __ CallRuntime(Runtime::kAllocateInNewSpace); | 4465 __ CallRuntime(Runtime::kAllocateInNewSpace); |
| 4474 __ Pop(ecx); | 4466 __ Pop(ecx); |
| 4475 } | 4467 } |
| 4476 STATIC_ASSERT(kHeapObjectTag == 1); | |
| 4477 __ dec(eax); | |
| 4478 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); | 4468 __ movzx_b(ebx, FieldOperand(ecx, Map::kInstanceSizeOffset)); |
| 4479 __ lea(edi, Operand(eax, ebx, times_pointer_size, 0)); | 4469 __ lea(edi, Operand(eax, ebx, times_pointer_size, 0)); |
| 4470 STATIC_ASSERT(kHeapObjectTag == 1); |
| 4471 __ dec(edi); |
| 4480 __ jmp(&done_allocate); | 4472 __ jmp(&done_allocate); |
| 4481 | 4473 |
| 4482 // Fall back to %NewObject. | 4474 // Fall back to %NewObject. |
| 4483 __ bind(&new_object); | 4475 __ bind(&new_object); |
| 4484 __ PopReturnAddressTo(ecx); | 4476 __ PopReturnAddressTo(ecx); |
| 4485 __ Push(edi); | 4477 __ Push(edi); |
| 4486 __ Push(edx); | 4478 __ Push(edx); |
| 4487 __ PushReturnAddressFrom(ecx); | 4479 __ PushReturnAddressFrom(ecx); |
| 4488 __ TailCallRuntime(Runtime::kNewObject); | 4480 __ TailCallRuntime(Runtime::kNewObject); |
| 4489 } | 4481 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4532 // Return an empty rest parameter array. | 4524 // Return an empty rest parameter array. |
| 4533 __ bind(&no_rest_parameters); | 4525 __ bind(&no_rest_parameters); |
| 4534 { | 4526 { |
| 4535 // ----------- S t a t e ------------- | 4527 // ----------- S t a t e ------------- |
| 4536 // -- esi : context | 4528 // -- esi : context |
| 4537 // -- esp[0] : return address | 4529 // -- esp[0] : return address |
| 4538 // ----------------------------------- | 4530 // ----------------------------------- |
| 4539 | 4531 |
| 4540 // Allocate an empty rest parameter array. | 4532 // Allocate an empty rest parameter array. |
| 4541 Label allocate, done_allocate; | 4533 Label allocate, done_allocate; |
| 4542 __ Allocate(JSArray::kSize, eax, edx, ecx, &allocate, TAG_OBJECT); | 4534 __ Allocate(JSArray::kSize, eax, edx, ecx, &allocate, NO_ALLOCATION_FLAGS); |
| 4543 __ bind(&done_allocate); | 4535 __ bind(&done_allocate); |
| 4544 | 4536 |
| 4545 // Setup the rest parameter array in rax. | 4537 // Setup the rest parameter array in rax. |
| 4546 __ LoadGlobalFunction(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, ecx); | 4538 __ LoadGlobalFunction(Context::JS_ARRAY_FAST_ELEMENTS_MAP_INDEX, ecx); |
| 4547 __ mov(FieldOperand(eax, JSArray::kMapOffset), ecx); | 4539 __ mov(FieldOperand(eax, JSArray::kMapOffset), ecx); |
| 4548 __ mov(ecx, isolate()->factory()->empty_fixed_array()); | 4540 __ mov(ecx, isolate()->factory()->empty_fixed_array()); |
| 4549 __ mov(FieldOperand(eax, JSArray::kPropertiesOffset), ecx); | 4541 __ mov(FieldOperand(eax, JSArray::kPropertiesOffset), ecx); |
| 4550 __ mov(FieldOperand(eax, JSArray::kElementsOffset), ecx); | 4542 __ mov(FieldOperand(eax, JSArray::kElementsOffset), ecx); |
| 4551 __ mov(FieldOperand(eax, JSArray::kLengthOffset), | 4543 __ mov(FieldOperand(eax, JSArray::kLengthOffset), |
| 4552 Immediate(Smi::FromInt(0))); | 4544 Immediate(Smi::FromInt(0))); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4574 // -- esi : context | 4566 // -- esi : context |
| 4575 // -- eax : number of rest parameters (tagged) | 4567 // -- eax : number of rest parameters (tagged) |
| 4576 // -- ebx : pointer to first rest parameters | 4568 // -- ebx : pointer to first rest parameters |
| 4577 // -- esp[0] : return address | 4569 // -- esp[0] : return address |
| 4578 // ----------------------------------- | 4570 // ----------------------------------- |
| 4579 | 4571 |
| 4580 // Allocate space for the rest parameter array plus the backing store. | 4572 // Allocate space for the rest parameter array plus the backing store. |
| 4581 Label allocate, done_allocate; | 4573 Label allocate, done_allocate; |
| 4582 __ lea(ecx, Operand(eax, times_half_pointer_size, | 4574 __ lea(ecx, Operand(eax, times_half_pointer_size, |
| 4583 JSArray::kSize + FixedArray::kHeaderSize)); | 4575 JSArray::kSize + FixedArray::kHeaderSize)); |
| 4584 __ Allocate(ecx, edx, edi, no_reg, &allocate, TAG_OBJECT); | 4576 __ Allocate(ecx, edx, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); |
| 4585 __ bind(&done_allocate); | 4577 __ bind(&done_allocate); |
| 4586 | 4578 |
| 4587 // Setup the elements array in edx. | 4579 // Setup the elements array in edx. |
| 4588 __ mov(FieldOperand(edx, FixedArray::kMapOffset), | 4580 __ mov(FieldOperand(edx, FixedArray::kMapOffset), |
| 4589 isolate()->factory()->fixed_array_map()); | 4581 isolate()->factory()->fixed_array_map()); |
| 4590 __ mov(FieldOperand(edx, FixedArray::kLengthOffset), eax); | 4582 __ mov(FieldOperand(edx, FixedArray::kLengthOffset), eax); |
| 4591 { | 4583 { |
| 4592 Label loop, done_loop; | 4584 Label loop, done_loop; |
| 4593 __ Move(ecx, Smi::FromInt(0)); | 4585 __ Move(ecx, Smi::FromInt(0)); |
| 4594 __ bind(&loop); | 4586 __ bind(&loop); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4698 __ lea(ebx, Operand(ebx, times_2, kParameterMapHeaderSize)); | 4690 __ lea(ebx, Operand(ebx, times_2, kParameterMapHeaderSize)); |
| 4699 __ bind(&no_parameter_map); | 4691 __ bind(&no_parameter_map); |
| 4700 | 4692 |
| 4701 // 2. Backing store. | 4693 // 2. Backing store. |
| 4702 __ lea(ebx, Operand(ebx, ecx, times_2, FixedArray::kHeaderSize)); | 4694 __ lea(ebx, Operand(ebx, ecx, times_2, FixedArray::kHeaderSize)); |
| 4703 | 4695 |
| 4704 // 3. Arguments object. | 4696 // 3. Arguments object. |
| 4705 __ add(ebx, Immediate(JSSloppyArgumentsObject::kSize)); | 4697 __ add(ebx, Immediate(JSSloppyArgumentsObject::kSize)); |
| 4706 | 4698 |
| 4707 // Do the allocation of all three objects in one go. | 4699 // Do the allocation of all three objects in one go. |
| 4708 __ Allocate(ebx, eax, edi, no_reg, &runtime, TAG_OBJECT); | 4700 __ Allocate(ebx, eax, edi, no_reg, &runtime, NO_ALLOCATION_FLAGS); |
| 4709 | 4701 |
| 4710 // eax = address of new object(s) (tagged) | 4702 // eax = address of new object(s) (tagged) |
| 4711 // ecx = argument count (smi-tagged) | 4703 // ecx = argument count (smi-tagged) |
| 4712 // esp[0] = mapped parameter count (tagged) | 4704 // esp[0] = mapped parameter count (tagged) |
| 4713 // esp[4] = function | 4705 // esp[4] = function |
| 4714 // esp[8] = parameter count (tagged) | 4706 // esp[8] = parameter count (tagged) |
| 4715 // Get the arguments map from the current native context into edi. | 4707 // Get the arguments map from the current native context into edi. |
| 4716 Label has_mapped_parameters, instantiate; | 4708 Label has_mapped_parameters, instantiate; |
| 4717 __ mov(edi, NativeContextOperand()); | 4709 __ mov(edi, NativeContextOperand()); |
| 4718 __ mov(ebx, Operand(esp, 0 * kPointerSize)); | 4710 __ mov(ebx, Operand(esp, 0 * kPointerSize)); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4927 // -- ebx : pointer to the first argument | 4919 // -- ebx : pointer to the first argument |
| 4928 // -- esi : context | 4920 // -- esi : context |
| 4929 // -- esp[0] : return address | 4921 // -- esp[0] : return address |
| 4930 // ----------------------------------- | 4922 // ----------------------------------- |
| 4931 | 4923 |
| 4932 // Allocate space for the strict arguments object plus the backing store. | 4924 // Allocate space for the strict arguments object plus the backing store. |
| 4933 Label allocate, done_allocate; | 4925 Label allocate, done_allocate; |
| 4934 __ lea(ecx, | 4926 __ lea(ecx, |
| 4935 Operand(eax, times_half_pointer_size, | 4927 Operand(eax, times_half_pointer_size, |
| 4936 JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); | 4928 JSStrictArgumentsObject::kSize + FixedArray::kHeaderSize)); |
| 4937 __ Allocate(ecx, edx, edi, no_reg, &allocate, TAG_OBJECT); | 4929 __ Allocate(ecx, edx, edi, no_reg, &allocate, NO_ALLOCATION_FLAGS); |
| 4938 __ bind(&done_allocate); | 4930 __ bind(&done_allocate); |
| 4939 | 4931 |
| 4940 // Setup the elements array in edx. | 4932 // Setup the elements array in edx. |
| 4941 __ mov(FieldOperand(edx, FixedArray::kMapOffset), | 4933 __ mov(FieldOperand(edx, FixedArray::kMapOffset), |
| 4942 isolate()->factory()->fixed_array_map()); | 4934 isolate()->factory()->fixed_array_map()); |
| 4943 __ mov(FieldOperand(edx, FixedArray::kLengthOffset), eax); | 4935 __ mov(FieldOperand(edx, FixedArray::kLengthOffset), eax); |
| 4944 { | 4936 { |
| 4945 Label loop, done_loop; | 4937 Label loop, done_loop; |
| 4946 __ Move(ecx, Smi::FromInt(0)); | 4938 __ Move(ecx, Smi::FromInt(0)); |
| 4947 __ bind(&loop); | 4939 __ bind(&loop); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5514 kStackUnwindSpace, nullptr, return_value_operand, | 5506 kStackUnwindSpace, nullptr, return_value_operand, |
| 5515 NULL); | 5507 NULL); |
| 5516 } | 5508 } |
| 5517 | 5509 |
| 5518 #undef __ | 5510 #undef __ |
| 5519 | 5511 |
| 5520 } // namespace internal | 5512 } // namespace internal |
| 5521 } // namespace v8 | 5513 } // namespace v8 |
| 5522 | 5514 |
| 5523 #endif // V8_TARGET_ARCH_X87 | 5515 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |