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 | 9 |
10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
(...skipping 6579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6590 // function source. Encoded in the 'flags' field. | 6590 // function source. Encoded in the 'flags' field. |
6591 inline bool hide_source(); | 6591 inline bool hide_source(); |
6592 inline void set_hide_source(bool value); | 6592 inline void set_hide_source(bool value); |
6593 | 6593 |
6594 // [origin_options]: optional attributes set by the embedder via ScriptOrigin, | 6594 // [origin_options]: optional attributes set by the embedder via ScriptOrigin, |
6595 // and used by the embedder to make decisions about the script. V8 just passes | 6595 // and used by the embedder to make decisions about the script. V8 just passes |
6596 // this through. Encoded in the 'flags' field. | 6596 // this through. Encoded in the 'flags' field. |
6597 inline v8::ScriptOriginOptions origin_options(); | 6597 inline v8::ScriptOriginOptions origin_options(); |
6598 inline void set_origin_options(ScriptOriginOptions origin_options); | 6598 inline void set_origin_options(ScriptOriginOptions origin_options); |
6599 | 6599 |
| 6600 // [is_module]: determines whether the script is an ES2015 module. Encoded in |
| 6601 // the 'flags' field. |
| 6602 inline bool is_module(); |
| 6603 inline void set_is_module(bool value); |
| 6604 |
6600 DECLARE_CAST(Script) | 6605 DECLARE_CAST(Script) |
6601 | 6606 |
6602 // If script source is an external string, check that the underlying | 6607 // If script source is an external string, check that the underlying |
6603 // resource is accessible. Otherwise, always return true. | 6608 // resource is accessible. Otherwise, always return true. |
6604 inline bool HasValidSource(); | 6609 inline bool HasValidSource(); |
6605 | 6610 |
6606 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); | 6611 static Handle<Object> GetNameOrSourceURL(Handle<Script> script); |
6607 | 6612 |
6608 // Set eval origin for stack trace formatting. | 6613 // Set eval origin for stack trace formatting. |
6609 static void SetEvalOrigin(Handle<Script> script, | 6614 static void SetEvalOrigin(Handle<Script> script, |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6687 int GetLineNumberWithArray(int code_pos); | 6692 int GetLineNumberWithArray(int code_pos); |
6688 | 6693 |
6689 // Bit positions in the flags field. | 6694 // Bit positions in the flags field. |
6690 static const int kCompilationTypeBit = 0; | 6695 static const int kCompilationTypeBit = 0; |
6691 static const int kCompilationStateBit = 1; | 6696 static const int kCompilationStateBit = 1; |
6692 static const int kHideSourceBit = 2; | 6697 static const int kHideSourceBit = 2; |
6693 static const int kOriginOptionsShift = 3; | 6698 static const int kOriginOptionsShift = 3; |
6694 static const int kOriginOptionsSize = 3; | 6699 static const int kOriginOptionsSize = 3; |
6695 static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1) | 6700 static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1) |
6696 << kOriginOptionsShift; | 6701 << kOriginOptionsShift; |
| 6702 static const int kIsModuleBit = kOriginOptionsShift + kOriginOptionsSize; |
6697 | 6703 |
6698 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 6704 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
6699 }; | 6705 }; |
6700 | 6706 |
6701 | 6707 |
6702 // List of builtin functions we want to identify to improve code | 6708 // List of builtin functions we want to identify to improve code |
6703 // generation. | 6709 // generation. |
6704 // | 6710 // |
6705 // Each entry has a name of a global object property holding an object | 6711 // Each entry has a name of a global object property holding an object |
6706 // optionally followed by ".prototype", a name of a builtin function | 6712 // optionally followed by ".prototype", a name of a builtin function |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8246 // is called while such a hash is live in the cache, the hash gets replaced by | 8252 // is called while such a hash is live in the cache, the hash gets replaced by |
8247 // an actual cache entry. Age also removes stale live entries from the cache. | 8253 // an actual cache entry. Age also removes stale live entries from the cache. |
8248 // Such entries are identified by SharedFunctionInfos pointing to either the | 8254 // Such entries are identified by SharedFunctionInfos pointing to either the |
8249 // recompilation stub, or to "old" code. This avoids memory leaks due to | 8255 // recompilation stub, or to "old" code. This avoids memory leaks due to |
8250 // premature caching of scripts and eval strings that are never needed later. | 8256 // premature caching of scripts and eval strings that are never needed later. |
8251 class CompilationCacheTable: public HashTable<CompilationCacheTable, | 8257 class CompilationCacheTable: public HashTable<CompilationCacheTable, |
8252 CompilationCacheShape, | 8258 CompilationCacheShape, |
8253 HashTableKey*> { | 8259 HashTableKey*> { |
8254 public: | 8260 public: |
8255 // Find cached value for a string key, otherwise return null. | 8261 // Find cached value for a string key, otherwise return null. |
8256 Handle<Object> Lookup( | 8262 Handle<Object> Lookup(Handle<String> src, Handle<Context> context, |
8257 Handle<String> src, Handle<Context> context, LanguageMode language_mode); | 8263 LanguageMode language_mode, bool is_module); |
8258 Handle<Object> LookupEval( | 8264 Handle<Object> LookupEval( |
8259 Handle<String> src, Handle<SharedFunctionInfo> shared, | 8265 Handle<String> src, Handle<SharedFunctionInfo> shared, |
8260 LanguageMode language_mode, int scope_position); | 8266 LanguageMode language_mode, int scope_position); |
8261 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); | 8267 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); |
8262 static Handle<CompilationCacheTable> Put( | 8268 static Handle<CompilationCacheTable> Put(Handle<CompilationCacheTable> cache, |
8263 Handle<CompilationCacheTable> cache, Handle<String> src, | 8269 Handle<String> src, |
8264 Handle<Context> context, LanguageMode language_mode, | 8270 Handle<Context> context, |
8265 Handle<Object> value); | 8271 LanguageMode language_mode, |
| 8272 bool is_module, |
| 8273 Handle<Object> value); |
8266 static Handle<CompilationCacheTable> PutEval( | 8274 static Handle<CompilationCacheTable> PutEval( |
8267 Handle<CompilationCacheTable> cache, Handle<String> src, | 8275 Handle<CompilationCacheTable> cache, Handle<String> src, |
8268 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, | 8276 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, |
8269 int scope_position); | 8277 int scope_position); |
8270 static Handle<CompilationCacheTable> PutRegExp( | 8278 static Handle<CompilationCacheTable> PutRegExp( |
8271 Handle<CompilationCacheTable> cache, Handle<String> src, | 8279 Handle<CompilationCacheTable> cache, Handle<String> src, |
8272 JSRegExp::Flags flags, Handle<FixedArray> value); | 8280 JSRegExp::Flags flags, Handle<FixedArray> value); |
8273 void Remove(Object* value); | 8281 void Remove(Object* value); |
8274 void Age(); | 8282 void Age(); |
8275 static const int kHashGenerations = 10; | 8283 static const int kHashGenerations = 10; |
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10968 } | 10976 } |
10969 return value; | 10977 return value; |
10970 } | 10978 } |
10971 }; | 10979 }; |
10972 | 10980 |
10973 | 10981 |
10974 } // NOLINT, false-positive due to second-order macros. | 10982 } // NOLINT, false-positive due to second-order macros. |
10975 } // NOLINT, false-positive due to second-order macros. | 10983 } // NOLINT, false-positive due to second-order macros. |
10976 | 10984 |
10977 #endif // V8_OBJECTS_H_ | 10985 #endif // V8_OBJECTS_H_ |
OLD | NEW |