@@ -787,10 +787,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
787
787
bool produce_cached_data = false ;
788
788
Local<Context> parsing_context = context;
789
789
790
+ bool needs_custom_host_defined_options = false ;
790
791
if (argc > 2 ) {
791
792
// new ContextifyScript(code, filename, lineOffset, columnOffset,
792
- // cachedData, produceCachedData, parsingContext)
793
- CHECK_EQ (argc, 7 );
793
+ // cachedData, produceCachedData, parsingContext,
794
+ // needsCustomHostDefinedOptions)
795
+ CHECK_EQ (argc, 8 );
794
796
CHECK (args[2 ]->IsNumber ());
795
797
line_offset = args[2 ].As <Int32>()->Value ();
796
798
CHECK (args[3 ]->IsNumber ());
@@ -809,6 +811,9 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
809
811
CHECK_NOT_NULL (sandbox);
810
812
parsing_context = sandbox->context ();
811
813
}
814
+ if (args[7 ]->IsTrue ()) {
815
+ needs_custom_host_defined_options = true ;
816
+ }
812
817
}
813
818
814
819
ContextifyScript* contextify_script =
@@ -832,7 +837,12 @@ void ContextifyScript::New(const FunctionCallbackInfo<Value>& args) {
832
837
833
838
Local<PrimitiveArray> host_defined_options =
834
839
PrimitiveArray::New (isolate, loader::HostDefinedOptions::kLength );
835
- Local<Symbol> id_symbol = Symbol::New (isolate, filename);
840
+ // We need a default host defined options that's the same for all scripts
841
+ // not needing custom module callbacks for so that the isolate compilation
842
+ // cache can be hit.
843
+ Local<Symbol> id_symbol = needs_custom_host_defined_options
844
+ ? Symbol::New (isolate, filename)
845
+ : env->default_host_defined_options ();
836
846
host_defined_options->Set (
837
847
isolate, loader::HostDefinedOptions::kID , id_symbol);
838
848
0 commit comments