| 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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 Result receiver = Pop(); | 1132 Result receiver = Pop(); |
| 1115 PrepareForCall(0, 0); | 1133 PrepareForCall(0, 0); |
| 1116 MoveResultsToRegisters(&key, &receiver, rax, rdx); | 1134 MoveResultsToRegisters(&key, &receiver, rax, rdx); |
| 1117 | 1135 |
| 1118 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 1136 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1119 Builtins::KeyedLoadIC_Initialize)); | 1137 Builtins::KeyedLoadIC_Initialize)); |
| 1120 return RawCallCodeObject(ic, mode); | 1138 return RawCallCodeObject(ic, mode); |
| 1121 } | 1139 } |
| 1122 | 1140 |
| 1123 | 1141 |
| 1124 Result VirtualFrame::CallStoreIC(Handle<String> name, bool is_contextual) { | 1142 Result VirtualFrame::CallStoreIC(Handle<String> name, |
| 1143 bool is_contextual, |
| 1144 StrictModeFlag strict_mode) { |
| 1125 // Value and (if not contextual) receiver are on top of the frame. | 1145 // 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. | 1146 // The IC expects name in rcx, value in rax, and receiver in rdx. |
| 1127 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 1147 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1128 Builtins::StoreIC_Initialize)); | 1148 (strict_mode == kStrictMode) ? Builtins::StoreIC_Initialize_Strict |
| 1149 : Builtins::StoreIC_Initialize)); |
| 1129 Result value = Pop(); | 1150 Result value = Pop(); |
| 1151 RelocInfo::Mode mode; |
| 1130 if (is_contextual) { | 1152 if (is_contextual) { |
| 1131 PrepareForCall(0, 0); | 1153 PrepareForCall(0, 0); |
| 1132 value.ToRegister(rax); | 1154 value.ToRegister(rax); |
| 1133 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); | 1155 __ movq(rdx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 1134 value.Unuse(); | 1156 value.Unuse(); |
| 1157 mode = RelocInfo::CODE_TARGET_CONTEXT; |
| 1135 } else { | 1158 } else { |
| 1136 Result receiver = Pop(); | 1159 Result receiver = Pop(); |
| 1137 PrepareForCall(0, 0); | 1160 PrepareForCall(0, 0); |
| 1138 MoveResultsToRegisters(&value, &receiver, rax, rdx); | 1161 MoveResultsToRegisters(&value, &receiver, rax, rdx); |
| 1162 mode = RelocInfo::CODE_TARGET; |
| 1139 } | 1163 } |
| 1140 __ Move(rcx, name); | 1164 __ Move(rcx, name); |
| 1141 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); | 1165 return RawCallCodeObject(ic, mode); |
| 1142 } | 1166 } |
| 1143 | 1167 |
| 1144 | 1168 |
| 1145 Result VirtualFrame::CallKeyedStoreIC() { | 1169 Result VirtualFrame::CallKeyedStoreIC(StrictModeFlag strict_mode) { |
| 1146 // Value, key, and receiver are on the top of the frame. The IC | 1170 // Value, key, and receiver are on the top of the frame. The IC |
| 1147 // expects value in rax, key in rcx, and receiver in rdx. | 1171 // expects value in rax, key in rcx, and receiver in rdx. |
| 1148 Result value = Pop(); | 1172 Result value = Pop(); |
| 1149 Result key = Pop(); | 1173 Result key = Pop(); |
| 1150 Result receiver = Pop(); | 1174 Result receiver = Pop(); |
| 1151 PrepareForCall(0, 0); | 1175 PrepareForCall(0, 0); |
| 1152 if (!cgen()->allocator()->is_used(rax) || | 1176 if (!cgen()->allocator()->is_used(rax) || |
| 1153 (value.is_register() && value.reg().is(rax))) { | 1177 (value.is_register() && value.reg().is(rax))) { |
| 1154 if (!cgen()->allocator()->is_used(rax)) { | 1178 if (!cgen()->allocator()->is_used(rax)) { |
| 1155 value.ToRegister(rax); | 1179 value.ToRegister(rax); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1180 } else { | 1204 } else { |
| 1181 __ xchg(rax, rcx); | 1205 __ xchg(rax, rcx); |
| 1182 __ xchg(rax, rdx); | 1206 __ xchg(rax, rdx); |
| 1183 } | 1207 } |
| 1184 value.Unuse(); | 1208 value.Unuse(); |
| 1185 key.Unuse(); | 1209 key.Unuse(); |
| 1186 receiver.Unuse(); | 1210 receiver.Unuse(); |
| 1187 } | 1211 } |
| 1188 | 1212 |
| 1189 Handle<Code> ic(Isolate::Current()->builtins()->builtin( | 1213 Handle<Code> ic(Isolate::Current()->builtins()->builtin( |
| 1190 Builtins::KeyedStoreIC_Initialize)); | 1214 (strict_mode == kStrictMode) ? Builtins::KeyedStoreIC_Initialize_Strict |
| 1215 : Builtins::KeyedStoreIC_Initialize)); |
| 1191 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); | 1216 return RawCallCodeObject(ic, RelocInfo::CODE_TARGET); |
| 1192 } | 1217 } |
| 1193 | 1218 |
| 1194 | 1219 |
| 1195 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, | 1220 Result VirtualFrame::CallCallIC(RelocInfo::Mode mode, |
| 1196 int arg_count, | 1221 int arg_count, |
| 1197 int loop_nesting) { | 1222 int loop_nesting) { |
| 1198 // Function name, arguments, and receiver are found on top of the frame | 1223 // Function name, arguments, and receiver are found on top of the frame |
| 1199 // and dropped by the call. The IC expects the name in rcx and the rest | 1224 // and dropped by the call. The IC expects the name in rcx and the rest |
| 1200 // on the stack, and drops them all. | 1225 // on the stack, and drops them all. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 Adjust(kHandlerSize - 1); | 1287 Adjust(kHandlerSize - 1); |
| 1263 __ PushTryHandler(IN_JAVASCRIPT, type); | 1288 __ PushTryHandler(IN_JAVASCRIPT, type); |
| 1264 } | 1289 } |
| 1265 | 1290 |
| 1266 | 1291 |
| 1267 #undef __ | 1292 #undef __ |
| 1268 | 1293 |
| 1269 } } // namespace v8::internal | 1294 } } // namespace v8::internal |
| 1270 | 1295 |
| 1271 #endif // V8_TARGET_ARCH_X64 | 1296 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |