OLD | NEW |
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 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 7096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7107 // function from which eval was called. | 7107 // function from which eval was called. |
7108 DECL_ACCESSORS(eval_from_shared, Object) | 7108 DECL_ACCESSORS(eval_from_shared, Object) |
7109 | 7109 |
7110 // [eval_from_position]: the source position in the code for the function | 7110 // [eval_from_position]: the source position in the code for the function |
7111 // from which eval was called, as positive integer. Or the code offset in the | 7111 // from which eval was called, as positive integer. Or the code offset in the |
7112 // code from which eval was called, as negative integer. | 7112 // code from which eval was called, as negative integer. |
7113 DECL_INT_ACCESSORS(eval_from_position) | 7113 DECL_INT_ACCESSORS(eval_from_position) |
7114 | 7114 |
7115 // [shared_function_infos]: weak fixed array containing all shared | 7115 // [shared_function_infos]: weak fixed array containing all shared |
7116 // function infos created from this script. | 7116 // function infos created from this script. |
7117 DECL_ACCESSORS(shared_function_infos, Object) | 7117 DECL_ACCESSORS(shared_function_infos, FixedArray) |
7118 | 7118 |
7119 // [flags]: Holds an exciting bitfield. | 7119 // [flags]: Holds an exciting bitfield. |
7120 DECL_INT_ACCESSORS(flags) | 7120 DECL_INT_ACCESSORS(flags) |
7121 | 7121 |
7122 // [source_url]: sourceURL from magic comment | 7122 // [source_url]: sourceURL from magic comment |
7123 DECL_ACCESSORS(source_url, Object) | 7123 DECL_ACCESSORS(source_url, Object) |
7124 | 7124 |
7125 // [source_mapping_url]: sourceMappingURL magic comment | 7125 // [source_mapping_url]: sourceMappingURL magic comment |
7126 DECL_ACCESSORS(source_mapping_url, Object) | 7126 DECL_ACCESSORS(source_mapping_url, Object) |
7127 | 7127 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7192 static int GetColumnNumber(Handle<Script> script, int code_offset); | 7192 static int GetColumnNumber(Handle<Script> script, int code_offset); |
7193 int GetColumnNumber(int code_pos) const; | 7193 int GetColumnNumber(int code_pos) const; |
7194 static int GetLineNumber(Handle<Script> script, int code_offset); | 7194 static int GetLineNumber(Handle<Script> script, int code_offset); |
7195 int GetLineNumber(int code_pos) const; | 7195 int GetLineNumber(int code_pos) const; |
7196 | 7196 |
7197 // Get the JS object wrapping the given script; create it if none exists. | 7197 // Get the JS object wrapping the given script; create it if none exists. |
7198 static Handle<JSObject> GetWrapper(Handle<Script> script); | 7198 static Handle<JSObject> GetWrapper(Handle<Script> script); |
7199 | 7199 |
7200 // Look through the list of existing shared function infos to find one | 7200 // Look through the list of existing shared function infos to find one |
7201 // that matches the function literal. Return empty handle if not found. | 7201 // that matches the function literal. Return empty handle if not found. |
7202 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); | 7202 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(Isolate* isolate, |
| 7203 FunctionLiteral* fun); |
7203 | 7204 |
7204 // Iterate over all script objects on the heap. | 7205 // Iterate over all script objects on the heap. |
7205 class Iterator { | 7206 class Iterator { |
7206 public: | 7207 public: |
7207 explicit Iterator(Isolate* isolate); | 7208 explicit Iterator(Isolate* isolate); |
7208 Script* Next(); | 7209 Script* Next(); |
7209 | 7210 |
7210 private: | 7211 private: |
7211 WeakFixedArray::Iterator iterator_; | 7212 WeakFixedArray::Iterator iterator_; |
7212 DISALLOW_COPY_AND_ASSIGN(Iterator); | 7213 DISALLOW_COPY_AND_ASSIGN(Iterator); |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7720 // Indicates that this is a synthesized function to set up class instance | 7721 // Indicates that this is a synthesized function to set up class instance |
7721 // fields. | 7722 // fields. |
7722 DECL_BOOLEAN_ACCESSORS(is_class_field_initializer) | 7723 DECL_BOOLEAN_ACCESSORS(is_class_field_initializer) |
7723 | 7724 |
7724 // Indicates that this function is an asm function. | 7725 // Indicates that this function is an asm function. |
7725 DECL_BOOLEAN_ACCESSORS(asm_function) | 7726 DECL_BOOLEAN_ACCESSORS(asm_function) |
7726 | 7727 |
7727 // Indicates that the the shared function info is deserialized from cache. | 7728 // Indicates that the the shared function info is deserialized from cache. |
7728 DECL_BOOLEAN_ACCESSORS(deserialized) | 7729 DECL_BOOLEAN_ACCESSORS(deserialized) |
7729 | 7730 |
7730 // Indicates that the the shared function info has never been compiled before. | |
7731 DECL_BOOLEAN_ACCESSORS(never_compiled) | |
7732 | |
7733 // Whether this function was created from a FunctionDeclaration. | 7731 // Whether this function was created from a FunctionDeclaration. |
7734 DECL_BOOLEAN_ACCESSORS(is_declaration) | 7732 DECL_BOOLEAN_ACCESSORS(is_declaration) |
7735 | 7733 |
7736 // Whether this function was marked to be tiered up. | 7734 // Whether this function was marked to be tiered up. |
7737 DECL_BOOLEAN_ACCESSORS(marked_for_tier_up) | 7735 DECL_BOOLEAN_ACCESSORS(marked_for_tier_up) |
7738 | 7736 |
7739 // Indicates that asm->wasm conversion failed and should not be re-attempted. | 7737 // Indicates that asm->wasm conversion failed and should not be re-attempted. |
7740 DECL_BOOLEAN_ACCESSORS(is_asm_wasm_broken) | 7738 DECL_BOOLEAN_ACCESSORS(is_asm_wasm_broken) |
7741 | 7739 |
7742 inline FunctionKind kind() const; | 7740 inline FunctionKind kind() const; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7810 // Initialize a SharedFunctionInfo from a parsed function literal. | 7808 // Initialize a SharedFunctionInfo from a parsed function literal. |
7811 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, | 7809 static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info, |
7812 FunctionLiteral* lit); | 7810 FunctionLiteral* lit); |
7813 | 7811 |
7814 // Dispatched behavior. | 7812 // Dispatched behavior. |
7815 DECLARE_PRINTER(SharedFunctionInfo) | 7813 DECLARE_PRINTER(SharedFunctionInfo) |
7816 DECLARE_VERIFIER(SharedFunctionInfo) | 7814 DECLARE_VERIFIER(SharedFunctionInfo) |
7817 | 7815 |
7818 void ResetForNewContext(int new_ic_age); | 7816 void ResetForNewContext(int new_ic_age); |
7819 | 7817 |
7820 // Iterate over all shared function infos. | 7818 // Iterate over all shared function infos in a given script. |
7821 class Iterator { | 7819 class ScriptIterator { |
7822 public: | 7820 public: |
7823 explicit Iterator(Isolate* isolate); | 7821 explicit ScriptIterator(Handle<Script> script); |
| 7822 ScriptIterator(Isolate* isolate, Handle<FixedArray> shared_function_infos); |
| 7823 SharedFunctionInfo* Next(); |
| 7824 |
| 7825 // Reset the iterator to run on |script|. |
| 7826 void Reset(Handle<Script> script); |
| 7827 |
| 7828 private: |
| 7829 Isolate* isolate_; |
| 7830 Handle<FixedArray> shared_function_infos_; |
| 7831 int index_; |
| 7832 DISALLOW_COPY_AND_ASSIGN(ScriptIterator); |
| 7833 }; |
| 7834 |
| 7835 // Iterate over all shared function infos on the heap. |
| 7836 class GlobalIterator { |
| 7837 public: |
| 7838 explicit GlobalIterator(Isolate* isolate); |
7824 SharedFunctionInfo* Next(); | 7839 SharedFunctionInfo* Next(); |
7825 | 7840 |
7826 private: | 7841 private: |
7827 bool NextScript(); | |
7828 | |
7829 Script::Iterator script_iterator_; | 7842 Script::Iterator script_iterator_; |
7830 WeakFixedArray::Iterator sfi_iterator_; | 7843 WeakFixedArray::Iterator noscript_sfi_iterator_; |
| 7844 SharedFunctionInfo::ScriptIterator sfi_iterator_; |
7831 DisallowHeapAllocation no_gc_; | 7845 DisallowHeapAllocation no_gc_; |
7832 DISALLOW_COPY_AND_ASSIGN(Iterator); | 7846 DISALLOW_COPY_AND_ASSIGN(GlobalIterator); |
7833 }; | 7847 }; |
7834 | 7848 |
7835 DECLARE_CAST(SharedFunctionInfo) | 7849 DECLARE_CAST(SharedFunctionInfo) |
7836 | 7850 |
7837 // Constants. | 7851 // Constants. |
7838 static const int kDontAdaptArgumentsSentinel = -1; | 7852 static const int kDontAdaptArgumentsSentinel = -1; |
7839 | 7853 |
7840 // Layout description. | 7854 // Layout description. |
7841 // Pointer fields. | 7855 // Pointer fields. |
7842 static const int kCodeOffset = HeapObject::kHeaderSize; | 7856 static const int kCodeOffset = HeapObject::kHeaderSize; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7982 static const int kIsTopLevelBit = 1; | 7996 static const int kIsTopLevelBit = 1; |
7983 static const int kStartPositionShift = 2; | 7997 static const int kStartPositionShift = 2; |
7984 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 7998 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
7985 | 7999 |
7986 // Bit positions in compiler_hints. | 8000 // Bit positions in compiler_hints. |
7987 enum CompilerHints { | 8001 enum CompilerHints { |
7988 // byte 0 | 8002 // byte 0 |
7989 kAllowLazyCompilation, | 8003 kAllowLazyCompilation, |
7990 kMarkedForTierUp, | 8004 kMarkedForTierUp, |
7991 kOptimizationDisabled, | 8005 kOptimizationDisabled, |
7992 kNeverCompiled, | 8006 kIsClassFieldInitializer, |
7993 kNative, | 8007 kNative, |
7994 kStrictModeFunction, | 8008 kStrictModeFunction, |
7995 kUsesArguments, | 8009 kUsesArguments, |
7996 kNeedsHomeObject, | 8010 kNeedsHomeObject, |
7997 // byte 1 | 8011 // byte 1 |
7998 kHasDuplicateParameters, | 8012 kHasDuplicateParameters, |
7999 kForceInline, | 8013 kForceInline, |
8000 kIsAsmFunction, | 8014 kIsAsmFunction, |
8001 kIsAnonymousExpression, | 8015 kIsAnonymousExpression, |
8002 kNameShouldPrintAsAnonymous, | 8016 kNameShouldPrintAsAnonymous, |
8003 kIsFunction, | 8017 kIsFunction, |
8004 kMustUseIgnitionTurbo, | 8018 kMustUseIgnitionTurbo, |
8005 kDontFlush, | 8019 kDontFlush, |
8006 // byte 2 | 8020 // byte 2 |
8007 kFunctionKind, | 8021 kFunctionKind, |
8008 // rest of byte 2 and first two bits of byte 3 are used by FunctionKind | 8022 // rest of byte 2 and first two bits of byte 3 are used by FunctionKind |
8009 // byte 3 | 8023 // byte 3 |
8010 kDeserialized = kFunctionKind + 10, | 8024 kDeserialized = kFunctionKind + 10, |
8011 kIsDeclaration, | 8025 kIsDeclaration, |
8012 kIsAsmWasmBroken, | 8026 kIsAsmWasmBroken, |
8013 kRequiresClassFieldInit, | 8027 kRequiresClassFieldInit, |
8014 kIsClassFieldInitializer, | |
8015 kCompilerHintsCount, // Pseudo entry | 8028 kCompilerHintsCount, // Pseudo entry |
8016 }; | 8029 }; |
8017 // kFunctionKind has to be byte-aligned | 8030 // kFunctionKind has to be byte-aligned |
8018 STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); | 8031 STATIC_ASSERT((kFunctionKind % kBitsPerByte) == 0); |
8019 | 8032 |
8020 class FunctionKindBits : public BitField<FunctionKind, kFunctionKind, 10> {}; | 8033 class FunctionKindBits : public BitField<FunctionKind, kFunctionKind, 10> {}; |
8021 | 8034 |
8022 class DeoptCountBits : public BitField<int, 0, 4> {}; | 8035 class DeoptCountBits : public BitField<int, 0, 4> {}; |
8023 class OptReenableTriesBits : public BitField<int, 4, 18> {}; | 8036 class OptReenableTriesBits : public BitField<int, 4, 18> {}; |
8024 class ICAgeBits : public BitField<int, 22, 8> {}; | 8037 class ICAgeBits : public BitField<int, 22, 8> {}; |
(...skipping 3970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11995 } | 12008 } |
11996 return value; | 12009 return value; |
11997 } | 12010 } |
11998 }; | 12011 }; |
11999 | 12012 |
12000 | 12013 |
12001 } // NOLINT, false-positive due to second-order macros. | 12014 } // NOLINT, false-positive due to second-order macros. |
12002 } // NOLINT, false-positive due to second-order macros. | 12015 } // NOLINT, false-positive due to second-order macros. |
12003 | 12016 |
12004 #endif // V8_OBJECTS_H_ | 12017 #endif // V8_OBJECTS_H_ |
OLD | NEW |