Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Unified Diff: src/objects.h

Issue 1618343002: [interpreter, debugger] abstraction for source position calculation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 6ef46beef64e6ca8acd7b28d9c6b41f87596ec4a..f9e3ea669c49921cf411688d58dae90042a6e490 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -127,6 +127,7 @@
// - Cell
// - PropertyCell
// - Code
+// - AbstractCode, a wrapper around Code or BytecodeArray
// - Map
// - Oddball
// - Foreign
@@ -947,6 +948,7 @@ template <class C> inline bool Is(Object* obj);
V(JSBoundFunction) \
V(JSFunction) \
V(Code) \
+ V(AbstractCode) \
V(Oddball) \
V(SharedFunctionInfo) \
V(JSValue) \
@@ -4431,6 +4433,10 @@ class BytecodeArray : public FixedArrayBase {
// Dispatched behavior.
inline int BytecodeArraySize();
+ inline int instruction_size();
+
+ int SourcePosition(int offset);
+
DECLARE_PRINTER(BytecodeArray)
DECLARE_VERIFIER(BytecodeArray)
@@ -5344,6 +5350,16 @@ class Code: public HeapObject {
};
+class AbstractCode : public HeapObject {
+ public:
+ int SourcePosition(int offset);
+
+ DECLARE_CAST(AbstractCode)
+ inline Code* GetCode();
+ inline BytecodeArray* GetBytecodeArray();
+};
+
+
// Dependent code is a singly linked list of fixed arrays. Each array contains
// code objects in weak cells for one dependent group. The suffix of the array
// can be filled with the undefined value if the number of codes is less than
@@ -6384,17 +6400,17 @@ class Script: public Struct {
// resource is accessible. Otherwise, always return true.
inline bool HasValidSource();
- // Convert code position into column number.
- static int GetColumnNumber(Handle<Script> script, int code_pos);
+ // Convert code offset into column number.
+ static int GetColumnNumber(Handle<Script> script, int code_offset);
- // Convert code position into (zero-based) line number.
+ // Convert code offset into (zero-based) line number.
// The non-handlified version does not allocate, but may be much slower.
- static int GetLineNumber(Handle<Script> script, int code_pos);
+ static int GetLineNumber(Handle<Script> script, int code_offset);
int GetLineNumber(int code_pos);
static Handle<Object> GetNameOrSourceURL(Handle<Script> script);
- // Init line_ends array with code positions of line ends inside script source.
+ // Init line_ends array with source code positions of line ends.
static void InitLineEnds(Handle<Script> script);
// Get the JS object wrapping the given script; create it if none exists.
@@ -6530,6 +6546,10 @@ class SharedFunctionInfo: public HeapObject {
// [code]: Function code.
DECL_ACCESSORS(code, Code)
+
+ // Retrieve interpreter bytecode or unoptimized function code.
+ inline AbstractCode* AbstractCode();
+
inline void ReplaceCode(Code* code);
// [optimized_code_map]: Map from native context to optimized code
@@ -10577,20 +10597,19 @@ class DebugInfo: public Struct {
// Fixed array holding status information for each active break point.
DECL_ACCESSORS(break_points, FixedArray)
- // Check if there is a break point at a code position.
- bool HasBreakPoint(int code_position);
- // Get the break point info object for a code position.
- Object* GetBreakPointInfo(int code_position);
+ // Check if there is a break point at a code offset.
+ bool HasBreakPoint(int code_offset);
+ // Get the break point info object for a code offset.
+ Object* GetBreakPointInfo(int code_offset);
// Clear a break point.
- static void ClearBreakPoint(Handle<DebugInfo> debug_info,
- int code_position,
+ static void ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
Handle<Object> break_point_object);
// Set a break point.
- static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_position,
+ static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
int source_position, int statement_position,
Handle<Object> break_point_object);
- // Get the break point objects for a code position.
- Handle<Object> GetBreakPointObjects(int code_position);
+ // Get the break point objects for a code offset.
+ Handle<Object> GetBreakPointObjects(int code_offset);
// Find the break point info holding this break point object.
static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info,
Handle<Object> break_point_object);
@@ -10613,8 +10632,8 @@ class DebugInfo: public Struct {
private:
static const int kNoBreakPointInfo = -1;
- // Lookup the index in the break_points array for a code position.
- int GetBreakPointInfoIndex(int code_position);
+ // Lookup the index in the break_points array for a code offset.
+ int GetBreakPointInfoIndex(int code_offset);
DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
};
@@ -10625,8 +10644,8 @@ class DebugInfo: public Struct {
// position with one or more break points.
class BreakPointInfo: public Struct {
public:
- // The position in the code for the break point.
- DECL_INT_ACCESSORS(code_position)
+ // The code offset for the break point.
+ DECL_INT_ACCESSORS(code_offset)
// The position in the source for the break position.
DECL_INT_ACCESSORS(source_position)
// The position in the source for the last statement before this break
@@ -10644,7 +10663,7 @@ class BreakPointInfo: public Struct {
// Check if break point info has this break point object.
static bool HasBreakPointObject(Handle<BreakPointInfo> info,
Handle<Object> break_point_object);
- // Get the number of break points for this code position.
+ // Get the number of break points for this code offset.
int GetBreakPointCount();
DECLARE_CAST(BreakPointInfo)
@@ -10653,8 +10672,8 @@ class BreakPointInfo: public Struct {
DECLARE_PRINTER(BreakPointInfo)
DECLARE_VERIFIER(BreakPointInfo)
- static const int kCodePositionIndex = Struct::kHeaderSize;
- static const int kSourcePositionIndex = kCodePositionIndex + kPointerSize;
+ static const int kCodeOffsetIndex = Struct::kHeaderSize;
+ static const int kSourcePositionIndex = kCodeOffsetIndex + kPointerSize;
static const int kStatementPositionIndex =
kSourcePositionIndex + kPointerSize;
static const int kBreakPointObjectsIndex =

Powered by Google App Engine
This is Rietveld 408576698