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

Side by Side Diff: src/ia32/macro-assembler-ia32.cc

Issue 462025: Better handling of allocation alignment in generated code... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } else { 680 } else {
681 ASSERT(!scratch.is(result_end)); 681 ASSERT(!scratch.is(result_end));
682 mov(Operand(scratch), Immediate(new_space_allocation_top)); 682 mov(Operand(scratch), Immediate(new_space_allocation_top));
683 mov(result, Operand(scratch, 0)); 683 mov(result, Operand(scratch, 0));
684 } 684 }
685 } 685 }
686 686
687 687
688 void MacroAssembler::UpdateAllocationTopHelper(Register result_end, 688 void MacroAssembler::UpdateAllocationTopHelper(Register result_end,
689 Register scratch) { 689 Register scratch) {
690 #ifdef DEBUG
Mads Ager (chromium) 2009/12/04 07:33:12 Please use the flag debug_code, so that we only ge
Søren Thygesen Gjesse 2009/12/04 07:57:22 Done.
691 test(result_end, Immediate(kObjectAlignmentMask));
692 Check(zero, "Unaligned allocation in new space");
693 #endif
694
690 ExternalReference new_space_allocation_top = 695 ExternalReference new_space_allocation_top =
691 ExternalReference::new_space_allocation_top_address(); 696 ExternalReference::new_space_allocation_top_address();
692 697
693 // Update new top. Use scratch if available. 698 // Update new top. Use scratch if available.
694 if (scratch.is(no_reg)) { 699 if (scratch.is(no_reg)) {
695 mov(Operand::StaticVariable(new_space_allocation_top), result_end); 700 mov(Operand::StaticVariable(new_space_allocation_top), result_end);
696 } else { 701 } else {
697 mov(Operand(scratch, 0), result_end); 702 mov(Operand(scratch, 0), result_end);
698 } 703 }
699 } 704 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 Immediate(Factory::heap_number_map())); 824 Immediate(Factory::heap_number_map()));
820 } 825 }
821 826
822 827
823 void MacroAssembler::AllocateTwoByteString(Register result, 828 void MacroAssembler::AllocateTwoByteString(Register result,
824 Register length, 829 Register length,
825 Register scratch1, 830 Register scratch1,
826 Register scratch2, 831 Register scratch2,
827 Register scratch3, 832 Register scratch3,
828 Label* gc_required) { 833 Label* gc_required) {
829 // Calculate the number of words needed for the number of characters in the 834 // Calculate the number of bytes needed for the characters in the string while
830 // string 835 // observing object alignment.
836 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0);
831 mov(scratch1, length); 837 mov(scratch1, length);
832 add(Operand(scratch1), Immediate(1)); 838 ASSERT(kShortSize == 2);
833 shr(scratch1, 1); 839 shl(scratch1, 1);
840 add(Operand(scratch1), Immediate(kObjectAlignmentMask));
841 and_(Operand(scratch1), Immediate(~kObjectAlignmentMask));
834 842
835 // Allocate two byte string in new space. 843 // Allocate two byte string in new space.
836 AllocateInNewSpace(SeqTwoByteString::kHeaderSize, 844 AllocateInNewSpace(SeqTwoByteString::kHeaderSize,
837 times_4, 845 times_1,
838 scratch1, 846 scratch1,
839 result, 847 result,
840 scratch2, 848 scratch2,
841 scratch3, 849 scratch3,
842 gc_required, 850 gc_required,
843 TAG_OBJECT); 851 TAG_OBJECT);
844 852
845 // Set the map, length and hash field. 853 // Set the map, length and hash field.
846 mov(FieldOperand(result, HeapObject::kMapOffset), 854 mov(FieldOperand(result, HeapObject::kMapOffset),
847 Immediate(Factory::string_map())); 855 Immediate(Factory::string_map()));
848 mov(FieldOperand(result, String::kLengthOffset), length); 856 mov(FieldOperand(result, String::kLengthOffset), length);
849 mov(FieldOperand(result, String::kHashFieldOffset), 857 mov(FieldOperand(result, String::kHashFieldOffset),
850 Immediate(String::kEmptyHashField)); 858 Immediate(String::kEmptyHashField));
851 } 859 }
852 860
853 861
854 void MacroAssembler::AllocateAsciiString(Register result, 862 void MacroAssembler::AllocateAsciiString(Register result,
855 Register length, 863 Register length,
856 Register scratch1, 864 Register scratch1,
857 Register scratch2, 865 Register scratch2,
858 Register scratch3, 866 Register scratch3,
859 Label* gc_required) { 867 Label* gc_required) {
860 // Calculate the number of words needed for the number of characters in the 868 // Calculate the number of bytes needed for the characters in the string while
861 // string 869 // observing object alignment.
870 ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0);
862 mov(scratch1, length); 871 mov(scratch1, length);
863 add(Operand(scratch1), Immediate(3)); 872 ASSERT(kCharSize == 1);
864 shr(scratch1, 2); 873 add(Operand(scratch1), Immediate(kObjectAlignmentMask));
874 and_(Operand(scratch1), Immediate(~kObjectAlignmentMask));
865 875
866 // Allocate ascii string in new space. 876 // Allocate ascii string in new space.
867 AllocateInNewSpace(SeqAsciiString::kHeaderSize, 877 AllocateInNewSpace(SeqAsciiString::kHeaderSize,
868 times_4, 878 times_1,
869 scratch1, 879 scratch1,
870 result, 880 result,
871 scratch2, 881 scratch2,
872 scratch3, 882 scratch3,
873 gc_required, 883 gc_required,
874 TAG_OBJECT); 884 TAG_OBJECT);
875 885
876 // Set the map, length and hash field. 886 // Set the map, length and hash field.
877 mov(FieldOperand(result, HeapObject::kMapOffset), 887 mov(FieldOperand(result, HeapObject::kMapOffset),
878 Immediate(Factory::ascii_string_map())); 888 Immediate(Factory::ascii_string_map()));
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 // from the real pointer as a smi. 1386 // from the real pointer as a smi.
1377 intptr_t p1 = reinterpret_cast<intptr_t>(msg); 1387 intptr_t p1 = reinterpret_cast<intptr_t>(msg);
1378 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag; 1388 intptr_t p0 = (p1 & ~kSmiTagMask) + kSmiTag;
1379 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi()); 1389 ASSERT(reinterpret_cast<Object*>(p0)->IsSmi());
1380 #ifdef DEBUG 1390 #ifdef DEBUG
1381 if (msg != NULL) { 1391 if (msg != NULL) {
1382 RecordComment("Abort message: "); 1392 RecordComment("Abort message: ");
1383 RecordComment(msg); 1393 RecordComment(msg);
1384 } 1394 }
1385 #endif 1395 #endif
1396 // Disable stub call restrictions to always allow cals to abort.
1397 set_allow_stub_calls(true);
1398
1386 push(eax); 1399 push(eax);
1387 push(Immediate(p0)); 1400 push(Immediate(p0));
1388 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0)))); 1401 push(Immediate(reinterpret_cast<intptr_t>(Smi::FromInt(p1 - p0))));
1389 CallRuntime(Runtime::kAbort, 2); 1402 CallRuntime(Runtime::kAbort, 2);
1390 // will not return here 1403 // will not return here
1404 int3();
1391 } 1405 }
1392 1406
1393 1407
1394 CodePatcher::CodePatcher(byte* address, int size) 1408 CodePatcher::CodePatcher(byte* address, int size)
1395 : address_(address), size_(size), masm_(address, size + Assembler::kGap) { 1409 : address_(address), size_(size), masm_(address, size + Assembler::kGap) {
1396 // Create a new macro assembler pointing to the address of the code to patch. 1410 // Create a new macro assembler pointing to the address of the code to patch.
1397 // The size is adjusted with kGap on order for the assembler to generate size 1411 // The size is adjusted with kGap on order for the assembler to generate size
1398 // bytes of instructions without failing with buffer size constraints. 1412 // bytes of instructions without failing with buffer size constraints.
1399 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1413 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1400 } 1414 }
1401 1415
1402 1416
1403 CodePatcher::~CodePatcher() { 1417 CodePatcher::~CodePatcher() {
1404 // Indicate that code has changed. 1418 // Indicate that code has changed.
1405 CPU::FlushICache(address_, size_); 1419 CPU::FlushICache(address_, size_);
1406 1420
1407 // Check that the code was patched as expected. 1421 // Check that the code was patched as expected.
1408 ASSERT(masm_.pc_ == address_ + size_); 1422 ASSERT(masm_.pc_ == address_ + size_);
1409 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); 1423 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap);
1410 } 1424 }
1411 1425
1412 1426
1413 } } // namespace v8::internal 1427 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698