V8 Project
v8::internal::OptimizedFrame Class Reference

#include <frames.h>

+ Inheritance diagram for v8::internal::OptimizedFrame:
+ Collaboration diagram for v8::internal::OptimizedFrame:

Public Member Functions

virtual Type type () const
 
virtual void Iterate (ObjectVisitor *v) const
 
virtual int GetInlineCount ()
 
virtual void GetFunctions (List< JSFunction * > *functions)
 
virtual void Summarize (List< FrameSummary > *frames)
 
DeoptimizationInputDataGetDeoptimizationData (int *deopt_index)
 
- Public Member Functions inherited from v8::internal::JavaScriptFrame
JSFunctionfunction () const
 
Objectreceiver () const
 
void set_receiver (Object *value)
 
Address GetParameterSlot (int index) const
 
ObjectGetParameter (int index) const
 
int ComputeParametersCount () const
 
Address GetOperandSlot (int index) const
 
ObjectGetOperand (int index) const
 
int ComputeOperandsCount () const
 
void SaveOperandStack (FixedArray *store, int *stack_handler_index) const
 
void RestoreOperandStack (FixedArray *store, int stack_handler_index)
 
void SetParameterValue (int index, Object *value) const
 
bool IsConstructor () const
 
bool has_adapted_arguments () const
 
int GetArgumentsLength () const
 
virtual void Print (StringStream *accumulator, PrintMode mode, int index) const
 
virtual Codeunchecked_code () const
 
- Public Member Functions inherited from v8::internal::StandardFrame
virtual bool is_standard () const
 
Objectcontext () const
 
ObjectGetExpression (int index) const
 
void SetExpression (int index, Object *value)
 
int ComputeExpressionsCount () const
 
virtual void SetCallerFp (Address caller_fp)
 
- Public Member Functions inherited from v8::StackFrame
int GetLineNumber () const
 Returns the number, 1-based, of the line for the associate function call. More...
 
int GetColumn () const
 Returns the 1-based column offset on the line for the associated function call. More...
 
int GetScriptId () const
 Returns the id of the script for the function for this StackFrame. More...
 
Local< StringGetScriptName () const
 Returns the name of the resource that contains the script for the function for this StackFrame. More...
 
Local< StringGetScriptNameOrSourceURL () const
 Returns the name of the resource that contains the script for the function for this StackFrame or sourceURL value if the script name is undefined and its source ends with //# sourceURL=... More...
 
Local< StringGetFunctionName () const
 Returns the name of the function associated with this stack frame. More...
 
bool IsEval () const
 Returns whether or not the associated function is compiled via a call to eval(). More...
 
bool IsConstructor () const
 Returns whether or not the associated function is called as a constructor via "new". More...
 

Protected Member Functions

 OptimizedFrame (StackFrameIteratorBase *iterator)
 
- Protected Member Functions inherited from v8::internal::JavaScriptFrame
 JavaScriptFrame (StackFrameIteratorBase *iterator)
 
virtual Address GetCallerStackPointer () const
 
virtual int GetNumberOfIncomingArguments () const
 
void IterateArguments (ObjectVisitor *v) const
 
- Protected Member Functions inherited from v8::internal::StandardFrame
 StandardFrame (StackFrameIteratorBase *iterator)
 
virtual void ComputeCallerState (State *state) const
 
Address caller_fp () const
 
Address caller_pc () const
 
void IterateExpressions (ObjectVisitor *v) const
 
Address GetExpressionAddress (int n) const
 
bool IsExpressionInsideHandler (int n) const
 
void IterateCompiledFrame (ObjectVisitor *v) const
 

Private Member Functions

JSFunctionLiteralAt (FixedArray *literal_array, int literal_id)
 

Friends

class StackFrameIteratorBase
 

Additional Inherited Members

- Static Public Member Functions inherited from v8::internal::JavaScriptFrame
static Register fp_register ()
 
static Register context_register ()
 
static Register constant_pool_pointer_register ()
 
static JavaScriptFramecast (StackFrame *frame)
 
static void PrintFunctionAndOffset (JSFunction *function, Code *code, Address pc, FILE *file, bool print_line_number)
 
static void PrintTop (Isolate *isolate, FILE *file, bool print_args, bool print_line_number)
 
- Static Public Member Functions inherited from v8::internal::StandardFrame
static ObjectGetExpression (Address fp, int index)
 
static StandardFramecast (StackFrame *frame)
 
- Static Protected Member Functions inherited from v8::internal::StandardFrame
static Address ComputePCAddress (Address fp)
 
static Address ComputeConstantPoolAddress (Address fp)
 
static Address GetExpressionAddress (Address fp, int n)
 
static bool IsArgumentsAdaptorFrame (Address fp)
 
static bool IsConstructFrame (Address fp)
 

Detailed Description

Definition at line 663 of file frames.h.

Constructor & Destructor Documentation

◆ OptimizedFrame()

v8::internal::OptimizedFrame::OptimizedFrame ( StackFrameIteratorBase iterator)
inlineexplicitprotected

Definition at line 275 of file frames-inl.h.

276  : JavaScriptFrame(iterator) {
277 }
JavaScriptFrame(StackFrameIteratorBase *iterator)
Definition: frames-inl.h:204

Member Function Documentation

◆ GetDeoptimizationData()

DeoptimizationInputData * v8::internal::OptimizedFrame::GetDeoptimizationData ( int deopt_index)

Definition at line 1034 of file frames.cc.

1035  {
1036  DCHECK(is_optimized());
1037 
1038  JSFunction* opt_function = function();
1039  Code* code = opt_function->code();
1040 
1041  // The code object may have been replaced by lazy deoptimization. Fall
1042  // back to a slow search in this case to find the original optimized
1043  // code object.
1044  if (!code->contains(pc())) {
1045  code = isolate()->inner_pointer_to_code_cache()->
1046  GcSafeFindCodeForInnerPointer(pc());
1047  }
1048  DCHECK(code != NULL);
1049  DCHECK(code->kind() == Code::OPTIMIZED_FUNCTION);
1050 
1051  SafepointEntry safepoint_entry = code->GetSafepointEntry(pc());
1052  *deopt_index = safepoint_entry.deoptimization_index();
1053  DCHECK(*deopt_index != Safepoint::kNoDeoptimizationIndex);
1054 
1055  return DeoptimizationInputData::cast(code->deoptimization_data());
1056 }
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK(condition)
Definition: logging.h:205
const Register pc

References v8::internal::JSFunction::code(), v8::internal::Code::contains(), DCHECK, v8::internal::Code::GetSafepointEntry(), v8::internal::Isolate::inner_pointer_to_code_cache(), v8::internal::Code::kind(), NULL, and v8::internal::pc.

Referenced by GetFunctions(), GetInlineCount(), and Summarize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFunctions()

void v8::internal::OptimizedFrame::GetFunctions ( List< JSFunction * > *  functions)
virtual

Reimplemented from v8::internal::JavaScriptFrame.

Definition at line 1082 of file frames.cc.

1082  {
1083  DCHECK(functions->length() == 0);
1084  DCHECK(is_optimized());
1085 
1086  // Delegate to JS frame in absence of turbofan deoptimization.
1087  // TODO(turbofan): Revisit once we support deoptimization across the board.
1088  if (LookupCode()->is_turbofanned() && !FLAG_turbo_deoptimization) {
1089  return JavaScriptFrame::GetFunctions(functions);
1090  }
1091 
1092  int deopt_index = Safepoint::kNoDeoptimizationIndex;
1093  DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
1094  FixedArray* literal_array = data->LiteralArray();
1095 
1096  TranslationIterator it(data->TranslationByteArray(),
1097  data->TranslationIndex(deopt_index)->value());
1098  Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
1099  DCHECK(opcode == Translation::BEGIN);
1100  it.Next(); // Drop frame count.
1101  int jsframe_count = it.Next();
1102 
1103  // We insert the frames in reverse order because the frames
1104  // in the deoptimization translation are ordered bottom-to-top.
1105  while (jsframe_count > 0) {
1106  opcode = static_cast<Translation::Opcode>(it.Next());
1107  if (opcode == Translation::JS_FRAME) {
1108  jsframe_count--;
1109  it.Next(); // Skip ast id.
1110  JSFunction* function = LiteralAt(literal_array, it.Next());
1111  it.Next(); // Skip height.
1112  functions->Add(function);
1113  } else {
1114  // Skip over operands to advance to the next opcode.
1115  it.Skip(Translation::NumberOfOperandsFor(opcode));
1116  }
1117  }
1118 }
virtual void GetFunctions(List< JSFunction * > *functions)
Definition: frames.cc:762
DeoptimizationInputData * GetDeoptimizationData(int *deopt_index)
Definition: frames.cc:1034
JSFunction * LiteralAt(FixedArray *literal_array, int literal_id)
Definition: frames.cc:921

References v8::internal::List< T, AllocationPolicy >::Add(), DCHECK, GetDeoptimizationData(), v8::internal::JavaScriptFrame::GetFunctions(), v8::internal::compiler::JS_FRAME, and LiteralAt().

+ Here is the call graph for this function:

◆ GetInlineCount()

int v8::internal::OptimizedFrame::GetInlineCount ( )
virtual

Reimplemented from v8::internal::JavaScriptFrame.

Definition at line 1059 of file frames.cc.

1059  {
1060  DCHECK(is_optimized());
1061 
1062  // Delegate to JS frame in absence of turbofan deoptimization.
1063  // TODO(turbofan): Revisit once we support deoptimization across the board.
1064  if (LookupCode()->is_turbofanned() && !FLAG_turbo_deoptimization) {
1066  }
1067 
1068  int deopt_index = Safepoint::kNoDeoptimizationIndex;
1069  DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
1070 
1071  TranslationIterator it(data->TranslationByteArray(),
1072  data->TranslationIndex(deopt_index)->value());
1073  Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
1074  DCHECK(opcode == Translation::BEGIN);
1075  USE(opcode);
1076  it.Next(); // Drop frame count.
1077  int jsframe_count = it.Next();
1078  return jsframe_count;
1079 }
virtual int GetInlineCount()
Definition: frames.h:599
void USE(T)
Definition: macros.h:322

References DCHECK, GetDeoptimizationData(), v8::internal::JavaScriptFrame::GetInlineCount(), and USE().

+ Here is the call graph for this function:

◆ Iterate()

void v8::internal::OptimizedFrame::Iterate ( ObjectVisitor v) const
virtual

Reimplemented from v8::internal::JavaScriptFrame.

Definition at line 708 of file frames.cc.

708  {
709 #ifdef DEBUG
710  // Make sure that optimized frames do not contain any stack handlers.
711  StackHandlerIterator it(this, top_handler());
712  DCHECK(it.done());
713 #endif
714 
716 }
void IterateCompiledFrame(ObjectVisitor *v) const
Definition: frames.cc:616

References DCHECK, and v8::internal::StandardFrame::IterateCompiledFrame().

+ Here is the call graph for this function:

◆ LiteralAt()

JSFunction * v8::internal::OptimizedFrame::LiteralAt ( FixedArray literal_array,
int  literal_id 
)
private

Definition at line 921 of file frames.cc.

922  {
923  if (literal_id == Translation::kSelfLiteralId) {
924  return function();
925  }
926 
927  return JSFunction::cast(literal_array->get(literal_id));
928 }

References v8::internal::FixedArray::get().

Referenced by GetFunctions(), and Summarize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Summarize()

void v8::internal::OptimizedFrame::Summarize ( List< FrameSummary > *  frames)
virtual

Reimplemented from v8::internal::JavaScriptFrame.

Definition at line 931 of file frames.cc.

931  {
932  DCHECK(frames->length() == 0);
933  DCHECK(is_optimized());
934 
935  // Delegate to JS frame in absence of turbofan deoptimization.
936  // TODO(turbofan): Revisit once we support deoptimization across the board.
937  if (LookupCode()->is_turbofanned() && !FLAG_turbo_deoptimization) {
938  return JavaScriptFrame::Summarize(frames);
939  }
940 
941  int deopt_index = Safepoint::kNoDeoptimizationIndex;
942  DeoptimizationInputData* data = GetDeoptimizationData(&deopt_index);
943  FixedArray* literal_array = data->LiteralArray();
944 
945  // BUG(3243555): Since we don't have a lazy-deopt registered at
946  // throw-statements, we can't use the translation at the call-site of
947  // throw. An entry with no deoptimization index indicates a call-site
948  // without a lazy-deopt. As a consequence we are not allowed to inline
949  // functions containing throw.
950  DCHECK(deopt_index != Safepoint::kNoDeoptimizationIndex);
951 
952  TranslationIterator it(data->TranslationByteArray(),
953  data->TranslationIndex(deopt_index)->value());
954  Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next());
955  DCHECK(opcode == Translation::BEGIN);
956  it.Next(); // Drop frame count.
957  int jsframe_count = it.Next();
958 
959  // We create the summary in reverse order because the frames
960  // in the deoptimization translation are ordered bottom-to-top.
961  bool is_constructor = IsConstructor();
962  int i = jsframe_count;
963  while (i > 0) {
964  opcode = static_cast<Translation::Opcode>(it.Next());
965  if (opcode == Translation::JS_FRAME) {
966  i--;
967  BailoutId ast_id = BailoutId(it.Next());
968  JSFunction* function = LiteralAt(literal_array, it.Next());
969  it.Next(); // Skip height.
970 
971  // The translation commands are ordered and the receiver is always
972  // at the first position.
973  // If we are at a call, the receiver is always in a stack slot.
974  // Otherwise we are not guaranteed to get the receiver value.
975  opcode = static_cast<Translation::Opcode>(it.Next());
976  int index = it.Next();
977 
978  // Get the correct receiver in the optimized frame.
979  Object* receiver = NULL;
980  if (opcode == Translation::LITERAL) {
981  receiver = data->LiteralArray()->get(index);
982  } else if (opcode == Translation::STACK_SLOT) {
983  // Positive index means the value is spilled to the locals
984  // area. Negative means it is stored in the incoming parameter
985  // area.
986  if (index >= 0) {
987  receiver = GetExpression(index);
988  } else {
989  // Index -1 overlaps with last parameter, -n with the first parameter,
990  // (-n - 1) with the receiver with n being the number of parameters
991  // of the outermost, optimized frame.
992  int parameter_count = ComputeParametersCount();
993  int parameter_index = index + parameter_count;
994  receiver = (parameter_index == -1)
995  ? this->receiver()
996  : this->GetParameter(parameter_index);
997  }
998  } else {
999  // The receiver is not in a stack slot nor in a literal. We give up.
1000  // TODO(3029): Materializing a captured object (or duplicated
1001  // object) is hard, we return undefined for now. This breaks the
1002  // produced stack trace, as constructor frames aren't marked as
1003  // such anymore.
1004  receiver = isolate()->heap()->undefined_value();
1005  }
1006 
1007  Code* code = function->shared()->code();
1008  DeoptimizationOutputData* output_data =
1009  DeoptimizationOutputData::cast(code->deoptimization_data());
1010  unsigned entry = Deoptimizer::GetOutputInfo(output_data,
1011  ast_id,
1012  function->shared());
1013  unsigned pc_offset =
1015  DCHECK(pc_offset > 0);
1016 
1017  FrameSummary summary(receiver, function, code, pc_offset, is_constructor);
1018  frames->Add(summary);
1019  is_constructor = false;
1020  } else if (opcode == Translation::CONSTRUCT_STUB_FRAME) {
1021  // The next encountered JS_FRAME will be marked as a constructor call.
1022  it.Skip(Translation::NumberOfOperandsFor(opcode));
1023  DCHECK(!is_constructor);
1024  is_constructor = true;
1025  } else {
1026  // Skip over operands to advance to the next opcode.
1027  it.Skip(Translation::NumberOfOperandsFor(opcode));
1028  }
1029  }
1030  DCHECK(!is_constructor);
1031 }
static T decode(U value)
Definition: utils.h:228
static const int kHeaderSize
Definition: objects.h:5373
static int GetOutputInfo(DeoptimizationOutputData *data, BailoutId node_id, SharedFunctionInfo *shared)
Definition: deoptimizer.cc:707
Object * receiver() const
Definition: frames-inl.h:250
bool IsConstructor() const
Definition: frames.cc:724
virtual void Summarize(List< FrameSummary > *frames)
Definition: frames.cc:768
Object * GetParameter(int index) const
Definition: frames-inl.h:217
JSFunction * function() const
Definition: frames-inl.h:265
int ComputeParametersCount() const
Definition: frames.h:562
Object * GetExpression(int index) const
Definition: frames-inl.h:154
kSerializedDataOffset Object
Definition: objects-inl.h:5322

References v8::internal::List< T, AllocationPolicy >::Add(), v8::internal::JavaScriptFrame::ComputeParametersCount(), DCHECK, v8::internal::BitFieldBase< T, shift, size, U >::decode(), v8::internal::JavaScriptFrame::function(), v8::internal::FixedArray::get(), GetDeoptimizationData(), v8::internal::StandardFrame::GetExpression(), v8::internal::Deoptimizer::GetOutputInfo(), v8::internal::JavaScriptFrame::GetParameter(), v8::internal::Isolate::heap(), v8::internal::JavaScriptFrame::IsConstructor(), v8::internal::compiler::JS_FRAME, v8::internal::Code::kHeaderSize, LiteralAt(), NULL, v8::internal::JavaScriptFrame::receiver(), and v8::internal::JavaScriptFrame::Summarize().

+ Here is the call graph for this function:

◆ type()

virtual Type v8::internal::OptimizedFrame::type ( ) const
inlinevirtual

Reimplemented from v8::internal::JavaScriptFrame.

Definition at line 665 of file frames.h.

665 { return OPTIMIZED; }

Friends And Related Function Documentation

◆ StackFrameIteratorBase

friend class StackFrameIteratorBase
friend

Definition at line 687 of file frames.h.


The documentation for this class was generated from the following files: