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

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 7901016: Basic support for tracking smi-only arrays on ia32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix remaining failing tests Created 9 years, 3 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 STATIC_ASSERT(kSmiTag == 0); 1462 STATIC_ASSERT(kSmiTag == 0);
1463 __ add(Operand(eax), Immediate(Smi::FromInt(argc))); 1463 __ add(Operand(eax), Immediate(Smi::FromInt(argc)));
1464 1464
1465 // Get the element's length into ecx. 1465 // Get the element's length into ecx.
1466 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset)); 1466 __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
1467 1467
1468 // Check if we could survive without allocation. 1468 // Check if we could survive without allocation.
1469 __ cmp(eax, Operand(ecx)); 1469 __ cmp(eax, Operand(ecx));
1470 __ j(greater, &attempt_to_grow_elements); 1470 __ j(greater, &attempt_to_grow_elements);
1471 1471
1472 // Check if value is a smi.
1473 __ mov(ecx, Operand(esp, argc * kPointerSize));
1474 __ JumpIfNotSmi(ecx, &with_write_barrier);
1475
1472 // Save new length. 1476 // Save new length.
1473 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax); 1477 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax);
1474 1478
1475 // Push the element. 1479 // Push the element.
1476 __ lea(edx, FieldOperand(ebx, 1480 __ lea(edx, FieldOperand(ebx,
1477 eax, times_half_pointer_size, 1481 eax, times_half_pointer_size,
1478 FixedArray::kHeaderSize - argc * kPointerSize)); 1482 FixedArray::kHeaderSize - argc * kPointerSize));
1479 __ mov(ecx, Operand(esp, argc * kPointerSize));
1480 __ mov(Operand(edx, 0), ecx); 1483 __ mov(Operand(edx, 0), ecx);
1481 1484
1482 // Check if value is a smi.
1483 __ JumpIfNotSmi(ecx, &with_write_barrier);
1484
1485 __ bind(&exit); 1485 __ bind(&exit);
Yang 2011/09/21 14:47:50 Remove unused label.
danno 2011/09/22 11:23:15 Done.
1486 __ ret((argc + 1) * kPointerSize); 1486 __ ret((argc + 1) * kPointerSize);
1487 1487
1488 __ bind(&with_write_barrier); 1488 __ bind(&with_write_barrier);
1489 1489
1490 if (FLAG_smi_only_arrays) {
1491 __ mov(edi, FieldOperand(edx, HeapObject::kMapOffset));
1492 __ CheckFastObjectElements(edi, &call_builtin);
1493 }
1494
1495 // Save new length.
1496 __ mov(FieldOperand(edx, JSArray::kLengthOffset), eax);
1497
1498 // Push the element.
1499 __ lea(edx, FieldOperand(ebx,
1500 eax, times_half_pointer_size,
1501 FixedArray::kHeaderSize - argc * kPointerSize));
1502 __ mov(Operand(edx, 0), ecx);
1503
1490 __ RecordWrite( 1504 __ RecordWrite(
1491 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); 1505 ebx, edx, ecx, kDontSaveFPRegs, EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
1492 1506
1493 __ ret((argc + 1) * kPointerSize); 1507 __ ret((argc + 1) * kPointerSize);
1494 1508
1495 __ bind(&attempt_to_grow_elements); 1509 __ bind(&attempt_to_grow_elements);
1496 if (!FLAG_inline_new) { 1510 if (!FLAG_inline_new) {
1497 __ jmp(&call_builtin); 1511 __ jmp(&call_builtin);
1498 } 1512 }
1499 1513
1514 __ mov(edi, Operand(esp, argc * kPointerSize));
1515 if (FLAG_smi_only_arrays) {
1516 // Growing elements that are SMI-only requires special handling in case
1517 // the new element is non-Smi. For now, delegate to the builtin.
1518 Label no_fast_elements_check;
1519 __ JumpIfSmi(edi, &no_fast_elements_check);
1520 __ mov(esi, FieldOperand(edx, HeapObject::kMapOffset));
1521 __ CheckFastObjectElements(esi, &call_builtin, Label::kFar);
1522 __ bind(&no_fast_elements_check);
Yang 2011/09/21 14:47:50 Nit: indentation.
danno 2011/09/22 11:23:15 Done.
1523 }
1524
1500 // We could be lucky and the elements array could be at the top of 1525 // We could be lucky and the elements array could be at the top of
1501 // new-space. In this case we can just grow it in place by moving the 1526 // new-space. In this case we can just grow it in place by moving the
1502 // allocation pointer up. 1527 // allocation pointer up.
1503 1528
1504 ExternalReference new_space_allocation_top = 1529 ExternalReference new_space_allocation_top =
1505 ExternalReference::new_space_allocation_top_address(isolate()); 1530 ExternalReference::new_space_allocation_top_address(isolate());
1506 ExternalReference new_space_allocation_limit = 1531 ExternalReference new_space_allocation_limit =
1507 ExternalReference::new_space_allocation_limit_address(isolate()); 1532 ExternalReference::new_space_allocation_limit_address(isolate());
1508 1533
1509 const int kAllocationDelta = 4; 1534 const int kAllocationDelta = 4;
1510 // Load top. 1535 // Load top.
1511 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top)); 1536 __ mov(ecx, Operand::StaticVariable(new_space_allocation_top));
1512 1537
1513 // Check if it's the end of elements. 1538 // Check if it's the end of elements.
1514 __ lea(edx, FieldOperand(ebx, 1539 __ lea(edx, FieldOperand(ebx,
1515 eax, times_half_pointer_size, 1540 eax, times_half_pointer_size,
1516 FixedArray::kHeaderSize - argc * kPointerSize)); 1541 FixedArray::kHeaderSize - argc * kPointerSize));
1517 __ cmp(edx, Operand(ecx)); 1542 __ cmp(edx, Operand(ecx));
1518 __ j(not_equal, &call_builtin); 1543 __ j(not_equal, &call_builtin);
1519 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize)); 1544 __ add(Operand(ecx), Immediate(kAllocationDelta * kPointerSize));
1520 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit)); 1545 __ cmp(ecx, Operand::StaticVariable(new_space_allocation_limit));
1521 __ j(above, &call_builtin); 1546 __ j(above, &call_builtin);
1522 1547
1523 // We fit and could grow elements. 1548 // We fit and could grow elements.
1524 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx); 1549 __ mov(Operand::StaticVariable(new_space_allocation_top), ecx);
1525 __ mov(ecx, Operand(esp, argc * kPointerSize));
1526 1550
1527 // Push the argument... 1551 // Push the argument...
1528 __ mov(Operand(edx, 0), ecx); 1552 __ mov(Operand(edx, 0), edi);
1529 // ... and fill the rest with holes. 1553 // ... and fill the rest with holes.
1530 for (int i = 1; i < kAllocationDelta; i++) { 1554 for (int i = 1; i < kAllocationDelta; i++) {
1531 __ mov(Operand(edx, i * kPointerSize), 1555 __ mov(Operand(edx, i * kPointerSize),
1532 Immediate(factory()->the_hole_value())); 1556 Immediate(factory()->the_hole_value()));
1533 } 1557 }
1534 1558
1535 // We know the elements array is in new space so we don't need the 1559 // We know the elements array is in new space so we don't need the
1536 // remembered set, but we just pushed a value onto it so we may have to 1560 // remembered set, but we just pushed a value onto it so we may have to
1537 // tell the incremental marker to rescan the object that we just grew. We 1561 // tell the incremental marker to rescan the object that we just grew. We
1538 // don't need to worry about the holes because they are in old space and 1562 // don't need to worry about the holes because they are in old space and
1539 // already marked black. 1563 // already marked black.
1540 __ RecordWrite(ebx, edx, ecx, kDontSaveFPRegs, OMIT_REMEMBERED_SET); 1564 __ RecordWrite(ebx, edx, edi, kDontSaveFPRegs, OMIT_REMEMBERED_SET);
1541 1565
1542 // Restore receiver to edx as finish sequence assumes it's here. 1566 // Restore receiver to edx as finish sequence assumes it's here.
1543 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); 1567 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize));
1544 1568
1545 // Increment element's and array's sizes. 1569 // Increment element's and array's sizes.
1546 __ add(FieldOperand(ebx, FixedArray::kLengthOffset), 1570 __ add(FieldOperand(ebx, FixedArray::kLengthOffset),
1547 Immediate(Smi::FromInt(kAllocationDelta))); 1571 Immediate(Smi::FromInt(kAllocationDelta)));
1548 1572
1549 // NOTE: This only happen in new-space, where we don't 1573 // NOTE: This only happen in new-space, where we don't
1550 // care about the black-byte-count on pages. Otherwise we should 1574 // care about the black-byte-count on pages. Otherwise we should
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 masm->isolate()->builtins()->KeyedLoadIC_Slow(); 3894 masm->isolate()->builtins()->KeyedLoadIC_Slow();
3871 __ jmp(slow_ic, RelocInfo::CODE_TARGET); 3895 __ jmp(slow_ic, RelocInfo::CODE_TARGET);
3872 3896
3873 __ bind(&miss_force_generic); 3897 __ bind(&miss_force_generic);
3874 Handle<Code> miss_ic = 3898 Handle<Code> miss_ic =
3875 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric(); 3899 masm->isolate()->builtins()->KeyedLoadIC_MissForceGeneric();
3876 __ jmp(miss_ic, RelocInfo::CODE_TARGET); 3900 __ jmp(miss_ic, RelocInfo::CODE_TARGET);
3877 } 3901 }
3878 3902
3879 3903
3880 void KeyedStoreStubCompiler::GenerateStoreFastElement(MacroAssembler* masm, 3904 void KeyedStoreStubCompiler::GenerateStoreFastElement(
3881 bool is_js_array) { 3905 MacroAssembler* masm,
3906 bool is_js_array,
3907 StoreObjectAction store_object_action) {
fschneider 2011/09/22 07:46:38 I find the name StoreObjectAction a little mislead
danno 2011/09/22 11:23:15 Done.
3882 // ----------- S t a t e ------------- 3908 // ----------- S t a t e -------------
3883 // -- eax : value 3909 // -- eax : value
3884 // -- ecx : key 3910 // -- ecx : key
3885 // -- edx : receiver 3911 // -- edx : receiver
3886 // -- esp[0] : return address 3912 // -- esp[0] : return address
3887 // ----------------------------------- 3913 // -----------------------------------
3888 Label miss_force_generic; 3914 Label miss_force_generic;
3889 3915
3890 // This stub is meant to be tail-jumped to, the receiver must already 3916 // This stub is meant to be tail-jumped to, the receiver must already
3891 // have been verified by the caller to not be a smi. 3917 // have been verified by the caller to not be a smi.
(...skipping 10 matching lines...) Expand all
3902 if (is_js_array) { 3928 if (is_js_array) {
3903 // Check that the key is within bounds. 3929 // Check that the key is within bounds.
3904 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis. 3930 __ cmp(ecx, FieldOperand(edx, JSArray::kLengthOffset)); // smis.
3905 __ j(above_equal, &miss_force_generic); 3931 __ j(above_equal, &miss_force_generic);
3906 } else { 3932 } else {
3907 // Check that the key is within bounds. 3933 // Check that the key is within bounds.
3908 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis. 3934 __ cmp(ecx, FieldOperand(edi, FixedArray::kLengthOffset)); // smis.
3909 __ j(above_equal, &miss_force_generic); 3935 __ j(above_equal, &miss_force_generic);
3910 } 3936 }
3911 3937
3912 // Do the store and update the write barrier. 3938 if (store_object_action == kObjectStoreForcesGeneric) {
3913 __ lea(ecx, FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize)); 3939 __ JumpIfNotSmi(eax, &miss_force_generic);
3914 __ mov(Operand(ecx, 0), eax); 3940 __ mov(FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize), eax);
Yang 2011/09/21 14:47:50 Maybe use times_half_pointer_size instead and comm
danno 2011/09/22 11:23:15 Done.
3915 // Make sure to preserve the value in register eax. 3941 } else {
3916 __ mov(edx, Operand(eax)); 3942 ASSERT(store_object_action == kObjectStoreCausesWriteBarrier);
3917 __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs); 3943 // Do the store and update the write barrier.
3944 __ lea(ecx, FieldOperand(edi, ecx, times_2, FixedArray::kHeaderSize));
3945 __ mov(Operand(ecx, 0), eax);
3946 // Make sure to preserve the value in register eax.
3947 __ mov(edx, Operand(eax));
3948 __ RecordWrite(edi, ecx, edx, kDontSaveFPRegs);
3949 }
3918 3950
3919 // Done. 3951 // Done.
3920 __ ret(0); 3952 __ ret(0);
3921 3953
3922 // Handle store cache miss, replacing the ic with the generic stub. 3954 // Handle store cache miss, replacing the ic with the generic stub.
3923 __ bind(&miss_force_generic); 3955 __ bind(&miss_force_generic);
3924 Handle<Code> ic_force_generic = 3956 Handle<Code> ic_force_generic =
3925 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 3957 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
3926 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); 3958 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
3927 } 3959 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
4019 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric(); 4051 masm->isolate()->builtins()->KeyedStoreIC_MissForceGeneric();
4020 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET); 4052 __ jmp(ic_force_generic, RelocInfo::CODE_TARGET);
4021 } 4053 }
4022 4054
4023 4055
4024 #undef __ 4056 #undef __
4025 4057
4026 } } // namespace v8::internal 4058 } } // namespace v8::internal
4027 4059
4028 #endif // V8_TARGET_ARCH_IA32 4060 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698