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

Side by Side Diff: src/objects.h

Issue 1374723002: Introduce LiteralsArray to hide it's implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More comments. Created 5 years, 2 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // - JSValue 69 // - JSValue
70 // - JSDate 70 // - JSDate
71 // - JSMessageObject 71 // - JSMessageObject
72 // - JSProxy 72 // - JSProxy
73 // - JSFunctionProxy 73 // - JSFunctionProxy
74 // - FixedArrayBase 74 // - FixedArrayBase
75 // - ByteArray 75 // - ByteArray
76 // - BytecodeArray 76 // - BytecodeArray
77 // - FixedArray 77 // - FixedArray
78 // - DescriptorArray 78 // - DescriptorArray
79 // - LiteralsArray
79 // - HashTable 80 // - HashTable
80 // - Dictionary 81 // - Dictionary
81 // - StringTable 82 // - StringTable
82 // - CompilationCacheTable 83 // - CompilationCacheTable
83 // - CodeCacheHashTable 84 // - CodeCacheHashTable
84 // - MapCache 85 // - MapCache
85 // - OrderedHashTable 86 // - OrderedHashTable
86 // - OrderedHashSet 87 // - OrderedHashSet
87 // - OrderedHashMap 88 // - OrderedHashMap
88 // - Context 89 // - Context
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 class AllocationSiteCreationContext; 842 class AllocationSiteCreationContext;
842 class AllocationSiteUsageContext; 843 class AllocationSiteUsageContext;
843 class Cell; 844 class Cell;
844 class ConsString; 845 class ConsString;
845 class ElementsAccessor; 846 class ElementsAccessor;
846 class FixedArrayBase; 847 class FixedArrayBase;
847 class FunctionLiteral; 848 class FunctionLiteral;
848 class GlobalObject; 849 class GlobalObject;
849 class JSBuiltinsObject; 850 class JSBuiltinsObject;
850 class LayoutDescriptor; 851 class LayoutDescriptor;
852 class LiteralsArray;
851 class LookupIterator; 853 class LookupIterator;
852 class ObjectHashTable; 854 class ObjectHashTable;
853 class ObjectVisitor; 855 class ObjectVisitor;
854 class PropertyCell; 856 class PropertyCell;
855 class SafepointEntry; 857 class SafepointEntry;
856 class SharedFunctionInfo; 858 class SharedFunctionInfo;
857 class StringStream; 859 class StringStream;
858 class TypeFeedbackInfo; 860 class TypeFeedbackInfo;
859 class TypeFeedbackVector; 861 class TypeFeedbackVector;
860 class WeakCell; 862 class WeakCell;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 V(FreeSpace) \ 931 V(FreeSpace) \
930 V(JSReceiver) \ 932 V(JSReceiver) \
931 V(JSObject) \ 933 V(JSObject) \
932 V(JSContextExtensionObject) \ 934 V(JSContextExtensionObject) \
933 V(JSGeneratorObject) \ 935 V(JSGeneratorObject) \
934 V(JSModule) \ 936 V(JSModule) \
935 V(LayoutDescriptor) \ 937 V(LayoutDescriptor) \
936 V(Map) \ 938 V(Map) \
937 V(DescriptorArray) \ 939 V(DescriptorArray) \
938 V(TransitionArray) \ 940 V(TransitionArray) \
941 V(LiteralsArray) \
939 V(TypeFeedbackVector) \ 942 V(TypeFeedbackVector) \
940 V(DeoptimizationInputData) \ 943 V(DeoptimizationInputData) \
941 V(DeoptimizationOutputData) \ 944 V(DeoptimizationOutputData) \
942 V(DependentCode) \ 945 V(DependentCode) \
943 V(HandlerTable) \ 946 V(HandlerTable) \
944 V(FixedArray) \ 947 V(FixedArray) \
945 V(FixedDoubleArray) \ 948 V(FixedDoubleArray) \
946 V(WeakFixedArray) \ 949 V(WeakFixedArray) \
947 V(ArrayList) \ 950 V(ArrayList) \
948 V(Context) \ 951 V(Context) \
(...skipping 3592 matching lines...) Expand 10 before | Expand all | Expand 10 after
4541 PretenureFlag pretenure); 4544 PretenureFlag pretenure);
4542 4545
4543 DECLARE_CAST(DeoptimizationOutputData) 4546 DECLARE_CAST(DeoptimizationOutputData)
4544 4547
4545 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) 4548 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
4546 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT 4549 void DeoptimizationOutputDataPrint(std::ostream& os); // NOLINT
4547 #endif 4550 #endif
4548 }; 4551 };
4549 4552
4550 4553
4554 // A literals array contains the literals for a JSFunction. It also holds
4555 // the type feedback vector.
4556 class LiteralsArray : public FixedArray {
4557 public:
4558 static const int kVectorIndex = 0;
4559 static const int kFirstLiteralIndex = 1;
4560 static const int kOffsetToFirstLiteral =
4561 FixedArray::kHeaderSize + kPointerSize;
4562
4563 static int OffsetOfLiteralAt(int index) {
4564 return SizeFor(index + kFirstLiteralIndex);
4565 }
4566
4567 inline TypeFeedbackVector* feedback_vector() const;
4568 inline void set_feedback_vector(TypeFeedbackVector* vector);
4569 inline Object* literal(int literal_index) const;
4570 inline void set_literal(int literal_index, Object* literal);
4571 inline int literals_count() const;
4572
4573 static Handle<LiteralsArray> Allocate(Isolate* isolate,
Igor Sheludko 2015/09/29 08:40:41 Maybe New() is a better name.
4574 Handle<TypeFeedbackVector> vector,
4575 int number_of_literals,
4576 PretenureFlag pretenure);
4577
4578 DECLARE_CAST(LiteralsArray)
4579
4580 private:
4581 inline Object* get(int index) const;
4582 inline void set(int index, Object* value);
4583 inline void set(int index, Smi* value);
4584 inline void set(int index, Object* value, WriteBarrierMode mode);
4585 };
4586
4587
4551 // HandlerTable is a fixed array containing entries for exception handlers in 4588 // HandlerTable is a fixed array containing entries for exception handlers in
4552 // the code object it is associated with. The tables comes in two flavors: 4589 // the code object it is associated with. The tables comes in two flavors:
4553 // 1) Based on ranges: Used for unoptimized code. Contains one entry per 4590 // 1) Based on ranges: Used for unoptimized code. Contains one entry per
4554 // exception handler and a range representing the try-block covered by that 4591 // exception handler and a range representing the try-block covered by that
4555 // handler. Layout looks as follows: 4592 // handler. Layout looks as follows:
4556 // [ range-start , range-end , handler-offset , stack-depth ] 4593 // [ range-start , range-end , handler-offset , stack-depth ]
4557 // 2) Based on return addresses: Used for turbofanned code. Contains one entry 4594 // 2) Based on return addresses: Used for turbofanned code. Contains one entry
4558 // per call-site that could throw an exception. Layout looks as follows: 4595 // per call-site that could throw an exception. Layout looks as follows:
4559 // [ return-address-offset , handler-offset ] 4596 // [ return-address-offset , handler-offset ]
4560 class HandlerTable : public FixedArray { 4597 class HandlerTable : public FixedArray {
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
6265 // Fake id for a special case of Math.pow. Note, it continues the 6302 // Fake id for a special case of Math.pow. Note, it continues the
6266 // list of math functions. 6303 // list of math functions.
6267 kMathPowHalf 6304 kMathPowHalf
6268 }; 6305 };
6269 6306
6270 6307
6271 // Result of searching in an optimized code map of a SharedFunctionInfo. Note 6308 // Result of searching in an optimized code map of a SharedFunctionInfo. Note
6272 // that both {code} and {literals} can be NULL to pass search result status. 6309 // that both {code} and {literals} can be NULL to pass search result status.
6273 struct CodeAndLiterals { 6310 struct CodeAndLiterals {
6274 Code* code; // Cached optimized code. 6311 Code* code; // Cached optimized code.
6275 FixedArray* literals; // Cached literals array. 6312 LiteralsArray* literals; // Cached literals array.
6276 }; 6313 };
6277 6314
6278 6315
6279 // SharedFunctionInfo describes the JSFunction information that can be 6316 // SharedFunctionInfo describes the JSFunction information that can be
6280 // shared by multiple instances of the function. 6317 // shared by multiple instances of the function.
6281 class SharedFunctionInfo: public HeapObject { 6318 class SharedFunctionInfo: public HeapObject {
6282 public: 6319 public:
6283 // [name]: Function name. 6320 // [name]: Function name.
6284 DECL_ACCESSORS(name, Object) 6321 DECL_ACCESSORS(name, Object)
6285 6322
(...skipping 26 matching lines...) Expand all
6312 // Add a new entry to the optimized code map for context-independent code. 6349 // Add a new entry to the optimized code map for context-independent code.
6313 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6350 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6314 Handle<Code> code); 6351 Handle<Code> code);
6315 6352
6316 // Add a new entry to the optimized code map for context-dependent code. 6353 // Add a new entry to the optimized code map for context-dependent code.
6317 // |code| is either a code object or an undefined value. In the latter case 6354 // |code| is either a code object or an undefined value. In the latter case
6318 // the entry just maps |native_context, osr_ast_id| pair to |literals| array. 6355 // the entry just maps |native_context, osr_ast_id| pair to |literals| array.
6319 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6356 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6320 Handle<Context> native_context, 6357 Handle<Context> native_context,
6321 Handle<HeapObject> code, 6358 Handle<HeapObject> code,
6322 Handle<FixedArray> literals, 6359 Handle<LiteralsArray> literals,
6323 BailoutId osr_ast_id); 6360 BailoutId osr_ast_id);
6324 6361
6325 // Set up the link between shared function info and the script. The shared 6362 // Set up the link between shared function info and the script. The shared
6326 // function info is added to the list on the script. 6363 // function info is added to the list on the script.
6327 static void SetScript(Handle<SharedFunctionInfo> shared, 6364 static void SetScript(Handle<SharedFunctionInfo> shared,
6328 Handle<Object> script_object); 6365 Handle<Object> script_object);
6329 6366
6330 // Layout description of the optimized code map. 6367 // Layout description of the optimized code map.
6331 static const int kNextMapIndex = 0; 6368 static const int kNextMapIndex = 0;
6332 static const int kSharedCodeIndex = 1; 6369 static const int kSharedCodeIndex = 1;
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
7108 // necessary so that we do not dynamically lookup the object, regexp 7145 // necessary so that we do not dynamically lookup the object, regexp
7109 // or array functions. Performing a dynamic lookup, we might end up 7146 // or array functions. Performing a dynamic lookup, we might end up
7110 // using the functions from a new context that we should not have 7147 // using the functions from a new context that we should not have
7111 // access to. 7148 // access to.
7112 // 7149 //
7113 // On bound functions, the array is a (copy-on-write) fixed-array containing 7150 // On bound functions, the array is a (copy-on-write) fixed-array containing
7114 // the function that was bound, bound this-value and any bound 7151 // the function that was bound, bound this-value and any bound
7115 // arguments. Bound functions never contain literals. 7152 // arguments. Bound functions never contain literals.
7116 DECL_ACCESSORS(literals_or_bindings, FixedArray) 7153 DECL_ACCESSORS(literals_or_bindings, FixedArray)
7117 7154
7118 inline FixedArray* literals(); 7155 inline LiteralsArray* literals();
7119 inline void set_literals(FixedArray* literals); 7156 inline void set_literals(LiteralsArray* literals);
7120 7157
7121 inline FixedArray* function_bindings(); 7158 inline FixedArray* function_bindings();
7122 inline void set_function_bindings(FixedArray* bindings); 7159 inline void set_function_bindings(FixedArray* bindings);
7123 7160
7124 // The initial map for an object created by this constructor. 7161 // The initial map for an object created by this constructor.
7125 inline Map* initial_map(); 7162 inline Map* initial_map();
7126 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, 7163 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
7127 Handle<Object> prototype); 7164 Handle<Object> prototype);
7128 inline bool has_initial_map(); 7165 inline bool has_initial_map();
7129 static void EnsureHasInitialMap(Handle<JSFunction> function); 7166 static void EnsureHasInitialMap(Handle<JSFunction> function);
(...skipping 3442 matching lines...) Expand 10 before | Expand all | Expand 10 after
10572 10609
10573 Isolate* isolate_; 10610 Isolate* isolate_;
10574 Handle<FixedArray> keys_; 10611 Handle<FixedArray> keys_;
10575 Handle<OrderedHashSet> set_; 10612 Handle<OrderedHashSet> set_;
10576 int length_; 10613 int length_;
10577 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); 10614 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator);
10578 }; 10615 };
10579 } } // namespace v8::internal 10616 } } // namespace v8::internal
10580 10617
10581 #endif // V8_OBJECTS_H_ 10618 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698