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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 __ Addu(a3, a3, Operand(-2)); | 622 __ Addu(a3, a3, Operand(-2)); |
623 __ Branch(&loop, greater_equal, a3, Operand(zero_reg)); | 623 __ Branch(&loop, greater_equal, a3, Operand(zero_reg)); |
624 | 624 |
625 // Call the function. | 625 // Call the function. |
626 // a0: number of arguments | 626 // a0: number of arguments |
627 // a1: constructor function | 627 // a1: constructor function |
628 if (is_api_function) { | 628 if (is_api_function) { |
629 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 629 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
630 Handle<Code> code = | 630 Handle<Code> code = |
631 masm->isolate()->builtins()->HandleApiCallConstruct(); | 631 masm->isolate()->builtins()->HandleApiCallConstruct(); |
632 ParameterCount expected(0); | 632 __ Call(code, RelocInfo::CODE_TARGET); |
633 __ InvokeCode(code, expected, expected, | |
634 RelocInfo::CODE_TARGET, CALL_FUNCTION); | |
635 } else { | 633 } else { |
636 ParameterCount actual(a0); | 634 ParameterCount actual(a0); |
637 __ InvokeFunction(a1, actual, CALL_FUNCTION, NullCallWrapper()); | 635 __ InvokeFunction(a1, actual, CALL_FUNCTION, NullCallWrapper()); |
638 } | 636 } |
639 | 637 |
640 // Store offset of return address for deoptimizer. | 638 // Store offset of return address for deoptimizer. |
641 if (!is_api_function && !count_constructions) { | 639 if (!is_api_function && !count_constructions) { |
642 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 640 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
643 } | 641 } |
644 | 642 |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 // a1: function | 1169 // a1: function |
1172 // t0: call type (0: JS function, 1: function proxy, 2: non-function) | 1170 // t0: call type (0: JS function, 1: function proxy, 2: non-function) |
1173 { Label function, non_proxy; | 1171 { Label function, non_proxy; |
1174 __ Branch(&function, eq, t0, Operand(zero_reg)); | 1172 __ Branch(&function, eq, t0, Operand(zero_reg)); |
1175 // Expected number of arguments is 0 for CALL_NON_FUNCTION. | 1173 // Expected number of arguments is 0 for CALL_NON_FUNCTION. |
1176 __ mov(a2, zero_reg); | 1174 __ mov(a2, zero_reg); |
1177 __ Branch(&non_proxy, ne, t0, Operand(1)); | 1175 __ Branch(&non_proxy, ne, t0, Operand(1)); |
1178 | 1176 |
1179 __ push(a1); // Re-add proxy object as additional argument. | 1177 __ push(a1); // Re-add proxy object as additional argument. |
1180 __ Addu(a0, a0, Operand(1)); | 1178 __ Addu(a0, a0, Operand(1)); |
1181 __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY); | 1179 __ GetBuiltinFunction(a1, Builtins::CALL_FUNCTION_PROXY); |
1182 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1180 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1183 RelocInfo::CODE_TARGET); | 1181 RelocInfo::CODE_TARGET); |
1184 | 1182 |
1185 __ bind(&non_proxy); | 1183 __ bind(&non_proxy); |
1186 __ GetBuiltinEntry(a3, Builtins::CALL_NON_FUNCTION); | 1184 __ GetBuiltinFunction(a1, Builtins::CALL_NON_FUNCTION); |
1187 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1185 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1188 RelocInfo::CODE_TARGET); | 1186 RelocInfo::CODE_TARGET); |
1189 __ bind(&function); | 1187 __ bind(&function); |
1190 } | 1188 } |
1191 | 1189 |
1192 // 5b. Get the code to call from the function and check that the number of | 1190 // 5b. Get the code to call from the function and check that the number of |
1193 // expected arguments matches what we're providing. If so, jump | 1191 // expected arguments matches what we're providing. If so, jump |
1194 // (tail-call) to the code in register edx without checking arguments. | 1192 // (tail-call) to the code in register edx without checking arguments. |
1195 // a0: actual number of arguments | 1193 // a0: actual number of arguments |
1196 // a1: function | 1194 // a1: function |
1197 __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1195 __ lw(a3, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1198 __ lw(a2, | 1196 __ lw(a2, |
1199 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); | 1197 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); |
1200 __ sra(a2, a2, kSmiTagSize); | 1198 __ sra(a2, a2, kSmiTagSize); |
1201 __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | |
1202 // Check formal and actual parameter counts. | 1199 // Check formal and actual parameter counts. |
1203 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1200 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1204 RelocInfo::CODE_TARGET, ne, a2, Operand(a0)); | 1201 RelocInfo::CODE_TARGET, ne, a2, Operand(a0)); |
1205 | 1202 |
| 1203 __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
1206 ParameterCount expected(0); | 1204 ParameterCount expected(0); |
1207 __ InvokeCode(a3, expected, expected, JUMP_FUNCTION, NullCallWrapper()); | 1205 __ InvokeCode(a3, expected, expected, JUMP_FUNCTION, NullCallWrapper()); |
1208 } | 1206 } |
1209 | 1207 |
1210 | 1208 |
1211 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1209 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
1212 const int kIndexOffset = | 1210 const int kIndexOffset = |
1213 StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize); | 1211 StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize); |
1214 const int kLimitOffset = | 1212 const int kLimitOffset = |
1215 StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize); | 1213 StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 | 1343 |
1346 frame_scope.GenerateLeaveFrame(); | 1344 frame_scope.GenerateLeaveFrame(); |
1347 __ Ret(USE_DELAY_SLOT); | 1345 __ Ret(USE_DELAY_SLOT); |
1348 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. | 1346 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. |
1349 | 1347 |
1350 // Call the function proxy. | 1348 // Call the function proxy. |
1351 __ bind(&call_proxy); | 1349 __ bind(&call_proxy); |
1352 __ push(a1); // Add function proxy as last argument. | 1350 __ push(a1); // Add function proxy as last argument. |
1353 __ Addu(a0, a0, Operand(1)); | 1351 __ Addu(a0, a0, Operand(1)); |
1354 __ li(a2, Operand(0, RelocInfo::NONE32)); | 1352 __ li(a2, Operand(0, RelocInfo::NONE32)); |
1355 __ GetBuiltinEntry(a3, Builtins::CALL_FUNCTION_PROXY); | 1353 __ GetBuiltinFunction(a1, Builtins::CALL_FUNCTION_PROXY); |
1356 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1354 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1357 RelocInfo::CODE_TARGET); | 1355 RelocInfo::CODE_TARGET); |
1358 // Tear down the internal frame and remove function, receiver and args. | 1356 // Tear down the internal frame and remove function, receiver and args. |
1359 } | 1357 } |
1360 | 1358 |
1361 __ Ret(USE_DELAY_SLOT); | 1359 __ Ret(USE_DELAY_SLOT); |
1362 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. | 1360 __ Addu(sp, sp, Operand(3 * kPointerSize)); // In delay slot. |
1363 } | 1361 } |
1364 | 1362 |
1365 | 1363 |
(...skipping 22 matching lines...) Expand all Loading... |
1388 __ Addu(sp, sp, Operand(kPointerSize)); | 1386 __ Addu(sp, sp, Operand(kPointerSize)); |
1389 } | 1387 } |
1390 | 1388 |
1391 | 1389 |
1392 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1390 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
1393 // State setup as expected by MacroAssembler::InvokePrologue. | 1391 // State setup as expected by MacroAssembler::InvokePrologue. |
1394 // ----------- S t a t e ------------- | 1392 // ----------- S t a t e ------------- |
1395 // -- a0: actual arguments count | 1393 // -- a0: actual arguments count |
1396 // -- a1: function (passed through to callee) | 1394 // -- a1: function (passed through to callee) |
1397 // -- a2: expected arguments count | 1395 // -- a2: expected arguments count |
1398 // -- a3: callee code entry | |
1399 // ----------------------------------- | 1396 // ----------------------------------- |
1400 | 1397 |
1401 Label invoke, dont_adapt_arguments; | 1398 Label invoke, dont_adapt_arguments; |
1402 | 1399 |
1403 Label enough, too_few; | 1400 Label enough, too_few; |
| 1401 __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
1404 __ Branch(&dont_adapt_arguments, eq, | 1402 __ Branch(&dont_adapt_arguments, eq, |
1405 a2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 1403 a2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
1406 // We use Uless as the number of argument should always be greater than 0. | 1404 // We use Uless as the number of argument should always be greater than 0. |
1407 __ Branch(&too_few, Uless, a0, Operand(a2)); | 1405 __ Branch(&too_few, Uless, a0, Operand(a2)); |
1408 | 1406 |
1409 { // Enough parameters: actual >= expected. | 1407 { // Enough parameters: actual >= expected. |
1410 // a0: actual number of arguments as a smi | 1408 // a0: actual number of arguments as a smi |
1411 // a1: function | 1409 // a1: function |
1412 // a2: expected number of arguments | 1410 // a2: expected number of arguments |
1413 // a3: code entry to call | 1411 // a3: code entry to call |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 __ bind(&dont_adapt_arguments); | 1504 __ bind(&dont_adapt_arguments); |
1507 __ Jump(a3); | 1505 __ Jump(a3); |
1508 } | 1506 } |
1509 | 1507 |
1510 | 1508 |
1511 #undef __ | 1509 #undef __ |
1512 | 1510 |
1513 } } // namespace v8::internal | 1511 } } // namespace v8::internal |
1514 | 1512 |
1515 #endif // V8_TARGET_ARCH_MIPS | 1513 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |