OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/interpreter/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // | 177 // |
178 // Store accumulator to register <dst>. | 178 // Store accumulator to register <dst>. |
179 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { | 179 void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) { |
180 Node* reg_index = __ BytecodeOperandReg8(0); | 180 Node* reg_index = __ BytecodeOperandReg8(0); |
181 Node* accumulator = __ GetAccumulator(); | 181 Node* accumulator = __ GetAccumulator(); |
182 __ StoreRegister(accumulator, reg_index); | 182 __ StoreRegister(accumulator, reg_index); |
183 __ Dispatch(); | 183 __ Dispatch(); |
184 } | 184 } |
185 | 185 |
186 | 186 |
| 187 void Interpreter::DoLoadGlobal(Callable ic, |
| 188 compiler::InterpreterAssembler* assembler) { |
| 189 // Get the global object. |
| 190 Node* context = __ GetContext(); |
| 191 Node* global = __ LoadContextSlot(context, Context::GLOBAL_OBJECT_INDEX); |
| 192 |
| 193 // Load the global via the LoadIC. |
| 194 Node* code_target = __ HeapConstant(ic.code()); |
| 195 Node* constant_index = __ BytecodeOperandIdx8(0); |
| 196 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 197 Node* raw_slot = __ BytecodeOperandIdx8(1); |
| 198 Node* smi_slot = __ SmiTag(raw_slot); |
| 199 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 200 Node* result = __ CallIC(ic.descriptor(), code_target, global, name, smi_slot, |
| 201 type_feedback_vector); |
| 202 __ SetAccumulator(result); |
| 203 |
| 204 __ Dispatch(); |
| 205 } |
| 206 |
| 207 |
| 208 // LdaGlobalSloppy <name_index> <slot> |
| 209 // |
| 210 // Load the global with name in constant pool entry <name_index> into the |
| 211 // accumulator using FeedBackVector slot <slot> in sloppy mode. |
| 212 void Interpreter::DoLdaGlobalSloppy(compiler::InterpreterAssembler* assembler) { |
| 213 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, |
| 214 SLOPPY, UNINITIALIZED); |
| 215 DoLoadGlobal(ic, assembler); |
| 216 } |
| 217 |
| 218 |
| 219 // LdaGlobalSloppy <name_index> <slot> |
| 220 // |
| 221 // Load the global with name in constant pool entry <name_index> into the |
| 222 // accumulator using FeedBackVector slot <slot> in strict mode. |
| 223 void Interpreter::DoLdaGlobalStrict(compiler::InterpreterAssembler* assembler) { |
| 224 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, |
| 225 STRICT, UNINITIALIZED); |
| 226 DoLoadGlobal(ic, assembler); |
| 227 } |
| 228 |
| 229 |
| 230 void Interpreter::DoStoreGlobal(Callable ic, |
| 231 compiler::InterpreterAssembler* assembler) { |
| 232 // Get the global object. |
| 233 Node* context = __ GetContext(); |
| 234 Node* global = __ LoadContextSlot(context, Context::GLOBAL_OBJECT_INDEX); |
| 235 |
| 236 // Store the global via the StoreIC. |
| 237 Node* code_target = __ HeapConstant(ic.code()); |
| 238 Node* constant_index = __ BytecodeOperandIdx8(0); |
| 239 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 240 Node* value = __ GetAccumulator(); |
| 241 Node* raw_slot = __ BytecodeOperandIdx8(1); |
| 242 Node* smi_slot = __ SmiTag(raw_slot); |
| 243 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 244 __ CallIC(ic.descriptor(), code_target, global, name, value, smi_slot, |
| 245 type_feedback_vector); |
| 246 |
| 247 __ Dispatch(); |
| 248 } |
| 249 |
| 250 |
| 251 // StaGlobalSloppy <name_index> <slot> |
| 252 // |
| 253 // Store the value in the accumulator into the global with name in constant pool |
| 254 // entry <name_index> using FeedBackVector slot <slot> in sloppy mode. |
| 255 void Interpreter::DoStaGlobalSloppy(compiler::InterpreterAssembler* assembler) { |
| 256 Callable ic = |
| 257 CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
| 258 DoStoreGlobal(ic, assembler); |
| 259 } |
| 260 |
| 261 |
| 262 // StaGlobalStrict <name_index> <slot> |
| 263 // |
| 264 // Store the value in the accumulator into the global with name in constant pool |
| 265 // entry <name_index> using FeedBackVector slot <slot> in strict mode. |
| 266 void Interpreter::DoStaGlobalStrict(compiler::InterpreterAssembler* assembler) { |
| 267 Callable ic = |
| 268 CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); |
| 269 DoStoreGlobal(ic, assembler); |
| 270 } |
| 271 |
| 272 |
187 // LdaContextSlot <context> <slot_index> | 273 // LdaContextSlot <context> <slot_index> |
188 // | 274 // |
189 // Load the object in |slot_index| of |context| into the accumulator. | 275 // Load the object in |slot_index| of |context| into the accumulator. |
190 void Interpreter::DoLdaContextSlot(compiler::InterpreterAssembler* assembler) { | 276 void Interpreter::DoLdaContextSlot(compiler::InterpreterAssembler* assembler) { |
191 Node* reg_index = __ BytecodeOperandReg8(0); | 277 Node* reg_index = __ BytecodeOperandReg8(0); |
192 Node* context = __ LoadRegister(reg_index); | 278 Node* context = __ LoadRegister(reg_index); |
193 Node* slot_index = __ BytecodeOperandIdx8(1); | 279 Node* slot_index = __ BytecodeOperandIdx8(1); |
194 Node* result = __ LoadContextSlot(context, slot_index); | 280 Node* result = __ LoadContextSlot(context, slot_index); |
195 __ SetAccumulator(result); | 281 __ SetAccumulator(result); |
196 __ Dispatch(); | 282 __ Dispatch(); |
197 } | 283 } |
198 | 284 |
199 | 285 |
200 // StaContextSlot <context> <slot_index> | 286 // StaContextSlot <context> <slot_index> |
201 // | 287 // |
202 // Stores the object in the accumulator into |slot_index| of |context|. | 288 // Stores the object in the accumulator into |slot_index| of |context|. |
203 void Interpreter::DoStaContextSlot(compiler::InterpreterAssembler* assembler) { | 289 void Interpreter::DoStaContextSlot(compiler::InterpreterAssembler* assembler) { |
204 Node* value = __ GetAccumulator(); | 290 Node* value = __ GetAccumulator(); |
205 Node* reg_index = __ BytecodeOperandReg8(0); | 291 Node* reg_index = __ BytecodeOperandReg8(0); |
206 Node* context = __ LoadRegister(reg_index); | 292 Node* context = __ LoadRegister(reg_index); |
207 Node* slot_index = __ BytecodeOperandIdx8(1); | 293 Node* slot_index = __ BytecodeOperandIdx8(1); |
208 __ StoreContextSlot(context, slot_index, value); | 294 __ StoreContextSlot(context, slot_index, value); |
209 __ Dispatch(); | 295 __ Dispatch(); |
210 } | 296 } |
211 | 297 |
212 | 298 |
213 void Interpreter::DoPropertyLoadIC(Callable ic, | 299 void Interpreter::DoLoadIC(Callable ic, |
214 compiler::InterpreterAssembler* assembler) { | 300 compiler::InterpreterAssembler* assembler) { |
215 Node* code_target = __ HeapConstant(ic.code()); | 301 Node* code_target = __ HeapConstant(ic.code()); |
216 Node* reg_index = __ BytecodeOperandReg8(0); | 302 Node* register_index = __ BytecodeOperandReg8(0); |
217 Node* object = __ LoadRegister(reg_index); | 303 Node* object = __ LoadRegister(register_index); |
218 Node* name = __ GetAccumulator(); | 304 Node* constant_index = __ BytecodeOperandIdx8(1); |
219 Node* raw_slot = __ BytecodeOperandIdx8(1); | 305 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 306 Node* raw_slot = __ BytecodeOperandIdx8(2); |
220 Node* smi_slot = __ SmiTag(raw_slot); | 307 Node* smi_slot = __ SmiTag(raw_slot); |
221 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 308 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
222 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, smi_slot, | 309 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, smi_slot, |
223 type_feedback_vector); | 310 type_feedback_vector); |
224 __ SetAccumulator(result); | 311 __ SetAccumulator(result); |
225 __ Dispatch(); | 312 __ Dispatch(); |
226 } | 313 } |
227 | 314 |
228 | 315 |
229 // LoadICSloppy <object> <slot> | 316 // LoadICSloppy <object> <name_index> <slot> |
230 // | 317 // |
231 // Calls the sloppy mode LoadIC at FeedBackVector slot <slot> for <object> and | 318 // Calls the sloppy mode LoadIC at FeedBackVector slot <slot> for <object> and |
232 // the name in the accumulator. | 319 // the name at constant pool entry <name_index>. |
233 void Interpreter::DoLoadICSloppy(compiler::InterpreterAssembler* assembler) { | 320 void Interpreter::DoLoadICSloppy(compiler::InterpreterAssembler* assembler) { |
234 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, | 321 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, |
235 SLOPPY, UNINITIALIZED); | 322 SLOPPY, UNINITIALIZED); |
236 DoPropertyLoadIC(ic, assembler); | 323 DoLoadIC(ic, assembler); |
237 } | 324 } |
238 | 325 |
239 | 326 |
240 // LoadICStrict <object> <slot> | 327 // LoadICStrict <object> <name_index> <slot> |
241 // | 328 // |
242 // Calls the strict mode LoadIC at FeedBackVector slot <slot> for <object> and | 329 // Calls the sloppy mode LoadIC at FeedBackVector slot <slot> for <object> and |
243 // the name in the accumulator. | 330 // the name at constant pool entry <name_index>. |
244 void Interpreter::DoLoadICStrict(compiler::InterpreterAssembler* assembler) { | 331 void Interpreter::DoLoadICStrict(compiler::InterpreterAssembler* assembler) { |
245 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, | 332 Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, |
246 STRICT, UNINITIALIZED); | 333 STRICT, UNINITIALIZED); |
247 DoPropertyLoadIC(ic, assembler); | 334 DoLoadIC(ic, assembler); |
248 } | 335 } |
249 | 336 |
250 | 337 |
| 338 void Interpreter::DoKeyedLoadIC(Callable ic, |
| 339 compiler::InterpreterAssembler* assembler) { |
| 340 Node* code_target = __ HeapConstant(ic.code()); |
| 341 Node* reg_index = __ BytecodeOperandReg8(0); |
| 342 Node* object = __ LoadRegister(reg_index); |
| 343 Node* name = __ GetAccumulator(); |
| 344 Node* raw_slot = __ BytecodeOperandIdx8(1); |
| 345 Node* smi_slot = __ SmiTag(raw_slot); |
| 346 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 347 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, smi_slot, |
| 348 type_feedback_vector); |
| 349 __ SetAccumulator(result); |
| 350 __ Dispatch(); |
| 351 } |
| 352 |
| 353 |
251 // KeyedLoadICSloppy <object> <slot> | 354 // KeyedLoadICSloppy <object> <slot> |
252 // | 355 // |
253 // Calls the sloppy mode KeyedLoadIC at FeedBackVector slot <slot> for <object> | 356 // Calls the sloppy mode KeyedLoadIC at FeedBackVector slot <slot> for <object> |
254 // and the key in the accumulator. | 357 // and the key in the accumulator. |
255 void Interpreter::DoKeyedLoadICSloppy( | 358 void Interpreter::DoKeyedLoadICSloppy( |
256 compiler::InterpreterAssembler* assembler) { | 359 compiler::InterpreterAssembler* assembler) { |
257 Callable ic = | 360 Callable ic = |
258 CodeFactory::KeyedLoadICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); | 361 CodeFactory::KeyedLoadICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
259 DoPropertyLoadIC(ic, assembler); | 362 DoKeyedLoadIC(ic, assembler); |
260 } | 363 } |
261 | 364 |
262 | 365 |
263 // KeyedLoadICStrict <object> <slot> | 366 // KeyedLoadICStrict <object> <slot> |
264 // | 367 // |
265 // Calls the strict mode KeyedLoadIC at FeedBackVector slot <slot> for <object> | 368 // Calls the strict mode KeyedLoadIC at FeedBackVector slot <slot> for <object> |
266 // and the key in the accumulator. | 369 // and the key in the accumulator. |
267 void Interpreter::DoKeyedLoadICStrict( | 370 void Interpreter::DoKeyedLoadICStrict( |
268 compiler::InterpreterAssembler* assembler) { | 371 compiler::InterpreterAssembler* assembler) { |
269 Callable ic = | 372 Callable ic = |
270 CodeFactory::KeyedLoadICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); | 373 CodeFactory::KeyedLoadICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); |
271 DoPropertyLoadIC(ic, assembler); | 374 DoKeyedLoadIC(ic, assembler); |
272 } | 375 } |
273 | 376 |
274 | 377 |
275 void Interpreter::DoPropertyStoreIC(Callable ic, | 378 void Interpreter::DoStoreIC(Callable ic, |
276 compiler::InterpreterAssembler* assembler) { | 379 compiler::InterpreterAssembler* assembler) { |
| 380 Node* code_target = __ HeapConstant(ic.code()); |
| 381 Node* object_reg_index = __ BytecodeOperandReg8(0); |
| 382 Node* object = __ LoadRegister(object_reg_index); |
| 383 Node* constant_index = __ BytecodeOperandIdx8(1); |
| 384 Node* name = __ LoadConstantPoolEntry(constant_index); |
| 385 Node* value = __ GetAccumulator(); |
| 386 Node* raw_slot = __ BytecodeOperandIdx8(2); |
| 387 Node* smi_slot = __ SmiTag(raw_slot); |
| 388 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
| 389 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, |
| 390 type_feedback_vector); |
| 391 __ Dispatch(); |
| 392 } |
| 393 |
| 394 |
| 395 // StoreICSloppy <object> <name_index> <slot> |
| 396 // |
| 397 // Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and |
| 398 // the name in constant pool entry <name_index> with the value in the |
| 399 // accumulator. |
| 400 void Interpreter::DoStoreICSloppy(compiler::InterpreterAssembler* assembler) { |
| 401 Callable ic = |
| 402 CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
| 403 DoStoreIC(ic, assembler); |
| 404 } |
| 405 |
| 406 |
| 407 // StoreICStrict <object> <name_index> <slot> |
| 408 // |
| 409 // Calls the strict mode StoreIC at FeedBackVector slot <slot> for <object> and |
| 410 // the name in constant pool entry <name_index> with the value in the |
| 411 // accumulator. |
| 412 void Interpreter::DoStoreICStrict(compiler::InterpreterAssembler* assembler) { |
| 413 Callable ic = |
| 414 CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); |
| 415 DoStoreIC(ic, assembler); |
| 416 } |
| 417 |
| 418 |
| 419 void Interpreter::DoKeyedStoreIC(Callable ic, |
| 420 compiler::InterpreterAssembler* assembler) { |
277 Node* code_target = __ HeapConstant(ic.code()); | 421 Node* code_target = __ HeapConstant(ic.code()); |
278 Node* object_reg_index = __ BytecodeOperandReg8(0); | 422 Node* object_reg_index = __ BytecodeOperandReg8(0); |
279 Node* object = __ LoadRegister(object_reg_index); | 423 Node* object = __ LoadRegister(object_reg_index); |
280 Node* name_reg_index = __ BytecodeOperandReg8(1); | 424 Node* name_reg_index = __ BytecodeOperandReg8(1); |
281 Node* name = __ LoadRegister(name_reg_index); | 425 Node* name = __ LoadRegister(name_reg_index); |
282 Node* value = __ GetAccumulator(); | 426 Node* value = __ GetAccumulator(); |
283 Node* raw_slot = __ BytecodeOperandIdx8(2); | 427 Node* raw_slot = __ BytecodeOperandIdx8(2); |
284 Node* smi_slot = __ SmiTag(raw_slot); | 428 Node* smi_slot = __ SmiTag(raw_slot); |
285 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 429 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
286 Node* result = __ CallIC(ic.descriptor(), code_target, object, name, value, | 430 __ CallIC(ic.descriptor(), code_target, object, name, value, smi_slot, |
287 smi_slot, type_feedback_vector); | 431 type_feedback_vector); |
288 __ SetAccumulator(result); | |
289 __ Dispatch(); | 432 __ Dispatch(); |
290 } | 433 } |
291 | 434 |
292 | 435 |
293 // StoreICSloppy <object> <name> <slot> | |
294 // | |
295 // Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and | |
296 // the name <name> with the value in the accumulator. | |
297 void Interpreter::DoStoreICSloppy(compiler::InterpreterAssembler* assembler) { | |
298 Callable ic = | |
299 CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); | |
300 DoPropertyStoreIC(ic, assembler); | |
301 } | |
302 | |
303 | |
304 // StoreICStrict <object> <name> <slot> | |
305 // | |
306 // Calls the strict mode StoreIC at FeedBackVector slot <slot> for <object> and | |
307 // the name <name> with the value in the accumulator. | |
308 void Interpreter::DoStoreICStrict(compiler::InterpreterAssembler* assembler) { | |
309 Callable ic = | |
310 CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); | |
311 DoPropertyStoreIC(ic, assembler); | |
312 } | |
313 | |
314 | |
315 // KeyedStoreICSloppy <object> <key> <slot> | 436 // KeyedStoreICSloppy <object> <key> <slot> |
316 // | 437 // |
317 // Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object> | 438 // Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object> |
318 // and the key <key> with the value in the accumulator. | 439 // and the key <key> with the value in the accumulator. |
319 void Interpreter::DoKeyedStoreICSloppy( | 440 void Interpreter::DoKeyedStoreICSloppy( |
320 compiler::InterpreterAssembler* assembler) { | 441 compiler::InterpreterAssembler* assembler) { |
321 Callable ic = | 442 Callable ic = |
322 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); | 443 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); |
323 DoPropertyStoreIC(ic, assembler); | 444 DoKeyedStoreIC(ic, assembler); |
324 } | 445 } |
325 | 446 |
326 | 447 |
327 // KeyedStoreICStore <object> <key> <slot> | 448 // KeyedStoreICStore <object> <key> <slot> |
328 // | 449 // |
329 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object> | 450 // Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object> |
330 // and the key <key> with the value in the accumulator. | 451 // and the key <key> with the value in the accumulator. |
331 void Interpreter::DoKeyedStoreICStrict( | 452 void Interpreter::DoKeyedStoreICStrict( |
332 compiler::InterpreterAssembler* assembler) { | 453 compiler::InterpreterAssembler* assembler) { |
333 Callable ic = | 454 Callable ic = |
334 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); | 455 CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED); |
335 DoPropertyStoreIC(ic, assembler); | 456 DoKeyedStoreIC(ic, assembler); |
336 } | 457 } |
337 | 458 |
338 | 459 |
339 // PushContext <context> | 460 // PushContext <context> |
340 // | 461 // |
341 // Pushes the accumulator as the current context, and saves it in <context> | 462 // Pushes the accumulator as the current context, and saves it in <context> |
342 void Interpreter::DoPushContext(compiler::InterpreterAssembler* assembler) { | 463 void Interpreter::DoPushContext(compiler::InterpreterAssembler* assembler) { |
343 Node* reg_index = __ BytecodeOperandReg8(0); | 464 Node* reg_index = __ BytecodeOperandReg8(0); |
344 Node* context = __ GetAccumulator(); | 465 Node* context = __ GetAccumulator(); |
345 __ SetContext(context); | 466 __ SetContext(context); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 // | 1006 // |
886 // Return the value in the accumulator. | 1007 // Return the value in the accumulator. |
887 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 1008 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
888 __ Return(); | 1009 __ Return(); |
889 } | 1010 } |
890 | 1011 |
891 | 1012 |
892 } // namespace interpreter | 1013 } // namespace interpreter |
893 } // namespace internal | 1014 } // namespace internal |
894 } // namespace v8 | 1015 } // namespace v8 |
OLD | NEW |