 Chromium Code Reviews
 Chromium Code Reviews Issue 1707693003:
  [Interpreter] Enable runtime profiler support for Ignition.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1707693003:
  [Interpreter] Enable runtime profiler support for Ignition.  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| Index: src/interpreter/interpreter-assembler.cc | 
| diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc | 
| index d19e8ac7f9262211e2abebd83269f1eca282b7f2..65046f189212d35164c073dd4ab7f5b4f01bd72a 100644 | 
| --- a/src/interpreter/interpreter-assembler.cc | 
| +++ b/src/interpreter/interpreter-assembler.cc | 
| @@ -10,6 +10,7 @@ | 
| #include "src/frames.h" | 
| #include "src/interface-descriptors.h" | 
| #include "src/interpreter/bytecodes.h" | 
| +#include "src/interpreter/interpreter.h" | 
| #include "src/machine-type.h" | 
| #include "src/macro-assembler.h" | 
| #include "src/zone.h" | 
| @@ -371,6 +372,36 @@ Node* InterpreterAssembler::CallRuntimeN(Node* function_id, Node* context, | 
| first_arg, function_entry, result_size); | 
| } | 
| +void InterpreterAssembler::UpdateProfilingCount(Node* weight) { | 
| + CodeStubAssembler::Label ok(this); | 
| + CodeStubAssembler::Label interrupt_check(this); | 
| + CodeStubAssembler::Label end(this); | 
| + Node* counter_offset = | 
| + IntPtrConstant(BytecodeArray::kProfilingCountOffset - kHeapObjectTag); | 
| + | 
| + // Update counter by |weight| and check if it reaches zero. | 
| + Node* old_count = | 
| + Load(MachineType::Int32(), BytecodeArrayTaggedPointer(), counter_offset); | 
| + Node* new_count = Int32Add(old_count, weight); | 
| + Node* condition = Int32GreaterThanOrEqual(new_count, Int32Constant(0)); | 
| + Branch(condition, &ok, &interrupt_check); | 
| + | 
| + // Perform interrupt and reset counter. | 
| + Bind(&interrupt_check); | 
| + CallRuntime(Runtime::kInterrupt, GetContext()); | 
| + StoreNoWriteBarrier(MachineRepresentation::kWord32, | 
| + BytecodeArrayTaggedPointer(), counter_offset, | 
| + Int32Constant(Interpreter::InterruptBudget())); | 
| + Goto(&end); | 
| + | 
| + // Update counter. | 
| + Bind(&ok); | 
| + StoreNoWriteBarrier(MachineRepresentation::kWord32, | 
| + BytecodeArrayTaggedPointer(), counter_offset, new_count); | 
| + Goto(&end); | 
| + Bind(&end); | 
| +} | 
| + | 
| Node* InterpreterAssembler::Advance(int delta) { | 
| return IntPtrAdd(BytecodeOffset(), Int32Constant(delta)); | 
| } | 
| @@ -379,7 +410,10 @@ Node* InterpreterAssembler::Advance(Node* delta) { | 
| return IntPtrAdd(BytecodeOffset(), delta); | 
| } | 
| -void InterpreterAssembler::Jump(Node* delta) { DispatchTo(Advance(delta)); } | 
| +void InterpreterAssembler::Jump(Node* delta) { | 
| + UpdateProfilingCount(delta); | 
| + DispatchTo(Advance(delta)); | 
| +} | 
| void InterpreterAssembler::JumpConditional(Node* condition, Node* delta) { | 
| CodeStubAssembler::Label match(this); | 
| @@ -387,7 +421,7 @@ void InterpreterAssembler::JumpConditional(Node* condition, Node* delta) { | 
| Branch(condition, &match, &no_match); | 
| Bind(&match); | 
| - DispatchTo(Advance(delta)); | 
| + Jump(delta); | 
| Bind(&no_match); | 
| Dispatch(); | 
| } | 
| @@ -429,6 +463,15 @@ void InterpreterAssembler::InterpreterReturn() { | 
| if (FLAG_trace_ignition) { | 
| TraceBytecode(Runtime::kInterpreterTraceBytecodeExit); | 
| } | 
| + | 
| + // TODO(rmcilroy): Deal with self optimization of primitive functions. | 
| 
Michael Starzinger
2016/02/18 17:55:26
Just for posterity: Unless we have data supporting
 
rmcilroy
2016/02/19 12:32:32
Ack. Updated comment.
 | 
| + // Update profiling count by -BytecodeOffset to simulate backedge to start of | 
| + // function. | 
| + Node* profiling_weight = | 
| + Int32Sub(Int32Constant(kHeapObjectTag + BytecodeArray::kHeaderSize), | 
| + BytecodeOffset()); | 
| + UpdateProfilingCount(profiling_weight); | 
| + | 
| InterpreterDispatchDescriptor descriptor(isolate()); | 
| Node* exit_trampoline_code_object = | 
| HeapConstant(isolate()->builtins()->InterpreterExitTrampoline()); |