/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
deps/v8/src/runtime/runtime-function.cc
85 строк
3 KB
Michaël Zasso
deps: update V8 to 14.6.202.33
24 апр 2026, 19:01
Не верифицирован
24 апр 2026, 19:01
f1e0b83
Код
Авторство
О чём код?
// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/builtins/accessors.h" #include "src/execution/isolate-inl.h" #include "src/roots/roots-inl.h" namespace v8 { namespace internal { // TODO(5530): Remove once uses in debug.js are gone. RUNTIME_FUNCTION(Runtime_FunctionGetScriptSource) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); DirectHandle<JSReceiver> function = args.at<JSReceiver>(0); if (IsJSFunction(*function)) { DirectHandle<Object> script(Cast<JSFunction>(function)->shared()->script(), isolate); if (IsScript(*script)) return Cast<Script>(script)->source(); } return ReadOnlyRoots(isolate).undefined_value(); } RUNTIME_FUNCTION(Runtime_FunctionGetScriptId) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); DirectHandle<JSReceiver> function = args.at<JSReceiver>(0); if (IsJSFunction(*function)) { DirectHandle<Object> script(Cast<JSFunction>(function)->shared()->script(), isolate); if (IsScript(*script)) { return Smi::FromInt(Cast<Script>(script)->id()); } } return Smi::FromInt(-1); } RUNTIME_FUNCTION(Runtime_FunctionGetSourceCode) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); DirectHandle<JSReceiver> function = args.at<JSReceiver>(0); if (IsJSFunction(*function)) { DirectHandle<SharedFunctionInfo> shared( Cast<JSFunction>(function)->shared(), isolate); return *SharedFunctionInfo::GetSourceCode(isolate, shared); } return ReadOnlyRoots(isolate).undefined_value(); } RUNTIME_FUNCTION(Runtime_FunctionGetScriptSourcePosition) { SealHandleScope shs(isolate); DCHECK_EQ(1, args.length()); auto fun = Cast<JSFunction>(args[0]); int pos = fun->shared()->StartPosition(); return Smi::FromInt(pos); } RUNTIME_FUNCTION(Runtime_FunctionIsAPIFunction) { SealHandleScope shs(isolate); DCHECK_EQ(1, args.length()); auto f = Cast<JSFunction>(args[0]); return ReadOnlyRoots(isolate).boolean_value(f->shared()->IsApiFunction()); } RUNTIME_FUNCTION(Runtime_Call) { HandleScope scope(isolate); DCHECK_LE(2, args.length()); int const argc = args.length() - 2; DirectHandle<Object> target = args.at(0); DirectHandle<Object> receiver = args.at(1); DirectHandleVector<Object> arguments(isolate, argc); for (int i = 0; i < argc; ++i) { arguments[i] = args.at(2 + i); } RETURN_RESULT_OR_FAILURE(isolate, Execution::Call(isolate, target, receiver, base::VectorOf(arguments))); } } // namespace internal } // namespace v8