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

Side by Side Diff: src/objects.h

Issue 2407183002: [modules] Don't unnecessarily keep function alive after evaluation. (Closed)
Patch Set: Remove shared(). Created 4 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
« no previous file with comments | « src/factory.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 #include <memory> 9 #include <memory>
10 10
(...skipping 7949 matching lines...) Expand 10 before | Expand all | Expand 10 after
7960 }; 7960 };
7961 7961
7962 // A Module object is a mapping from export names to cells 7962 // A Module object is a mapping from export names to cells
7963 // This is still very much in flux. 7963 // This is still very much in flux.
7964 class Module : public Struct { 7964 class Module : public Struct {
7965 public: 7965 public:
7966 DECLARE_CAST(Module) 7966 DECLARE_CAST(Module)
7967 DECLARE_VERIFIER(Module) 7967 DECLARE_VERIFIER(Module)
7968 DECLARE_PRINTER(Module) 7968 DECLARE_PRINTER(Module)
7969 7969
7970 // The code representing this Module, either a SharedFunctionInfo or a 7970 // The code representing this Module, or an abstraction thereof.
7971 // JSFunction depending on whether it's been instantiated. 7971 // This is either a SharedFunctionInfo or a JSFunction or a ModuleInfo
7972 // depending on whether the module has been instantiated and evaluated. See
7973 // Module::ModuleVerify() for the precise invariant.
7972 DECL_ACCESSORS(code, Object) 7974 DECL_ACCESSORS(code, Object)
7973 7975
7976 // The export table.
7974 DECL_ACCESSORS(exports, ObjectHashTable) 7977 DECL_ACCESSORS(exports, ObjectHashTable)
7975 7978
7976 // The namespace object (or undefined). 7979 // The namespace object (or undefined).
7977 DECL_ACCESSORS(module_namespace, HeapObject) 7980 DECL_ACCESSORS(module_namespace, HeapObject)
7978 7981
7979 // [[RequestedModules]]: Modules imported or re-exported by this module. 7982 // [[RequestedModules]]: Modules imported or re-exported by this module.
7980 // Corresponds 1-to-1 to the module specifier strings in 7983 // Corresponds 1-to-1 to the module specifier strings in
7981 // ModuleInfo::module_requests. 7984 // ModuleInfo::module_requests.
7982 DECL_ACCESSORS(requested_modules, FixedArray) 7985 DECL_ACCESSORS(requested_modules, FixedArray)
7983 7986
7984 // [[Evaluated]]: Whether this module has been evaluated. Modules
7985 // are only evaluated a single time.
7986 DECL_BOOLEAN_ACCESSORS(evaluated)
7987
7988 // Storage for [[Evaluated]].
7989 DECL_INT_ACCESSORS(flags)
7990
7991 // Hash for this object (a random non-zero Smi). 7987 // Hash for this object (a random non-zero Smi).
7992 DECL_INT_ACCESSORS(hash) 7988 DECL_INT_ACCESSORS(hash)
7993 7989
7994 // Get the SharedFunctionInfo associated with the code.
7995 inline SharedFunctionInfo* shared() const;
7996
7997 // Get the ModuleInfo associated with the code. 7990 // Get the ModuleInfo associated with the code.
7998 inline ModuleInfo* info() const; 7991 inline ModuleInfo* info() const;
7999 7992
7993 inline bool instantiated() const;
7994 inline bool evaluated() const;
7995 inline void set_evaluated();
7996
8000 // Implementation of spec operation ModuleDeclarationInstantiation. 7997 // Implementation of spec operation ModuleDeclarationInstantiation.
8001 // Returns false if an exception occurred during instantiation, true 7998 // Returns false if an exception occurred during instantiation, true
8002 // otherwise. 7999 // otherwise.
8003 static MUST_USE_RESULT bool Instantiate(Handle<Module> module, 8000 static MUST_USE_RESULT bool Instantiate(Handle<Module> module,
8004 v8::Local<v8::Context> context, 8001 v8::Local<v8::Context> context,
8005 v8::Module::ResolveCallback callback); 8002 v8::Module::ResolveCallback callback);
8006 8003
8007 // Implementation of spec operation ModuleEvaluation. 8004 // Implementation of spec operation ModuleEvaluation.
8008 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module); 8005 static MUST_USE_RESULT MaybeHandle<Object> Evaluate(Handle<Module> module);
8009 8006
8010 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name); 8007 static Handle<Object> LoadExport(Handle<Module> module, Handle<String> name);
8011 static void StoreExport(Handle<Module> module, Handle<String> name, 8008 static void StoreExport(Handle<Module> module, Handle<String> name,
8012 Handle<Object> value); 8009 Handle<Object> value);
8013 8010
8014 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name, 8011 static Handle<Object> LoadImport(Handle<Module> module, Handle<String> name,
8015 int module_request); 8012 int module_request);
8016 8013
8017 // Get the namespace object for [module_request] of [module]. If it doesn't 8014 // Get the namespace object for [module_request] of [module]. If it doesn't
8018 // exist yet, it is created. 8015 // exist yet, it is created.
8019 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module, 8016 static Handle<JSModuleNamespace> GetModuleNamespace(Handle<Module> module,
8020 int module_request); 8017 int module_request);
8021 8018
8022 static const int kCodeOffset = HeapObject::kHeaderSize; 8019 static const int kCodeOffset = HeapObject::kHeaderSize;
8023 static const int kExportsOffset = kCodeOffset + kPointerSize; 8020 static const int kExportsOffset = kCodeOffset + kPointerSize;
8024 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize; 8021 static const int kRequestedModulesOffset = kExportsOffset + kPointerSize;
8025 static const int kFlagsOffset = kRequestedModulesOffset + kPointerSize; 8022 static const int kEmbedderDataOffset = kRequestedModulesOffset + kPointerSize;
adamk 2016/10/14 18:01:02 Looks like you'll need a merge here, as embedder d
8026 static const int kEmbedderDataOffset = kFlagsOffset + kPointerSize;
8027 static const int kModuleNamespaceOffset = kEmbedderDataOffset + kPointerSize; 8023 static const int kModuleNamespaceOffset = kEmbedderDataOffset + kPointerSize;
8028 static const int kHashOffset = kModuleNamespaceOffset + kPointerSize; 8024 static const int kHashOffset = kModuleNamespaceOffset + kPointerSize;
8029 static const int kSize = kHashOffset + kPointerSize; 8025 static const int kSize = kHashOffset + kPointerSize;
8030 8026
8031 private: 8027 private:
8032 enum { kEvaluatedBit }; 8028 enum { kEvaluatedBit };
8033 8029
8034 static void CreateExport(Handle<Module> module, Handle<FixedArray> names); 8030 static void CreateExport(Handle<Module> module, Handle<FixedArray> names);
8035 static void CreateIndirectExport(Handle<Module> module, Handle<String> name, 8031 static void CreateIndirectExport(Handle<Module> module, Handle<String> name,
8036 Handle<ModuleInfoEntry> entry); 8032 Handle<ModuleInfoEntry> entry);
(...skipping 3518 matching lines...) Expand 10 before | Expand all | Expand 10 after
11555 } 11551 }
11556 return value; 11552 return value;
11557 } 11553 }
11558 }; 11554 };
11559 11555
11560 11556
11561 } // NOLINT, false-positive due to second-order macros. 11557 } // NOLINT, false-positive due to second-order macros.
11562 } // NOLINT, false-positive due to second-order macros. 11558 } // NOLINT, false-positive due to second-order macros.
11563 11559
11564 #endif // V8_OBJECTS_H_ 11560 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698