OLD | NEW |
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 6270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6281 | 6281 |
6282 // [code]: Function code. | 6282 // [code]: Function code. |
6283 DECL_ACCESSORS(code, Code) | 6283 DECL_ACCESSORS(code, Code) |
6284 inline void ReplaceCode(Code* code); | 6284 inline void ReplaceCode(Code* code); |
6285 | 6285 |
6286 // [optimized_code_map]: Map from native context to optimized code | 6286 // [optimized_code_map]: Map from native context to optimized code |
6287 // and a shared literals array or Smi(0) if none. | 6287 // and a shared literals array or Smi(0) if none. |
6288 DECL_ACCESSORS(optimized_code_map, Object) | 6288 DECL_ACCESSORS(optimized_code_map, Object) |
6289 | 6289 |
6290 // Returns entry from optimized code map for specified context and OSR entry. | 6290 // Returns entry from optimized code map for specified context and OSR entry. |
6291 // Note that {code == nullptr} indicates no matching entry has been found, | 6291 // Note that {code == nullptr, literals == nullptr} indicates no matching |
6292 // whereas {literals == nullptr} indicates the code is context-independent. | 6292 // entry has been found, whereas {code, literals == nullptr} indicates that |
| 6293 // code is context-independent. |
6293 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, | 6294 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, |
6294 BailoutId osr_ast_id); | 6295 BailoutId osr_ast_id); |
6295 | 6296 |
6296 // Clear optimized code map. | 6297 // Clear optimized code map. |
6297 void ClearOptimizedCodeMap(); | 6298 void ClearOptimizedCodeMap(); |
6298 | 6299 |
6299 // Removed a specific optimized code object from the optimized code map. | 6300 // Removes a specific optimized code object from the optimized code map. |
| 6301 // In case of non-OSR the code reference is cleared from the cache entry but |
| 6302 // the entry itself is left in the map in order to proceed sharing literals. |
6300 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); | 6303 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); |
6301 | 6304 |
6302 // Trims the optimized code map after entries have been removed. | 6305 // Trims the optimized code map after entries have been removed. |
6303 void TrimOptimizedCodeMap(int shrink_by); | 6306 void TrimOptimizedCodeMap(int shrink_by); |
6304 | 6307 |
6305 // Add a new entry to the optimized code map for context-independent code. | 6308 // Add a new entry to the optimized code map for context-independent code. |
6306 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6309 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6307 Handle<Code> code); | 6310 Handle<Code> code); |
6308 | 6311 |
6309 // Add a new entry to the optimized code map for context-dependent code. | 6312 // Add a new entry to the optimized code map for context-dependent code. |
| 6313 // |code| is either a code object or an undefined value. In the latter case |
| 6314 // the entry just maps |native_context, osr_ast_id| pair to |literals| array. |
6310 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6315 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6311 Handle<Context> native_context, | 6316 Handle<Context> native_context, |
6312 Handle<Code> code, | 6317 Handle<HeapObject> code, |
6313 Handle<FixedArray> literals, | 6318 Handle<FixedArray> literals, |
6314 BailoutId osr_ast_id); | 6319 BailoutId osr_ast_id); |
6315 | 6320 |
6316 // Set up the link between shared function info and the script. The shared | 6321 // Set up the link between shared function info and the script. The shared |
6317 // function info is added to the list on the script. | 6322 // function info is added to the list on the script. |
6318 static void SetScript(Handle<SharedFunctionInfo> shared, | 6323 static void SetScript(Handle<SharedFunctionInfo> shared, |
6319 Handle<Object> script_object); | 6324 Handle<Object> script_object); |
6320 | 6325 |
6321 // Layout description of the optimized code map. | 6326 // Layout description of the optimized code map. |
6322 static const int kNextMapIndex = 0; | 6327 static const int kNextMapIndex = 0; |
6323 static const int kSharedCodeIndex = 1; | 6328 static const int kSharedCodeIndex = 1; |
6324 static const int kEntriesStart = 2; | 6329 static const int kEntriesStart = 2; |
6325 static const int kContextOffset = 0; | 6330 static const int kContextOffset = 0; |
6326 static const int kCachedCodeOffset = 1; | 6331 static const int kCachedCodeOffset = 1; |
6327 static const int kLiteralsOffset = 2; | 6332 static const int kLiteralsOffset = 2; |
6328 static const int kOsrAstIdOffset = 3; | 6333 static const int kOsrAstIdOffset = 3; |
6329 static const int kEntryLength = 4; | 6334 static const int kEntryLength = 4; |
6330 static const int kInitialLength = kEntriesStart + kEntryLength; | 6335 static const int kInitialLength = kEntriesStart + kEntryLength; |
6331 | 6336 |
| 6337 static const int kNotFound = -1; |
| 6338 |
6332 // [scope_info]: Scope info. | 6339 // [scope_info]: Scope info. |
6333 DECL_ACCESSORS(scope_info, ScopeInfo) | 6340 DECL_ACCESSORS(scope_info, ScopeInfo) |
6334 | 6341 |
6335 // [construct stub]: Code stub for constructing instances of this function. | 6342 // [construct stub]: Code stub for constructing instances of this function. |
6336 DECL_ACCESSORS(construct_stub, Code) | 6343 DECL_ACCESSORS(construct_stub, Code) |
6337 | 6344 |
6338 // Returns if this function has been compiled to native code yet. | 6345 // Returns if this function has been compiled to native code yet. |
6339 inline bool is_compiled(); | 6346 inline bool is_compiled(); |
6340 | 6347 |
6341 // [length]: The function length - usually the number of declared parameters. | 6348 // [length]: The function length - usually the number of declared parameters. |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6890 (kCompilerHintsSize - 1) - | 6897 (kCompilerHintsSize - 1) - |
6891 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); | 6898 ((kNative + kCompilerHintsSmiTagSize) / kBitsPerByte); |
6892 static const int kBoundByteOffset = | 6899 static const int kBoundByteOffset = |
6893 kCompilerHintsOffset + (kCompilerHintsSize - 1) - | 6900 kCompilerHintsOffset + (kCompilerHintsSize - 1) - |
6894 ((kBoundFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); | 6901 ((kBoundFunction + kCompilerHintsSmiTagSize) / kBitsPerByte); |
6895 #else | 6902 #else |
6896 #error Unknown byte ordering | 6903 #error Unknown byte ordering |
6897 #endif | 6904 #endif |
6898 | 6905 |
6899 private: | 6906 private: |
| 6907 // Returns entry from optimized code map for specified context and OSR entry. |
| 6908 // The result is either kNotFound, kSharedCodeIndex for context-independent |
| 6909 // entry or a start index of the context-dependent entry. |
| 6910 int SearchOptimizedCodeMapEntry(Context* native_context, |
| 6911 BailoutId osr_ast_id); |
| 6912 |
6900 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); | 6913 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); |
6901 }; | 6914 }; |
6902 | 6915 |
6903 | 6916 |
6904 // Printing support. | 6917 // Printing support. |
6905 struct SourceCodeOf { | 6918 struct SourceCodeOf { |
6906 explicit SourceCodeOf(SharedFunctionInfo* v, int max = -1) | 6919 explicit SourceCodeOf(SharedFunctionInfo* v, int max = -1) |
6907 : value(v), max_length(max) {} | 6920 : value(v), max_length(max) {} |
6908 const SharedFunctionInfo* value; | 6921 const SharedFunctionInfo* value; |
6909 int max_length; | 6922 int max_length; |
(...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10561 | 10574 |
10562 Isolate* isolate_; | 10575 Isolate* isolate_; |
10563 Handle<FixedArray> keys_; | 10576 Handle<FixedArray> keys_; |
10564 Handle<OrderedHashSet> set_; | 10577 Handle<OrderedHashSet> set_; |
10565 int length_; | 10578 int length_; |
10566 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10579 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
10567 }; | 10580 }; |
10568 } } // namespace v8::internal | 10581 } } // namespace v8::internal |
10569 | 10582 |
10570 #endif // V8_OBJECTS_H_ | 10583 #endif // V8_OBJECTS_H_ |
OLD | NEW |