| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| 1012 void MacroAssembler::AllocateTwoByteConsString(Register result, |
| 1013 Register length, |
| 1014 Register scratch1, |
| 1015 Register scratch2, |
| 1016 Label* gc_required) { |
| 1017 AllocateInNewSpace(ConsString::kSize / kPointerSize, |
| 1018 result, |
| 1019 scratch1, |
| 1020 scratch2, |
| 1021 gc_required, |
| 1022 TAG_OBJECT); |
| 1023 LoadRoot(scratch1, Heap::kConsStringMapRootIndex); |
| 1024 mov(scratch2, Operand(String::kEmptyHashField)); |
| 1025 str(length, FieldMemOperand(result, String::kLengthOffset)); |
| 1026 str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset)); |
| 1027 str(scratch2, FieldMemOperand(result, String::kHashFieldOffset)); |
| 1028 } |
| 1029 |
| 1030 |
| 1031 void MacroAssembler::AllocateAsciiConsString(Register result, |
| 1032 Register length, |
| 1033 Register scratch1, |
| 1034 Register scratch2, |
| 1035 Label* gc_required) { |
| 1036 AllocateInNewSpace(ConsString::kSize / kPointerSize, |
| 1037 result, |
| 1038 scratch1, |
| 1039 scratch2, |
| 1040 gc_required, |
| 1041 TAG_OBJECT); |
| 1042 LoadRoot(scratch1, Heap::kConsAsciiStringMapRootIndex); |
| 1043 mov(scratch2, Operand(String::kEmptyHashField)); |
| 1044 str(length, FieldMemOperand(result, String::kLengthOffset)); |
| 1045 str(scratch1, FieldMemOperand(result, HeapObject::kMapOffset)); |
| 1046 str(scratch2, FieldMemOperand(result, String::kHashFieldOffset)); |
| 1047 } |
| 1048 |
| 1049 |
| 943 void MacroAssembler::CompareObjectType(Register function, | 1050 void MacroAssembler::CompareObjectType(Register function, |
| 944 Register map, | 1051 Register map, |
| 945 Register type_reg, | 1052 Register type_reg, |
| 946 InstanceType type) { | 1053 InstanceType type) { |
| 947 ldr(map, FieldMemOperand(function, HeapObject::kMapOffset)); | 1054 ldr(map, FieldMemOperand(function, HeapObject::kMapOffset)); |
| 948 CompareInstanceType(map, type_reg, type); | 1055 CompareInstanceType(map, type_reg, type); |
| 949 } | 1056 } |
| 950 | 1057 |
| 951 | 1058 |
| 952 void MacroAssembler::CompareInstanceType(Register map, | 1059 void MacroAssembler::CompareInstanceType(Register map, |
| 953 Register type_reg, | 1060 Register type_reg, |
| 954 InstanceType type) { | 1061 InstanceType type) { |
| 955 ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); | 1062 ldrb(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); |
| 956 cmp(type_reg, Operand(type)); | 1063 cmp(type_reg, Operand(type)); |
| 957 } | 1064 } |
| 958 | 1065 |
| 959 | 1066 |
| 1067 void MacroAssembler::CheckMap(Register obj, |
| 1068 Register scratch, |
| 1069 Handle<Map> map, |
| 1070 Label* fail, |
| 1071 bool is_heap_object) { |
| 1072 if (!is_heap_object) { |
| 1073 BranchOnSmi(obj, fail); |
| 1074 } |
| 1075 ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset)); |
| 1076 mov(ip, Operand(map)); |
| 1077 cmp(scratch, ip); |
| 1078 b(ne, fail); |
| 1079 } |
| 1080 |
| 1081 |
| 960 void MacroAssembler::TryGetFunctionPrototype(Register function, | 1082 void MacroAssembler::TryGetFunctionPrototype(Register function, |
| 961 Register result, | 1083 Register result, |
| 962 Register scratch, | 1084 Register scratch, |
| 963 Label* miss) { | 1085 Label* miss) { |
| 964 // Check that the receiver isn't a smi. | 1086 // Check that the receiver isn't a smi. |
| 965 BranchOnSmi(function, miss); | 1087 BranchOnSmi(function, miss); |
| 966 | 1088 |
| 967 // Check that the function really is a function. Load map into result reg. | 1089 // Check that the function really is a function. Load map into result reg. |
| 968 CompareObjectType(function, result, scratch, JS_FUNCTION_TYPE); | 1090 CompareObjectType(function, result, scratch, JS_FUNCTION_TYPE); |
| 969 b(ne, miss); | 1091 b(ne, miss); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 bind(&done); | 1125 bind(&done); |
| 1004 } | 1126 } |
| 1005 | 1127 |
| 1006 | 1128 |
| 1007 void MacroAssembler::CallStub(CodeStub* stub, Condition cond) { | 1129 void MacroAssembler::CallStub(CodeStub* stub, Condition cond) { |
| 1008 ASSERT(allow_stub_calls()); // stub calls are not allowed in some stubs | 1130 ASSERT(allow_stub_calls()); // stub calls are not allowed in some stubs |
| 1009 Call(stub->GetCode(), RelocInfo::CODE_TARGET, cond); | 1131 Call(stub->GetCode(), RelocInfo::CODE_TARGET, cond); |
| 1010 } | 1132 } |
| 1011 | 1133 |
| 1012 | 1134 |
| 1135 void MacroAssembler::TailCallStub(CodeStub* stub, Condition cond) { |
| 1136 ASSERT(allow_stub_calls()); // stub calls are not allowed in some stubs |
| 1137 Jump(stub->GetCode(), RelocInfo::CODE_TARGET, cond); |
| 1138 } |
| 1139 |
| 1140 |
| 1013 void MacroAssembler::StubReturn(int argc) { | 1141 void MacroAssembler::StubReturn(int argc) { |
| 1014 ASSERT(argc >= 1 && generating_stub()); | 1142 ASSERT(argc >= 1 && generating_stub()); |
| 1015 if (argc > 1) | 1143 if (argc > 1) { |
| 1016 add(sp, sp, Operand((argc - 1) * kPointerSize)); | 1144 add(sp, sp, Operand((argc - 1) * kPointerSize)); |
| 1145 } |
| 1017 Ret(); | 1146 Ret(); |
| 1018 } | 1147 } |
| 1019 | 1148 |
| 1020 | 1149 |
| 1021 void MacroAssembler::IllegalOperation(int num_arguments) { | 1150 void MacroAssembler::IllegalOperation(int num_arguments) { |
| 1022 if (num_arguments > 0) { | 1151 if (num_arguments > 0) { |
| 1023 add(sp, sp, Operand(num_arguments * kPointerSize)); | 1152 add(sp, sp, Operand(num_arguments * kPointerSize)); |
| 1024 } | 1153 } |
| 1025 LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 1154 LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 1026 } | 1155 } |
| 1027 | 1156 |
| 1028 | 1157 |
| 1029 void MacroAssembler::IntegerToDoubleConversionWithVFP3(Register inReg, | 1158 void MacroAssembler::IntegerToDoubleConversionWithVFP3(Register inReg, |
| 1030 Register outHighReg, | 1159 Register outHighReg, |
| 1031 Register outLowReg) { | 1160 Register outLowReg) { |
| 1032 // ARMv7 VFP3 instructions to implement integer to double conversion. | 1161 // ARMv7 VFP3 instructions to implement integer to double conversion. |
| 1033 mov(r7, Operand(inReg, ASR, kSmiTagSize)); | 1162 mov(r7, Operand(inReg, ASR, kSmiTagSize)); |
| 1034 vmov(s15, r7); | 1163 vmov(s15, r7); |
| 1035 vcvt(d7, s15); | 1164 vcvt(d7, s15); |
| 1036 vmov(outLowReg, outHighReg, d7); | 1165 vmov(outLowReg, outHighReg, d7); |
| 1037 } | 1166 } |
| 1038 | 1167 |
| 1039 | 1168 |
| 1169 void MacroAssembler::GetLeastBitsFromSmi(Register dst, |
| 1170 Register src, |
| 1171 int num_least_bits) { |
| 1172 if (CpuFeatures::IsSupported(ARMv7)) { |
| 1173 ubfx(dst, src, Operand(kSmiTagSize), Operand(num_least_bits - 1)); |
| 1174 } else { |
| 1175 mov(dst, Operand(src, ASR, kSmiTagSize)); |
| 1176 and_(dst, dst, Operand((1 << num_least_bits) - 1)); |
| 1177 } |
| 1178 } |
| 1179 |
| 1180 |
| 1040 void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) { | 1181 void MacroAssembler::CallRuntime(Runtime::Function* f, int num_arguments) { |
| 1041 // All parameters are on the stack. r0 has the return value after call. | 1182 // All parameters are on the stack. r0 has the return value after call. |
| 1042 | 1183 |
| 1043 // If the expected number of arguments of the runtime function is | 1184 // If the expected number of arguments of the runtime function is |
| 1044 // constant, we check that the actual number of arguments match the | 1185 // constant, we check that the actual number of arguments match the |
| 1045 // expectation. | 1186 // expectation. |
| 1046 if (f->nargs >= 0 && f->nargs != num_arguments) { | 1187 if (f->nargs >= 0 && f->nargs != num_arguments) { |
| 1047 IllegalOperation(num_arguments); | 1188 IllegalOperation(num_arguments); |
| 1048 return; | 1189 return; |
| 1049 } | 1190 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 } | 1372 } |
| 1232 // The context may be an intermediate context, not a function context. | 1373 // The context may be an intermediate context, not a function context. |
| 1233 ldr(dst, MemOperand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1374 ldr(dst, MemOperand(dst, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 1234 } else { // Slot is in the current function context. | 1375 } else { // Slot is in the current function context. |
| 1235 // The context may be an intermediate context, not a function context. | 1376 // The context may be an intermediate context, not a function context. |
| 1236 ldr(dst, MemOperand(cp, Context::SlotOffset(Context::FCONTEXT_INDEX))); | 1377 ldr(dst, MemOperand(cp, Context::SlotOffset(Context::FCONTEXT_INDEX))); |
| 1237 } | 1378 } |
| 1238 } | 1379 } |
| 1239 | 1380 |
| 1240 | 1381 |
| 1382 void MacroAssembler::JumpIfNotBothSmi(Register reg1, |
| 1383 Register reg2, |
| 1384 Label* on_not_both_smi) { |
| 1385 ASSERT_EQ(0, kSmiTag); |
| 1386 tst(reg1, Operand(kSmiTagMask)); |
| 1387 tst(reg2, Operand(kSmiTagMask), eq); |
| 1388 b(ne, on_not_both_smi); |
| 1389 } |
| 1390 |
| 1391 |
| 1392 void MacroAssembler::JumpIfEitherSmi(Register reg1, |
| 1393 Register reg2, |
| 1394 Label* on_either_smi) { |
| 1395 ASSERT_EQ(0, kSmiTag); |
| 1396 tst(reg1, Operand(kSmiTagMask)); |
| 1397 tst(reg2, Operand(kSmiTagMask), ne); |
| 1398 b(eq, on_either_smi); |
| 1399 } |
| 1400 |
| 1401 |
| 1241 void MacroAssembler::JumpIfNonSmisNotBothSequentialAsciiStrings( | 1402 void MacroAssembler::JumpIfNonSmisNotBothSequentialAsciiStrings( |
| 1242 Register first, | 1403 Register first, |
| 1243 Register second, | 1404 Register second, |
| 1244 Register scratch1, | 1405 Register scratch1, |
| 1245 Register scratch2, | 1406 Register scratch2, |
| 1246 Label* failure) { | 1407 Label* failure) { |
| 1247 // Test that both first and second are sequential ASCII strings. | 1408 // Test that both first and second are sequential ASCII strings. |
| 1248 // Assume that they are non-smis. | 1409 // Assume that they are non-smis. |
| 1249 ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); | 1410 ldr(scratch1, FieldMemOperand(first, HeapObject::kMapOffset)); |
| 1250 ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); | 1411 ldr(scratch2, FieldMemOperand(second, HeapObject::kMapOffset)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1307 } | 1468 } |
| 1308 | 1469 |
| 1309 | 1470 |
| 1310 void CodePatcher::Emit(Address addr) { | 1471 void CodePatcher::Emit(Address addr) { |
| 1311 masm()->emit(reinterpret_cast<Instr>(addr)); | 1472 masm()->emit(reinterpret_cast<Instr>(addr)); |
| 1312 } | 1473 } |
| 1313 #endif // ENABLE_DEBUGGER_SUPPORT | 1474 #endif // ENABLE_DEBUGGER_SUPPORT |
| 1314 | 1475 |
| 1315 | 1476 |
| 1316 } } // namespace v8::internal | 1477 } } // namespace v8::internal |
| OLD | NEW |