GeezerVison is showing github.com — src: remove usage on ScriptCompiler::CompileFunctionInContext · nodejs/node@ceb62e5
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/node_builtins.cc +11-11Lines changed: 11 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -243,9 +243,9 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal( | 243 | 243 | ScriptCompiler::CachedData* cached_data = nullptr; | 244 | 244 | { | 245 | 245 | // Note: The lock here should not extend into the | 246 | | - // `CompileFunctionInContext()` call below, because this function may | 247 | | - // recurse if there is a syntax error during bootstrap (because the fatal | 248 | | - // exception handler is invoked, which may load built-in modules). | | 246 | + // `CompileFunction()` call below, because this function may recurse if | | 247 | + // there is a syntax error during bootstrap (because the fatal exception | | 248 | + // handler is invoked, which may load built-in modules). | 249 | 249 | Mutex::ScopedLock lock(code_cache_mutex_); | 250 | 250 | auto cache_it = code_cache_.find(id); | 251 | 251 | if (cache_it != code_cache_.end()) { | @@ -267,20 +267,20 @@ MaybeLocal<Function> BuiltinLoader::LookupAndCompileInternal( | 267 | 267 | has_cache ? "with" : "without"); | 268 | 268 |
| 269 | 269 | MaybeLocal<Function> maybe_fun = | 270 | | - ScriptCompiler::CompileFunctionInContext(context, | 271 | | - &script_source, | 272 | | - parameters->size(), | 273 | | - parameters->data(), | 274 | | - 0, | 275 | | - nullptr, | 276 | | - options); | | 270 | + ScriptCompiler::CompileFunction(context, | | 271 | + &script_source, | | 272 | + parameters->size(), | | 273 | + parameters->data(), | | 274 | + 0, | | 275 | + nullptr, | | 276 | + options); | 277 | 277 |
| 278 | 278 | // This could fail when there are early errors in the built-in modules, | 279 | 279 | // e.g. the syntax errors | 280 | 280 | Local<Function> fun; | 281 | 281 | if (!maybe_fun.ToLocal(&fun)) { | 282 | 282 | // In the case of early errors, v8 is already capable of | 283 | | - // decorating the stack for us - note that we use CompileFunctionInContext | | 283 | + // decorating the stack for us - note that we use CompileFunction | 284 | 284 | // so there is no need to worry about wrappers. | 285 | 285 | return MaybeLocal<Function>(); | 286 | 286 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_contextify.cc +14-13Lines changed: 14 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -70,7 +70,6 @@ using v8::PropertyHandlerFlags; | 70 | 70 | using v8::Script; | 71 | 71 | using v8::ScriptCompiler; | 72 | 72 | using v8::ScriptOrigin; | 73 | | -using v8::ScriptOrModule; | 74 | 73 | using v8::String; | 75 | 74 | using v8::Uint32; | 76 | 75 | using v8::UnboundScript; | @@ -1126,11 +1125,15 @@ void ContextifyContext::CompileFunction( | 1126 | 1125 | } | 1127 | 1126 | } | 1128 | 1127 |
| 1129 | | - Local<ScriptOrModule> script; | 1130 | | - MaybeLocal<Function> maybe_fn = ScriptCompiler::CompileFunctionInContext( | 1131 | | - parsing_context, &source, params.size(), params.data(), | 1132 | | - context_extensions.size(), context_extensions.data(), options, | 1133 | | - v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason, &script); | | 1128 | + MaybeLocal<Function> maybe_fn = ScriptCompiler::CompileFunction( | | 1129 | + parsing_context, | | 1130 | + &source, | | 1131 | + params.size(), | | 1132 | + params.data(), | | 1133 | + context_extensions.size(), | | 1134 | + context_extensions.data(), | | 1135 | + options, | | 1136 | + v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason); | 1134 | 1137 |
| 1135 | 1138 | Local<Function> fn; | 1136 | 1139 | if (!maybe_fn.ToLocal(&fn)) { | @@ -1146,7 +1149,7 @@ void ContextifyContext::CompileFunction( | 1146 | 1149 | context).ToLocal(&cache_key)) { | 1147 | 1150 | return; | 1148 | 1151 | } | 1149 | | - CompiledFnEntry* entry = new CompiledFnEntry(env, cache_key, id, script); | | 1152 | + CompiledFnEntry* entry = new CompiledFnEntry(env, cache_key, id, fn); | 1150 | 1153 | env->id_to_function_map.emplace(id, entry); | 1151 | 1154 |
| 1152 | 1155 | Local<Object> result = Object::New(isolate); | @@ -1192,16 +1195,14 @@ void CompiledFnEntry::WeakCallback( | 1192 | 1195 | CompiledFnEntry::CompiledFnEntry(Environment* env, | 1193 | 1196 | Local<Object> object, | 1194 | 1197 | uint32_t id, | 1195 | | - Local<ScriptOrModule> script) | 1196 | | - : BaseObject(env, object), | 1197 | | - id_(id), | 1198 | | - script_(env->isolate(), script) { | 1199 | | - script_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter); | | 1198 | + Local<Function> fn) | | 1199 | + : BaseObject(env, object), id_(id), fn_(env->isolate(), fn) { | | 1200 | + fn_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter); | 1200 | 1201 | } | 1201 | 1202 |
| 1202 | 1203 | CompiledFnEntry::~CompiledFnEntry() { | 1203 | 1204 | env()->id_to_function_map.erase(id_); | 1204 | | - script_.ClearWeak(); | | 1205 | + fn_.ClearWeak(); | 1205 | 1206 | } | 1206 | 1207 |
| 1207 | 1208 | static void StartSigintWatchdog(const FunctionCallbackInfo<Value>& args) { | |
Collapse file Copy file name to clipboardExpand all lines: src/node_contextify.h +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -174,14 +174,14 @@ class CompiledFnEntry final : public BaseObject { | 174 | 174 | CompiledFnEntry(Environment* env, | 175 | 175 | v8::Local<v8::Object> object, | 176 | 176 | uint32_t id, | 177 | | - v8::Local<v8::ScriptOrModule> script); | | 177 | + v8::Local<v8::Function> fn); | 178 | 178 | ~CompiledFnEntry(); | 179 | 179 |
| 180 | 180 | bool IsNotIndicativeOfMemoryLeakAtExit() const override { return true; } | 181 | 181 |
| 182 | 182 | private: | 183 | 183 | uint32_t id_; | 184 | | - v8::Global<v8::ScriptOrModule> script_; | | 184 | + v8::Global<v8::Function> fn_; | 185 | 185 |
| 186 | 186 | static void WeakCallback(const v8::WeakCallbackInfo<CompiledFnEntry>& data); | 187 | 187 | }; | |
Collapse file Copy file name to clipboardExpand all lines: src/node_snapshotable.cc +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1335,13 +1335,13 @@ void CompileSerializeMain(const FunctionCallbackInfo<Value>& args) { | 1335 | 1335 | }; | 1336 | 1336 | ScriptCompiler::Source script_source(source, origin); | 1337 | 1337 | Local<Function> fn; | 1338 | | - if (ScriptCompiler::CompileFunctionInContext(context, | 1339 | | - &script_source, | 1340 | | - parameters.size(), | 1341 | | - parameters.data(), | 1342 | | - 0, | 1343 | | - nullptr, | 1344 | | - ScriptCompiler::kEagerCompile) | | 1338 | + if (ScriptCompiler::CompileFunction(context, | | 1339 | + &script_source, | | 1340 | + parameters.size(), | | 1341 | + parameters.data(), | | 1342 | + 0, | | 1343 | + nullptr, | | 1344 | + ScriptCompiler::kEagerCompile) | 1345 | 1345 | .ToLocal(&fn)) { | 1346 | 1346 | args.GetReturnValue().Set(fn); | 1347 | 1347 | } | |
|