OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 } | 1089 } |
1090 } | 1090 } |
1091 | 1091 |
1092 | 1092 |
1093 // On ARM this is just a synonym to make the purpose clear. | 1093 // On ARM this is just a synonym to make the purpose clear. |
1094 void MacroAssembler::MovFromFloatParameter(DwVfpRegister dst) { | 1094 void MacroAssembler::MovFromFloatParameter(DwVfpRegister dst) { |
1095 MovFromFloatResult(dst); | 1095 MovFromFloatResult(dst); |
1096 } | 1096 } |
1097 | 1097 |
1098 | 1098 |
1099 void MacroAssembler::SetCallKind(Register dst, CallKind call_kind) { | |
1100 // This macro takes the dst register to make the code more readable | |
1101 // at the call sites. However, the dst register has to be r5 to | |
1102 // follow the calling convention which requires the call type to be | |
1103 // in r5. | |
1104 ASSERT(dst.is(r5)); | |
1105 if (call_kind == CALL_AS_FUNCTION) { | |
1106 mov(dst, Operand(Smi::FromInt(1))); | |
1107 } else { | |
1108 mov(dst, Operand(Smi::FromInt(0))); | |
1109 } | |
1110 } | |
1111 | |
1112 | |
1113 void MacroAssembler::InvokePrologue(const ParameterCount& expected, | 1099 void MacroAssembler::InvokePrologue(const ParameterCount& expected, |
1114 const ParameterCount& actual, | 1100 const ParameterCount& actual, |
1115 Handle<Code> code_constant, | 1101 Handle<Code> code_constant, |
1116 Register code_reg, | 1102 Register code_reg, |
1117 Label* done, | 1103 Label* done, |
1118 bool* definitely_mismatches, | 1104 bool* definitely_mismatches, |
1119 InvokeFlag flag, | 1105 InvokeFlag flag, |
1120 const CallWrapper& call_wrapper, | 1106 const CallWrapper& call_wrapper) { |
1121 CallKind call_kind) { | |
1122 bool definitely_matches = false; | 1107 bool definitely_matches = false; |
1123 *definitely_mismatches = false; | 1108 *definitely_mismatches = false; |
1124 Label regular_invoke; | 1109 Label regular_invoke; |
1125 | 1110 |
1126 // Check whether the expected and actual arguments count match. If not, | 1111 // Check whether the expected and actual arguments count match. If not, |
1127 // setup registers according to contract with ArgumentsAdaptorTrampoline: | 1112 // setup registers according to contract with ArgumentsAdaptorTrampoline: |
1128 // r0: actual arguments count | 1113 // r0: actual arguments count |
1129 // r1: function (passed through to callee) | 1114 // r1: function (passed through to callee) |
1130 // r2: expected arguments count | 1115 // r2: expected arguments count |
1131 // r3: callee code entry | 1116 // r3: callee code entry |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 if (!definitely_matches) { | 1154 if (!definitely_matches) { |
1170 if (!code_constant.is_null()) { | 1155 if (!code_constant.is_null()) { |
1171 mov(r3, Operand(code_constant)); | 1156 mov(r3, Operand(code_constant)); |
1172 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1157 add(r3, r3, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1173 } | 1158 } |
1174 | 1159 |
1175 Handle<Code> adaptor = | 1160 Handle<Code> adaptor = |
1176 isolate()->builtins()->ArgumentsAdaptorTrampoline(); | 1161 isolate()->builtins()->ArgumentsAdaptorTrampoline(); |
1177 if (flag == CALL_FUNCTION) { | 1162 if (flag == CALL_FUNCTION) { |
1178 call_wrapper.BeforeCall(CallSize(adaptor)); | 1163 call_wrapper.BeforeCall(CallSize(adaptor)); |
1179 SetCallKind(r5, call_kind); | |
1180 Call(adaptor); | 1164 Call(adaptor); |
1181 call_wrapper.AfterCall(); | 1165 call_wrapper.AfterCall(); |
1182 if (!*definitely_mismatches) { | 1166 if (!*definitely_mismatches) { |
1183 b(done); | 1167 b(done); |
1184 } | 1168 } |
1185 } else { | 1169 } else { |
1186 SetCallKind(r5, call_kind); | |
1187 Jump(adaptor, RelocInfo::CODE_TARGET); | 1170 Jump(adaptor, RelocInfo::CODE_TARGET); |
1188 } | 1171 } |
1189 bind(®ular_invoke); | 1172 bind(®ular_invoke); |
1190 } | 1173 } |
1191 } | 1174 } |
1192 | 1175 |
1193 | 1176 |
1194 void MacroAssembler::InvokeCode(Register code, | 1177 void MacroAssembler::InvokeCode(Register code, |
1195 const ParameterCount& expected, | 1178 const ParameterCount& expected, |
1196 const ParameterCount& actual, | 1179 const ParameterCount& actual, |
1197 InvokeFlag flag, | 1180 InvokeFlag flag, |
1198 const CallWrapper& call_wrapper, | 1181 const CallWrapper& call_wrapper) { |
1199 CallKind call_kind) { | |
1200 // You can't call a function without a valid frame. | 1182 // You can't call a function without a valid frame. |
1201 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1183 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
1202 | 1184 |
1203 Label done; | 1185 Label done; |
1204 bool definitely_mismatches = false; | 1186 bool definitely_mismatches = false; |
1205 InvokePrologue(expected, actual, Handle<Code>::null(), code, | 1187 InvokePrologue(expected, actual, Handle<Code>::null(), code, |
1206 &done, &definitely_mismatches, flag, | 1188 &done, &definitely_mismatches, flag, |
1207 call_wrapper, call_kind); | 1189 call_wrapper); |
1208 if (!definitely_mismatches) { | 1190 if (!definitely_mismatches) { |
1209 if (flag == CALL_FUNCTION) { | 1191 if (flag == CALL_FUNCTION) { |
1210 call_wrapper.BeforeCall(CallSize(code)); | 1192 call_wrapper.BeforeCall(CallSize(code)); |
1211 SetCallKind(r5, call_kind); | |
1212 Call(code); | 1193 Call(code); |
1213 call_wrapper.AfterCall(); | 1194 call_wrapper.AfterCall(); |
1214 } else { | 1195 } else { |
1215 ASSERT(flag == JUMP_FUNCTION); | 1196 ASSERT(flag == JUMP_FUNCTION); |
1216 SetCallKind(r5, call_kind); | |
1217 Jump(code); | 1197 Jump(code); |
1218 } | 1198 } |
1219 | 1199 |
1220 // Continue here if InvokePrologue does handle the invocation due to | 1200 // Continue here if InvokePrologue does handle the invocation due to |
1221 // mismatched parameter counts. | 1201 // mismatched parameter counts. |
1222 bind(&done); | 1202 bind(&done); |
1223 } | 1203 } |
1224 } | 1204 } |
1225 | 1205 |
1226 | 1206 |
1227 void MacroAssembler::InvokeCode(Handle<Code> code, | 1207 void MacroAssembler::InvokeCode(Handle<Code> code, |
1228 const ParameterCount& expected, | 1208 const ParameterCount& expected, |
1229 const ParameterCount& actual, | 1209 const ParameterCount& actual, |
1230 RelocInfo::Mode rmode, | 1210 RelocInfo::Mode rmode, |
1231 InvokeFlag flag, | 1211 InvokeFlag flag) { |
1232 CallKind call_kind) { | |
1233 // You can't call a function without a valid frame. | 1212 // You can't call a function without a valid frame. |
1234 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1213 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
1235 | 1214 |
1236 Label done; | 1215 Label done; |
1237 bool definitely_mismatches = false; | 1216 bool definitely_mismatches = false; |
1238 InvokePrologue(expected, actual, code, no_reg, | 1217 InvokePrologue(expected, actual, code, no_reg, |
1239 &done, &definitely_mismatches, flag, | 1218 &done, &definitely_mismatches, flag, |
1240 NullCallWrapper(), call_kind); | 1219 NullCallWrapper()); |
1241 if (!definitely_mismatches) { | 1220 if (!definitely_mismatches) { |
1242 if (flag == CALL_FUNCTION) { | 1221 if (flag == CALL_FUNCTION) { |
1243 SetCallKind(r5, call_kind); | |
1244 Call(code, rmode); | 1222 Call(code, rmode); |
1245 } else { | 1223 } else { |
1246 SetCallKind(r5, call_kind); | |
1247 Jump(code, rmode); | 1224 Jump(code, rmode); |
1248 } | 1225 } |
1249 | 1226 |
1250 // Continue here if InvokePrologue does handle the invocation due to | 1227 // Continue here if InvokePrologue does handle the invocation due to |
1251 // mismatched parameter counts. | 1228 // mismatched parameter counts. |
1252 bind(&done); | 1229 bind(&done); |
1253 } | 1230 } |
1254 } | 1231 } |
1255 | 1232 |
1256 | 1233 |
1257 void MacroAssembler::InvokeFunction(Register fun, | 1234 void MacroAssembler::InvokeFunction(Register fun, |
1258 const ParameterCount& actual, | 1235 const ParameterCount& actual, |
1259 InvokeFlag flag, | 1236 InvokeFlag flag, |
1260 const CallWrapper& call_wrapper, | 1237 const CallWrapper& call_wrapper) { |
1261 CallKind call_kind) { | |
1262 // You can't call a function without a valid frame. | 1238 // You can't call a function without a valid frame. |
1263 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1239 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
1264 | 1240 |
1265 // Contract with called JS functions requires that function is passed in r1. | 1241 // Contract with called JS functions requires that function is passed in r1. |
1266 ASSERT(fun.is(r1)); | 1242 ASSERT(fun.is(r1)); |
1267 | 1243 |
1268 Register expected_reg = r2; | 1244 Register expected_reg = r2; |
1269 Register code_reg = r3; | 1245 Register code_reg = r3; |
1270 | 1246 |
1271 ldr(code_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 1247 ldr(code_reg, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
1272 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 1248 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
1273 ldr(expected_reg, | 1249 ldr(expected_reg, |
1274 FieldMemOperand(code_reg, | 1250 FieldMemOperand(code_reg, |
1275 SharedFunctionInfo::kFormalParameterCountOffset)); | 1251 SharedFunctionInfo::kFormalParameterCountOffset)); |
1276 SmiUntag(expected_reg); | 1252 SmiUntag(expected_reg); |
1277 ldr(code_reg, | 1253 ldr(code_reg, |
1278 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1254 FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
1279 | 1255 |
1280 ParameterCount expected(expected_reg); | 1256 ParameterCount expected(expected_reg); |
1281 InvokeCode(code_reg, expected, actual, flag, call_wrapper, call_kind); | 1257 InvokeCode(code_reg, expected, actual, flag, call_wrapper); |
1282 } | 1258 } |
1283 | 1259 |
1284 | 1260 |
1285 void MacroAssembler::InvokeFunction(Register function, | 1261 void MacroAssembler::InvokeFunction(Register function, |
1286 const ParameterCount& expected, | 1262 const ParameterCount& expected, |
1287 const ParameterCount& actual, | 1263 const ParameterCount& actual, |
1288 InvokeFlag flag, | 1264 InvokeFlag flag, |
1289 const CallWrapper& call_wrapper, | 1265 const CallWrapper& call_wrapper) { |
1290 CallKind call_kind) { | |
1291 // You can't call a function without a valid frame. | 1266 // You can't call a function without a valid frame. |
1292 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 1267 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
1293 | 1268 |
1294 // Contract with called JS functions requires that function is passed in r1. | 1269 // Contract with called JS functions requires that function is passed in r1. |
1295 ASSERT(function.is(r1)); | 1270 ASSERT(function.is(r1)); |
1296 | 1271 |
1297 // Get the function and setup the context. | 1272 // Get the function and setup the context. |
1298 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); | 1273 ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); |
1299 | 1274 |
1300 // We call indirectly through the code field in the function to | 1275 // We call indirectly through the code field in the function to |
1301 // allow recompilation to take effect without changing any of the | 1276 // allow recompilation to take effect without changing any of the |
1302 // call sites. | 1277 // call sites. |
1303 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1278 ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
1304 InvokeCode(r3, expected, actual, flag, call_wrapper, call_kind); | 1279 InvokeCode(r3, expected, actual, flag, call_wrapper); |
1305 } | 1280 } |
1306 | 1281 |
1307 | 1282 |
1308 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, | 1283 void MacroAssembler::InvokeFunction(Handle<JSFunction> function, |
1309 const ParameterCount& expected, | 1284 const ParameterCount& expected, |
1310 const ParameterCount& actual, | 1285 const ParameterCount& actual, |
1311 InvokeFlag flag, | 1286 InvokeFlag flag, |
1312 const CallWrapper& call_wrapper, | 1287 const CallWrapper& call_wrapper) { |
1313 CallKind call_kind) { | |
1314 Move(r1, function); | 1288 Move(r1, function); |
1315 InvokeFunction(r1, expected, actual, flag, call_wrapper, call_kind); | 1289 InvokeFunction(r1, expected, actual, flag, call_wrapper); |
1316 } | 1290 } |
1317 | 1291 |
1318 | 1292 |
1319 void MacroAssembler::IsObjectJSObjectType(Register heap_object, | 1293 void MacroAssembler::IsObjectJSObjectType(Register heap_object, |
1320 Register map, | 1294 Register map, |
1321 Register scratch, | 1295 Register scratch, |
1322 Label* fail) { | 1296 Label* fail) { |
1323 ldr(map, FieldMemOperand(heap_object, HeapObject::kMapOffset)); | 1297 ldr(map, FieldMemOperand(heap_object, HeapObject::kMapOffset)); |
1324 IsInstanceJSObjectType(map, scratch, fail); | 1298 IsInstanceJSObjectType(map, scratch, fail); |
1325 } | 1299 } |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 | 2726 |
2753 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, | 2727 void MacroAssembler::InvokeBuiltin(Builtins::JavaScript id, |
2754 InvokeFlag flag, | 2728 InvokeFlag flag, |
2755 const CallWrapper& call_wrapper) { | 2729 const CallWrapper& call_wrapper) { |
2756 // You can't call a builtin without a valid frame. | 2730 // You can't call a builtin without a valid frame. |
2757 ASSERT(flag == JUMP_FUNCTION || has_frame()); | 2731 ASSERT(flag == JUMP_FUNCTION || has_frame()); |
2758 | 2732 |
2759 GetBuiltinEntry(r2, id); | 2733 GetBuiltinEntry(r2, id); |
2760 if (flag == CALL_FUNCTION) { | 2734 if (flag == CALL_FUNCTION) { |
2761 call_wrapper.BeforeCall(CallSize(r2)); | 2735 call_wrapper.BeforeCall(CallSize(r2)); |
2762 SetCallKind(r5, CALL_AS_METHOD); | |
2763 Call(r2); | 2736 Call(r2); |
2764 call_wrapper.AfterCall(); | 2737 call_wrapper.AfterCall(); |
2765 } else { | 2738 } else { |
2766 ASSERT(flag == JUMP_FUNCTION); | 2739 ASSERT(flag == JUMP_FUNCTION); |
2767 SetCallKind(r5, CALL_AS_METHOD); | |
2768 Jump(r2); | 2740 Jump(r2); |
2769 } | 2741 } |
2770 } | 2742 } |
2771 | 2743 |
2772 | 2744 |
2773 void MacroAssembler::GetBuiltinFunction(Register target, | 2745 void MacroAssembler::GetBuiltinFunction(Register target, |
2774 Builtins::JavaScript id) { | 2746 Builtins::JavaScript id) { |
2775 // Load the builtins object into target register. | 2747 // Load the builtins object into target register. |
2776 ldr(target, | 2748 ldr(target, |
2777 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 2749 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); |
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4127 void CodePatcher::EmitCondition(Condition cond) { | 4099 void CodePatcher::EmitCondition(Condition cond) { |
4128 Instr instr = Assembler::instr_at(masm_.pc_); | 4100 Instr instr = Assembler::instr_at(masm_.pc_); |
4129 instr = (instr & ~kCondMask) | cond; | 4101 instr = (instr & ~kCondMask) | cond; |
4130 masm_.emit(instr); | 4102 masm_.emit(instr); |
4131 } | 4103 } |
4132 | 4104 |
4133 | 4105 |
4134 } } // namespace v8::internal | 4106 } } // namespace v8::internal |
4135 | 4107 |
4136 #endif // V8_TARGET_ARCH_ARM | 4108 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |