// 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/runtime/runtime-utils.h" #include "src/accessors.h" #include "src/arguments.h" #include "src/compiler.h" #include "src/frames-inl.h" #include "src/isolate-inl.h" #include "src/messages.h" #include "src/profiler/cpu-profiler.h" namespace v8 { namespace internal { RUNTIME_FUNCTION(Runtime_FunctionGetName) { HandleScope scope(isolate); DCHECK(args.length() == 1); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); if (function->IsJSBoundFunction()) { Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, JSBoundFunction::GetName( isolate, Handle::cast(function))); return *result; } else { RUNTIME_ASSERT(function->IsJSFunction()); return Handle::cast(function)->shared()->name(); } } RUNTIME_FUNCTION(Runtime_FunctionSetName) { HandleScope scope(isolate); DCHECK(args.length() == 2); CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); CONVERT_ARG_HANDLE_CHECKED(String, name, 1); name = String::Flatten(name); f->shared()->set_name(*name); return isolate->heap()->undefined_value(); } RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) { SealHandleScope shs(isolate); DCHECK(args.length() == 1); CONVERT_ARG_CHECKED(JSFunction, f, 0); RUNTIME_ASSERT(f->RemovePrototype()); f->shared()->set_construct_stub( *isolate->builtins()->ConstructedNonConstructable()); return isolate->heap()->undefined_value(); } RUNTIME_FUNCTION(Runtime_FunctionGetScript) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, function, 0); if (function->IsJSFunction()) { Handle script( Handle::cast(function)->shared()->script(), isolate); if (script->IsScript()) { return *Script::GetWrapper(Handle