@@ -1214,12 +1214,9 @@ void TurboAssembler::PrepareForTailCall(const ParameterCount& callee_args_count,
12141214 mr (sp, dst_reg);
12151215}
12161216
1217- void MacroAssembler::InvokePrologue (const ParameterCount& expected,
1218- const ParameterCount& actual, Label* done,
1219- bool * definitely_mismatches,
1220- InvokeFlag flag) {
1221- bool definitely_matches = false ;
1222- *definitely_mismatches = false ;
1217+ void MacroAssembler::InvokePrologue (Register expected_parameter_count,
1218+ Register actual_parameter_count,
1219+ Label* done, InvokeFlag flag) {
12231220 Label regular_invoke;
12241221
12251222 // Check whether the expected and actual arguments count match. If not,
@@ -1232,56 +1229,28 @@ void MacroAssembler::InvokePrologue(const ParameterCount& expected,
12321229 // up actual and expected registers according to the contract if values are
12331230 // passed in registers.
12341231
1232+ // The code below is made a lot easier because the calling code already sets
1233+ // up actual and expected registers according to the contract.
12351234 // ARM has some sanity checks as per below, considering add them for PPC
1236- // DCHECK(actual.is_immediate() || actual.reg() == r3);
1237- // DCHECK(expected.is_immediate() || expected.reg() == r5);
1238-
1239- if (expected.is_immediate ()) {
1240- DCHECK (actual.is_immediate ());
1241- mov (r3, Operand (actual.immediate ()));
1242- if (expected.immediate () == actual.immediate ()) {
1243- definitely_matches = true ;
1244- } else {
1245- const int sentinel = SharedFunctionInfo::kDontAdaptArgumentsSentinel ;
1246- if (expected.immediate () == sentinel) {
1247- // Don't worry about adapting arguments for builtins that
1248- // don't want that done. Skip adaption code by making it look
1249- // like we have a match between expected and actual number of
1250- // arguments.
1251- definitely_matches = true ;
1252- } else {
1253- *definitely_mismatches = true ;
1254- mov (r5, Operand (expected.immediate ()));
1255- }
1256- }
1235+ // DCHECK_EQ(actual_parameter_count, r3);
1236+ // DCHECK_EQ(expected_parameter_count, r5);
1237+
1238+ cmp (expected_parameter_count, actual_parameter_count);
1239+ beq (®ular_invoke);
1240+
1241+ Handle<Code> adaptor = BUILTIN_CODE (isolate (), ArgumentsAdaptorTrampoline);
1242+ if (flag == CALL_FUNCTION ) {
1243+ Call (adaptor);
1244+ b (done);
12571245 } else {
1258- if (actual.is_immediate ()) {
1259- mov (r3, Operand (actual.immediate ()));
1260- cmpi (expected.reg (), Operand (actual.immediate ()));
1261- beq (®ular_invoke);
1262- } else {
1263- cmp (expected.reg (), actual.reg ());
1264- beq (®ular_invoke);
1265- }
1246+ Jump (adaptor, RelocInfo::CODE_TARGET );
12661247 }
1267-
1268- if (!definitely_matches) {
1269- Handle<Code> adaptor = BUILTIN_CODE (isolate (), ArgumentsAdaptorTrampoline);
1270- if (flag == CALL_FUNCTION ) {
1271- Call (adaptor);
1272- if (!*definitely_mismatches) {
1273- b (done);
1274- }
1275- } else {
1276- Jump (adaptor, RelocInfo::CODE_TARGET );
1277- }
12781248 bind (®ular_invoke);
1279- }
12801249}
12811250
12821251void MacroAssembler::CheckDebugHook (Register fun, Register new_target,
1283- const ParameterCount& expected ,
1284- const ParameterCount& actual ) {
1252+ Register expected_parameter_count ,
1253+ Register actual_parameter_count ) {
12851254 Label skip_hook;
12861255
12871256 ExternalReference debug_hook_active =
@@ -1294,22 +1263,17 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
12941263
12951264 {
12961265 // Load receiver to pass it later to DebugOnFunctionCall hook.
1297- if (actual.is_reg ()) {
1298- ShiftLeftImm (r7, actual.reg (), Operand (kPointerSizeLog2 ));
1299- LoadPX (r7, MemOperand (sp, r7));
1300- } else {
1301- LoadP (r7, MemOperand (sp, actual.immediate () << kPointerSizeLog2 ), r0);
1302- }
1266+ ShiftLeftImm (r7, actual_parameter_count, Operand (kPointerSizeLog2 ));
1267+ LoadPX (r7, MemOperand (sp, r7));
13031268 FrameScope frame (this ,
13041269 has_frame () ? StackFrame::NONE : StackFrame::INTERNAL );
1305- if (expected.is_reg ()) {
1306- SmiTag (expected.reg ());
1307- Push (expected.reg ());
1308- }
1309- if (actual.is_reg ()) {
1310- SmiTag (actual.reg ());
1311- Push (actual.reg ());
1312- }
1270+
1271+ SmiTag (expected_parameter_count);
1272+ Push (expected_parameter_count);
1273+
1274+ SmiTag (actual_parameter_count);
1275+ Push (actual_parameter_count);
1276+
13131277 if (new_target.is_valid ()) {
13141278 Push (new_target);
13151279 }
@@ -1319,65 +1283,61 @@ void MacroAssembler::CheckDebugHook(Register fun, Register new_target,
13191283 if (new_target.is_valid ()) {
13201284 Pop (new_target);
13211285 }
1322- if (actual.is_reg ()) {
1323- Pop (actual.reg ());
1324- SmiUntag (actual.reg ());
1325- }
1326- if (expected.is_reg ()) {
1327- Pop (expected.reg ());
1328- SmiUntag (expected.reg ());
1329- }
1286+
1287+ Pop (actual_parameter_count);
1288+ SmiUntag (actual_parameter_count);
1289+
1290+ Pop (expected_parameter_count);
1291+ SmiUntag (expected_parameter_count);
13301292 }
13311293 bind (&skip_hook);
13321294}
13331295
13341296void MacroAssembler::InvokeFunctionCode (Register function, Register new_target,
1335- const ParameterCount& expected ,
1336- const ParameterCount& actual ,
1297+ Register expected_parameter_count ,
1298+ Register actual_parameter_count ,
13371299 InvokeFlag flag) {
13381300 // You can't call a function without a valid frame.
1339- DCHECK (flag == JUMP_FUNCTION || has_frame ());
1340- DCHECK (function == r4);
1301+ DCHECK_IMPLIES (flag == CALL_FUNCTION , has_frame ());
1302+ DCHECK_EQ (function, r4);
13411303 DCHECK_IMPLIES (new_target.is_valid (), new_target == r6);
13421304
13431305 // On function call, call into the debugger if necessary.
1344- CheckDebugHook (function, new_target, expected, actual);
1306+ CheckDebugHook (function, new_target, expected_parameter_count,
1307+ actual_parameter_count);
13451308
13461309 // Clear the new.target register if not given.
13471310 if (!new_target.is_valid ()) {
13481311 LoadRoot (r6, RootIndex::kUndefinedValue );
13491312 }
13501313
13511314 Label done;
1352- bool definitely_mismatches = false ;
1353- InvokePrologue (expected, actual, &done, &definitely_mismatches, flag);
1354- if (!definitely_mismatches) {
1355- // We call indirectly through the code field in the function to
1356- // allow recompilation to take effect without changing any of the
1357- // call sites.
1358- Register code = kJavaScriptCallCodeStartRegister ;
1359- LoadP (code, FieldMemOperand (function, JSFunction::kCodeOffset ));
1360- if (flag == CALL_FUNCTION ) {
1361- CallCodeObject (code);
1362- } else {
1363- DCHECK (flag == JUMP_FUNCTION );
1364- JumpCodeObject (code);
1365- }
1315+ InvokePrologue (expected_parameter_count, actual_parameter_count, &done, flag);
1316+ // We call indirectly through the code field in the function to
1317+ // allow recompilation to take effect without changing any of the
1318+ // call sites.
1319+ Register code = kJavaScriptCallCodeStartRegister ;
1320+ LoadP (code, FieldMemOperand (function, JSFunction::kCodeOffset ));
1321+ if (flag == CALL_FUNCTION ) {
1322+ CallCodeObject (code);
1323+ } else {
1324+ DCHECK (flag == JUMP_FUNCTION );
1325+ JumpCodeObject (code);
1326+ }
13661327
13671328 // Continue here if InvokePrologue does handle the invocation due to
13681329 // mismatched parameter counts.
13691330 bind (&done);
1370- }
13711331}
13721332
1373- void MacroAssembler::InvokeFunction (Register fun, Register new_target,
1374- const ParameterCount& actual ,
1375- InvokeFlag flag) {
1333+ void MacroAssembler::InvokeFunctionWithNewTarget (
1334+ Register fun, Register new_target, Register actual_parameter_count ,
1335+ InvokeFlag flag) {
13761336 // You can't call a function without a valid frame.
1377- DCHECK (flag == JUMP_FUNCTION || has_frame ());
1337+ DCHECK_IMPLIES (flag == CALL_FUNCTION , has_frame ());
13781338
13791339 // Contract with called JS functions requires that function is passed in r4.
1380- DCHECK (fun == r4);
1340+ DCHECK_EQ (fun, r4);
13811341
13821342 Register expected_reg = r5;
13831343 Register temp_reg = r7;
@@ -1388,24 +1348,25 @@ void MacroAssembler::InvokeFunction(Register fun, Register new_target,
13881348 FieldMemOperand (
13891349 temp_reg, SharedFunctionInfo::kFormalParameterCountOffset ));
13901350
1391- ParameterCount expected ( expected_reg);
1392- InvokeFunctionCode (fun, new_target, expected, actual, flag);
1351+ InvokeFunctionCode (fun, new_target, expected_reg, actual_parameter_count,
1352+ flag);
13931353}
13941354
13951355void MacroAssembler::InvokeFunction (Register function,
1396- const ParameterCount& expected ,
1397- const ParameterCount& actual ,
1356+ Register expected_parameter_count ,
1357+ Register actual_parameter_count ,
13981358 InvokeFlag flag) {
13991359 // You can't call a function without a valid frame.
1400- DCHECK (flag == JUMP_FUNCTION || has_frame ());
1360+ DCHECK_IMPLIES (flag == CALL_FUNCTION , has_frame ());
14011361
14021362 // Contract with called JS functions requires that function is passed in r4.
1403- DCHECK (function == r4);
1363+ DCHECK_EQ (function, r4);
14041364
14051365 // Get the function and setup the context.
14061366 LoadP (cp, FieldMemOperand (r4, JSFunction::kContextOffset ));
14071367
1408- InvokeFunctionCode (r4, no_reg, expected, actual, flag);
1368+ InvokeFunctionCode (r4, no_reg, expected_parameter_count,
1369+ actual_parameter_count, flag);
14091370}
14101371
14111372void MacroAssembler::MaybeDropFrames () {
0 commit comments