| OLD | NEW |
| 1 // Copyright 2010 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 if (slot->type() == Slot::PARAMETER) { | 268 if (slot->type() == Slot::PARAMETER) { |
| 269 PushParameterAt(slot->index()); | 269 PushParameterAt(slot->index()); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 UNREACHABLE(); | 273 UNREACHABLE(); |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 void VirtualFrame::Push(Handle<Object> value) { |
| 278 if (ConstantPoolOverflowed()) { |
| 279 Result temp = cgen()->allocator()->Allocate(); |
| 280 ASSERT(temp.is_valid()); |
| 281 if (value->IsSmi()) { |
| 282 __ Move(temp.reg(), Smi::cast(*value)); |
| 283 } else { |
| 284 __ movq(temp.reg(), value, RelocInfo::EMBEDDED_OBJECT); |
| 285 } |
| 286 Push(&temp); |
| 287 } else { |
| 288 FrameElement element = |
| 289 FrameElement::ConstantElement(value, FrameElement::NOT_SYNCED); |
| 290 elements_.Add(element); |
| 291 } |
| 292 } |
| 293 |
| 294 |
| 277 void VirtualFrame::Drop(int count) { | 295 void VirtualFrame::Drop(int count) { |
| 278 ASSERT(count >= 0); | 296 ASSERT(count >= 0); |
| 279 ASSERT(height() >= count); | 297 ASSERT(height() >= count); |
| 280 int num_virtual_elements = (element_count() - 1) - stack_pointer_; | 298 int num_virtual_elements = (element_count() - 1) - stack_pointer_; |
| 281 | 299 |
| 282 // Emit code to lower the stack pointer if necessary. | 300 // Emit code to lower the stack pointer if necessary. |
| 283 if (num_virtual_elements < count) { | 301 if (num_virtual_elements < count) { |
| 284 int num_dropped = count - num_virtual_elements; | 302 int num_dropped = count - num_virtual_elements; |
| 285 stack_pointer_ -= num_dropped; | 303 stack_pointer_ -= num_dropped; |
| 286 __ addq(rsp, Immediate(num_dropped * kPointerSize)); | 304 __ addq(rsp, Immediate(num_dropped * kPointerSize)); |
| (...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); | 1135 Handle<Code> ic(Builtins::builtin(Builtins::KeyedLoadIC_Initialize)); |
| 1118 return RawCallCodeObject(ic, mode); | 1136 return RawCallCodeObject(ic, mode); |
| 1119 } | 1137 } |
| 1120 | 1138 |
| 1121 | 1139 |
| 1122 Result VirtualFrame::CallStoreIC(Handle<String> name, | 1140 Result VirtualFrame::CallStoreIC(Handle<String> name, |
| 1123 bool is_contextual, | 1141 bool is_contextual, |
| 1124 StrictModeFlag strict_mode) { | 1142 StrictModeFlag strict_mode) { |
| 1125 // Value and (if not contextual) receiver are on top of the frame. | 1143 // Value and (if not contextual) receiver are on top of the frame. |
| 1126 // The IC expects name in rcx, value in rax, and receiver in rdx. | 1144 // The IC expects name in rcx, value in rax, and receiver in rdx. |
| 1127 Handle<Code> ic(Builtins::builtin(strict_mode == kStrictMode | 1145 Handle<Code> ic(Builtins::builtin( |
| 1128 ? Builtins::StoreIC_Initialize_Strict | 1146 (strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict |
| 1129 : Builtins::StoreIC_Initialize)); | 1147 : Builtins::StoreIC_Initialize)); |
| 1130 Result value = Pop(); | 1148 Result value = Pop(); |
| 1131 RelocInfo::Mode mode; | 1149 RelocInfo::Mode mode; |
| 1132 if (is_contextual) { | 1150 if (is_contextual) { |
| 1133 PrepareForCall(0, 0); | 1151 PrepareForCall(0, 0); |
| 1134 value.ToRegister(rax); | 1152 value.ToRegister(rax); |
| 1135 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1153 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1136 value.Unuse(); | 1154 value.Unuse(); |
| 1137 mode = RelocInfo::CODE_TARGET_CONTEXT; | 1155 mode = RelocInfo::CODE_TARGET_CONTEXT; |
| 1138 } else { | 1156 } else { |
| 1139 Result receiver = Pop(); | 1157 Result receiver = Pop(); |
| 1140 PrepareForCall(0, 0); | 1158 PrepareForCall(0, 0); |
| 1141 MoveResultsToRegisters(&value, &receiver, rax, rdx); | 1159 MoveResultsToRegisters(&value, &receiver, rax, rdx); |
| 1142 mode = RelocInfo::CODE_TARGET; | 1160 mode = RelocInfo::CODE_TARGET; |
| 1143 } | 1161 } |
| 1144 __ Move(rcx, name); | 1162 __ Move(rcx, name); |
| 1145 return RawCallCodeObject(ic, mode); | 1163 return RawCallCodeObject(ic, mode); |
| 1146 } | 1164 } |
| 1147 | 1165 |
| 1148 | 1166 |
| 1149 Result VirtualFrame::CallKeyedStoreIC() { | 1167 Result VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) { |
| 1150 // Value, key, and receiver are on the top of the frame. The IC | 1168 // Value, key, and receiver are on the top of the frame. The IC |
| 1151 // expects value in rax, key in rcx, and receiver in rdx. | 1169 // expects value in rax, key in rcx, and receiver in rdx. |
| 1152 Result value = Pop(); | 1170 Result value = Pop(); |
| 1153 Result key = Pop(); | 1171 Result key = Pop(); |
| 1154 Result receiver = Pop(); | 1172 Result receiver = Pop(); |
| 1155 PrepareForCall(0, 0); | 1173 PrepareForCall(0, 0); |
| 1156 if (!cgen()->allocator()->is_used(rax) || | 1174 if (!cgen()->allocator()->is_used(rax) || |
| 1157 (value.is_register() && value.reg().is(rax))) { | 1175 (value.is_register() && value.reg().is(rax))) { |
| 1158 if (!cgen()->allocator()->is_used(rax)) { | 1176 if (!cgen()->allocator()->is_used(rax)) { |
| 1159 value.ToRegister(rax); | 1177 value.ToRegister(rax); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1183 __ xchg(rax, rcx); | 1201 __ xchg(rax, rcx); |
| 1184 } else { | 1202 } else { |
| 1185 __ xchg(rax, rcx); | 1203 __ xchg(rax, rcx); |
| 1186 __ xchg(rax, rdx); | 1204 __ xchg(rax, rdx); |
| 1187 } | 1205 } |
| 1188 value.Unuse(); | 1206 value.Unuse(); |
| 1189 key.Unuse(); | 1207 key.Unuse(); |
| 1190 receiver.Unuse(); | 1208 receiver.Unuse(); |
| 1191 } | 1209 } |
| 1192 | 1210 |
| 1193 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 1211 Handle<Code> ic(Builtins::builtin( |
| 1212 (strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict |
| 1213 : Builtins::KeyedStoreIC_Initialize)); |
| 1194 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); | 1214 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); |
| 1195 } | 1215 } |
| 1196 | 1216 |
| 1197 | 1217 |
| 1198 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, | 1218 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, |
| 1199 int arg_count, | 1219 int arg_count, |
| 1200 int loop_nesting) { | 1220 int loop_nesting) { |
| 1201 // Function name, arguments, and receiver are found on top of the frame | 1221 // Function name, arguments, and receiver are found on top of the frame |
| 1202 // and dropped by the call. The IC expects the name in rcx and the rest | 1222 // and dropped by the call. The IC expects the name in rcx and the rest |
| 1203 // on the stack, and drops them all. | 1223 // on the stack, and drops them all. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 Adjust(kHandlerSize - 1); | 1283 Adjust(kHandlerSize - 1); |
| 1264 __ PushTryHandler(IN_JAVASCRIPT, type); | 1284 __ PushTryHandler(IN_JAVASCRIPT, type); |
| 1265 } | 1285 } |
| 1266 | 1286 |
| 1267 | 1287 |
| 1268 #undef __ | 1288 #undef __ |
| 1269 | 1289 |
| 1270 } } // namespace v8::internal | 1290 } } // namespace v8::internal |
| 1271 | 1291 |
| 1272 #endif // V8_TARGET_ARCH_X64 | 1292 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |