| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 ASSERT(cgen()->HasValidEntryRegisters()); | 923 ASSERT(cgen()->HasValidEntryRegisters()); |
| 924 ParameterCount count(arg_count); | 924 ParameterCount count(arg_count); |
| 925 __ InvokeFunction(edi, count, CALL_FUNCTION); | 925 __ InvokeFunction(edi, count, CALL_FUNCTION); |
| 926 RestoreContextRegister(); | 926 RestoreContextRegister(); |
| 927 Result result = cgen()->allocator()->Allocate(eax); | 927 Result result = cgen()->allocator()->Allocate(eax); |
| 928 ASSERT(result.is_valid()); | 928 ASSERT(result.is_valid()); |
| 929 return result; | 929 return result; |
| 930 } | 930 } |
| 931 | 931 |
| 932 | 932 |
| 933 Result VirtualFrame::CallRuntime(Runtime::Function* f, int arg_count) { | 933 Result VirtualFrame::CallRuntime(const Runtime::Function* f, int arg_count) { |
| 934 PrepareForCall(arg_count, arg_count); | 934 PrepareForCall(arg_count, arg_count); |
| 935 ASSERT(cgen()->HasValidEntryRegisters()); | 935 ASSERT(cgen()->HasValidEntryRegisters()); |
| 936 __ CallRuntime(f, arg_count); | 936 __ CallRuntime(f, arg_count); |
| 937 Result result = cgen()->allocator()->Allocate(eax); | 937 Result result = cgen()->allocator()->Allocate(eax); |
| 938 ASSERT(result.is_valid()); | 938 ASSERT(result.is_valid()); |
| 939 return result; | 939 return result; |
| 940 } | 940 } |
| 941 | 941 |
| 942 | 942 |
| 943 Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { | 943 Result VirtualFrame::CallRuntime(Runtime::FunctionId id, int arg_count) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 | 1008 |
| 1009 | 1009 |
| 1010 Result VirtualFrame::CallLoadIC(RelocInfo::Mode mode) { | 1010 Result VirtualFrame::CallLoadIC(RelocInfo::Mode mode) { |
| 1011 // Name and receiver are on the top of the frame. The IC expects | 1011 // Name and receiver are on the top of the frame. The IC expects |
| 1012 // name in ecx and receiver in eax. | 1012 // name in ecx and receiver in eax. |
| 1013 Result name = Pop(); | 1013 Result name = Pop(); |
| 1014 Result receiver = Pop(); | 1014 Result receiver = Pop(); |
| 1015 PrepareForCall(0, 0); // No stack arguments. | 1015 PrepareForCall(0, 0); // No stack arguments. |
| 1016 MoveResultsToRegisters(&name, &receiver, ecx, eax); | 1016 MoveResultsToRegisters(&name, &receiver, ecx, eax); |
| 1017 | 1017 |
| 1018 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 1018 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1019 Builtins::LoadIC_Initialize)); |
| 1019 return RawCallCodeObject(ic, mode); | 1020 return RawCallCodeObject(ic, mode); |
| 1020 } | 1021 } |
| 1021 | 1022 |
| 1022 | 1023 |
| 1023 Result VirtualFrame::CallKeyedLoadIC(RelocInfo::Mode mode) { | 1024 Result VirtualFrame::CallKeyedLoadIC(RelocInfo::Mode mode) { |
| 1024 // Key and receiver are on top of the frame. Put them in eax and edx. | 1025 // Key and receiver are on top of the frame. Put them in eax and edx. |
| 1025 Result key = Pop(); | 1026 Result key = Pop(); |
| 1026 Result receiver = Pop(); | 1027 Result receiver = Pop(); |
| 1027 PrepareForCall(0, 0); | 1028 PrepareForCall(0, 0); |
| 1028 MoveResultsToRegisters(&key, &receiver, eax, edx); | 1029 MoveResultsToRegisters(&key, &receiver, eax, edx); |
| 1029 | 1030 |
| 1030 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 1031 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1032 Builtins::KeyedLoadIC_Initialize)); |
| 1031 return RawCallCodeObject(ic, mode); | 1033 return RawCallCodeObject(ic, mode); |
| 1032 } | 1034 } |
| 1033 | 1035 |
| 1034 | 1036 |
| 1035 Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) { | 1037 Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) { |
| 1036 // Value and (if not contextual) receiver are on top of the frame. | 1038 // Value and (if not contextual) receiver are on top of the frame. |
| 1037 // The IC expects name in ecx, value in eax, and receiver in edx. | 1039 // The IC expects name in ecx, value in eax, and receiver in edx. |
| 1038 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 1040 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1041 Builtins::StoreIC_Initialize)); |
| 1039 Result value = Pop(); | 1042 Result value = Pop(); |
| 1040 if (is_contextual) { | 1043 if (is_contextual) { |
| 1041 PrepareForCall(0, 0); | 1044 PrepareForCall(0, 0); |
| 1042 value.ToRegister(eax); | 1045 value.ToRegister(eax); |
| 1043 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1046 __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1044 value.Unuse(); | 1047 value.Unuse(); |
| 1045 } else { | 1048 } else { |
| 1046 Result receiver = Pop(); | 1049 Result receiver = Pop(); |
| 1047 PrepareForCall(0, 0); | 1050 PrepareForCall(0, 0); |
| 1048 MoveResultsToRegisters(&value, &receiver, eax, edx); | 1051 MoveResultsToRegisters(&value, &receiver, eax, edx); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 __ xchg(eax, ecx); | 1092 __ xchg(eax, ecx); |
| 1090 } else { | 1093 } else { |
| 1091 __ xchg(eax, ecx); | 1094 __ xchg(eax, ecx); |
| 1092 __ xchg(eax, edx); | 1095 __ xchg(eax, edx); |
| 1093 } | 1096 } |
| 1094 value.Unuse(); | 1097 value.Unuse(); |
| 1095 key.Unuse(); | 1098 key.Unuse(); |
| 1096 receiver.Unuse(); | 1099 receiver.Unuse(); |
| 1097 } | 1100 } |
| 1098 | 1101 |
| 1099 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 1102 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1103 Builtins::KeyedStoreIC_Initialize)); |
| 1100 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); | 1104 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); |
| 1101 } | 1105 } |
| 1102 | 1106 |
| 1103 | 1107 |
| 1104 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, | 1108 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, |
| 1105 int arg_count, | 1109 int arg_count, |
| 1106 int loop_nesting) { | 1110 int loop_nesting) { |
| 1107 // Function name, arguments, and receiver are on top of the frame. | 1111 // Function name, arguments, and receiver are on top of the frame. |
| 1108 // The IC expects the name in ecx and the rest on the stack and | 1112 // The IC expects the name in ecx and the rest on the stack and |
| 1109 // drops them all. | 1113 // drops them all. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1134 name.ToRegister(ecx); | 1138 name.ToRegister(ecx); |
| 1135 name.Unuse(); | 1139 name.Unuse(); |
| 1136 return RawCallCodeObject(ic, mode); | 1140 return RawCallCodeObject(ic, mode); |
| 1137 } | 1141 } |
| 1138 | 1142 |
| 1139 | 1143 |
| 1140 Result VirtualFrame::CallConstructor(int arg_count) { | 1144 Result VirtualFrame::CallConstructor(int arg_count) { |
| 1141 // Arguments, receiver, and function are on top of the frame. The | 1145 // Arguments, receiver, and function are on top of the frame. The |
| 1142 // IC expects arg count in eax, function in edi, and the arguments | 1146 // IC expects arg count in eax, function in edi, and the arguments |
| 1143 // and receiver on the stack. | 1147 // and receiver on the stack. |
| 1144 Handle<Code> ic(Builtins::builtin(Builtins::JSConstructCall)); | 1148 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1149 Builtins::JSConstructCall)); |
| 1145 // Duplicate the function before preparing the frame. | 1150 // Duplicate the function before preparing the frame. |
| 1146 PushElementAt(arg_count + 1); | 1151 PushElementAt(arg_count + 1); |
| 1147 Result function = Pop(); | 1152 Result function = Pop(); |
| 1148 PrepareForCall(arg_count + 1, arg_count + 1); // Spill args and receiver. | 1153 PrepareForCall(arg_count + 1, arg_count + 1); // Spill args and receiver. |
| 1149 function.ToRegister(edi); | 1154 function.ToRegister(edi); |
| 1150 | 1155 |
| 1151 // Constructors are called with the number of arguments in register | 1156 // Constructors are called with the number of arguments in register |
| 1152 // eax for now. Another option would be to have separate construct | 1157 // eax for now. Another option would be to have separate construct |
| 1153 // call trampolines per different arguments counts encountered. | 1158 // call trampolines per different arguments counts encountered. |
| 1154 Result num_args = cgen()->allocator()->Allocate(eax); | 1159 Result num_args = cgen()->allocator()->Allocate(eax); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 } | 1330 } |
| 1326 UNREACHABLE(); | 1331 UNREACHABLE(); |
| 1327 } | 1332 } |
| 1328 | 1333 |
| 1329 | 1334 |
| 1330 #undef __ | 1335 #undef __ |
| 1331 | 1336 |
| 1332 } } // namespace v8::internal | 1337 } } // namespace v8::internal |
| 1333 | 1338 |
| 1334 #endif // V8_TARGET_ARCH_IA32 | 1339 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |