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

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

Issue 552186: ARM: Implement native substring copying. (Closed)
Patch Set: Changed order of tests to bail out earlier on short substrings. Created 10 years, 10 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
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 nop(); // Jump table alignment. 189 nop(); // Jump table alignment.
190 for (int i = 0; i < targets.length(); i++) { 190 for (int i = 0; i < targets.length(); i++) {
191 b(targets[i]); 191 b(targets[i]);
192 } 192 }
193 } 193 }
194 194
195 195
196 void MacroAssembler::LoadRoot(Register destination, 196 void MacroAssembler::LoadRoot(Register destination,
197 Heap::RootListIndex index, 197 Heap::RootListIndex index,
198 Condition cond) { 198 Condition cond) {
199 ldr(destination, MemOperand(r10, index << kPointerSizeLog2), cond); 199 ldr(destination, MemOperand(roots, index << kPointerSizeLog2), cond);
200 } 200 }
201 201
202 202
203 // Will clobber 4 registers: object, offset, scratch, ip. The 203 // Will clobber 4 registers: object, offset, scratch, ip. The
204 // register 'object' contains a heap object pointer. The heap object 204 // register 'object' contains a heap object pointer. The heap object
205 // tag is shifted away. 205 // tag is shifted away.
206 void MacroAssembler::RecordWrite(Register object, Register offset, 206 void MacroAssembler::RecordWrite(Register object, Register offset,
207 Register scratch) { 207 Register scratch) {
208 // The compiled code assumes that record write doesn't change the 208 // The compiled code assumes that record write doesn't change the
209 // context register, so we check that none of the clobbered 209 // context register, so we check that none of the clobbered
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 ldr(scratch, MemOperand(scratch)); 933 ldr(scratch, MemOperand(scratch));
934 cmp(object, scratch); 934 cmp(object, scratch);
935 Check(lt, "Undo allocation of non allocated memory"); 935 Check(lt, "Undo allocation of non allocated memory");
936 #endif 936 #endif
937 // Write the address of the object to un-allocate as the current top. 937 // Write the address of the object to un-allocate as the current top.
938 mov(scratch, Operand(new_space_allocation_top)); 938 mov(scratch, Operand(new_space_allocation_top));
939 str(object, MemOperand(scratch)); 939 str(object, MemOperand(scratch));
940 } 940 }
941 941
942 942
943 void MacroAssembler::AllocateTwoByteString(Register result,
944 Register length,
945 Register scratch1,
946 Register scratch2,
947 Register scratch3,
948 Label* gc_required) {
949 // Calculate the number of bytes needed for the characters in the string while
950 // observing object alignment.
951 ASSERT((SeqTwoByteString::kHeaderSize & kObjectAlignmentMask) == 0);
952 mov(scratch1, Operand(length, LSL, 1)); // Length in bytes, not chars.
953 add(scratch1, scratch1,
954 Operand(kObjectAlignmentMask + SeqTwoByteString::kHeaderSize));
955 // AllocateInNewSpace expects the size in words, so we can round down
956 // to kObjectAlignment and divide by kPointerSize in the same shift.
957 ASSERT_EQ(kPointerSize, kObjectAlignmentMask + 1);
958 mov(scratch1, Operand(scratch1, ASR, kPointerSizeLog2));
959
960 // Allocate two-byte string in new space.
961 AllocateInNewSpace(scratch1,
962 result,
963 scratch2,
964 scratch3,
965 gc_required,
966 TAG_OBJECT);
967
968 // Set the map, length and hash field.
969 LoadRoot(scratch1, Heap::kStringMapRootIndex);
970 str(length, FieldMemOperand(result, String::kLengthOffset));
971 str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset));
972 mov(scratch2, Operand(String::kEmptyHashField));
973 str(scratch2, FieldMemOperand(result, String::kHashFieldOffset));
974 }
975
976
977 void MacroAssembler::AllocateAsciiString(Register result,
978 Register length,
979 Register scratch1,
980 Register scratch2,
981 Register scratch3,
982 Label* gc_required) {
983 // Calculate the number of bytes needed for the characters in the string while
984 // observing object alignment.
985 ASSERT((SeqAsciiString::kHeaderSize & kObjectAlignmentMask) == 0);
986 ASSERT(kCharSize == 1);
987 add(scratch1, length,
988 Operand(kObjectAlignmentMask + SeqAsciiString::kHeaderSize));
989 // AllocateInNewSpace expects the size in words, so we can round down
990 // to kObjectAlignment and divide by kPointerSize in the same shift.
991 ASSERT_EQ(kPointerSize, kObjectAlignmentMask + 1);
992 mov(scratch1, Operand(scratch1, ASR, kPointerSizeLog2));
993
994 // Allocate ASCII string in new space.
995 AllocateInNewSpace(scratch1,
996 result,
997 scratch2,
998 scratch3,
999 gc_required,
1000 TAG_OBJECT);
1001
1002 // Set the map, length and hash field.
1003 LoadRoot(scratch1, Heap::kAsciiStringMapRootIndex);
1004 mov(scratch1, Operand(Factory::ascii_string_map()));
1005 str(length, FieldMemOperand(result, String::kLengthOffset));
1006 str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset));
1007 mov(scratch2, Operand(String::kEmptyHashField));
1008 str(scratch2, FieldMemOperand(result, String::kHashFieldOffset));
1009 }
1010
1011
943 void MacroAssembler::CompareObjectType(Register function, 1012 void MacroAssembler::CompareObjectType(Register function,
944 Register map, 1013 Register map,
945 Register type_reg, 1014 Register type_reg,
946 InstanceType type) { 1015 InstanceType type) {
947 ldr(map, FieldMemOperand(function, HeapObject::kMapOffset)); 1016 ldr(map, FieldMemOperand(function, HeapObject::kMapOffset));
948 CompareInstanceType(map, type_reg, type); 1017 CompareInstanceType(map, type_reg, type);
949 } 1018 }
950 1019
951 1020
952 void MacroAssembler::CompareInstanceType(Register map, 1021 void MacroAssembler::CompareInstanceType(Register map,
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 } 1376 }
1308 1377
1309 1378
1310 void CodePatcher::Emit(Address addr) { 1379 void CodePatcher::Emit(Address addr) {
1311 masm()->emit(reinterpret_cast<Instr>(addr)); 1380 masm()->emit(reinterpret_cast<Instr>(addr));
1312 } 1381 }
1313 #endif // ENABLE_DEBUGGER_SUPPORT 1382 #endif // ENABLE_DEBUGGER_SUPPORT
1314 1383
1315 1384
1316 } } // namespace v8::internal 1385 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698