[runtime] Cleanup js/prologue.js.

This CL removes unused utils.InstallFunctions, utils.InstallGetter(),
utils.SetFunctionName, utils.OverrideFunction and respective runtime
functions (%FunctionSetSharedName and %FunctionRemovePrototype).

This CL is one of a series of cleanup CL which are the preliminary steps for
improving function closures creation.

Bug: v8:6459
Change-Id: I0fb5940ed628f0c1958f585411e2fca3e2038054
Reviewed-on: https://chromium-review.googlesource.com/548037
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46336}
This commit is contained in:
Igor Sheludko 2017-06-26 15:16:40 +02:00 committed by Commit Bot
parent a4694a42bb
commit f79b3d4e97
5 changed files with 0 additions and 108 deletions

View File

@ -38,18 +38,6 @@ function ImportNow(name) {
}
function SetFunctionName(f, name, prefix) {
if (IS_SYMBOL(name)) {
name = "[" + %SymbolDescription(name) + "]";
}
if (IS_UNDEFINED(prefix)) {
%FunctionSetSharedName(f, name);
} else {
%FunctionSetSharedName(f, prefix + " " + name);
}
}
function InstallConstants(object, constants) {
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
@ -63,44 +51,6 @@ function InstallConstants(object, constants) {
}
function InstallFunctions(object, attributes, functions) {
%CheckIsBootstrapping();
%OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
for (var i = 0; i < functions.length; i += 2) {
var key = functions[i];
var f = functions[i + 1];
SetFunctionName(f, key);
%FunctionRemovePrototype(f);
%AddNamedProperty(object, key, f, attributes);
%SetNativeFlag(f);
}
%ToFastProperties(object);
}
// Helper function to install a getter-only accessor property.
function InstallGetter(object, name, getter, attributes, prefix) {
%CheckIsBootstrapping();
if (IS_UNDEFINED(attributes)) attributes = DONT_ENUM;
SetFunctionName(getter, name, IS_UNDEFINED(prefix) ? "get" : prefix);
%FunctionRemovePrototype(getter);
%DefineGetterPropertyUnchecked(object, name, getter, attributes);
%SetNativeFlag(getter);
}
function OverrideFunction(object, name, f, afterInitialBootstrap) {
%CheckIsBootstrapping();
%object_define_property(object, name, { value: f,
writeable: true,
configurable: true,
enumerable: false });
SetFunctionName(f, name);
if (!afterInitialBootstrap) %FunctionRemovePrototype(f);
%SetNativeFlag(f);
}
// Prevents changes to the prototype of a built-in function.
// The "prototype" property of the function object is made non-configurable,
// and the prototype object is made non-extensible. The latter prevents
@ -156,11 +106,7 @@ function PostNatives(utils) {
utils.Import = Import;
utils.ImportNow = ImportNow;
utils.Export = Export;
utils.SetFunctionName = SetFunctionName;
utils.InstallConstants = InstallConstants;
utils.InstallFunctions = InstallFunctions;
utils.InstallGetter = InstallGetter;
utils.OverrideFunction = OverrideFunction;
utils.SetUpLockedPrototype = SetUpLockedPrototype;
utils.PostNatives = PostNatives;

View File

@ -12371,29 +12371,6 @@ void JSFunction::SetPrototype(Handle<JSFunction> function,
}
bool JSFunction::RemovePrototype() {
Context* native_context = context()->native_context();
Map* no_prototype_map =
is_strict(shared()->language_mode())
? native_context->strict_function_without_prototype_map()
: native_context->sloppy_function_without_prototype_map();
if (map() == no_prototype_map) return true;
#ifdef DEBUG
if (map() != (is_strict(shared()->language_mode())
? native_context->strict_function_map()
: native_context->sloppy_function_map())) {
return false;
}
#endif
set_map(no_prototype_map);
set_prototype_or_initial_map(no_prototype_map->GetHeap()->the_hole_value());
return true;
}
void JSFunction::SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
Handle<Object> prototype) {
if (map->prototype() != *prototype) Map::SetPrototype(map, prototype);

View File

@ -5152,10 +5152,6 @@ class JSFunction: public JSObject {
static void SetPrototype(Handle<JSFunction> function,
Handle<Object> value);
// After prototype is removed, it will not be created when accessed, and
// [[Construct]] from this function will not be allowed.
bool RemovePrototype();
// Returns if this function has been compiled to native code yet.
inline bool is_compiled();

View File

@ -29,31 +29,6 @@ RUNTIME_FUNCTION(Runtime_FunctionGetName) {
}
}
RUNTIME_FUNCTION(Runtime_FunctionSetSharedName) {
HandleScope scope(isolate);
DCHECK_EQ(2, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0);
CONVERT_ARG_HANDLE_CHECKED(String, name, 1);
name = String::Flatten(name);
f->shared()->set_raw_name(*name);
return isolate->heap()->undefined_value();
}
RUNTIME_FUNCTION(Runtime_FunctionRemovePrototype) {
SealHandleScope shs(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(JSFunction, f, 0);
CHECK(f->RemovePrototype());
f->shared()->SetConstructStub(
*isolate->builtins()->ConstructedNonConstructable());
return isolate->heap()->undefined_value();
}
// TODO(5530): Remove once uses in debug.js are gone.
RUNTIME_FUNCTION(Runtime_FunctionGetScript) {
HandleScope scope(isolate);

View File

@ -231,8 +231,6 @@ namespace internal {
#define FOR_EACH_INTRINSIC_FUNCTION(F) \
F(FunctionGetName, 1, 1) \
F(FunctionSetSharedName, 2, 1) \
F(FunctionRemovePrototype, 1, 1) \
F(FunctionGetScript, 1, 1) \
F(FunctionGetScriptId, 1, 1) \
F(FunctionGetSourceCode, 1, 1) \