| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 | 935 |
| 936 // Call the function. | 936 // Call the function. |
| 937 // a0: number of arguments | 937 // a0: number of arguments |
| 938 // a1: constructor function | 938 // a1: constructor function |
| 939 if (is_api_function) { | 939 if (is_api_function) { |
| 940 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 940 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
| 941 Handle<Code> code = | 941 Handle<Code> code = |
| 942 masm->isolate()->builtins()->HandleApiCallConstruct(); | 942 masm->isolate()->builtins()->HandleApiCallConstruct(); |
| 943 ParameterCount expected(0); | 943 ParameterCount expected(0); |
| 944 __ InvokeCode(code, expected, expected, | 944 __ InvokeCode(code, expected, expected, |
| 945 RelocInfo::CODE_TARGET, CALL_FUNCTION); | 945 RelocInfo::CODE_TARGET, CALL_FUNCTION, CALL_AS_METHOD); |
| 946 } else { | 946 } else { |
| 947 ParameterCount actual(a0); | 947 ParameterCount actual(a0); |
| 948 __ InvokeFunction(a1, actual, CALL_FUNCTION); | 948 __ InvokeFunction(a1, actual, CALL_FUNCTION, |
| 949 NullCallWrapper(), CALL_AS_METHOD); |
| 949 } | 950 } |
| 950 | 951 |
| 951 // Pop the function from the stack. | 952 // Pop the function from the stack. |
| 952 // v0: result | 953 // v0: result |
| 953 // sp[0]: constructor function | 954 // sp[0]: constructor function |
| 954 // sp[2]: receiver | 955 // sp[2]: receiver |
| 955 // sp[3]: constructor function | 956 // sp[3]: constructor function |
| 956 // sp[4]: number of arguments (smi-tagged) | 957 // sp[4]: number of arguments (smi-tagged) |
| 957 __ Pop(); | 958 __ Pop(); |
| 958 | 959 |
| 959 // Restore context from the frame. | 960 // Restore context from the frame. |
| 960 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 961 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 961 | 962 |
| 962 // If the result is an object (in the ECMA sense), we should get rid | 963 // If the result is an object (in the ECMA sense), we should get rid |
| 963 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 964 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
| 964 // on page 74. | 965 // on page 74. |
| 965 Label use_receiver, exit; | 966 Label use_receiver, exit; |
| 966 | 967 |
| 967 // If the result is a smi, it is *not* an object in the ECMA sense. | 968 // If the result is a smi, it is *not* an object in the ECMA sense. |
| 968 // v0: result | 969 // v0: result |
| 969 // sp[0]: receiver (newly allocated object) | 970 // sp[0]: receiver (newly allocated object) |
| 970 // sp[1]: constructor function | 971 // sp[1]: constructor function |
| 971 // sp[2]: number of arguments (smi-tagged) | 972 // sp[2]: number of arguments (smi-tagged) |
| 972 __ And(t0, v0, Operand(kSmiTagMask)); | 973 __ And(t0, v0, Operand(kSmiTagMask)); |
| 973 __ Branch(&use_receiver, eq, t0, Operand(zero_reg)); | 974 __ Branch(&use_receiver, eq, t0, Operand(zero_reg)); |
| 974 | 975 |
| 975 // If the type of the result (stored in its map) is less than | 976 // If the type of the result (stored in its map) is less than |
| 976 // FIRST_JS_OBJECT_TYPE, it is not an object in the ECMA sense. | 977 // FIRST_SPEC_OBJECT_TYPE, it is not an object in the ECMA sense. |
| 977 __ GetObjectType(v0, a3, a3); | 978 __ GetObjectType(v0, a3, a3); |
| 978 __ Branch(&exit, greater_equal, a3, Operand(FIRST_JS_OBJECT_TYPE)); | 979 __ Branch(&exit, greater_equal, a3, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 979 | 980 |
| 980 // Throw away the result of the constructor invocation and use the | 981 // Throw away the result of the constructor invocation and use the |
| 981 // on-stack receiver as the result. | 982 // on-stack receiver as the result. |
| 982 __ bind(&use_receiver); | 983 __ bind(&use_receiver); |
| 983 __ lw(v0, MemOperand(sp)); | 984 __ lw(v0, MemOperand(sp)); |
| 984 | 985 |
| 985 // Remove receiver from the stack, remove caller arguments, and | 986 // Remove receiver from the stack, remove caller arguments, and |
| 986 // return. | 987 // return. |
| 987 __ bind(&exit); | 988 __ bind(&exit); |
| 988 // v0: result | 989 // v0: result |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 // s6 holds the root address. Do not clobber. | 1072 // s6 holds the root address. Do not clobber. |
| 1072 // s7 is cp. Do not init. | 1073 // s7 is cp. Do not init. |
| 1073 | 1074 |
| 1074 // Invoke the code and pass argc as a0. | 1075 // Invoke the code and pass argc as a0. |
| 1075 __ mov(a0, a3); | 1076 __ mov(a0, a3); |
| 1076 if (is_construct) { | 1077 if (is_construct) { |
| 1077 __ Call(masm->isolate()->builtins()->JSConstructCall(), | 1078 __ Call(masm->isolate()->builtins()->JSConstructCall(), |
| 1078 RelocInfo::CODE_TARGET); | 1079 RelocInfo::CODE_TARGET); |
| 1079 } else { | 1080 } else { |
| 1080 ParameterCount actual(a0); | 1081 ParameterCount actual(a0); |
| 1081 __ InvokeFunction(a1, actual, CALL_FUNCTION); | 1082 __ InvokeFunction(a1, actual, CALL_FUNCTION, |
| 1083 NullCallWrapper(), CALL_AS_METHOD); |
| 1082 } | 1084 } |
| 1083 | 1085 |
| 1084 __ LeaveInternalFrame(); | 1086 __ LeaveInternalFrame(); |
| 1085 | 1087 |
| 1086 __ Jump(ra); | 1088 __ Jump(ra); |
| 1087 } | 1089 } |
| 1088 | 1090 |
| 1089 | 1091 |
| 1090 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 1092 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
| 1091 Generate_JSEntryTrampolineHelper(masm, false); | 1093 Generate_JSEntryTrampolineHelper(masm, false); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 // a0: actual number of arguments | 1227 // a0: actual number of arguments |
| 1226 // a1: function | 1228 // a1: function |
| 1227 // a2: first argument | 1229 // a2: first argument |
| 1228 __ JumpIfSmi(a2, &convert_to_object, t2); | 1230 __ JumpIfSmi(a2, &convert_to_object, t2); |
| 1229 | 1231 |
| 1230 __ LoadRoot(a3, Heap::kUndefinedValueRootIndex); | 1232 __ LoadRoot(a3, Heap::kUndefinedValueRootIndex); |
| 1231 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); | 1233 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); |
| 1232 __ LoadRoot(a3, Heap::kNullValueRootIndex); | 1234 __ LoadRoot(a3, Heap::kNullValueRootIndex); |
| 1233 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); | 1235 __ Branch(&use_global_receiver, eq, a2, Operand(a3)); |
| 1234 | 1236 |
| 1235 STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE); | 1237 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 1236 STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | |
| 1237 __ GetObjectType(a2, a3, a3); | 1238 __ GetObjectType(a2, a3, a3); |
| 1238 __ Branch(&shift_arguments, ge, a3, Operand(FIRST_JS_OBJECT_TYPE)); | 1239 __ Branch(&shift_arguments, ge, a3, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 1239 | 1240 |
| 1240 __ bind(&convert_to_object); | 1241 __ bind(&convert_to_object); |
| 1241 __ EnterInternalFrame(); // In order to preserve argument count. | 1242 __ EnterInternalFrame(); // In order to preserve argument count. |
| 1242 __ sll(a0, a0, kSmiTagSize); // Smi tagged. | 1243 __ sll(a0, a0, kSmiTagSize); // Smi tagged. |
| 1243 __ push(a0); | 1244 __ push(a0); |
| 1244 | 1245 |
| 1245 __ push(a2); | 1246 __ push(a2); |
| 1246 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1247 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 1247 __ mov(a2, v0); | 1248 __ mov(a2, v0); |
| 1248 | 1249 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1331 __ lw(a2, | 1332 __ lw(a2, |
| 1332 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); | 1333 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1333 __ sra(a2, a2, kSmiTagSize); | 1334 __ sra(a2, a2, kSmiTagSize); |
| 1334 __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 1335 __ lw(a3, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
| 1335 __ SetCallKind(t1, CALL_AS_METHOD); | 1336 __ SetCallKind(t1, CALL_AS_METHOD); |
| 1336 // Check formal and actual parameter counts. | 1337 // Check formal and actual parameter counts. |
| 1337 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1338 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 1338 RelocInfo::CODE_TARGET, ne, a2, Operand(a0)); | 1339 RelocInfo::CODE_TARGET, ne, a2, Operand(a0)); |
| 1339 | 1340 |
| 1340 ParameterCount expected(0); | 1341 ParameterCount expected(0); |
| 1341 __ InvokeCode(a3, expected, expected, JUMP_FUNCTION); | 1342 __ InvokeCode(a3, expected, expected, JUMP_FUNCTION, |
| 1343 NullCallWrapper(), CALL_AS_METHOD); |
| 1342 } | 1344 } |
| 1343 | 1345 |
| 1344 | 1346 |
| 1345 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1347 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| 1346 const int kIndexOffset = -5 * kPointerSize; | 1348 const int kIndexOffset = -5 * kPointerSize; |
| 1347 const int kLimitOffset = -4 * kPointerSize; | 1349 const int kLimitOffset = -4 * kPointerSize; |
| 1348 const int kArgsOffset = 2 * kPointerSize; | 1350 const int kArgsOffset = 2 * kPointerSize; |
| 1349 const int kRecvOffset = 3 * kPointerSize; | 1351 const int kRecvOffset = 3 * kPointerSize; |
| 1350 const int kFunctionOffset = 4 * kPointerSize; | 1352 const int kFunctionOffset = 4 * kPointerSize; |
| 1351 | 1353 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1406 // Compute the receiver in non-strict mode. | 1408 // Compute the receiver in non-strict mode. |
| 1407 __ And(t0, a0, Operand(kSmiTagMask)); | 1409 __ And(t0, a0, Operand(kSmiTagMask)); |
| 1408 __ Branch(&call_to_object, eq, t0, Operand(zero_reg)); | 1410 __ Branch(&call_to_object, eq, t0, Operand(zero_reg)); |
| 1409 __ LoadRoot(a1, Heap::kNullValueRootIndex); | 1411 __ LoadRoot(a1, Heap::kNullValueRootIndex); |
| 1410 __ Branch(&use_global_receiver, eq, a0, Operand(a1)); | 1412 __ Branch(&use_global_receiver, eq, a0, Operand(a1)); |
| 1411 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 1413 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
| 1412 __ Branch(&use_global_receiver, eq, a0, Operand(a2)); | 1414 __ Branch(&use_global_receiver, eq, a0, Operand(a2)); |
| 1413 | 1415 |
| 1414 // Check if the receiver is already a JavaScript object. | 1416 // Check if the receiver is already a JavaScript object. |
| 1415 // a0: receiver | 1417 // a0: receiver |
| 1416 STATIC_ASSERT(LAST_JS_OBJECT_TYPE + 1 == LAST_TYPE); | 1418 STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); |
| 1417 STATIC_ASSERT(LAST_TYPE == JS_FUNCTION_TYPE); | |
| 1418 __ GetObjectType(a0, a1, a1); | 1419 __ GetObjectType(a0, a1, a1); |
| 1419 __ Branch(&push_receiver, ge, a1, Operand(FIRST_JS_OBJECT_TYPE)); | 1420 __ Branch(&push_receiver, ge, a1, Operand(FIRST_SPEC_OBJECT_TYPE)); |
| 1420 | 1421 |
| 1421 // Convert the receiver to a regular object. | 1422 // Convert the receiver to a regular object. |
| 1422 // a0: receiver | 1423 // a0: receiver |
| 1423 __ bind(&call_to_object); | 1424 __ bind(&call_to_object); |
| 1424 __ push(a0); | 1425 __ push(a0); |
| 1425 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); | 1426 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); |
| 1426 __ mov(a0, v0); // Put object in a0 to match other paths to push_receiver. | 1427 __ mov(a0, v0); // Put object in a0 to match other paths to push_receiver. |
| 1427 __ Branch(&push_receiver); | 1428 __ Branch(&push_receiver); |
| 1428 | 1429 |
| 1429 // Use the current global receiver object as the receiver. | 1430 // Use the current global receiver object as the receiver. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1464 | 1465 |
| 1465 // Test if the copy loop has finished copying all the elements from the | 1466 // Test if the copy loop has finished copying all the elements from the |
| 1466 // arguments object. | 1467 // arguments object. |
| 1467 __ bind(&entry); | 1468 __ bind(&entry); |
| 1468 __ lw(a1, MemOperand(fp, kLimitOffset)); | 1469 __ lw(a1, MemOperand(fp, kLimitOffset)); |
| 1469 __ Branch(&loop, ne, a0, Operand(a1)); | 1470 __ Branch(&loop, ne, a0, Operand(a1)); |
| 1470 // Invoke the function. | 1471 // Invoke the function. |
| 1471 ParameterCount actual(a0); | 1472 ParameterCount actual(a0); |
| 1472 __ sra(a0, a0, kSmiTagSize); | 1473 __ sra(a0, a0, kSmiTagSize); |
| 1473 __ lw(a1, MemOperand(fp, kFunctionOffset)); | 1474 __ lw(a1, MemOperand(fp, kFunctionOffset)); |
| 1474 __ InvokeFunction(a1, actual, CALL_FUNCTION); | 1475 __ InvokeFunction(a1, actual, CALL_FUNCTION, |
| 1476 NullCallWrapper(), CALL_AS_METHOD); |
| 1475 | 1477 |
| 1476 // Tear down the internal frame and remove function, receiver and args. | 1478 // Tear down the internal frame and remove function, receiver and args. |
| 1477 __ LeaveInternalFrame(); | 1479 __ LeaveInternalFrame(); |
| 1478 __ Addu(sp, sp, Operand(3 * kPointerSize)); | 1480 __ Addu(sp, sp, Operand(3 * kPointerSize)); |
| 1479 __ Ret(); | 1481 __ Ret(); |
| 1480 } | 1482 } |
| 1481 | 1483 |
| 1482 | 1484 |
| 1483 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1485 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
| 1484 __ sll(a0, a0, kSmiTagSize); | 1486 __ sll(a0, a0, kSmiTagSize); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1564 // Calculate copy start address into a0 and copy end address is fp. | 1566 // Calculate copy start address into a0 and copy end address is fp. |
| 1565 // a0: actual number of arguments as a smi | 1567 // a0: actual number of arguments as a smi |
| 1566 // a1: function | 1568 // a1: function |
| 1567 // a2: expected number of arguments | 1569 // a2: expected number of arguments |
| 1568 // a3: code entry to call | 1570 // a3: code entry to call |
| 1569 __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize); | 1571 __ sll(a0, a0, kPointerSizeLog2 - kSmiTagSize); |
| 1570 __ Addu(a0, fp, a0); | 1572 __ Addu(a0, fp, a0); |
| 1571 // Adjust for return address and receiver. | 1573 // Adjust for return address and receiver. |
| 1572 __ Addu(a0, a0, Operand(2 * kPointerSize)); | 1574 __ Addu(a0, a0, Operand(2 * kPointerSize)); |
| 1573 // Compute copy end address. Also adjust for return address. | 1575 // Compute copy end address. Also adjust for return address. |
| 1574 __ Addu(t1, fp, kPointerSize); | 1576 __ Addu(t3, fp, kPointerSize); |
| 1575 | 1577 |
| 1576 // Copy the arguments (including the receiver) to the new stack frame. | 1578 // Copy the arguments (including the receiver) to the new stack frame. |
| 1577 // a0: copy start address | 1579 // a0: copy start address |
| 1578 // a1: function | 1580 // a1: function |
| 1579 // a2: expected number of arguments | 1581 // a2: expected number of arguments |
| 1580 // a3: code entry to call | 1582 // a3: code entry to call |
| 1581 // t1: copy end address | 1583 // t3: copy end address |
| 1582 Label copy; | 1584 Label copy; |
| 1583 __ bind(©); | 1585 __ bind(©); |
| 1584 __ lw(t0, MemOperand(a0)); // Adjusted above for return addr and receiver. | 1586 __ lw(t0, MemOperand(a0)); // Adjusted above for return addr and receiver. |
| 1585 __ push(t0); | 1587 __ push(t0); |
| 1586 __ Subu(a0, a0, kPointerSize); | 1588 __ Subu(a0, a0, kPointerSize); |
| 1587 __ Branch(©, ne, a0, Operand(t1)); | 1589 __ Branch(©, ne, a0, Operand(t3)); |
| 1588 | 1590 |
| 1589 // Fill the remaining expected arguments with undefined. | 1591 // Fill the remaining expected arguments with undefined. |
| 1590 // a1: function | 1592 // a1: function |
| 1591 // a2: expected number of arguments | 1593 // a2: expected number of arguments |
| 1592 // a3: code entry to call | 1594 // a3: code entry to call |
| 1593 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); | 1595 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); |
| 1594 __ sll(t2, a2, kPointerSizeLog2); | 1596 __ sll(t2, a2, kPointerSizeLog2); |
| 1595 __ Subu(a2, fp, Operand(t2)); | 1597 __ Subu(a2, fp, Operand(t2)); |
| 1596 __ Addu(a2, a2, Operand(-4 * kPointerSize)); // Adjust for frame. | 1598 __ Addu(a2, a2, Operand(-4 * kPointerSize)); // Adjust for frame. |
| 1597 | 1599 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1617 __ bind(&dont_adapt_arguments); | 1619 __ bind(&dont_adapt_arguments); |
| 1618 __ Jump(a3); | 1620 __ Jump(a3); |
| 1619 } | 1621 } |
| 1620 | 1622 |
| 1621 | 1623 |
| 1622 #undef __ | 1624 #undef __ |
| 1623 | 1625 |
| 1624 } } // namespace v8::internal | 1626 } } // namespace v8::internal |
| 1625 | 1627 |
| 1626 #endif // V8_TARGET_ARCH_MIPS | 1628 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |