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

Side by Side 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: remove bogus assertion Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef V8_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // - Bool32x4 120 // - Bool32x4
121 // - Int16x8 121 // - Int16x8
122 // - Uint16x8 122 // - Uint16x8
123 // - Bool16x8 123 // - Bool16x8
124 // - Int8x16 124 // - Int8x16
125 // - Uint8x16 125 // - Uint8x16
126 // - Bool8x16 126 // - Bool8x16
127 // - Cell 127 // - Cell
128 // - PropertyCell 128 // - PropertyCell
129 // - Code 129 // - Code
130 // - AbstractCode, a wrapper around Code or BytecodeArray
130 // - Map 131 // - Map
131 // - Oddball 132 // - Oddball
132 // - Foreign 133 // - Foreign
133 // - SharedFunctionInfo 134 // - SharedFunctionInfo
134 // - Struct 135 // - Struct
135 // - Box 136 // - Box
136 // - AccessorInfo 137 // - AccessorInfo
137 // - AccessorPair 138 // - AccessorPair
138 // - AccessCheckInfo 139 // - AccessCheckInfo
139 // - InterceptorInfo 140 // - InterceptorInfo
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 V(FixedDoubleArray) \ 937 V(FixedDoubleArray) \
937 V(WeakFixedArray) \ 938 V(WeakFixedArray) \
938 V(ArrayList) \ 939 V(ArrayList) \
939 V(Context) \ 940 V(Context) \
940 V(ScriptContextTable) \ 941 V(ScriptContextTable) \
941 V(NativeContext) \ 942 V(NativeContext) \
942 V(ScopeInfo) \ 943 V(ScopeInfo) \
943 V(JSBoundFunction) \ 944 V(JSBoundFunction) \
944 V(JSFunction) \ 945 V(JSFunction) \
945 V(Code) \ 946 V(Code) \
947 V(AbstractCode) \
946 V(Oddball) \ 948 V(Oddball) \
947 V(SharedFunctionInfo) \ 949 V(SharedFunctionInfo) \
948 V(JSValue) \ 950 V(JSValue) \
949 V(JSDate) \ 951 V(JSDate) \
950 V(JSMessageObject) \ 952 V(JSMessageObject) \
951 V(StringWrapper) \ 953 V(StringWrapper) \
952 V(Foreign) \ 954 V(Foreign) \
953 V(Boolean) \ 955 V(Boolean) \
954 V(JSArray) \ 956 V(JSArray) \
955 V(JSArrayBuffer) \ 957 V(JSArrayBuffer) \
(...skipping 3465 matching lines...) Expand 10 before | Expand all | Expand 10 after
4421 4423
4422 // Accessors for source position table containing mappings between byte code 4424 // Accessors for source position table containing mappings between byte code
4423 // offset and source position. 4425 // offset and source position.
4424 DECL_ACCESSORS(source_position_table, FixedArray) 4426 DECL_ACCESSORS(source_position_table, FixedArray)
4425 4427
4426 DECLARE_CAST(BytecodeArray) 4428 DECLARE_CAST(BytecodeArray)
4427 4429
4428 // Dispatched behavior. 4430 // Dispatched behavior.
4429 inline int BytecodeArraySize(); 4431 inline int BytecodeArraySize();
4430 4432
4433 inline int instruction_size();
4434
4435 int SourcePosition(int offset);
4436
4431 DECLARE_PRINTER(BytecodeArray) 4437 DECLARE_PRINTER(BytecodeArray)
4432 DECLARE_VERIFIER(BytecodeArray) 4438 DECLARE_VERIFIER(BytecodeArray)
4433 4439
4434 void Disassemble(std::ostream& os); 4440 void Disassemble(std::ostream& os);
4435 4441
4436 // Layout description. 4442 // Layout description.
4437 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; 4443 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize;
4438 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize; 4444 static const int kParameterSizeOffset = kFrameSizeOffset + kIntSize;
4439 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize; 4445 static const int kConstantPoolOffset = kParameterSizeOffset + kIntSize;
4440 static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize; 4446 static const int kHandlerTableOffset = kConstantPoolOffset + kPointerSize;
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 static int SizeFor(int body_size) { 5144 static int SizeFor(int body_size) {
5139 DCHECK_SIZE_TAG_ALIGNED(body_size); 5145 DCHECK_SIZE_TAG_ALIGNED(body_size);
5140 return RoundUp(kHeaderSize + body_size, kCodeAlignment); 5146 return RoundUp(kHeaderSize + body_size, kCodeAlignment);
5141 } 5147 }
5142 5148
5143 // Calculate the size of the code object to report for log events. This takes 5149 // Calculate the size of the code object to report for log events. This takes
5144 // the layout of the code object into account. 5150 // the layout of the code object into account.
5145 inline int ExecutableSize(); 5151 inline int ExecutableSize();
5146 5152
5147 // Locating source position. 5153 // Locating source position.
5148 int SourcePosition(Address pc); 5154 int SourcePosition(int code_offset);
5149 int SourceStatementPosition(Address pc); 5155 int SourceStatementPosition(int code_offset);
5150 5156
5151 DECLARE_CAST(Code) 5157 DECLARE_CAST(Code)
5152 5158
5153 // Dispatched behavior. 5159 // Dispatched behavior.
5154 inline int CodeSize(); 5160 inline int CodeSize();
5155 5161
5156 DECLARE_PRINTER(Code) 5162 DECLARE_PRINTER(Code)
5157 DECLARE_VERIFIER(Code) 5163 DECLARE_VERIFIER(Code)
5158 5164
5159 void ClearInlineCaches(); 5165 void ClearInlineCaches();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
5336 static Code* GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity); 5342 static Code* GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity);
5337 5343
5338 // Code aging -- platform-specific 5344 // Code aging -- platform-specific
5339 static void PatchPlatformCodeAge(Isolate* isolate, 5345 static void PatchPlatformCodeAge(Isolate* isolate,
5340 byte* sequence, Age age, 5346 byte* sequence, Age age,
5341 MarkingParity parity); 5347 MarkingParity parity);
5342 5348
5343 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 5349 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
5344 }; 5350 };
5345 5351
5352 class AbstractCode : public HeapObject {
5353 public:
5354 int SourcePosition(int offset);
5355
5356 DECLARE_CAST(AbstractCode)
5357 inline Code* GetCode();
5358 inline BytecodeArray* GetBytecodeArray();
5359 };
5346 5360
5347 // Dependent code is a singly linked list of fixed arrays. Each array contains 5361 // Dependent code is a singly linked list of fixed arrays. Each array contains
5348 // code objects in weak cells for one dependent group. The suffix of the array 5362 // code objects in weak cells for one dependent group. The suffix of the array
5349 // can be filled with the undefined value if the number of codes is less than 5363 // can be filled with the undefined value if the number of codes is less than
5350 // the length of the array. 5364 // the length of the array.
5351 // 5365 //
5352 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ 5366 // +------+-----------------+--------+--------+-----+--------+-----------+-----+
5353 // | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... | 5367 // | next | count & group 1 | code 1 | code 2 | ... | code n | undefined | ... |
5354 // +------+-----------------+--------+--------+-----+--------+-----------+-----+ 5368 // +------+-----------------+--------+--------+-----+--------+-----------+-----+
5355 // | 5369 // |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
6372 // this through. Encoded in the 'flags' field. 6386 // this through. Encoded in the 'flags' field.
6373 inline v8::ScriptOriginOptions origin_options(); 6387 inline v8::ScriptOriginOptions origin_options();
6374 inline void set_origin_options(ScriptOriginOptions origin_options); 6388 inline void set_origin_options(ScriptOriginOptions origin_options);
6375 6389
6376 DECLARE_CAST(Script) 6390 DECLARE_CAST(Script)
6377 6391
6378 // If script source is an external string, check that the underlying 6392 // If script source is an external string, check that the underlying
6379 // resource is accessible. Otherwise, always return true. 6393 // resource is accessible. Otherwise, always return true.
6380 inline bool HasValidSource(); 6394 inline bool HasValidSource();
6381 6395
6382 // Convert code position into column number. 6396 // Convert code offset into column number.
6383 static int GetColumnNumber(Handle<Script> script, int code_pos); 6397 static int GetColumnNumber(Handle<Script> script, int code_offset);
6384 6398
6385 // Convert code position into (zero-based) line number. 6399 // Convert code offset into (zero-based) line number.
6386 // The non-handlified version does not allocate, but may be much slower. 6400 // The non-handlified version does not allocate, but may be much slower.
6387 static int GetLineNumber(Handle<Script> script, int code_pos); 6401 static int GetLineNumber(Handle<Script> script, int code_offset);
6388 int GetLineNumber(int code_pos); 6402 int GetLineNumber(int code_pos);
6389 6403
6390 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); 6404 static Handle<Object> GetNameOrSourceURL(Handle<Script> script);
6391 6405
6392 // Init line_ends array with code positions of line ends inside script source. 6406 // Init line_ends array with source code positions of line ends.
6393 static void InitLineEnds(Handle<Script> script); 6407 static void InitLineEnds(Handle<Script> script);
6394 6408
6395 // Get the JS object wrapping the given script; create it if none exists. 6409 // Get the JS object wrapping the given script; create it if none exists.
6396 static Handle<JSObject> GetWrapper(Handle<Script> script); 6410 static Handle<JSObject> GetWrapper(Handle<Script> script);
6397 6411
6398 // Look through the list of existing shared function infos to find one 6412 // Look through the list of existing shared function infos to find one
6399 // that matches the function literal. Return empty handle if not found. 6413 // that matches the function literal. Return empty handle if not found.
6400 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); 6414 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun);
6401 6415
6402 // Iterate over all script objects on the heap. 6416 // Iterate over all script objects on the heap.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
6518 6532
6519 // SharedFunctionInfo describes the JSFunction information that can be 6533 // SharedFunctionInfo describes the JSFunction information that can be
6520 // shared by multiple instances of the function. 6534 // shared by multiple instances of the function.
6521 class SharedFunctionInfo: public HeapObject { 6535 class SharedFunctionInfo: public HeapObject {
6522 public: 6536 public:
6523 // [name]: Function name. 6537 // [name]: Function name.
6524 DECL_ACCESSORS(name, Object) 6538 DECL_ACCESSORS(name, Object)
6525 6539
6526 // [code]: Function code. 6540 // [code]: Function code.
6527 DECL_ACCESSORS(code, Code) 6541 DECL_ACCESSORS(code, Code)
6542
6528 inline void ReplaceCode(Code* code); 6543 inline void ReplaceCode(Code* code);
6529 6544
6530 // [optimized_code_map]: Map from native context to optimized code 6545 // [optimized_code_map]: Map from native context to optimized code
6531 // and a shared literals array. 6546 // and a shared literals array.
6532 DECL_ACCESSORS(optimized_code_map, FixedArray) 6547 DECL_ACCESSORS(optimized_code_map, FixedArray)
6533 6548
6534 // Returns entry from optimized code map for specified context and OSR entry. 6549 // Returns entry from optimized code map for specified context and OSR entry.
6535 // Note that {code == nullptr, literals == nullptr} indicates no matching 6550 // Note that {code == nullptr, literals == nullptr} indicates no matching
6536 // entry has been found, whereas {code, literals == nullptr} indicates that 6551 // entry has been found, whereas {code, literals == nullptr} indicates that
6537 // code is context-independent. 6552 // code is context-independent.
(...skipping 4028 matching lines...) Expand 10 before | Expand all | Expand 10 after
10566 class DebugInfo: public Struct { 10581 class DebugInfo: public Struct {
10567 public: 10582 public:
10568 // The shared function info for the source being debugged. 10583 // The shared function info for the source being debugged.
10569 DECL_ACCESSORS(shared, SharedFunctionInfo) 10584 DECL_ACCESSORS(shared, SharedFunctionInfo)
10570 // Code object for the patched code. This code object is the code object 10585 // Code object for the patched code. This code object is the code object
10571 // currently active for the function. 10586 // currently active for the function.
10572 DECL_ACCESSORS(code, Code) 10587 DECL_ACCESSORS(code, Code)
10573 // Fixed array holding status information for each active break point. 10588 // Fixed array holding status information for each active break point.
10574 DECL_ACCESSORS(break_points, FixedArray) 10589 DECL_ACCESSORS(break_points, FixedArray)
10575 10590
10576 // Check if there is a break point at a code position. 10591 // Check if there is a break point at a code offset.
10577 bool HasBreakPoint(int code_position); 10592 bool HasBreakPoint(int code_offset);
10578 // Get the break point info object for a code position. 10593 // Get the break point info object for a code offset.
10579 Object* GetBreakPointInfo(int code_position); 10594 Object* GetBreakPointInfo(int code_offset);
10580 // Clear a break point. 10595 // Clear a break point.
10581 static void ClearBreakPoint(Handle<DebugInfo> debug_info, 10596 static void ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
10582 int code_position,
10583 Handle<Object> break_point_object); 10597 Handle<Object> break_point_object);
10584 // Set a break point. 10598 // Set a break point.
10585 static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_position, 10599 static void SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset,
10586 int source_position, int statement_position, 10600 int source_position, int statement_position,
10587 Handle<Object> break_point_object); 10601 Handle<Object> break_point_object);
10588 // Get the break point objects for a code position. 10602 // Get the break point objects for a code offset.
10589 Handle<Object> GetBreakPointObjects(int code_position); 10603 Handle<Object> GetBreakPointObjects(int code_offset);
10590 // Find the break point info holding this break point object. 10604 // Find the break point info holding this break point object.
10591 static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info, 10605 static Handle<Object> FindBreakPointInfo(Handle<DebugInfo> debug_info,
10592 Handle<Object> break_point_object); 10606 Handle<Object> break_point_object);
10593 // Get the number of break points for this function. 10607 // Get the number of break points for this function.
10594 int GetBreakPointCount(); 10608 int GetBreakPointCount();
10595 10609
10596 DECLARE_CAST(DebugInfo) 10610 DECLARE_CAST(DebugInfo)
10597 10611
10598 // Dispatched behavior. 10612 // Dispatched behavior.
10599 DECLARE_PRINTER(DebugInfo) 10613 DECLARE_PRINTER(DebugInfo)
10600 DECLARE_VERIFIER(DebugInfo) 10614 DECLARE_VERIFIER(DebugInfo)
10601 10615
10602 static const int kSharedFunctionInfoIndex = Struct::kHeaderSize; 10616 static const int kSharedFunctionInfoIndex = Struct::kHeaderSize;
10603 static const int kCodeIndex = kSharedFunctionInfoIndex + kPointerSize; 10617 static const int kCodeIndex = kSharedFunctionInfoIndex + kPointerSize;
10604 static const int kBreakPointsStateIndex = kCodeIndex + kPointerSize; 10618 static const int kBreakPointsStateIndex = kCodeIndex + kPointerSize;
10605 static const int kSize = kBreakPointsStateIndex + kPointerSize; 10619 static const int kSize = kBreakPointsStateIndex + kPointerSize;
10606 10620
10607 static const int kEstimatedNofBreakPointsInFunction = 16; 10621 static const int kEstimatedNofBreakPointsInFunction = 16;
10608 10622
10609 private: 10623 private:
10610 static const int kNoBreakPointInfo = -1; 10624 static const int kNoBreakPointInfo = -1;
10611 10625
10612 // Lookup the index in the break_points array for a code position. 10626 // Lookup the index in the break_points array for a code offset.
10613 int GetBreakPointInfoIndex(int code_position); 10627 int GetBreakPointInfoIndex(int code_offset);
10614 10628
10615 DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo); 10629 DISALLOW_IMPLICIT_CONSTRUCTORS(DebugInfo);
10616 }; 10630 };
10617 10631
10618 10632
10619 // The BreakPointInfo class holds information for break points set in a 10633 // The BreakPointInfo class holds information for break points set in a
10620 // function. The DebugInfo object holds a BreakPointInfo object for each code 10634 // function. The DebugInfo object holds a BreakPointInfo object for each code
10621 // position with one or more break points. 10635 // position with one or more break points.
10622 class BreakPointInfo: public Struct { 10636 class BreakPointInfo: public Struct {
10623 public: 10637 public:
10624 // The position in the code for the break point. 10638 // The code offset for the break point.
10625 DECL_INT_ACCESSORS(code_position) 10639 DECL_INT_ACCESSORS(code_offset)
10626 // The position in the source for the break position. 10640 // The position in the source for the break position.
10627 DECL_INT_ACCESSORS(source_position) 10641 DECL_INT_ACCESSORS(source_position)
10628 // The position in the source for the last statement before this break 10642 // The position in the source for the last statement before this break
10629 // position. 10643 // position.
10630 DECL_INT_ACCESSORS(statement_position) 10644 DECL_INT_ACCESSORS(statement_position)
10631 // List of related JavaScript break points. 10645 // List of related JavaScript break points.
10632 DECL_ACCESSORS(break_point_objects, Object) 10646 DECL_ACCESSORS(break_point_objects, Object)
10633 10647
10634 // Removes a break point. 10648 // Removes a break point.
10635 static void ClearBreakPoint(Handle<BreakPointInfo> info, 10649 static void ClearBreakPoint(Handle<BreakPointInfo> info,
10636 Handle<Object> break_point_object); 10650 Handle<Object> break_point_object);
10637 // Set a break point. 10651 // Set a break point.
10638 static void SetBreakPoint(Handle<BreakPointInfo> info, 10652 static void SetBreakPoint(Handle<BreakPointInfo> info,
10639 Handle<Object> break_point_object); 10653 Handle<Object> break_point_object);
10640 // Check if break point info has this break point object. 10654 // Check if break point info has this break point object.
10641 static bool HasBreakPointObject(Handle<BreakPointInfo> info, 10655 static bool HasBreakPointObject(Handle<BreakPointInfo> info,
10642 Handle<Object> break_point_object); 10656 Handle<Object> break_point_object);
10643 // Get the number of break points for this code position. 10657 // Get the number of break points for this code offset.
10644 int GetBreakPointCount(); 10658 int GetBreakPointCount();
10645 10659
10646 DECLARE_CAST(BreakPointInfo) 10660 DECLARE_CAST(BreakPointInfo)
10647 10661
10648 // Dispatched behavior. 10662 // Dispatched behavior.
10649 DECLARE_PRINTER(BreakPointInfo) 10663 DECLARE_PRINTER(BreakPointInfo)
10650 DECLARE_VERIFIER(BreakPointInfo) 10664 DECLARE_VERIFIER(BreakPointInfo)
10651 10665
10652 static const int kCodePositionIndex = Struct::kHeaderSize; 10666 static const int kCodeOffsetIndex = Struct::kHeaderSize;
10653 static const int kSourcePositionIndex = kCodePositionIndex + kPointerSize; 10667 static const int kSourcePositionIndex = kCodeOffsetIndex + kPointerSize;
10654 static const int kStatementPositionIndex = 10668 static const int kStatementPositionIndex =
10655 kSourcePositionIndex + kPointerSize; 10669 kSourcePositionIndex + kPointerSize;
10656 static const int kBreakPointObjectsIndex = 10670 static const int kBreakPointObjectsIndex =
10657 kStatementPositionIndex + kPointerSize; 10671 kStatementPositionIndex + kPointerSize;
10658 static const int kSize = kBreakPointObjectsIndex + kPointerSize; 10672 static const int kSize = kBreakPointObjectsIndex + kPointerSize;
10659 10673
10660 private: 10674 private:
10661 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo); 10675 DISALLOW_IMPLICIT_CONSTRUCTORS(BreakPointInfo);
10662 }; 10676 };
10663 10677
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
10779 } 10793 }
10780 return value; 10794 return value;
10781 } 10795 }
10782 }; 10796 };
10783 10797
10784 10798
10785 } // NOLINT, false-positive due to second-order macros. 10799 } // NOLINT, false-positive due to second-order macros.
10786 } // NOLINT, false-positive due to second-order macros. 10800 } // NOLINT, false-positive due to second-order macros.
10787 10801
10788 #endif // V8_OBJECTS_H_ 10802 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698