Chromium Code Reviews| 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 <fstream> | 7 #include <fstream> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
| 11 #include "src/builtins/builtins-arguments.h" | 11 #include "src/builtins/builtins-arguments.h" |
| 12 #include "src/builtins/builtins-constructor.h" | 12 #include "src/builtins/builtins-constructor.h" |
| 13 #include "src/code-factory.h" | 13 #include "src/code-factory.h" |
| 14 #include "src/compilation-info.h" | 14 #include "src/compilation-info.h" |
| 15 #include "src/compiler.h" | 15 #include "src/compiler.h" |
| 16 #include "src/factory.h" | 16 #include "src/factory.h" |
| 17 #include "src/ic/accessor-assembler.h" | |
| 17 #include "src/interpreter/bytecode-flags.h" | 18 #include "src/interpreter/bytecode-flags.h" |
| 18 #include "src/interpreter/bytecode-generator.h" | 19 #include "src/interpreter/bytecode-generator.h" |
| 19 #include "src/interpreter/bytecodes.h" | 20 #include "src/interpreter/bytecodes.h" |
| 20 #include "src/interpreter/interpreter-assembler.h" | 21 #include "src/interpreter/interpreter-assembler.h" |
| 21 #include "src/interpreter/interpreter-intrinsics.h" | 22 #include "src/interpreter/interpreter-intrinsics.h" |
| 22 #include "src/log.h" | 23 #include "src/log.h" |
| 23 #include "src/zone/zone.h" | 24 #include "src/zone/zone.h" |
| 24 | 25 |
| 25 namespace v8 { | 26 namespace v8 { |
| 26 namespace internal { | 27 namespace internal { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 // | 452 // |
| 452 // Stores the value of register <src> to register <dst>. | 453 // Stores the value of register <src> to register <dst>. |
| 453 void Interpreter::DoMov(InterpreterAssembler* assembler) { | 454 void Interpreter::DoMov(InterpreterAssembler* assembler) { |
| 454 Node* src_index = __ BytecodeOperandReg(0); | 455 Node* src_index = __ BytecodeOperandReg(0); |
| 455 Node* src_value = __ LoadRegister(src_index); | 456 Node* src_value = __ LoadRegister(src_index); |
| 456 Node* dst_index = __ BytecodeOperandReg(1); | 457 Node* dst_index = __ BytecodeOperandReg(1); |
| 457 __ StoreRegister(src_value, dst_index); | 458 __ StoreRegister(src_value, dst_index); |
| 458 __ Dispatch(); | 459 __ Dispatch(); |
| 459 } | 460 } |
| 460 | 461 |
| 461 Node* Interpreter::BuildLoadGlobal(Callable ic, Node* context, Node* name_index, | 462 void Interpreter::BuildLoadGlobal(int slot_index, int name_index_index, |
|
rmcilroy
2017/02/09 10:30:44
name_index_index? ;) How about name_operand_index?
jgruber
2017/02/09 11:40:32
I liked name_index_index because it implies that t
| |
| 462 Node* feedback_slot, | 463 TypeofMode typeof_mode, |
| 463 InterpreterAssembler* assembler) { | 464 InterpreterAssembler* assembler) { |
| 464 // Load the global via the LoadGlobalIC. | 465 // Load the global via the LoadGlobalIC. |
| 465 Node* code_target = __ HeapConstant(ic.code()); | |
| 466 Node* name = __ LoadConstantPoolEntry(name_index); | |
| 467 Node* smi_slot = __ SmiTag(feedback_slot); | |
| 468 Node* feedback_vector = __ LoadFeedbackVector(); | 466 Node* feedback_vector = __ LoadFeedbackVector(); |
| 469 return __ CallStub(ic.descriptor(), code_target, context, name, smi_slot, | 467 Node* feedback_slot = __ BytecodeOperandIdx(slot_index); |
| 470 feedback_vector); | 468 |
| 469 AccessorAssembler accessor_asm(assembler->state()); | |
| 470 | |
| 471 Label try_handler(assembler, Label::kDeferred), | |
| 472 miss(assembler, Label::kDeferred); | |
| 473 | |
| 474 // Fast path without frame construction for the data case. | |
| 475 { | |
| 476 Label done(assembler); | |
| 477 Variable var_result(assembler, MachineRepresentation::kTagged); | |
| 478 ExitPoint exit_point(assembler, &done, &var_result); | |
| 479 | |
| 480 accessor_asm.LoadGlobalIC_TryPropertyCellCase( | |
| 481 feedback_vector, feedback_slot, &exit_point, &try_handler, &miss, | |
| 482 CodeStubAssembler::INTPTR_PARAMETERS); | |
| 483 | |
| 484 __ Bind(&done); | |
| 485 __ SetAccumulator(var_result.value()); | |
| 486 __ Dispatch(); | |
| 487 } | |
| 488 | |
| 489 // Slow path with frame construction. | |
| 490 { | |
| 491 Label done(assembler); | |
| 492 Variable var_result(assembler, MachineRepresentation::kTagged); | |
| 493 ExitPoint exit_point(assembler, &done, &var_result); | |
| 494 | |
| 495 __ Bind(&try_handler); | |
| 496 { | |
| 497 Node* context = __ GetContext(); | |
| 498 Node* smi_slot = __ SmiTag(feedback_slot); | |
| 499 Node* name_index = __ BytecodeOperandIdx(name_index_index); | |
| 500 Node* name = __ LoadConstantPoolEntry(name_index); | |
| 501 | |
| 502 AccessorAssembler::LoadICParameters params(context, nullptr, name, | |
| 503 smi_slot, feedback_vector); | |
| 504 accessor_asm.LoadGlobalIC_TryHandlerCase(¶ms, typeof_mode, | |
| 505 &exit_point, &miss); | |
| 506 } | |
| 507 | |
| 508 __ Bind(&miss); | |
| 509 { | |
| 510 Node* context = __ GetContext(); | |
| 511 Node* smi_slot = __ SmiTag(feedback_slot); | |
| 512 Node* name_index = __ BytecodeOperandIdx(name_index_index); | |
| 513 Node* name = __ LoadConstantPoolEntry(name_index); | |
| 514 | |
| 515 AccessorAssembler::LoadICParameters params(context, nullptr, name, | |
| 516 smi_slot, feedback_vector); | |
| 517 accessor_asm.LoadGlobalIC_MissCase(¶ms, &exit_point); | |
| 518 } | |
| 519 | |
| 520 __ Bind(&done); | |
| 521 { | |
| 522 __ SetAccumulator(var_result.value()); | |
| 523 __ Dispatch(); | |
| 524 } | |
| 525 } | |
| 471 } | 526 } |
| 472 | 527 |
| 473 // LdaGlobal <name_index> <slot> | 528 // LdaGlobal <name_index> <slot> |
| 474 // | 529 // |
| 475 // Load the global with name in constant pool entry <name_index> into the | 530 // Load the global with name in constant pool entry <name_index> into the |
| 476 // accumulator using FeedBackVector slot <slot> outside of a typeof. | 531 // accumulator using FeedBackVector slot <slot> outside of a typeof. |
| 477 void Interpreter::DoLdaGlobal(InterpreterAssembler* assembler) { | 532 void Interpreter::DoLdaGlobal(InterpreterAssembler* assembler) { |
| 478 Callable ic = | 533 static const int kNameIndexIndex = 0; |
| 479 CodeFactory::LoadGlobalICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF); | 534 static const int kSlotIndex = 1; |
| 480 | 535 |
| 481 Node* context = __ GetContext(); | 536 BuildLoadGlobal(kSlotIndex, kNameIndexIndex, NOT_INSIDE_TYPEOF, assembler); |
| 482 | |
| 483 Node* name_index = __ BytecodeOperandIdx(0); | |
| 484 Node* raw_slot = __ BytecodeOperandIdx(1); | |
| 485 Node* result = BuildLoadGlobal(ic, context, name_index, raw_slot, assembler); | |
| 486 __ SetAccumulator(result); | |
| 487 __ Dispatch(); | |
| 488 } | 537 } |
| 489 | 538 |
| 490 // LdaGlobalInsideTypeof <name_index> <slot> | 539 // LdaGlobalInsideTypeof <name_index> <slot> |
| 491 // | 540 // |
| 492 // Load the global with name in constant pool entry <name_index> into the | 541 // Load the global with name in constant pool entry <name_index> into the |
| 493 // accumulator using FeedBackVector slot <slot> inside of a typeof. | 542 // accumulator using FeedBackVector slot <slot> inside of a typeof. |
| 494 void Interpreter::DoLdaGlobalInsideTypeof(InterpreterAssembler* assembler) { | 543 void Interpreter::DoLdaGlobalInsideTypeof(InterpreterAssembler* assembler) { |
| 495 Callable ic = | 544 static const int kNameIndexIndex = 0; |
| 496 CodeFactory::LoadGlobalICInOptimizedCode(isolate_, INSIDE_TYPEOF); | 545 static const int kSlotIndex = 1; |
| 497 | 546 |
| 498 Node* context = __ GetContext(); | 547 BuildLoadGlobal(kSlotIndex, kNameIndexIndex, INSIDE_TYPEOF, assembler); |
| 499 | |
| 500 Node* name_index = __ BytecodeOperandIdx(0); | |
| 501 Node* raw_slot = __ BytecodeOperandIdx(1); | |
| 502 Node* result = BuildLoadGlobal(ic, context, name_index, raw_slot, assembler); | |
| 503 __ SetAccumulator(result); | |
| 504 __ Dispatch(); | |
| 505 } | 548 } |
| 506 | 549 |
| 507 void Interpreter::DoStaGlobal(Callable ic, InterpreterAssembler* assembler) { | 550 void Interpreter::DoStaGlobal(Callable ic, InterpreterAssembler* assembler) { |
| 508 // Get the global object. | 551 // Get the global object. |
| 509 Node* context = __ GetContext(); | 552 Node* context = __ GetContext(); |
| 510 Node* native_context = __ LoadNativeContext(context); | 553 Node* native_context = __ LoadNativeContext(context); |
| 511 Node* global = | 554 Node* global = |
| 512 __ LoadContextElement(native_context, Context::EXTENSION_INDEX); | 555 __ LoadContextElement(native_context, Context::EXTENSION_INDEX); |
| 513 | 556 |
| 514 // Store the global via the StoreIC. | 557 // Store the global via the StoreIC. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 // Lookup the object with the name in constant pool entry |name_index| | 725 // Lookup the object with the name in constant pool entry |name_index| |
| 683 // dynamically without causing a NoReferenceError. | 726 // dynamically without causing a NoReferenceError. |
| 684 void Interpreter::DoLdaLookupContextSlotInsideTypeof( | 727 void Interpreter::DoLdaLookupContextSlotInsideTypeof( |
| 685 InterpreterAssembler* assembler) { | 728 InterpreterAssembler* assembler) { |
| 686 DoLdaLookupContextSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler); | 729 DoLdaLookupContextSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler); |
| 687 } | 730 } |
| 688 | 731 |
| 689 void Interpreter::DoLdaLookupGlobalSlot(Runtime::FunctionId function_id, | 732 void Interpreter::DoLdaLookupGlobalSlot(Runtime::FunctionId function_id, |
| 690 InterpreterAssembler* assembler) { | 733 InterpreterAssembler* assembler) { |
| 691 Node* context = __ GetContext(); | 734 Node* context = __ GetContext(); |
| 692 Node* name_index = __ BytecodeOperandIdx(0); | |
| 693 Node* feedback_slot = __ BytecodeOperandIdx(1); | |
| 694 Node* depth = __ BytecodeOperandUImm(2); | 735 Node* depth = __ BytecodeOperandUImm(2); |
| 695 | 736 |
| 696 Label slowpath(assembler, Label::kDeferred); | 737 Label slowpath(assembler, Label::kDeferred); |
| 697 | 738 |
| 698 // Check for context extensions to allow the fast path | 739 // Check for context extensions to allow the fast path |
| 699 __ GotoIfHasContextExtensionUpToDepth(context, depth, &slowpath); | 740 __ GotoIfHasContextExtensionUpToDepth(context, depth, &slowpath); |
| 700 | 741 |
| 701 // Fast path does a normal load global | 742 // Fast path does a normal load global |
| 702 { | 743 { |
| 703 Callable ic = CodeFactory::LoadGlobalICInOptimizedCode( | 744 static const int kNameIndexIndex = 0; |
| 704 isolate_, function_id == Runtime::kLoadLookupSlotInsideTypeof | 745 static const int kSlotIndex = 1; |
| 705 ? INSIDE_TYPEOF | 746 |
| 706 : NOT_INSIDE_TYPEOF); | 747 TypeofMode typeof_mode = function_id == Runtime::kLoadLookupSlotInsideTypeof |
| 707 Node* result = | 748 ? INSIDE_TYPEOF |
| 708 BuildLoadGlobal(ic, context, name_index, feedback_slot, assembler); | 749 : NOT_INSIDE_TYPEOF; |
| 709 __ SetAccumulator(result); | 750 |
| 710 __ Dispatch(); | 751 BuildLoadGlobal(kSlotIndex, kNameIndexIndex, typeof_mode, assembler); |
| 711 } | 752 } |
| 712 | 753 |
| 713 // Slow path when we have to call out to the runtime | 754 // Slow path when we have to call out to the runtime |
| 714 __ Bind(&slowpath); | 755 __ Bind(&slowpath); |
| 715 { | 756 { |
| 757 Node* name_index = __ BytecodeOperandIdx(0); | |
| 716 Node* name = __ LoadConstantPoolEntry(name_index); | 758 Node* name = __ LoadConstantPoolEntry(name_index); |
| 717 Node* result = __ CallRuntime(function_id, context, name); | 759 Node* result = __ CallRuntime(function_id, context, name); |
| 718 __ SetAccumulator(result); | 760 __ SetAccumulator(result); |
| 719 __ Dispatch(); | 761 __ Dispatch(); |
| 720 } | 762 } |
| 721 } | 763 } |
| 722 | 764 |
| 723 // LdaLookupGlobalSlot <name_index> <feedback_slot> <depth> | 765 // LdaLookupGlobalSlot <name_index> <feedback_slot> <depth> |
| 724 // | 766 // |
| 725 // Lookup the object with the name in constant pool entry |name_index| | 767 // Lookup the object with the name in constant pool entry |name_index| |
| (...skipping 2599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3325 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 3367 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 3326 __ SmiTag(new_state)); | 3368 __ SmiTag(new_state)); |
| 3327 __ SetAccumulator(old_state); | 3369 __ SetAccumulator(old_state); |
| 3328 | 3370 |
| 3329 __ Dispatch(); | 3371 __ Dispatch(); |
| 3330 } | 3372 } |
| 3331 | 3373 |
| 3332 } // namespace interpreter | 3374 } // namespace interpreter |
| 3333 } // namespace internal | 3375 } // namespace internal |
| 3334 } // namespace v8 | 3376 } // namespace v8 |
| OLD | NEW |