 Chromium Code Reviews
 Chromium Code Reviews Issue 1852213002:
  [interpreter] Add accumulator use description to bytecodes.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1852213002:
  [interpreter] Add accumulator use description to bytecodes.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" | 
| 6 | 6 | 
| 7 #include <ostream> | 7 #include <ostream> | 
| 8 | 8 | 
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" | 
| 10 #include "src/frames.h" | 10 #include "src/frames.h" | 
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, | 24 InterpreterAssembler::InterpreterAssembler(Isolate* isolate, Zone* zone, | 
| 25 Bytecode bytecode, | 25 Bytecode bytecode, | 
| 26 OperandScale operand_scale) | 26 OperandScale operand_scale) | 
| 27 : compiler::CodeStubAssembler(isolate, zone, | 27 : compiler::CodeStubAssembler(isolate, zone, | 
| 28 InterpreterDispatchDescriptor(isolate), | 28 InterpreterDispatchDescriptor(isolate), | 
| 29 Code::ComputeFlags(Code::BYTECODE_HANDLER), | 29 Code::ComputeFlags(Code::BYTECODE_HANDLER), | 
| 30 Bytecodes::ToString(bytecode), 0), | 30 Bytecodes::ToString(bytecode), 0), | 
| 31 bytecode_(bytecode), | 31 bytecode_(bytecode), | 
| 32 operand_scale_(operand_scale), | 32 operand_scale_(operand_scale), | 
| 33 accumulator_(this, MachineRepresentation::kTagged), | 33 accumulator_(this, MachineRepresentation::kTagged), | 
| 34 accumulator_use_(AccumulatorUse::kNone), | |
| 34 context_(this, MachineRepresentation::kTagged), | 35 context_(this, MachineRepresentation::kTagged), | 
| 35 bytecode_array_(this, MachineRepresentation::kTagged), | 36 bytecode_array_(this, MachineRepresentation::kTagged), | 
| 36 disable_stack_check_across_call_(false), | 37 disable_stack_check_across_call_(false), | 
| 37 stack_pointer_before_call_(nullptr) { | 38 stack_pointer_before_call_(nullptr) { | 
| 38 accumulator_.Bind( | 39 accumulator_.Bind( | 
| 39 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); | 40 Parameter(InterpreterDispatchDescriptor::kAccumulatorParameter)); | 
| 40 context_.Bind(Parameter(InterpreterDispatchDescriptor::kContextParameter)); | 41 context_.Bind(Parameter(InterpreterDispatchDescriptor::kContextParameter)); | 
| 41 bytecode_array_.Bind( | 42 bytecode_array_.Bind( | 
| 42 Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter)); | 43 Parameter(InterpreterDispatchDescriptor::kBytecodeArrayParameter)); | 
| 43 if (FLAG_trace_ignition) { | 44 if (FLAG_trace_ignition) { | 
| 44 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); | 45 TraceBytecode(Runtime::kInterpreterTraceBytecodeEntry); | 
| 45 } | 46 } | 
| 46 } | 47 } | 
| 47 | 48 | 
| 48 InterpreterAssembler::~InterpreterAssembler() {} | 49 InterpreterAssembler::~InterpreterAssembler() { | 
| 50 CHECK_EQ(accumulator_use_, Bytecodes::GetAccumulatorUse(bytecode_)); | |
| 
rmcilroy
2016/04/05 12:59:22
DCHECK_EQ - also please add a comment on how to fi
 
oth
2016/04/05 14:12:10
Comment added and switched to DCHECK though I disa
 | |
| 51 } | |
| 49 | 52 | 
| 50 Node* InterpreterAssembler::GetAccumulator() { return accumulator_.value(); } | 53 Node* InterpreterAssembler::GetAccumulatorUnchecked() { | 
| 54 return accumulator_.value(); | |
| 55 } | |
| 56 | |
| 57 Node* InterpreterAssembler::GetAccumulator() { | |
| 58 DCHECK(Bytecodes::ReadsAccumulator(bytecode_)); | |
| 59 accumulator_use_ = accumulator_use_ | AccumulatorUse::kRead; | |
| 60 return GetAccumulatorUnchecked(); | |
| 61 } | |
| 51 | 62 | 
| 52 void InterpreterAssembler::SetAccumulator(Node* value) { | 63 void InterpreterAssembler::SetAccumulator(Node* value) { | 
| 64 DCHECK(Bytecodes::WritesAccumulator(bytecode_)); | |
| 65 accumulator_use_ = accumulator_use_ | AccumulatorUse::kWrite; | |
| 53 accumulator_.Bind(value); | 66 accumulator_.Bind(value); | 
| 54 } | 67 } | 
| 55 | 68 | 
| 56 Node* InterpreterAssembler::GetContext() { return context_.value(); } | 69 Node* InterpreterAssembler::GetContext() { return context_.value(); } | 
| 57 | 70 | 
| 58 void InterpreterAssembler::SetContext(Node* value) { | 71 void InterpreterAssembler::SetContext(Node* value) { | 
| 59 StoreRegister(value, Register::current_context()); | 72 StoreRegister(value, Register::current_context()); | 
| 60 context_.Bind(value); | 73 context_.Bind(value); | 
| 61 } | 74 } | 
| 62 | 75 | 
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 DispatchToBytecodeHandler(target_code_object, new_bytecode_offset); | 560 DispatchToBytecodeHandler(target_code_object, new_bytecode_offset); | 
| 548 } | 561 } | 
| 549 | 562 | 
| 550 void InterpreterAssembler::DispatchToBytecodeHandler(Node* handler, | 563 void InterpreterAssembler::DispatchToBytecodeHandler(Node* handler, | 
| 551 Node* bytecode_offset) { | 564 Node* bytecode_offset) { | 
| 552 if (FLAG_trace_ignition) { | 565 if (FLAG_trace_ignition) { | 
| 553 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 566 TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 
| 554 } | 567 } | 
| 555 | 568 | 
| 556 InterpreterDispatchDescriptor descriptor(isolate()); | 569 InterpreterDispatchDescriptor descriptor(isolate()); | 
| 557 Node* args[] = {GetAccumulator(), RegisterFileRawPointer(), | 570 Node* args[] = {GetAccumulatorUnchecked(), RegisterFileRawPointer(), | 
| 558 bytecode_offset, BytecodeArrayTaggedPointer(), | 571 bytecode_offset, BytecodeArrayTaggedPointer(), | 
| 559 DispatchTableRawPointer(), GetContext()}; | 572 DispatchTableRawPointer(), GetContext()}; | 
| 560 TailCall(descriptor, handler, args, 0); | 573 TailCall(descriptor, handler, args, 0); | 
| 561 } | 574 } | 
| 562 | 575 | 
| 563 void InterpreterAssembler::DispatchWide(OperandScale operand_scale) { | 576 void InterpreterAssembler::DispatchWide(OperandScale operand_scale) { | 
| 564 // Dispatching a wide bytecode requires treating the prefix | 577 // Dispatching a wide bytecode requires treating the prefix | 
| 565 // bytecode a base pointer into the dispatch table and dispatching | 578 // bytecode a base pointer into the dispatch table and dispatching | 
| 566 // the bytecode that follows relative to this base. | 579 // the bytecode that follows relative to this base. | 
| 567 // | 580 // | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 Bind(&no_match); | 660 Bind(&no_match); | 
| 648 Abort(bailout_reason); | 661 Abort(bailout_reason); | 
| 649 Goto(&end); | 662 Goto(&end); | 
| 650 Bind(&match); | 663 Bind(&match); | 
| 651 Goto(&end); | 664 Goto(&end); | 
| 652 Bind(&end); | 665 Bind(&end); | 
| 653 } | 666 } | 
| 654 | 667 | 
| 655 void InterpreterAssembler::TraceBytecode(Runtime::FunctionId function_id) { | 668 void InterpreterAssembler::TraceBytecode(Runtime::FunctionId function_id) { | 
| 656 CallRuntime(function_id, GetContext(), BytecodeArrayTaggedPointer(), | 669 CallRuntime(function_id, GetContext(), BytecodeArrayTaggedPointer(), | 
| 657 SmiTag(BytecodeOffset()), GetAccumulator()); | 670 SmiTag(BytecodeOffset()), GetAccumulatorUnchecked()); | 
| 658 } | 671 } | 
| 659 | 672 | 
| 660 // static | 673 // static | 
| 661 bool InterpreterAssembler::TargetSupportsUnalignedAccess() { | 674 bool InterpreterAssembler::TargetSupportsUnalignedAccess() { | 
| 662 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 675 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 
| 663 return false; | 676 return false; | 
| 664 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC | 677 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC | 
| 665 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); | 678 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); | 
| 666 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ | 679 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ | 
| 667 V8_TARGET_ARCH_S390 | 680 V8_TARGET_ARCH_S390 | 
| 668 return true; | 681 return true; | 
| 669 #else | 682 #else | 
| 670 #error "Unknown Architecture" | 683 #error "Unknown Architecture" | 
| 671 #endif | 684 #endif | 
| 672 } | 685 } | 
| 673 | 686 | 
| 674 } // namespace interpreter | 687 } // namespace interpreter | 
| 675 } // namespace internal | 688 } // namespace internal | 
| 676 } // namespace v8 | 689 } // namespace v8 | 
| OLD | NEW |